.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* Low-level parallel port routines for built-in port on SGI IP32 |
---|
2 | 3 | * |
---|
3 | 4 | * Author: Arnaud Giersch <arnaud.giersch@free.fr> |
---|
.. | .. |
---|
9 | 10 | * Thanks to Ilya A. Volynets-Evenbakh for his help. |
---|
10 | 11 | * |
---|
11 | 12 | * Copyright (C) 2005, 2006 Arnaud Giersch. |
---|
12 | | - * |
---|
13 | | - * This program is free software; you can redistribute it and/or modify it |
---|
14 | | - * under the terms of the GNU General Public License as published by the Free |
---|
15 | | - * Software Foundation; either version 2 of the License, or (at your option) |
---|
16 | | - * any later version. |
---|
17 | | - * |
---|
18 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
---|
19 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
20 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
21 | | - * more details. |
---|
22 | | - * |
---|
23 | | - * You should have received a copy of the GNU General Public License along |
---|
24 | | - * with this program; if not, write to the Free Software Foundation, Inc., 59 |
---|
25 | | - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
26 | 13 | */ |
---|
27 | 14 | |
---|
28 | 15 | /* Current status: |
---|
.. | .. |
---|
341 | 328 | "TST", "CFG"}; |
---|
342 | 329 | unsigned int ecr = readb(priv->regs.ecr); |
---|
343 | 330 | printk(KERN_DEBUG PPIP32 " ecr=0x%02x", ecr); |
---|
344 | | - printk(" %s", |
---|
345 | | - ecr_modes[(ecr & ECR_MODE_MASK) >> ECR_MODE_SHIFT]); |
---|
| 331 | + pr_cont(" %s", |
---|
| 332 | + ecr_modes[(ecr & ECR_MODE_MASK) >> ECR_MODE_SHIFT]); |
---|
346 | 333 | if (ecr & ECR_nERRINTR) |
---|
347 | | - printk(",nErrIntrEn"); |
---|
| 334 | + pr_cont(",nErrIntrEn"); |
---|
348 | 335 | if (ecr & ECR_DMAEN) |
---|
349 | | - printk(",dmaEn"); |
---|
| 336 | + pr_cont(",dmaEn"); |
---|
350 | 337 | if (ecr & ECR_SERVINTR) |
---|
351 | | - printk(",serviceIntr"); |
---|
| 338 | + pr_cont(",serviceIntr"); |
---|
352 | 339 | if (ecr & ECR_F_FULL) |
---|
353 | | - printk(",f_full"); |
---|
| 340 | + pr_cont(",f_full"); |
---|
354 | 341 | if (ecr & ECR_F_EMPTY) |
---|
355 | | - printk(",f_empty"); |
---|
356 | | - printk("\n"); |
---|
| 342 | + pr_cont(",f_empty"); |
---|
| 343 | + pr_cont("\n"); |
---|
357 | 344 | } |
---|
358 | 345 | if (show_ecp_config) { |
---|
359 | 346 | unsigned int oecr, cnfgA, cnfgB; |
---|
.. | .. |
---|
365 | 352 | writeb(ECR_MODE_PS2, priv->regs.ecr); |
---|
366 | 353 | writeb(oecr, priv->regs.ecr); |
---|
367 | 354 | printk(KERN_DEBUG PPIP32 " cnfgA=0x%02x", cnfgA); |
---|
368 | | - printk(" ISA-%s", (cnfgA & CNFGA_IRQ) ? "Level" : "Pulses"); |
---|
| 355 | + pr_cont(" ISA-%s", (cnfgA & CNFGA_IRQ) ? "Level" : "Pulses"); |
---|
369 | 356 | switch (cnfgA & CNFGA_ID_MASK) { |
---|
370 | 357 | case CNFGA_ID_8: |
---|
371 | | - printk(",8 bits"); |
---|
| 358 | + pr_cont(",8 bits"); |
---|
372 | 359 | break; |
---|
373 | 360 | case CNFGA_ID_16: |
---|
374 | | - printk(",16 bits"); |
---|
| 361 | + pr_cont(",16 bits"); |
---|
375 | 362 | break; |
---|
376 | 363 | case CNFGA_ID_32: |
---|
377 | | - printk(",32 bits"); |
---|
| 364 | + pr_cont(",32 bits"); |
---|
378 | 365 | break; |
---|
379 | 366 | default: |
---|
380 | | - printk(",unknown ID"); |
---|
| 367 | + pr_cont(",unknown ID"); |
---|
381 | 368 | break; |
---|
382 | 369 | } |
---|
383 | 370 | if (!(cnfgA & CNFGA_nBYTEINTRANS)) |
---|
384 | | - printk(",ByteInTrans"); |
---|
| 371 | + pr_cont(",ByteInTrans"); |
---|
385 | 372 | if ((cnfgA & CNFGA_ID_MASK) != CNFGA_ID_8) |
---|
386 | | - printk(",%d byte%s left", cnfgA & CNFGA_PWORDLEFT, |
---|
387 | | - ((cnfgA & CNFGA_PWORDLEFT) > 1) ? "s" : ""); |
---|
388 | | - printk("\n"); |
---|
| 373 | + pr_cont(",%d byte%s left", |
---|
| 374 | + cnfgA & CNFGA_PWORDLEFT, |
---|
| 375 | + ((cnfgA & CNFGA_PWORDLEFT) > 1) ? "s" : ""); |
---|
| 376 | + pr_cont("\n"); |
---|
389 | 377 | printk(KERN_DEBUG PPIP32 " cnfgB=0x%02x", cnfgB); |
---|
390 | | - printk(" irq=%u,dma=%u", |
---|
391 | | - (cnfgB & CNFGB_IRQ_MASK) >> CNFGB_IRQ_SHIFT, |
---|
392 | | - (cnfgB & CNFGB_DMA_MASK) >> CNFGB_DMA_SHIFT); |
---|
393 | | - printk(",intrValue=%d", !!(cnfgB & CNFGB_INTRVAL)); |
---|
| 378 | + pr_cont(" irq=%u,dma=%u", |
---|
| 379 | + (cnfgB & CNFGB_IRQ_MASK) >> CNFGB_IRQ_SHIFT, |
---|
| 380 | + (cnfgB & CNFGB_DMA_MASK) >> CNFGB_DMA_SHIFT); |
---|
| 381 | + pr_cont(",intrValue=%d", !!(cnfgB & CNFGB_INTRVAL)); |
---|
394 | 382 | if (cnfgB & CNFGB_COMPRESS) |
---|
395 | | - printk(",compress"); |
---|
396 | | - printk("\n"); |
---|
| 383 | + pr_cont(",compress"); |
---|
| 384 | + pr_cont("\n"); |
---|
397 | 385 | } |
---|
398 | 386 | for (i = 0; i < 2; i++) { |
---|
399 | 387 | unsigned int dcr = i ? priv->dcr_cache : readb(priv->regs.dcr); |
---|
400 | 388 | printk(KERN_DEBUG PPIP32 " dcr(%s)=0x%02x", |
---|
401 | 389 | i ? "soft" : "hard", dcr); |
---|
402 | | - printk(" %s", (dcr & DCR_DIR) ? "rev" : "fwd"); |
---|
| 390 | + pr_cont(" %s", (dcr & DCR_DIR) ? "rev" : "fwd"); |
---|
403 | 391 | if (dcr & DCR_IRQ) |
---|
404 | | - printk(",ackIntEn"); |
---|
| 392 | + pr_cont(",ackIntEn"); |
---|
405 | 393 | if (!(dcr & DCR_SELECT)) |
---|
406 | | - printk(",nSelectIn"); |
---|
| 394 | + pr_cont(",nSelectIn"); |
---|
407 | 395 | if (dcr & DCR_nINIT) |
---|
408 | | - printk(",nInit"); |
---|
| 396 | + pr_cont(",nInit"); |
---|
409 | 397 | if (!(dcr & DCR_AUTOFD)) |
---|
410 | | - printk(",nAutoFD"); |
---|
| 398 | + pr_cont(",nAutoFD"); |
---|
411 | 399 | if (!(dcr & DCR_STROBE)) |
---|
412 | | - printk(",nStrobe"); |
---|
413 | | - printk("\n"); |
---|
| 400 | + pr_cont(",nStrobe"); |
---|
| 401 | + pr_cont("\n"); |
---|
414 | 402 | } |
---|
415 | 403 | #define sep (f++ ? ',' : ' ') |
---|
416 | 404 | { |
---|
.. | .. |
---|
418 | 406 | unsigned int dsr = readb(priv->regs.dsr); |
---|
419 | 407 | printk(KERN_DEBUG PPIP32 " dsr=0x%02x", dsr); |
---|
420 | 408 | if (!(dsr & DSR_nBUSY)) |
---|
421 | | - printk("%cBusy", sep); |
---|
| 409 | + pr_cont("%cBusy", sep); |
---|
422 | 410 | if (dsr & DSR_nACK) |
---|
423 | | - printk("%cnAck", sep); |
---|
| 411 | + pr_cont("%cnAck", sep); |
---|
424 | 412 | if (dsr & DSR_PERROR) |
---|
425 | | - printk("%cPError", sep); |
---|
| 413 | + pr_cont("%cPError", sep); |
---|
426 | 414 | if (dsr & DSR_SELECT) |
---|
427 | | - printk("%cSelect", sep); |
---|
| 415 | + pr_cont("%cSelect", sep); |
---|
428 | 416 | if (dsr & DSR_nFAULT) |
---|
429 | | - printk("%cnFault", sep); |
---|
| 417 | + pr_cont("%cnFault", sep); |
---|
430 | 418 | if (!(dsr & DSR_nPRINT)) |
---|
431 | | - printk("%c(Print)", sep); |
---|
| 419 | + pr_cont("%c(Print)", sep); |
---|
432 | 420 | if (dsr & DSR_TIMEOUT) |
---|
433 | | - printk("%cTimeout", sep); |
---|
434 | | - printk("\n"); |
---|
| 421 | + pr_cont("%cTimeout", sep); |
---|
| 422 | + pr_cont("\n"); |
---|
435 | 423 | } |
---|
436 | 424 | #undef sep |
---|
437 | 425 | } |
---|
.. | .. |
---|
568 | 556 | |
---|
569 | 557 | /** |
---|
570 | 558 | * parport_ip32_dma_start - begins a DMA transfer |
---|
| 559 | + * @p: partport to work on |
---|
571 | 560 | * @dir: DMA direction: DMA_TO_DEVICE or DMA_FROM_DEVICE |
---|
572 | 561 | * @addr: pointer to data buffer |
---|
573 | 562 | * @count: buffer size |
---|
.. | .. |
---|
575 | 564 | * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be |
---|
576 | 565 | * correctly balanced. |
---|
577 | 566 | */ |
---|
578 | | -static int parport_ip32_dma_start(enum dma_data_direction dir, |
---|
579 | | - void *addr, size_t count) |
---|
| 567 | +static int parport_ip32_dma_start(struct parport *p, |
---|
| 568 | + enum dma_data_direction dir, void *addr, size_t count) |
---|
580 | 569 | { |
---|
581 | 570 | unsigned int limit; |
---|
582 | 571 | u64 ctrl; |
---|
.. | .. |
---|
601 | 590 | |
---|
602 | 591 | /* Prepare DMA pointers */ |
---|
603 | 592 | parport_ip32_dma.dir = dir; |
---|
604 | | - parport_ip32_dma.buf = dma_map_single(NULL, addr, count, dir); |
---|
| 593 | + parport_ip32_dma.buf = dma_map_single(&p->bus_dev, addr, count, dir); |
---|
605 | 594 | parport_ip32_dma.len = count; |
---|
606 | 595 | parport_ip32_dma.next = parport_ip32_dma.buf; |
---|
607 | 596 | parport_ip32_dma.left = parport_ip32_dma.len; |
---|
.. | .. |
---|
625 | 614 | |
---|
626 | 615 | /** |
---|
627 | 616 | * parport_ip32_dma_stop - ends a running DMA transfer |
---|
| 617 | + * @p: partport to work on |
---|
628 | 618 | * |
---|
629 | 619 | * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be |
---|
630 | 620 | * correctly balanced. |
---|
631 | 621 | */ |
---|
632 | | -static void parport_ip32_dma_stop(void) |
---|
| 622 | +static void parport_ip32_dma_stop(struct parport *p) |
---|
633 | 623 | { |
---|
634 | 624 | u64 ctx_a; |
---|
635 | 625 | u64 ctx_b; |
---|
.. | .. |
---|
685 | 675 | enable_irq(MACEISA_PAR_CTXB_IRQ); |
---|
686 | 676 | parport_ip32_dma.irq_on = 1; |
---|
687 | 677 | |
---|
688 | | - dma_unmap_single(NULL, parport_ip32_dma.buf, parport_ip32_dma.len, |
---|
689 | | - parport_ip32_dma.dir); |
---|
| 678 | + dma_unmap_single(&p->bus_dev, parport_ip32_dma.buf, |
---|
| 679 | + parport_ip32_dma.len, parport_ip32_dma.dir); |
---|
690 | 680 | } |
---|
691 | 681 | |
---|
692 | 682 | /** |
---|
.. | .. |
---|
1348 | 1338 | ecr = parport_ip32_read_econtrol(p); |
---|
1349 | 1339 | if ((ecr & ECR_F_EMPTY) && !(ecr & ECR_SERVINTR) |
---|
1350 | 1340 | && !lost_interrupt) { |
---|
1351 | | - printk(KERN_WARNING PPIP32 |
---|
1352 | | - "%s: lost interrupt in %s\n", |
---|
1353 | | - p->name, __func__); |
---|
| 1341 | + pr_warn(PPIP32 "%s: lost interrupt in %s\n", |
---|
| 1342 | + p->name, __func__); |
---|
1354 | 1343 | lost_interrupt = 1; |
---|
1355 | 1344 | } |
---|
1356 | 1345 | } |
---|
.. | .. |
---|
1445 | 1434 | |
---|
1446 | 1435 | priv->irq_mode = PARPORT_IP32_IRQ_HERE; |
---|
1447 | 1436 | |
---|
1448 | | - parport_ip32_dma_start(DMA_TO_DEVICE, (void *)buf, len); |
---|
| 1437 | + parport_ip32_dma_start(p, DMA_TO_DEVICE, (void *)buf, len); |
---|
1449 | 1438 | reinit_completion(&priv->irq_complete); |
---|
1450 | 1439 | parport_ip32_frob_econtrol(p, ECR_DMAEN | ECR_SERVINTR, ECR_DMAEN); |
---|
1451 | 1440 | |
---|
.. | .. |
---|
1461 | 1450 | if (ecr & ECR_SERVINTR) |
---|
1462 | 1451 | break; /* DMA transfer just finished */ |
---|
1463 | 1452 | } |
---|
1464 | | - parport_ip32_dma_stop(); |
---|
| 1453 | + parport_ip32_dma_stop(p); |
---|
1465 | 1454 | written = len - parport_ip32_dma_get_residue(); |
---|
1466 | 1455 | |
---|
1467 | 1456 | priv->irq_mode = PARPORT_IP32_IRQ_FWD; |
---|
.. | .. |
---|
1654 | 1643 | DSR_nBUSY | DSR_nFAULT)) { |
---|
1655 | 1644 | /* Avoid to flood the logs */ |
---|
1656 | 1645 | if (ready_before) |
---|
1657 | | - printk(KERN_INFO PPIP32 "%s: not ready in %s\n", |
---|
1658 | | - p->name, __func__); |
---|
| 1646 | + pr_info(PPIP32 "%s: not ready in %s\n", |
---|
| 1647 | + p->name, __func__); |
---|
1659 | 1648 | ready_before = 0; |
---|
1660 | 1649 | goto stop; |
---|
1661 | 1650 | } |
---|
.. | .. |
---|
1715 | 1704 | |
---|
1716 | 1705 | /* Event 49: PError goes high. */ |
---|
1717 | 1706 | if (parport_wait_peripheral(p, DSR_PERROR, DSR_PERROR)) { |
---|
1718 | | - printk(KERN_DEBUG PPIP32 "%s: PError timeout in %s", |
---|
| 1707 | + printk(KERN_DEBUG PPIP32 "%s: PError timeout in %s\n", |
---|
1719 | 1708 | p->name, __func__); |
---|
1720 | 1709 | physport->ieee1284.phase = IEEE1284_PH_ECP_DIR_UNKNOWN; |
---|
1721 | 1710 | return 0; |
---|
.. | .. |
---|
1735 | 1724 | DSR_nBUSY | DSR_nFAULT)) { |
---|
1736 | 1725 | /* Avoid to flood the logs */ |
---|
1737 | 1726 | if (ready_before) |
---|
1738 | | - printk(KERN_INFO PPIP32 "%s: not ready in %s\n", |
---|
1739 | | - p->name, __func__); |
---|
| 1727 | + pr_info(PPIP32 "%s: not ready in %s\n", |
---|
| 1728 | + p->name, __func__); |
---|
1740 | 1729 | ready_before = 0; |
---|
1741 | 1730 | goto stop; |
---|
1742 | 1731 | } |
---|
.. | .. |
---|
2075 | 2064 | p->modes |= PARPORT_MODE_TRISTATE; |
---|
2076 | 2065 | |
---|
2077 | 2066 | if (!parport_ip32_fifo_supported(p)) { |
---|
2078 | | - printk(KERN_WARNING PPIP32 |
---|
2079 | | - "%s: error: FIFO disabled\n", p->name); |
---|
| 2067 | + pr_warn(PPIP32 "%s: error: FIFO disabled\n", p->name); |
---|
2080 | 2068 | /* Disable hardware modes depending on a working FIFO. */ |
---|
2081 | 2069 | features &= ~PARPORT_IP32_ENABLE_SPP; |
---|
2082 | 2070 | features &= ~PARPORT_IP32_ENABLE_ECP; |
---|
.. | .. |
---|
2088 | 2076 | if (features & PARPORT_IP32_ENABLE_IRQ) { |
---|
2089 | 2077 | int irq = MACEISA_PARALLEL_IRQ; |
---|
2090 | 2078 | if (request_irq(irq, parport_ip32_interrupt, 0, p->name, p)) { |
---|
2091 | | - printk(KERN_WARNING PPIP32 |
---|
2092 | | - "%s: error: IRQ disabled\n", p->name); |
---|
| 2079 | + pr_warn(PPIP32 "%s: error: IRQ disabled\n", p->name); |
---|
2093 | 2080 | /* DMA cannot work without interrupts. */ |
---|
2094 | 2081 | features &= ~PARPORT_IP32_ENABLE_DMA; |
---|
2095 | 2082 | } else { |
---|
.. | .. |
---|
2102 | 2089 | /* Allocate DMA resources */ |
---|
2103 | 2090 | if (features & PARPORT_IP32_ENABLE_DMA) { |
---|
2104 | 2091 | if (parport_ip32_dma_register()) |
---|
2105 | | - printk(KERN_WARNING PPIP32 |
---|
2106 | | - "%s: error: DMA disabled\n", p->name); |
---|
| 2092 | + pr_warn(PPIP32 "%s: error: DMA disabled\n", p->name); |
---|
2107 | 2093 | else { |
---|
2108 | 2094 | pr_probe(p, "DMA support enabled\n"); |
---|
2109 | 2095 | p->dma = 0; /* arbitrary value != PARPORT_DMA_NONE */ |
---|
.. | .. |
---|
2145 | 2131 | parport_ip32_dump_state(p, "end init", 0); |
---|
2146 | 2132 | |
---|
2147 | 2133 | /* Print out what we found */ |
---|
2148 | | - printk(KERN_INFO "%s: SGI IP32 at 0x%lx (0x%lx)", |
---|
2149 | | - p->name, p->base, p->base_hi); |
---|
| 2134 | + pr_info("%s: SGI IP32 at 0x%lx (0x%lx)", p->name, p->base, p->base_hi); |
---|
2150 | 2135 | if (p->irq != PARPORT_IRQ_NONE) |
---|
2151 | | - printk(", irq %d", p->irq); |
---|
2152 | | - printk(" ["); |
---|
2153 | | -#define printmode(x) if (p->modes & PARPORT_MODE_##x) \ |
---|
2154 | | - printk("%s%s", f++ ? "," : "", #x) |
---|
| 2136 | + pr_cont(", irq %d", p->irq); |
---|
| 2137 | + pr_cont(" ["); |
---|
| 2138 | +#define printmode(x) \ |
---|
| 2139 | +do { \ |
---|
| 2140 | + if (p->modes & PARPORT_MODE_##x) \ |
---|
| 2141 | + pr_cont("%s%s", f++ ? "," : "", #x); \ |
---|
| 2142 | +} while (0) |
---|
2155 | 2143 | { |
---|
2156 | 2144 | unsigned int f = 0; |
---|
2157 | 2145 | printmode(PCSPP); |
---|
.. | .. |
---|
2162 | 2150 | printmode(DMA); |
---|
2163 | 2151 | } |
---|
2164 | 2152 | #undef printmode |
---|
2165 | | - printk("]\n"); |
---|
| 2153 | + pr_cont("]\n"); |
---|
2166 | 2154 | |
---|
2167 | 2155 | parport_announce_port(p); |
---|
2168 | 2156 | return p; |
---|