diff options
Diffstat (limited to 'drivers/serial')
28 files changed, 1294 insertions, 176 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 5261f0af8b10..98ec86185328 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -364,6 +364,23 @@ serial_out(struct uart_8250_port *up, int offset, int value) | |||
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | static void | ||
368 | serial_out_sync(struct uart_8250_port *up, int offset, int value) | ||
369 | { | ||
370 | switch (up->port.iotype) { | ||
371 | case UPIO_MEM: | ||
372 | case UPIO_MEM32: | ||
373 | #ifdef CONFIG_SERIAL_8250_AU1X00 | ||
374 | case UPIO_AU: | ||
375 | #endif | ||
376 | serial_out(up, offset, value); | ||
377 | serial_in(up, UART_LCR); /* safe, no side-effects */ | ||
378 | break; | ||
379 | default: | ||
380 | serial_out(up, offset, value); | ||
381 | } | ||
382 | } | ||
383 | |||
367 | /* | 384 | /* |
368 | * We used to support using pause I/O for certain machines. We | 385 | * We used to support using pause I/O for certain machines. We |
369 | * haven't supported this for a while, but just in case it's badly | 386 | * haven't supported this for a while, but just in case it's badly |
@@ -920,12 +937,16 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) | |||
920 | #ifdef __i386__ | 937 | #ifdef __i386__ |
921 | outb(0xff, 0x080); | 938 | outb(0xff, 0x080); |
922 | #endif | 939 | #endif |
923 | scratch2 = serial_inp(up, UART_IER); | 940 | /* |
941 | * Mask out IER[7:4] bits for test as some UARTs (e.g. TL | ||
942 | * 16C754B) allow only to modify them if an EFR bit is set. | ||
943 | */ | ||
944 | scratch2 = serial_inp(up, UART_IER) & 0x0f; | ||
924 | serial_outp(up, UART_IER, 0x0F); | 945 | serial_outp(up, UART_IER, 0x0F); |
925 | #ifdef __i386__ | 946 | #ifdef __i386__ |
926 | outb(0, 0x080); | 947 | outb(0, 0x080); |
927 | #endif | 948 | #endif |
928 | scratch3 = serial_inp(up, UART_IER); | 949 | scratch3 = serial_inp(up, UART_IER) & 0x0f; |
929 | serial_outp(up, UART_IER, scratch); | 950 | serial_outp(up, UART_IER, scratch); |
930 | if (scratch2 != 0 || scratch3 != 0x0F) { | 951 | if (scratch2 != 0 || scratch3 != 0x0F) { |
931 | /* | 952 | /* |
@@ -1041,7 +1062,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) | |||
1041 | #endif | 1062 | #endif |
1042 | serial_outp(up, UART_MCR, save_mcr); | 1063 | serial_outp(up, UART_MCR, save_mcr); |
1043 | serial8250_clear_fifos(up); | 1064 | serial8250_clear_fifos(up); |
1044 | (void)serial_in(up, UART_RX); | 1065 | serial_in(up, UART_RX); |
1045 | if (up->capabilities & UART_CAP_UUE) | 1066 | if (up->capabilities & UART_CAP_UUE) |
1046 | serial_outp(up, UART_IER, UART_IER_UUE); | 1067 | serial_outp(up, UART_IER, UART_IER_UUE); |
1047 | else | 1068 | else |
@@ -1447,6 +1468,12 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up) | |||
1447 | serial_do_unlink(i, up); | 1468 | serial_do_unlink(i, up); |
1448 | } | 1469 | } |
1449 | 1470 | ||
1471 | /* Base timer interval for polling */ | ||
1472 | static inline int poll_timeout(int timeout) | ||
1473 | { | ||
1474 | return timeout > 6 ? (timeout / 2 - 2) : 1; | ||
1475 | } | ||
1476 | |||
1450 | /* | 1477 | /* |
1451 | * This function is used to handle ports that do not have an | 1478 | * This function is used to handle ports that do not have an |
1452 | * interrupt. This doesn't work very well for 16450's, but gives | 1479 | * interrupt. This doesn't work very well for 16450's, but gives |
@@ -1456,16 +1483,51 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up) | |||
1456 | static void serial8250_timeout(unsigned long data) | 1483 | static void serial8250_timeout(unsigned long data) |
1457 | { | 1484 | { |
1458 | struct uart_8250_port *up = (struct uart_8250_port *)data; | 1485 | struct uart_8250_port *up = (struct uart_8250_port *)data; |
1459 | unsigned int timeout; | ||
1460 | unsigned int iir; | 1486 | unsigned int iir; |
1461 | 1487 | ||
1462 | iir = serial_in(up, UART_IIR); | 1488 | iir = serial_in(up, UART_IIR); |
1463 | if (!(iir & UART_IIR_NO_INT)) | 1489 | if (!(iir & UART_IIR_NO_INT)) |
1464 | serial8250_handle_port(up); | 1490 | serial8250_handle_port(up); |
1491 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); | ||
1492 | } | ||
1493 | |||
1494 | static void serial8250_backup_timeout(unsigned long data) | ||
1495 | { | ||
1496 | struct uart_8250_port *up = (struct uart_8250_port *)data; | ||
1497 | unsigned int iir, ier = 0; | ||
1498 | |||
1499 | /* | ||
1500 | * Must disable interrupts or else we risk racing with the interrupt | ||
1501 | * based handler. | ||
1502 | */ | ||
1503 | if (is_real_interrupt(up->port.irq)) { | ||
1504 | ier = serial_in(up, UART_IER); | ||
1505 | serial_out(up, UART_IER, 0); | ||
1506 | } | ||
1507 | |||
1508 | iir = serial_in(up, UART_IIR); | ||
1509 | |||
1510 | /* | ||
1511 | * This should be a safe test for anyone who doesn't trust the | ||
1512 | * IIR bits on their UART, but it's specifically designed for | ||
1513 | * the "Diva" UART used on the management processor on many HP | ||
1514 | * ia64 and parisc boxes. | ||
1515 | */ | ||
1516 | if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) && | ||
1517 | (!uart_circ_empty(&up->port.info->xmit) || up->port.x_char) && | ||
1518 | (serial_in(up, UART_LSR) & UART_LSR_THRE)) { | ||
1519 | iir &= ~(UART_IIR_ID | UART_IIR_NO_INT); | ||
1520 | iir |= UART_IIR_THRI; | ||
1521 | } | ||
1522 | |||
1523 | if (!(iir & UART_IIR_NO_INT)) | ||
1524 | serial8250_handle_port(up); | ||
1525 | |||
1526 | if (is_real_interrupt(up->port.irq)) | ||
1527 | serial_out(up, UART_IER, ier); | ||
1465 | 1528 | ||
1466 | timeout = up->port.timeout; | 1529 | /* Standard timer interval plus 0.2s to keep the port running */ |
1467 | timeout = timeout > 6 ? (timeout / 2 - 2) : 1; | 1530 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout) + HZ/5); |
1468 | mod_timer(&up->timer, jiffies + timeout); | ||
1469 | } | 1531 | } |
1470 | 1532 | ||
1471 | static unsigned int serial8250_tx_empty(struct uart_port *port) | 1533 | static unsigned int serial8250_tx_empty(struct uart_port *port) |
@@ -1536,6 +1598,37 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state) | |||
1536 | spin_unlock_irqrestore(&up->port.lock, flags); | 1598 | spin_unlock_irqrestore(&up->port.lock, flags); |
1537 | } | 1599 | } |
1538 | 1600 | ||
1601 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | ||
1602 | |||
1603 | /* | ||
1604 | * Wait for transmitter & holding register to empty | ||
1605 | */ | ||
1606 | static inline void wait_for_xmitr(struct uart_8250_port *up, int bits) | ||
1607 | { | ||
1608 | unsigned int status, tmout = 10000; | ||
1609 | |||
1610 | /* Wait up to 10ms for the character(s) to be sent. */ | ||
1611 | do { | ||
1612 | status = serial_in(up, UART_LSR); | ||
1613 | |||
1614 | if (status & UART_LSR_BI) | ||
1615 | up->lsr_break_flag = UART_LSR_BI; | ||
1616 | |||
1617 | if (--tmout == 0) | ||
1618 | break; | ||
1619 | udelay(1); | ||
1620 | } while ((status & bits) != bits); | ||
1621 | |||
1622 | /* Wait up to 1s for flow control if necessary */ | ||
1623 | if (up->port.flags & UPF_CONS_FLOW) { | ||
1624 | tmout = 1000000; | ||
1625 | while (!(serial_in(up, UART_MSR) & UART_MSR_CTS) && --tmout) { | ||
1626 | udelay(1); | ||
1627 | touch_nmi_watchdog(); | ||
1628 | } | ||
1629 | } | ||
1630 | } | ||
1631 | |||
1539 | static int serial8250_startup(struct uart_port *port) | 1632 | static int serial8250_startup(struct uart_port *port) |
1540 | { | 1633 | { |
1541 | struct uart_8250_port *up = (struct uart_8250_port *)port; | 1634 | struct uart_8250_port *up = (struct uart_8250_port *)port; |
@@ -1609,18 +1702,50 @@ static int serial8250_startup(struct uart_port *port) | |||
1609 | serial_outp(up, UART_LCR, 0); | 1702 | serial_outp(up, UART_LCR, 0); |
1610 | } | 1703 | } |
1611 | 1704 | ||
1705 | if (is_real_interrupt(up->port.irq)) { | ||
1706 | /* | ||
1707 | * Test for UARTs that do not reassert THRE when the | ||
1708 | * transmitter is idle and the interrupt has already | ||
1709 | * been cleared. Real 16550s should always reassert | ||
1710 | * this interrupt whenever the transmitter is idle and | ||
1711 | * the interrupt is enabled. Delays are necessary to | ||
1712 | * allow register changes to become visible. | ||
1713 | */ | ||
1714 | spin_lock_irqsave(&up->port.lock, flags); | ||
1715 | |||
1716 | wait_for_xmitr(up, UART_LSR_THRE); | ||
1717 | serial_out_sync(up, UART_IER, UART_IER_THRI); | ||
1718 | udelay(1); /* allow THRE to set */ | ||
1719 | serial_in(up, UART_IIR); | ||
1720 | serial_out(up, UART_IER, 0); | ||
1721 | serial_out_sync(up, UART_IER, UART_IER_THRI); | ||
1722 | udelay(1); /* allow a working UART time to re-assert THRE */ | ||
1723 | iir = serial_in(up, UART_IIR); | ||
1724 | serial_out(up, UART_IER, 0); | ||
1725 | |||
1726 | spin_unlock_irqrestore(&up->port.lock, flags); | ||
1727 | |||
1728 | /* | ||
1729 | * If the interrupt is not reasserted, setup a timer to | ||
1730 | * kick the UART on a regular basis. | ||
1731 | */ | ||
1732 | if (iir & UART_IIR_NO_INT) { | ||
1733 | pr_debug("ttyS%d - using backup timer\n", port->line); | ||
1734 | up->timer.function = serial8250_backup_timeout; | ||
1735 | up->timer.data = (unsigned long)up; | ||
1736 | mod_timer(&up->timer, jiffies + | ||
1737 | poll_timeout(up->port.timeout) + HZ/5); | ||
1738 | } | ||
1739 | } | ||
1740 | |||
1612 | /* | 1741 | /* |
1613 | * If the "interrupt" for this port doesn't correspond with any | 1742 | * If the "interrupt" for this port doesn't correspond with any |
1614 | * hardware interrupt, we use a timer-based system. The original | 1743 | * hardware interrupt, we use a timer-based system. The original |
1615 | * driver used to do this with IRQ0. | 1744 | * driver used to do this with IRQ0. |
1616 | */ | 1745 | */ |
1617 | if (!is_real_interrupt(up->port.irq)) { | 1746 | if (!is_real_interrupt(up->port.irq)) { |
1618 | unsigned int timeout = up->port.timeout; | ||
1619 | |||
1620 | timeout = timeout > 6 ? (timeout / 2 - 2) : 1; | ||
1621 | |||
1622 | up->timer.data = (unsigned long)up; | 1747 | up->timer.data = (unsigned long)up; |
1623 | mod_timer(&up->timer, jiffies + timeout); | 1748 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); |
1624 | } else { | 1749 | } else { |
1625 | retval = serial_link_irq_chain(up); | 1750 | retval = serial_link_irq_chain(up); |
1626 | if (retval) | 1751 | if (retval) |
@@ -1736,9 +1861,9 @@ static void serial8250_shutdown(struct uart_port *port) | |||
1736 | */ | 1861 | */ |
1737 | (void) serial_in(up, UART_RX); | 1862 | (void) serial_in(up, UART_RX); |
1738 | 1863 | ||
1739 | if (!is_real_interrupt(up->port.irq)) | 1864 | del_timer_sync(&up->timer); |
1740 | del_timer_sync(&up->timer); | 1865 | up->timer.function = serial8250_timeout; |
1741 | else | 1866 | if (is_real_interrupt(up->port.irq)) |
1742 | serial_unlink_irq_chain(up); | 1867 | serial_unlink_irq_chain(up); |
1743 | } | 1868 | } |
1744 | 1869 | ||
@@ -2208,37 +2333,6 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) | |||
2208 | 2333 | ||
2209 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 2334 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
2210 | 2335 | ||
2211 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | ||
2212 | |||
2213 | /* | ||
2214 | * Wait for transmitter & holding register to empty | ||
2215 | */ | ||
2216 | static inline void wait_for_xmitr(struct uart_8250_port *up, int bits) | ||
2217 | { | ||
2218 | unsigned int status, tmout = 10000; | ||
2219 | |||
2220 | /* Wait up to 10ms for the character(s) to be sent. */ | ||
2221 | do { | ||
2222 | status = serial_in(up, UART_LSR); | ||
2223 | |||
2224 | if (status & UART_LSR_BI) | ||
2225 | up->lsr_break_flag = UART_LSR_BI; | ||
2226 | |||
2227 | if (--tmout == 0) | ||
2228 | break; | ||
2229 | udelay(1); | ||
2230 | } while ((status & bits) != bits); | ||
2231 | |||
2232 | /* Wait up to 1s for flow control if necessary */ | ||
2233 | if (up->port.flags & UPF_CONS_FLOW) { | ||
2234 | tmout = 1000000; | ||
2235 | while (!(serial_in(up, UART_MSR) & UART_MSR_CTS) && --tmout) { | ||
2236 | udelay(1); | ||
2237 | touch_nmi_watchdog(); | ||
2238 | } | ||
2239 | } | ||
2240 | } | ||
2241 | |||
2242 | static void serial8250_console_putchar(struct uart_port *port, int ch) | 2336 | static void serial8250_console_putchar(struct uart_port *port, int ch) |
2243 | { | 2337 | { |
2244 | struct uart_8250_port *up = (struct uart_8250_port *)port; | 2338 | struct uart_8250_port *up = (struct uart_8250_port *)port; |
diff --git a/drivers/serial/8250_acorn.c b/drivers/serial/8250_acorn.c index ef8cc8a70c60..562ba745a044 100644 --- a/drivers/serial/8250_acorn.c +++ b/drivers/serial/8250_acorn.c | |||
@@ -47,11 +47,10 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
47 | unsigned long bus_addr; | 47 | unsigned long bus_addr; |
48 | unsigned int i; | 48 | unsigned int i; |
49 | 49 | ||
50 | info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL); | 50 | info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL); |
51 | if (!info) | 51 | if (!info) |
52 | return -ENOMEM; | 52 | return -ENOMEM; |
53 | 53 | ||
54 | memset(info, 0, sizeof(struct serial_card_info)); | ||
55 | info->num_ports = type->num_ports; | 54 | info->num_ports = type->num_ports; |
56 | 55 | ||
57 | bus_addr = ecard_resource_start(ec, type->type); | 56 | bus_addr = ecard_resource_start(ec, type->type); |
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 52e2e64c6649..6d7d616e9ccd 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
19 | #include <linux/sched.h> | ||
20 | #include <linux/string.h> | 19 | #include <linux/string.h> |
21 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
22 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
@@ -679,6 +678,13 @@ static struct pci_serial_quirk pci_serial_quirks[] = { | |||
679 | */ | 678 | */ |
680 | { | 679 | { |
681 | .vendor = PCI_VENDOR_ID_PLX, | 680 | .vendor = PCI_VENDOR_ID_PLX, |
681 | .device = PCI_DEVICE_ID_PLX_9030, | ||
682 | .subvendor = PCI_SUBVENDOR_ID_PERLE, | ||
683 | .subdevice = PCI_ANY_ID, | ||
684 | .setup = pci_default_setup, | ||
685 | }, | ||
686 | { | ||
687 | .vendor = PCI_VENDOR_ID_PLX, | ||
682 | .device = PCI_DEVICE_ID_PLX_9050, | 688 | .device = PCI_DEVICE_ID_PLX_9050, |
683 | .subvendor = PCI_SUBVENDOR_ID_EXSYS, | 689 | .subvendor = PCI_SUBVENDOR_ID_EXSYS, |
684 | .subdevice = PCI_SUBDEVICE_ID_EXSYS_4055, | 690 | .subdevice = PCI_SUBDEVICE_ID_EXSYS_4055, |
@@ -936,6 +942,7 @@ enum pci_board_num_t { | |||
936 | 942 | ||
937 | pbn_b2_1_115200, | 943 | pbn_b2_1_115200, |
938 | pbn_b2_2_115200, | 944 | pbn_b2_2_115200, |
945 | pbn_b2_4_115200, | ||
939 | pbn_b2_8_115200, | 946 | pbn_b2_8_115200, |
940 | 947 | ||
941 | pbn_b2_1_460800, | 948 | pbn_b2_1_460800, |
@@ -1249,6 +1256,12 @@ static struct pciserial_board pci_boards[] __devinitdata = { | |||
1249 | .base_baud = 115200, | 1256 | .base_baud = 115200, |
1250 | .uart_offset = 8, | 1257 | .uart_offset = 8, |
1251 | }, | 1258 | }, |
1259 | [pbn_b2_4_115200] = { | ||
1260 | .flags = FL_BASE2, | ||
1261 | .num_ports = 4, | ||
1262 | .base_baud = 115200, | ||
1263 | .uart_offset = 8, | ||
1264 | }, | ||
1252 | [pbn_b2_8_115200] = { | 1265 | [pbn_b2_8_115200] = { |
1253 | .flags = FL_BASE2, | 1266 | .flags = FL_BASE2, |
1254 | .num_ports = 8, | 1267 | .num_ports = 8, |
@@ -1614,7 +1627,7 @@ pciserial_init_ports(struct pci_dev *dev, struct pciserial_board *board) | |||
1614 | nr_ports = rc; | 1627 | nr_ports = rc; |
1615 | } | 1628 | } |
1616 | 1629 | ||
1617 | priv = kmalloc(sizeof(struct serial_private) + | 1630 | priv = kzalloc(sizeof(struct serial_private) + |
1618 | sizeof(unsigned int) * nr_ports, | 1631 | sizeof(unsigned int) * nr_ports, |
1619 | GFP_KERNEL); | 1632 | GFP_KERNEL); |
1620 | if (!priv) { | 1633 | if (!priv) { |
@@ -1622,9 +1635,6 @@ pciserial_init_ports(struct pci_dev *dev, struct pciserial_board *board) | |||
1622 | goto err_deinit; | 1635 | goto err_deinit; |
1623 | } | 1636 | } |
1624 | 1637 | ||
1625 | memset(priv, 0, sizeof(struct serial_private) + | ||
1626 | sizeof(unsigned int) * nr_ports); | ||
1627 | |||
1628 | priv->dev = dev; | 1638 | priv->dev = dev; |
1629 | priv->quirk = quirk; | 1639 | priv->quirk = quirk; |
1630 | 1640 | ||
@@ -1990,6 +2000,10 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
1990 | { PCI_VENDOR_ID_PANACOM, PCI_DEVICE_ID_PANACOM_DUALMODEM, | 2000 | { PCI_VENDOR_ID_PANACOM, PCI_DEVICE_ID_PANACOM_DUALMODEM, |
1991 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 2001 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
1992 | pbn_panacom2 }, | 2002 | pbn_panacom2 }, |
2003 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, | ||
2004 | PCI_VENDOR_ID_ESDGMBH, | ||
2005 | PCI_DEVICE_ID_ESDGMBH_CPCIASIO4, 0, 0, | ||
2006 | pbn_b2_4_115200 }, | ||
1993 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, | 2007 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, |
1994 | PCI_SUBVENDOR_ID_CHASE_PCIFAST, | 2008 | PCI_SUBVENDOR_ID_CHASE_PCIFAST, |
1995 | PCI_SUBDEVICE_ID_CHASE_PCIFAST4, 0, 0, | 2009 | PCI_SUBDEVICE_ID_CHASE_PCIFAST4, 0, 0, |
@@ -2379,6 +2393,15 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
2379 | pbn_b2_2_115200 }, | 2393 | pbn_b2_2_115200 }, |
2380 | 2394 | ||
2381 | /* | 2395 | /* |
2396 | * Perle PCI-RAS cards | ||
2397 | */ | ||
2398 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, | ||
2399 | PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS4, | ||
2400 | 0, 0, pbn_b2_4_921600 }, | ||
2401 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, | ||
2402 | PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS8, | ||
2403 | 0, 0, pbn_b2_8_921600 }, | ||
2404 | /* | ||
2382 | * These entries match devices with class COMMUNICATION_SERIAL, | 2405 | * These entries match devices with class COMMUNICATION_SERIAL, |
2383 | * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL | 2406 | * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL |
2384 | */ | 2407 | */ |
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c index d3d6b82706b5..cde5db44abf6 100644 --- a/drivers/serial/8250_pnp.c +++ b/drivers/serial/8250_pnp.c | |||
@@ -450,11 +450,11 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | |||
450 | port.dev = &dev->dev; | 450 | port.dev = &dev->dev; |
451 | 451 | ||
452 | line = serial8250_register_port(&port); | 452 | line = serial8250_register_port(&port); |
453 | if (line < 0) | ||
454 | return -ENODEV; | ||
453 | 455 | ||
454 | if (line >= 0) | 456 | pnp_set_drvdata(dev, (void *)((long)line + 1)); |
455 | pnp_set_drvdata(dev, (void *)((long)line + 1)); | 457 | return 0; |
456 | return line >= 0 ? 0 : -ENODEV; | ||
457 | |||
458 | } | 458 | } |
459 | 459 | ||
460 | static void __devexit serial_pnp_remove(struct pnp_dev *dev) | 460 | static void __devexit serial_pnp_remove(struct pnp_dev *dev) |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 09f8bff1fbd1..ad9f321968e1 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -687,6 +687,22 @@ config SERIAL_SH_SCI_CONSOLE | |||
687 | depends on SERIAL_SH_SCI=y | 687 | depends on SERIAL_SH_SCI=y |
688 | select SERIAL_CORE_CONSOLE | 688 | select SERIAL_CORE_CONSOLE |
689 | 689 | ||
690 | config SERIAL_PNX8XXX | ||
691 | bool "Enable PNX8XXX SoCs' UART Support" | ||
692 | depends on MIPS && SOC_PNX8550 | ||
693 | select SERIAL_CORE | ||
694 | help | ||
695 | If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330 | ||
696 | and you want to use serial ports, say Y. Otherwise, say N. | ||
697 | |||
698 | config SERIAL_PNX8XXX_CONSOLE | ||
699 | bool "Enable PNX8XX0 serial console" | ||
700 | depends on SERIAL_PNX8XXX | ||
701 | select SERIAL_CORE_CONSOLE | ||
702 | help | ||
703 | If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330 | ||
704 | and you want to use serial console, say Y. Otherwise, say N. | ||
705 | |||
690 | config SERIAL_CORE | 706 | config SERIAL_CORE |
691 | tristate | 707 | tristate |
692 | 708 | ||
@@ -917,6 +933,11 @@ config SERIAL_TXX9 | |||
917 | config HAS_TXX9_SERIAL | 933 | config HAS_TXX9_SERIAL |
918 | bool | 934 | bool |
919 | 935 | ||
936 | config SERIAL_TXX9_NR_UARTS | ||
937 | int "Maximum number of TMPTX39XX/49XX SIO ports" | ||
938 | depends on SERIAL_TXX9 | ||
939 | default "6" | ||
940 | |||
920 | config SERIAL_TXX9_CONSOLE | 941 | config SERIAL_TXX9_CONSOLE |
921 | bool "TMPTX39XX/49XX SIO Console support" | 942 | bool "TMPTX39XX/49XX SIO Console support" |
922 | depends on SERIAL_TXX9=y | 943 | depends on SERIAL_TXX9=y |
@@ -995,4 +1016,14 @@ config SERIAL_NETX_CONSOLE | |||
995 | If you have enabled the serial port on the Motorola IMX | 1016 | If you have enabled the serial port on the Motorola IMX |
996 | CPU you can make it the console by answering Y to this option. | 1017 | CPU you can make it the console by answering Y to this option. |
997 | 1018 | ||
1019 | config SERIAL_OF_PLATFORM | ||
1020 | tristate "Serial port on Open Firmware platform bus" | ||
1021 | depends on PPC_OF | ||
1022 | depends on SERIAL_8250 | ||
1023 | help | ||
1024 | If you have a PowerPC based system that has serial ports | ||
1025 | on a platform specific bus, you should enable this option. | ||
1026 | Currently, only 8250 compatible ports are supported, but | ||
1027 | others can easily be added. | ||
1028 | |||
998 | endmenu | 1029 | endmenu |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index df3632cd7df9..6b3560c5749a 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -25,6 +25,7 @@ obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o | |||
25 | obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o | 25 | obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o |
26 | obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o | 26 | obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o |
27 | obj-$(CONFIG_SERIAL_PXA) += pxa.o | 27 | obj-$(CONFIG_SERIAL_PXA) += pxa.o |
28 | obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o | ||
28 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o | 29 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o |
29 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o | 30 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o |
30 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o | 31 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o |
@@ -58,3 +59,4 @@ obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o | |||
58 | obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o | 59 | obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o |
59 | obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o | 60 | obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o |
60 | obj-$(CONFIG_SERIAL_NETX) += netx-serial.o | 61 | obj-$(CONFIG_SERIAL_NETX) += netx-serial.o |
62 | obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o | ||
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c index 071564790993..935f48fa501d 100644 --- a/drivers/serial/atmel_serial.c +++ b/drivers/serial/atmel_serial.c | |||
@@ -74,35 +74,35 @@ | |||
74 | 74 | ||
75 | #define ATMEL_ISR_PASS_LIMIT 256 | 75 | #define ATMEL_ISR_PASS_LIMIT 256 |
76 | 76 | ||
77 | #define UART_PUT_CR(port,v) writel(v, (port)->membase + ATMEL_US_CR) | 77 | #define UART_PUT_CR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_CR) |
78 | #define UART_GET_MR(port) readl((port)->membase + ATMEL_US_MR) | 78 | #define UART_GET_MR(port) __raw_readl((port)->membase + ATMEL_US_MR) |
79 | #define UART_PUT_MR(port,v) writel(v, (port)->membase + ATMEL_US_MR) | 79 | #define UART_PUT_MR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_MR) |
80 | #define UART_PUT_IER(port,v) writel(v, (port)->membase + ATMEL_US_IER) | 80 | #define UART_PUT_IER(port,v) __raw_writel(v, (port)->membase + ATMEL_US_IER) |
81 | #define UART_PUT_IDR(port,v) writel(v, (port)->membase + ATMEL_US_IDR) | 81 | #define UART_PUT_IDR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_IDR) |
82 | #define UART_GET_IMR(port) readl((port)->membase + ATMEL_US_IMR) | 82 | #define UART_GET_IMR(port) __raw_readl((port)->membase + ATMEL_US_IMR) |
83 | #define UART_GET_CSR(port) readl((port)->membase + ATMEL_US_CSR) | 83 | #define UART_GET_CSR(port) __raw_readl((port)->membase + ATMEL_US_CSR) |
84 | #define UART_GET_CHAR(port) readl((port)->membase + ATMEL_US_RHR) | 84 | #define UART_GET_CHAR(port) __raw_readl((port)->membase + ATMEL_US_RHR) |
85 | #define UART_PUT_CHAR(port,v) writel(v, (port)->membase + ATMEL_US_THR) | 85 | #define UART_PUT_CHAR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_THR) |
86 | #define UART_GET_BRGR(port) readl((port)->membase + ATMEL_US_BRGR) | 86 | #define UART_GET_BRGR(port) __raw_readl((port)->membase + ATMEL_US_BRGR) |
87 | #define UART_PUT_BRGR(port,v) writel(v, (port)->membase + ATMEL_US_BRGR) | 87 | #define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR) |
88 | #define UART_PUT_RTOR(port,v) writel(v, (port)->membase + ATMEL_US_RTOR) | 88 | #define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR) |
89 | 89 | ||
90 | // #define UART_GET_CR(port) readl((port)->membase + ATMEL_US_CR) // is write-only | 90 | // #define UART_GET_CR(port) __raw_readl((port)->membase + ATMEL_US_CR) // is write-only |
91 | 91 | ||
92 | /* PDC registers */ | 92 | /* PDC registers */ |
93 | #define UART_PUT_PTCR(port,v) writel(v, (port)->membase + ATMEL_PDC_PTCR) | 93 | #define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) |
94 | #define UART_GET_PTSR(port) readl((port)->membase + ATMEL_PDC_PTSR) | 94 | #define UART_GET_PTSR(port) __raw_readl((port)->membase + ATMEL_PDC_PTSR) |
95 | 95 | ||
96 | #define UART_PUT_RPR(port,v) writel(v, (port)->membase + ATMEL_PDC_RPR) | 96 | #define UART_PUT_RPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RPR) |
97 | #define UART_GET_RPR(port) readl((port)->membase + ATMEL_PDC_RPR) | 97 | #define UART_GET_RPR(port) __raw_readl((port)->membase + ATMEL_PDC_RPR) |
98 | #define UART_PUT_RCR(port,v) writel(v, (port)->membase + ATMEL_PDC_RCR) | 98 | #define UART_PUT_RCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RCR) |
99 | #define UART_PUT_RNPR(port,v) writel(v, (port)->membase + ATMEL_PDC_RNPR) | 99 | #define UART_PUT_RNPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RNPR) |
100 | #define UART_PUT_RNCR(port,v) writel(v, (port)->membase + ATMEL_PDC_RNCR) | 100 | #define UART_PUT_RNCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RNCR) |
101 | 101 | ||
102 | #define UART_PUT_TPR(port,v) writel(v, (port)->membase + ATMEL_PDC_TPR) | 102 | #define UART_PUT_TPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TPR) |
103 | #define UART_PUT_TCR(port,v) writel(v, (port)->membase + ATMEL_PDC_TCR) | 103 | #define UART_PUT_TCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TCR) |
104 | //#define UART_PUT_TNPR(port,v) writel(v, (port)->membase + ATMEL_PDC_TNPR) | 104 | //#define UART_PUT_TNPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TNPR) |
105 | //#define UART_PUT_TNCR(port,v) writel(v, (port)->membase + ATMEL_PDC_TNCR) | 105 | //#define UART_PUT_TNCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TNCR) |
106 | 106 | ||
107 | static int (*atmel_open_hook)(struct uart_port *); | 107 | static int (*atmel_open_hook)(struct uart_port *); |
108 | static void (*atmel_close_hook)(struct uart_port *); | 108 | static void (*atmel_close_hook)(struct uart_port *); |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c index 08e55fdc882a..925fb607d8c4 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | #include <asm/io.h> | 41 | #include <asm/io.h> |
42 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
43 | #include <asm/fs_pd.h> | ||
43 | 44 | ||
44 | #include <linux/serial_core.h> | 45 | #include <linux/serial_core.h> |
45 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
@@ -145,7 +146,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
145 | /* was hostalloc but changed cause it blows away the */ | 146 | /* was hostalloc but changed cause it blows away the */ |
146 | /* large tlb mapping when pinning the kernel area */ | 147 | /* large tlb mapping when pinning the kernel area */ |
147 | mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8)); | 148 | mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8)); |
148 | dma_addr = (u32)mem_addr; | 149 | dma_addr = (u32)cpm_dpram_phys(mem_addr); |
149 | } else | 150 | } else |
150 | mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr, | 151 | mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr, |
151 | GFP_KERNEL); | 152 | GFP_KERNEL); |
@@ -205,7 +206,7 @@ int __init cpm_uart_init_portdesc(void) | |||
205 | (unsigned long)&cpmp->cp_smc[0]; | 206 | (unsigned long)&cpmp->cp_smc[0]; |
206 | cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX); | 207 | cpm_uart_ports[UART_SMC1].smcp->smc_smcm |= (SMCM_RX | SMCM_TX); |
207 | cpm_uart_ports[UART_SMC1].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); | 208 | cpm_uart_ports[UART_SMC1].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); |
208 | cpm_uart_ports[UART_SMC1].port.uartclk = (((bd_t *) __res)->bi_intfreq); | 209 | cpm_uart_ports[UART_SMC1].port.uartclk = uart_clock(); |
209 | cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1; | 210 | cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1; |
210 | #endif | 211 | #endif |
211 | 212 | ||
@@ -217,7 +218,7 @@ int __init cpm_uart_init_portdesc(void) | |||
217 | (unsigned long)&cpmp->cp_smc[1]; | 218 | (unsigned long)&cpmp->cp_smc[1]; |
218 | cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX); | 219 | cpm_uart_ports[UART_SMC2].smcp->smc_smcm |= (SMCM_RX | SMCM_TX); |
219 | cpm_uart_ports[UART_SMC2].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); | 220 | cpm_uart_ports[UART_SMC2].smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); |
220 | cpm_uart_ports[UART_SMC2].port.uartclk = (((bd_t *) __res)->bi_intfreq); | 221 | cpm_uart_ports[UART_SMC2].port.uartclk = uart_clock(); |
221 | cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2; | 222 | cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2; |
222 | #endif | 223 | #endif |
223 | 224 | ||
@@ -231,7 +232,7 @@ int __init cpm_uart_init_portdesc(void) | |||
231 | ~(UART_SCCM_TX | UART_SCCM_RX); | 232 | ~(UART_SCCM_TX | UART_SCCM_RX); |
232 | cpm_uart_ports[UART_SCC1].sccp->scc_gsmrl &= | 233 | cpm_uart_ports[UART_SCC1].sccp->scc_gsmrl &= |
233 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); | 234 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); |
234 | cpm_uart_ports[UART_SCC1].port.uartclk = (((bd_t *) __res)->bi_intfreq); | 235 | cpm_uart_ports[UART_SCC1].port.uartclk = uart_clock(); |
235 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1; | 236 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1; |
236 | #endif | 237 | #endif |
237 | 238 | ||
@@ -245,7 +246,7 @@ int __init cpm_uart_init_portdesc(void) | |||
245 | ~(UART_SCCM_TX | UART_SCCM_RX); | 246 | ~(UART_SCCM_TX | UART_SCCM_RX); |
246 | cpm_uart_ports[UART_SCC2].sccp->scc_gsmrl &= | 247 | cpm_uart_ports[UART_SCC2].sccp->scc_gsmrl &= |
247 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); | 248 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); |
248 | cpm_uart_ports[UART_SCC2].port.uartclk = (((bd_t *) __res)->bi_intfreq); | 249 | cpm_uart_ports[UART_SCC2].port.uartclk = uart_clock(); |
249 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2; | 250 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2; |
250 | #endif | 251 | #endif |
251 | 252 | ||
@@ -259,7 +260,7 @@ int __init cpm_uart_init_portdesc(void) | |||
259 | ~(UART_SCCM_TX | UART_SCCM_RX); | 260 | ~(UART_SCCM_TX | UART_SCCM_RX); |
260 | cpm_uart_ports[UART_SCC3].sccp->scc_gsmrl &= | 261 | cpm_uart_ports[UART_SCC3].sccp->scc_gsmrl &= |
261 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); | 262 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); |
262 | cpm_uart_ports[UART_SCC3].port.uartclk = (((bd_t *) __res)->bi_intfreq); | 263 | cpm_uart_ports[UART_SCC3].port.uartclk = uart_clock(); |
263 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3; | 264 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3; |
264 | #endif | 265 | #endif |
265 | 266 | ||
@@ -273,7 +274,7 @@ int __init cpm_uart_init_portdesc(void) | |||
273 | ~(UART_SCCM_TX | UART_SCCM_RX); | 274 | ~(UART_SCCM_TX | UART_SCCM_RX); |
274 | cpm_uart_ports[UART_SCC4].sccp->scc_gsmrl &= | 275 | cpm_uart_ports[UART_SCC4].sccp->scc_gsmrl &= |
275 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); | 276 | ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); |
276 | cpm_uart_ports[UART_SCC4].port.uartclk = (((bd_t *) __res)->bi_intfreq); | 277 | cpm_uart_ports[UART_SCC4].port.uartclk = uart_clock(); |
277 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4; | 278 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4; |
278 | #endif | 279 | #endif |
279 | return 0; | 280 | return 0; |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.h b/drivers/serial/cpm_uart/cpm_uart_cpm1.h index 5eb49ea63bfe..a99e45e2b6d8 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm1.h +++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.h | |||
@@ -20,9 +20,6 @@ | |||
20 | #define SCC3_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC3) | 20 | #define SCC3_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC3) |
21 | #define SCC4_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC4) | 21 | #define SCC4_IRQ (CPM_IRQ_OFFSET + CPMVEC_SCC4) |
22 | 22 | ||
23 | /* the CPM address */ | ||
24 | #define CPM_ADDR IMAP_ADDR | ||
25 | |||
26 | static inline void cpm_set_brg(int brg, int baud) | 23 | static inline void cpm_set_brg(int brg, int baud) |
27 | { | 24 | { |
28 | cpm_setbrg(brg, baud); | 25 | cpm_setbrg(brg, baud); |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index 787a8f134677..fa455996ad8f 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -285,7 +285,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo) | |||
285 | int __init cpm_uart_init_portdesc(void) | 285 | int __init cpm_uart_init_portdesc(void) |
286 | { | 286 | { |
287 | #if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) | 287 | #if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) |
288 | u32 addr; | 288 | u16 *addr; |
289 | #endif | 289 | #endif |
290 | pr_debug("CPM uart[-]:init portdesc\n"); | 290 | pr_debug("CPM uart[-]:init portdesc\n"); |
291 | 291 | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.h b/drivers/serial/cpm_uart/cpm_uart_cpm2.h index 4b779111eaf9..1b3219f56c81 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.h +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.h | |||
@@ -20,9 +20,6 @@ | |||
20 | #define SCC3_IRQ SIU_INT_SCC3 | 20 | #define SCC3_IRQ SIU_INT_SCC3 |
21 | #define SCC4_IRQ SIU_INT_SCC4 | 21 | #define SCC4_IRQ SIU_INT_SCC4 |
22 | 22 | ||
23 | /* the CPM address */ | ||
24 | #define CPM_ADDR CPM_MAP_ADDR | ||
25 | |||
26 | static inline void cpm_set_brg(int brg, int baud) | 23 | static inline void cpm_set_brg(int brg, int baud) |
27 | { | 24 | { |
28 | cpm_setbrg(brg, baud); | 25 | cpm_setbrg(brg, baud); |
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 42b050c46abe..312bef6bd583 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -3173,12 +3173,8 @@ do_softint(void *private_) | |||
3173 | if (!tty) | 3173 | if (!tty) |
3174 | return; | 3174 | return; |
3175 | 3175 | ||
3176 | if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) { | 3176 | if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) |
3177 | if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && | 3177 | tty_wakeup(tty); |
3178 | tty->ldisc.write_wakeup) | ||
3179 | (tty->ldisc.write_wakeup)(tty); | ||
3180 | wake_up_interruptible(&tty->write_wait); | ||
3181 | } | ||
3182 | } | 3178 | } |
3183 | 3179 | ||
3184 | static int | 3180 | static int |
@@ -3798,11 +3794,7 @@ rs_flush_buffer(struct tty_struct *tty) | |||
3798 | info->xmit.head = info->xmit.tail = 0; | 3794 | info->xmit.head = info->xmit.tail = 0; |
3799 | restore_flags(flags); | 3795 | restore_flags(flags); |
3800 | 3796 | ||
3801 | wake_up_interruptible(&tty->write_wait); | 3797 | tty_wakeup(tty); |
3802 | |||
3803 | if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && | ||
3804 | tty->ldisc.write_wakeup) | ||
3805 | (tty->ldisc.write_wakeup)(tty); | ||
3806 | } | 3798 | } |
3807 | 3799 | ||
3808 | /* | 3800 | /* |
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c index 71e6a24d8c28..41431d0d5512 100644 --- a/drivers/serial/icom.c +++ b/drivers/serial/icom.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/signal.h> | 29 | #include <linux/signal.h> |
30 | #include <linux/sched.h> | ||
31 | #include <linux/timer.h> | 30 | #include <linux/timer.h> |
32 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
33 | #include <linux/tty.h> | 32 | #include <linux/tty.h> |
@@ -1417,14 +1416,12 @@ static int __devinit icom_alloc_adapter(struct icom_adapter | |||
1417 | struct list_head *tmp; | 1416 | struct list_head *tmp; |
1418 | 1417 | ||
1419 | icom_adapter = (struct icom_adapter *) | 1418 | icom_adapter = (struct icom_adapter *) |
1420 | kmalloc(sizeof(struct icom_adapter), GFP_KERNEL); | 1419 | kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); |
1421 | 1420 | ||
1422 | if (!icom_adapter) { | 1421 | if (!icom_adapter) { |
1423 | return -ENOMEM; | 1422 | return -ENOMEM; |
1424 | } | 1423 | } |
1425 | 1424 | ||
1426 | memset(icom_adapter, 0, sizeof(struct icom_adapter)); | ||
1427 | |||
1428 | list_for_each(tmp, &icom_adapter_head) { | 1425 | list_for_each(tmp, &icom_adapter_head) { |
1429 | cur_adapter_entry = | 1426 | cur_adapter_entry = |
1430 | list_entry(tmp, struct icom_adapter, | 1427 | list_entry(tmp, struct icom_adapter, |
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c index 9cc0be932316..168073f12cec 100644 --- a/drivers/serial/ioc3_serial.c +++ b/drivers/serial/ioc3_serial.c | |||
@@ -2019,13 +2019,12 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd) | |||
2019 | 2019 | ||
2020 | DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); | 2020 | DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); |
2021 | 2021 | ||
2022 | card_ptr = kmalloc(sizeof(struct ioc3_card), GFP_KERNEL); | 2022 | card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL); |
2023 | if (!card_ptr) { | 2023 | if (!card_ptr) { |
2024 | printk(KERN_WARNING "ioc3_attach_one" | 2024 | printk(KERN_WARNING "ioc3_attach_one" |
2025 | ": unable to get memory for the IOC3\n"); | 2025 | ": unable to get memory for the IOC3\n"); |
2026 | return -ENOMEM; | 2026 | return -ENOMEM; |
2027 | } | 2027 | } |
2028 | memset(card_ptr, 0, sizeof(struct ioc3_card)); | ||
2029 | idd->data[is->id] = card_ptr; | 2028 | idd->data[is->id] = card_ptr; |
2030 | Submodule_slot = is->id; | 2029 | Submodule_slot = is->id; |
2031 | 2030 | ||
@@ -2040,13 +2039,12 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd) | |||
2040 | 2039 | ||
2041 | /* Create port structures for each port */ | 2040 | /* Create port structures for each port */ |
2042 | for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) { | 2041 | for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) { |
2043 | port = kmalloc(sizeof(struct ioc3_port), GFP_KERNEL); | 2042 | port = kzalloc(sizeof(struct ioc3_port), GFP_KERNEL); |
2044 | if (!port) { | 2043 | if (!port) { |
2045 | printk(KERN_WARNING | 2044 | printk(KERN_WARNING |
2046 | "IOC3 serial memory not available for port\n"); | 2045 | "IOC3 serial memory not available for port\n"); |
2047 | goto out4; | 2046 | goto out4; |
2048 | } | 2047 | } |
2049 | memset(port, 0, sizeof(struct ioc3_port)); | ||
2050 | spin_lock_init(&port->ip_lock); | 2048 | spin_lock_init(&port->ip_lock); |
2051 | 2049 | ||
2052 | /* we need to remember the previous ones, to point back to | 2050 | /* we need to remember the previous ones, to point back to |
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c index c862f67c985a..0c179384fb0c 100644 --- a/drivers/serial/ioc4_serial.c +++ b/drivers/serial/ioc4_serial.c | |||
@@ -1076,13 +1076,12 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd) | |||
1076 | /* Create port structures for each port */ | 1076 | /* Create port structures for each port */ |
1077 | for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS; | 1077 | for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS; |
1078 | port_number++) { | 1078 | port_number++) { |
1079 | port = kmalloc(sizeof(struct ioc4_port), GFP_KERNEL); | 1079 | port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL); |
1080 | if (!port) { | 1080 | if (!port) { |
1081 | printk(KERN_WARNING | 1081 | printk(KERN_WARNING |
1082 | "IOC4 serial memory not available for port\n"); | 1082 | "IOC4 serial memory not available for port\n"); |
1083 | return -ENOMEM; | 1083 | return -ENOMEM; |
1084 | } | 1084 | } |
1085 | memset(port, 0, sizeof(struct ioc4_port)); | ||
1086 | spin_lock_init(&port->ip_lock); | 1085 | spin_lock_init(&port->ip_lock); |
1087 | 1086 | ||
1088 | /* we need to remember the previous ones, to point back to | 1087 | /* we need to remember the previous ones, to point back to |
@@ -2685,7 +2684,7 @@ static int ioc4_serial_remove_one(struct ioc4_driver_data *idd) | |||
2685 | free_irq(control->ic_irq, soft); | 2684 | free_irq(control->ic_irq, soft); |
2686 | if (soft->is_ioc4_serial_addr) { | 2685 | if (soft->is_ioc4_serial_addr) { |
2687 | iounmap(soft->is_ioc4_serial_addr); | 2686 | iounmap(soft->is_ioc4_serial_addr); |
2688 | release_region((unsigned long) | 2687 | release_mem_region((unsigned long) |
2689 | soft->is_ioc4_serial_addr, | 2688 | soft->is_ioc4_serial_addr, |
2690 | sizeof(struct ioc4_serial)); | 2689 | sizeof(struct ioc4_serial)); |
2691 | } | 2690 | } |
@@ -2790,7 +2789,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) | |||
2790 | /* request serial registers */ | 2789 | /* request serial registers */ |
2791 | tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET; | 2790 | tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET; |
2792 | 2791 | ||
2793 | if (!request_region(tmp_addr1, sizeof(struct ioc4_serial), | 2792 | if (!request_mem_region(tmp_addr1, sizeof(struct ioc4_serial), |
2794 | "sioc4_uart")) { | 2793 | "sioc4_uart")) { |
2795 | printk(KERN_WARNING | 2794 | printk(KERN_WARNING |
2796 | "ioc4 (%p): unable to get request region for " | 2795 | "ioc4 (%p): unable to get request region for " |
@@ -2811,7 +2810,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) | |||
2811 | (void *)serial)); | 2810 | (void *)serial)); |
2812 | 2811 | ||
2813 | /* Get memory for the new card */ | 2812 | /* Get memory for the new card */ |
2814 | control = kmalloc(sizeof(struct ioc4_control), GFP_KERNEL); | 2813 | control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL); |
2815 | 2814 | ||
2816 | if (!control) { | 2815 | if (!control) { |
2817 | printk(KERN_WARNING "ioc4_attach_one" | 2816 | printk(KERN_WARNING "ioc4_attach_one" |
@@ -2819,11 +2818,10 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) | |||
2819 | ret = -ENOMEM; | 2818 | ret = -ENOMEM; |
2820 | goto out2; | 2819 | goto out2; |
2821 | } | 2820 | } |
2822 | memset(control, 0, sizeof(struct ioc4_control)); | ||
2823 | idd->idd_serial_data = control; | 2821 | idd->idd_serial_data = control; |
2824 | 2822 | ||
2825 | /* Allocate the soft structure */ | 2823 | /* Allocate the soft structure */ |
2826 | soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL); | 2824 | soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL); |
2827 | if (!soft) { | 2825 | if (!soft) { |
2828 | printk(KERN_WARNING | 2826 | printk(KERN_WARNING |
2829 | "ioc4 (%p): unable to get memory for the soft struct\n", | 2827 | "ioc4 (%p): unable to get memory for the soft struct\n", |
@@ -2831,7 +2829,6 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd) | |||
2831 | ret = -ENOMEM; | 2829 | ret = -ENOMEM; |
2832 | goto out3; | 2830 | goto out3; |
2833 | } | 2831 | } |
2834 | memset(soft, 0, sizeof(struct ioc4_soft)); | ||
2835 | 2832 | ||
2836 | spin_lock_init(&soft->is_ir_lock); | 2833 | spin_lock_init(&soft->is_ir_lock); |
2837 | soft->is_ioc4_misc_addr = idd->idd_misc_regs; | 2834 | soft->is_ioc4_misc_addr = idd->idd_misc_regs; |
@@ -2889,7 +2886,7 @@ out3: | |||
2889 | out2: | 2886 | out2: |
2890 | if (serial) | 2887 | if (serial) |
2891 | iounmap(serial); | 2888 | iounmap(serial); |
2892 | release_region(tmp_addr1, sizeof(struct ioc4_serial)); | 2889 | release_mem_region(tmp_addr1, sizeof(struct ioc4_serial)); |
2893 | out1: | 2890 | out1: |
2894 | 2891 | ||
2895 | return ret; | 2892 | return ret; |
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c index 0746c9446ae0..c3abfb39f316 100644 --- a/drivers/serial/ip22zilog.c +++ b/drivers/serial/ip22zilog.c | |||
@@ -14,7 +14,6 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
19 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
20 | #include <linux/tty.h> | 19 | #include <linux/tty.h> |
@@ -922,13 +921,7 @@ static int zilog_irq = -1; | |||
922 | 921 | ||
923 | static void * __init alloc_one_table(unsigned long size) | 922 | static void * __init alloc_one_table(unsigned long size) |
924 | { | 923 | { |
925 | void *ret; | 924 | return kzalloc(size, GFP_KERNEL); |
926 | |||
927 | ret = kmalloc(size, GFP_KERNEL); | ||
928 | if (ret != NULL) | ||
929 | memset(ret, 0, size); | ||
930 | |||
931 | return ret; | ||
932 | } | 925 | } |
933 | 926 | ||
934 | static void __init ip22zilog_alloc_tables(void) | 927 | static void __init ip22zilog_alloc_tables(void) |
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c index 244f63be3a03..81792e6eeb2d 100644 --- a/drivers/serial/jsm/jsm_driver.c +++ b/drivers/serial/jsm/jsm_driver.c | |||
@@ -71,14 +71,13 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
71 | goto out_disable_device; | 71 | goto out_disable_device; |
72 | } | 72 | } |
73 | 73 | ||
74 | brd = kmalloc(sizeof(struct jsm_board), GFP_KERNEL); | 74 | brd = kzalloc(sizeof(struct jsm_board), GFP_KERNEL); |
75 | if (!brd) { | 75 | if (!brd) { |
76 | dev_err(&pdev->dev, | 76 | dev_err(&pdev->dev, |
77 | "memory allocation for board structure failed\n"); | 77 | "memory allocation for board structure failed\n"); |
78 | rc = -ENOMEM; | 78 | rc = -ENOMEM; |
79 | goto out_release_regions; | 79 | goto out_release_regions; |
80 | } | 80 | } |
81 | memset(brd, 0, sizeof(struct jsm_board)); | ||
82 | 81 | ||
83 | /* store the info for the board we've found */ | 82 | /* store the info for the board we've found */ |
84 | brd->boardnum = adapter_count++; | 83 | brd->boardnum = adapter_count++; |
@@ -152,7 +151,7 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
152 | * Okay to malloc with GFP_KERNEL, we are not at interrupt | 151 | * Okay to malloc with GFP_KERNEL, we are not at interrupt |
153 | * context, and there are no locks held. | 152 | * context, and there are no locks held. |
154 | */ | 153 | */ |
155 | brd->flipbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); | 154 | brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL); |
156 | if (!brd->flipbuf) { | 155 | if (!brd->flipbuf) { |
157 | /* XXX: leaking all resources from jsm_tty_init and | 156 | /* XXX: leaking all resources from jsm_tty_init and |
158 | jsm_uart_port_init here! */ | 157 | jsm_uart_port_init here! */ |
@@ -160,7 +159,6 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
160 | retval = -ENOMEM; | 159 | retval = -ENOMEM; |
161 | goto out_free_irq; | 160 | goto out_free_irq; |
162 | } | 161 | } |
163 | memset(brd->flipbuf, 0, MYFLIPLEN); | ||
164 | 162 | ||
165 | pci_set_drvdata(pdev, brd); | 163 | pci_set_drvdata(pdev, brd); |
166 | 164 | ||
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c index 7cf1c60027f8..be22bbdbc8e5 100644 --- a/drivers/serial/jsm/jsm_tty.c +++ b/drivers/serial/jsm/jsm_tty.c | |||
@@ -194,31 +194,28 @@ static int jsm_tty_open(struct uart_port *port) | |||
194 | /* Drop locks, as malloc with GFP_KERNEL can sleep */ | 194 | /* Drop locks, as malloc with GFP_KERNEL can sleep */ |
195 | 195 | ||
196 | if (!channel->ch_rqueue) { | 196 | if (!channel->ch_rqueue) { |
197 | channel->ch_rqueue = (u8 *) kmalloc(RQUEUESIZE, GFP_KERNEL); | 197 | channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); |
198 | if (!channel->ch_rqueue) { | 198 | if (!channel->ch_rqueue) { |
199 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, | 199 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, |
200 | "unable to allocate read queue buf"); | 200 | "unable to allocate read queue buf"); |
201 | return -ENOMEM; | 201 | return -ENOMEM; |
202 | } | 202 | } |
203 | memset(channel->ch_rqueue, 0, RQUEUESIZE); | ||
204 | } | 203 | } |
205 | if (!channel->ch_equeue) { | 204 | if (!channel->ch_equeue) { |
206 | channel->ch_equeue = (u8 *) kmalloc(EQUEUESIZE, GFP_KERNEL); | 205 | channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL); |
207 | if (!channel->ch_equeue) { | 206 | if (!channel->ch_equeue) { |
208 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, | 207 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, |
209 | "unable to allocate error queue buf"); | 208 | "unable to allocate error queue buf"); |
210 | return -ENOMEM; | 209 | return -ENOMEM; |
211 | } | 210 | } |
212 | memset(channel->ch_equeue, 0, EQUEUESIZE); | ||
213 | } | 211 | } |
214 | if (!channel->ch_wqueue) { | 212 | if (!channel->ch_wqueue) { |
215 | channel->ch_wqueue = (u8 *) kmalloc(WQUEUESIZE, GFP_KERNEL); | 213 | channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL); |
216 | if (!channel->ch_wqueue) { | 214 | if (!channel->ch_wqueue) { |
217 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, | 215 | jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, |
218 | "unable to allocate write queue buf"); | 216 | "unable to allocate write queue buf"); |
219 | return -ENOMEM; | 217 | return -ENOMEM; |
220 | } | 218 | } |
221 | memset(channel->ch_wqueue, 0, WQUEUESIZE); | ||
222 | } | 219 | } |
223 | 220 | ||
224 | channel->ch_flags &= ~(CH_OPENING); | 221 | channel->ch_flags &= ~(CH_OPENING); |
@@ -392,13 +389,12 @@ int jsm_tty_init(struct jsm_board *brd) | |||
392 | * Okay to malloc with GFP_KERNEL, we are not at | 389 | * Okay to malloc with GFP_KERNEL, we are not at |
393 | * interrupt context, and there are no locks held. | 390 | * interrupt context, and there are no locks held. |
394 | */ | 391 | */ |
395 | brd->channels[i] = kmalloc(sizeof(struct jsm_channel), GFP_KERNEL); | 392 | brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL); |
396 | if (!brd->channels[i]) { | 393 | if (!brd->channels[i]) { |
397 | jsm_printk(CORE, ERR, &brd->pci_dev, | 394 | jsm_printk(CORE, ERR, &brd->pci_dev, |
398 | "%s:%d Unable to allocate memory for channel struct\n", | 395 | "%s:%d Unable to allocate memory for channel struct\n", |
399 | __FILE__, __LINE__); | 396 | __FILE__, __LINE__); |
400 | } | 397 | } |
401 | memset(brd->channels[i], 0, sizeof(struct jsm_channel)); | ||
402 | } | 398 | } |
403 | } | 399 | } |
404 | 400 | ||
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 3c4b6c243712..8d24cd521056 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -127,8 +127,7 @@ static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id); | |||
127 | 127 | ||
128 | #if defined(CONFIG_PPC_MERGE) | 128 | #if defined(CONFIG_PPC_MERGE) |
129 | static struct of_device_id mpc52xx_uart_of_match[] = { | 129 | static struct of_device_id mpc52xx_uart_of_match[] = { |
130 | { .type = "serial", .compatible = "mpc52xx-psc-uart", }, | 130 | { .type = "serial", .compatible = "mpc5200-psc-uart", }, |
131 | { .type = "serial", .compatible = "mpc5200-psc", }, /* Efika only! */ | ||
132 | {}, | 131 | {}, |
133 | }; | 132 | }; |
134 | #endif | 133 | #endif |
@@ -996,8 +995,10 @@ mpc52xx_uart_of_remove(struct of_device *op) | |||
996 | struct uart_port *port = dev_get_drvdata(&op->dev); | 995 | struct uart_port *port = dev_get_drvdata(&op->dev); |
997 | dev_set_drvdata(&op->dev, NULL); | 996 | dev_set_drvdata(&op->dev, NULL); |
998 | 997 | ||
999 | if (port) | 998 | if (port) { |
1000 | uart_remove_one_port(&mpc52xx_uart_driver, port); | 999 | uart_remove_one_port(&mpc52xx_uart_driver, port); |
1000 | irq_dispose_mapping(port->irq); | ||
1001 | } | ||
1001 | 1002 | ||
1002 | return 0; | 1003 | return 0; |
1003 | } | 1004 | } |
@@ -1068,7 +1069,7 @@ mpc52xx_uart_of_enumerate(void) | |||
1068 | continue; | 1069 | continue; |
1069 | 1070 | ||
1070 | /* Is a particular device number requested? */ | 1071 | /* Is a particular device number requested? */ |
1071 | devno = get_property(np, "device_no", NULL); | 1072 | devno = get_property(np, "port-number", NULL); |
1072 | mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1); | 1073 | mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1); |
1073 | } | 1074 | } |
1074 | 1075 | ||
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c new file mode 100644 index 000000000000..09b0b736a751 --- /dev/null +++ b/drivers/serial/of_serial.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * Serial Port driver for Open Firmware platform devices | ||
3 | * | ||
4 | * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/serial_core.h> | ||
15 | #include <linux/serial_8250.h> | ||
16 | |||
17 | #include <asm/of_platform.h> | ||
18 | #include <asm/prom.h> | ||
19 | |||
20 | /* | ||
21 | * Fill a struct uart_port for a given device node | ||
22 | */ | ||
23 | static int __devinit of_platform_serial_setup(struct of_device *ofdev, | ||
24 | int type, struct uart_port *port) | ||
25 | { | ||
26 | struct resource resource; | ||
27 | struct device_node *np = ofdev->node; | ||
28 | const unsigned int *clk, *spd; | ||
29 | int ret; | ||
30 | |||
31 | memset(port, 0, sizeof *port); | ||
32 | spd = get_property(np, "current-speed", NULL); | ||
33 | clk = get_property(np, "clock-frequency", NULL); | ||
34 | if (!clk) { | ||
35 | dev_warn(&ofdev->dev, "no clock-frequency property set\n"); | ||
36 | return -ENODEV; | ||
37 | } | ||
38 | |||
39 | ret = of_address_to_resource(np, 0, &resource); | ||
40 | if (ret) { | ||
41 | dev_warn(&ofdev->dev, "invalid address\n"); | ||
42 | return ret; | ||
43 | } | ||
44 | |||
45 | spin_lock_init(&port->lock); | ||
46 | port->mapbase = resource.start; | ||
47 | port->irq = irq_of_parse_and_map(np, 0); | ||
48 | port->iotype = UPIO_MEM; | ||
49 | port->type = type; | ||
50 | port->uartclk = *clk; | ||
51 | port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP; | ||
52 | port->dev = &ofdev->dev; | ||
53 | port->custom_divisor = *clk / (16 * (*spd)); | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | * Try to register a serial port | ||
60 | */ | ||
61 | static int __devinit of_platform_serial_probe(struct of_device *ofdev, | ||
62 | const struct of_device_id *id) | ||
63 | { | ||
64 | struct uart_port port; | ||
65 | int port_type; | ||
66 | int ret; | ||
67 | |||
68 | if (of_find_property(ofdev->node, "used-by-rtas", NULL)) | ||
69 | return -EBUSY; | ||
70 | |||
71 | port_type = (unsigned long)id->data; | ||
72 | ret = of_platform_serial_setup(ofdev, port_type, &port); | ||
73 | if (ret) | ||
74 | goto out; | ||
75 | |||
76 | switch (port_type) { | ||
77 | case PORT_UNKNOWN: | ||
78 | dev_info(&ofdev->dev, "Unknown serial port found, " | ||
79 | "attempting to use 8250 driver\n"); | ||
80 | /* fallthrough */ | ||
81 | case PORT_8250 ... PORT_MAX_8250: | ||
82 | ret = serial8250_register_port(&port); | ||
83 | break; | ||
84 | default: | ||
85 | /* need to add code for these */ | ||
86 | ret = -ENODEV; | ||
87 | break; | ||
88 | } | ||
89 | if (ret < 0) | ||
90 | goto out; | ||
91 | |||
92 | ofdev->dev.driver_data = (void *)(unsigned long)ret; | ||
93 | return 0; | ||
94 | out: | ||
95 | irq_dispose_mapping(port.irq); | ||
96 | return ret; | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Release a line | ||
101 | */ | ||
102 | static int of_platform_serial_remove(struct of_device *ofdev) | ||
103 | { | ||
104 | int line = (unsigned long)ofdev->dev.driver_data; | ||
105 | serial8250_unregister_port(line); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | /* | ||
110 | * A few common types, add more as needed. | ||
111 | */ | ||
112 | static struct of_device_id __devinitdata of_platform_serial_table[] = { | ||
113 | { .type = "serial", .compatible = "ns8250", .data = (void *)PORT_8250, }, | ||
114 | { .type = "serial", .compatible = "ns16450", .data = (void *)PORT_16450, }, | ||
115 | { .type = "serial", .compatible = "ns16550", .data = (void *)PORT_16550, }, | ||
116 | { .type = "serial", .compatible = "ns16750", .data = (void *)PORT_16750, }, | ||
117 | { .type = "serial", .data = (void *)PORT_UNKNOWN, }, | ||
118 | { /* end of list */ }, | ||
119 | }; | ||
120 | |||
121 | static struct of_platform_driver __devinitdata of_platform_serial_driver = { | ||
122 | .owner = THIS_MODULE, | ||
123 | .name = "of_serial", | ||
124 | .probe = of_platform_serial_probe, | ||
125 | .remove = of_platform_serial_remove, | ||
126 | .match_table = of_platform_serial_table, | ||
127 | }; | ||
128 | |||
129 | static int __init of_platform_serial_init(void) | ||
130 | { | ||
131 | return of_register_platform_driver(&of_platform_serial_driver); | ||
132 | } | ||
133 | module_init(of_platform_serial_init); | ||
134 | |||
135 | static void __exit of_platform_serial_exit(void) | ||
136 | { | ||
137 | return of_unregister_platform_driver(&of_platform_serial_driver); | ||
138 | }; | ||
139 | module_exit(of_platform_serial_exit); | ||
140 | |||
141 | MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>"); | ||
142 | MODULE_LICENSE("GPL"); | ||
143 | MODULE_DESCRIPTION("Serial Port driver for Open Firmware platform devices"); | ||
diff --git a/drivers/serial/pnx8xxx_uart.c b/drivers/serial/pnx8xxx_uart.c new file mode 100644 index 000000000000..8d01c59e8d04 --- /dev/null +++ b/drivers/serial/pnx8xxx_uart.c | |||
@@ -0,0 +1,852 @@ | |||
1 | /* | ||
2 | * UART driver for PNX8XXX SoCs | ||
3 | * | ||
4 | * Author: Per Hallsmark per.hallsmark@mvista.com | ||
5 | * Ported to 2.6 kernel by EmbeddedAlley | ||
6 | * Reworked by Vitaly Wool <vitalywool@gmail.com> | ||
7 | * | ||
8 | * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. | ||
9 | * Copyright (C) 2000 Deep Blue Solutions Ltd. | ||
10 | * | ||
11 | * This file is licensed under the terms of the GNU General Public License | ||
12 | * version 2. This program is licensed "as is" without any warranty of | ||
13 | * any kind, whether express or implied. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #if defined(CONFIG_SERIAL_PNX8XXX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | ||
18 | #define SUPPORT_SYSRQ | ||
19 | #endif | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/ioport.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/console.h> | ||
25 | #include <linux/sysrq.h> | ||
26 | #include <linux/device.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/tty.h> | ||
29 | #include <linux/tty_flip.h> | ||
30 | #include <linux/serial_core.h> | ||
31 | #include <linux/serial.h> | ||
32 | #include <linux/serial_pnx8xxx.h> | ||
33 | |||
34 | #include <asm/io.h> | ||
35 | #include <asm/irq.h> | ||
36 | |||
37 | /* We'll be using StrongARM sa1100 serial port major/minor */ | ||
38 | #define SERIAL_PNX8XXX_MAJOR 204 | ||
39 | #define MINOR_START 5 | ||
40 | |||
41 | #define NR_PORTS 2 | ||
42 | |||
43 | #define PNX8XXX_ISR_PASS_LIMIT 256 | ||
44 | |||
45 | /* | ||
46 | * Convert from ignore_status_mask or read_status_mask to FIFO | ||
47 | * and interrupt status bits | ||
48 | */ | ||
49 | #define SM_TO_FIFO(x) ((x) >> 10) | ||
50 | #define SM_TO_ISTAT(x) ((x) & 0x000001ff) | ||
51 | #define FIFO_TO_SM(x) ((x) << 10) | ||
52 | #define ISTAT_TO_SM(x) ((x) & 0x000001ff) | ||
53 | |||
54 | /* | ||
55 | * This is the size of our serial port register set. | ||
56 | */ | ||
57 | #define UART_PORT_SIZE 0x1000 | ||
58 | |||
59 | /* | ||
60 | * This determines how often we check the modem status signals | ||
61 | * for any change. They generally aren't connected to an IRQ | ||
62 | * so we have to poll them. We also check immediately before | ||
63 | * filling the TX fifo incase CTS has been dropped. | ||
64 | */ | ||
65 | #define MCTRL_TIMEOUT (250*HZ/1000) | ||
66 | |||
67 | extern struct pnx8xxx_port pnx8xxx_ports[]; | ||
68 | |||
69 | static inline int serial_in(struct pnx8xxx_port *sport, int offset) | ||
70 | { | ||
71 | return (__raw_readl(sport->port.membase + offset)); | ||
72 | } | ||
73 | |||
74 | static inline void serial_out(struct pnx8xxx_port *sport, int offset, int value) | ||
75 | { | ||
76 | __raw_writel(value, sport->port.membase + offset); | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * Handle any change of modem status signal since we were last called. | ||
81 | */ | ||
82 | static void pnx8xxx_mctrl_check(struct pnx8xxx_port *sport) | ||
83 | { | ||
84 | unsigned int status, changed; | ||
85 | |||
86 | status = sport->port.ops->get_mctrl(&sport->port); | ||
87 | changed = status ^ sport->old_status; | ||
88 | |||
89 | if (changed == 0) | ||
90 | return; | ||
91 | |||
92 | sport->old_status = status; | ||
93 | |||
94 | if (changed & TIOCM_RI) | ||
95 | sport->port.icount.rng++; | ||
96 | if (changed & TIOCM_DSR) | ||
97 | sport->port.icount.dsr++; | ||
98 | if (changed & TIOCM_CAR) | ||
99 | uart_handle_dcd_change(&sport->port, status & TIOCM_CAR); | ||
100 | if (changed & TIOCM_CTS) | ||
101 | uart_handle_cts_change(&sport->port, status & TIOCM_CTS); | ||
102 | |||
103 | wake_up_interruptible(&sport->port.info->delta_msr_wait); | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * This is our per-port timeout handler, for checking the | ||
108 | * modem status signals. | ||
109 | */ | ||
110 | static void pnx8xxx_timeout(unsigned long data) | ||
111 | { | ||
112 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)data; | ||
113 | unsigned long flags; | ||
114 | |||
115 | if (sport->port.info) { | ||
116 | spin_lock_irqsave(&sport->port.lock, flags); | ||
117 | pnx8xxx_mctrl_check(sport); | ||
118 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
119 | |||
120 | mod_timer(&sport->timer, jiffies + MCTRL_TIMEOUT); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * interrupts disabled on entry | ||
126 | */ | ||
127 | static void pnx8xxx_stop_tx(struct uart_port *port) | ||
128 | { | ||
129 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
130 | u32 ien; | ||
131 | |||
132 | /* Disable TX intr */ | ||
133 | ien = serial_in(sport, PNX8XXX_IEN); | ||
134 | serial_out(sport, PNX8XXX_IEN, ien & ~PNX8XXX_UART_INT_ALLTX); | ||
135 | |||
136 | /* Clear all pending TX intr */ | ||
137 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLTX); | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | * interrupts may not be disabled on entry | ||
142 | */ | ||
143 | static void pnx8xxx_start_tx(struct uart_port *port) | ||
144 | { | ||
145 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
146 | u32 ien; | ||
147 | |||
148 | /* Clear all pending TX intr */ | ||
149 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLTX); | ||
150 | |||
151 | /* Enable TX intr */ | ||
152 | ien = serial_in(sport, PNX8XXX_IEN); | ||
153 | serial_out(sport, PNX8XXX_IEN, ien | PNX8XXX_UART_INT_ALLTX); | ||
154 | } | ||
155 | |||
156 | /* | ||
157 | * Interrupts enabled | ||
158 | */ | ||
159 | static void pnx8xxx_stop_rx(struct uart_port *port) | ||
160 | { | ||
161 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
162 | u32 ien; | ||
163 | |||
164 | /* Disable RX intr */ | ||
165 | ien = serial_in(sport, PNX8XXX_IEN); | ||
166 | serial_out(sport, PNX8XXX_IEN, ien & ~PNX8XXX_UART_INT_ALLRX); | ||
167 | |||
168 | /* Clear all pending RX intr */ | ||
169 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLRX); | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Set the modem control timer to fire immediately. | ||
174 | */ | ||
175 | static void pnx8xxx_enable_ms(struct uart_port *port) | ||
176 | { | ||
177 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
178 | |||
179 | mod_timer(&sport->timer, jiffies); | ||
180 | } | ||
181 | |||
182 | static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) | ||
183 | { | ||
184 | struct tty_struct *tty = sport->port.info->tty; | ||
185 | unsigned int status, ch, flg; | ||
186 | |||
187 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | | ||
188 | ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); | ||
189 | while (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFIFO)) { | ||
190 | ch = serial_in(sport, PNX8XXX_FIFO); | ||
191 | |||
192 | sport->port.icount.rx++; | ||
193 | |||
194 | flg = TTY_NORMAL; | ||
195 | |||
196 | /* | ||
197 | * note that the error handling code is | ||
198 | * out of the main execution path | ||
199 | */ | ||
200 | if (status & (FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE | | ||
201 | PNX8XXX_UART_FIFO_RXPAR) | | ||
202 | ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN))) { | ||
203 | if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR)) | ||
204 | sport->port.icount.parity++; | ||
205 | else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE)) | ||
206 | sport->port.icount.frame++; | ||
207 | if (status & ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN)) | ||
208 | sport->port.icount.overrun++; | ||
209 | |||
210 | status &= sport->port.read_status_mask; | ||
211 | |||
212 | if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR)) | ||
213 | flg = TTY_PARITY; | ||
214 | else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE)) | ||
215 | flg = TTY_FRAME; | ||
216 | |||
217 | #ifdef SUPPORT_SYSRQ | ||
218 | sport->port.sysrq = 0; | ||
219 | #endif | ||
220 | } | ||
221 | |||
222 | if (uart_handle_sysrq_char(&sport->port, ch)) | ||
223 | goto ignore_char; | ||
224 | |||
225 | uart_insert_char(&sport->port, status, | ||
226 | ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN), ch, flg); | ||
227 | |||
228 | ignore_char: | ||
229 | serial_out(sport, PNX8XXX_LCR, serial_in(sport, PNX8XXX_LCR) | | ||
230 | PNX8XXX_UART_LCR_RX_NEXT); | ||
231 | status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | | ||
232 | ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); | ||
233 | } | ||
234 | tty_flip_buffer_push(tty); | ||
235 | } | ||
236 | |||
237 | static void pnx8xxx_tx_chars(struct pnx8xxx_port *sport) | ||
238 | { | ||
239 | struct circ_buf *xmit = &sport->port.info->xmit; | ||
240 | |||
241 | if (sport->port.x_char) { | ||
242 | serial_out(sport, PNX8XXX_FIFO, sport->port.x_char); | ||
243 | sport->port.icount.tx++; | ||
244 | sport->port.x_char = 0; | ||
245 | return; | ||
246 | } | ||
247 | |||
248 | /* | ||
249 | * Check the modem control lines before | ||
250 | * transmitting anything. | ||
251 | */ | ||
252 | pnx8xxx_mctrl_check(sport); | ||
253 | |||
254 | if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) { | ||
255 | pnx8xxx_stop_tx(&sport->port); | ||
256 | return; | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * TX while bytes available | ||
261 | */ | ||
262 | while (((serial_in(sport, PNX8XXX_FIFO) & | ||
263 | PNX8XXX_UART_FIFO_TXFIFO) >> 16) < 16) { | ||
264 | serial_out(sport, PNX8XXX_FIFO, xmit->buf[xmit->tail]); | ||
265 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
266 | sport->port.icount.tx++; | ||
267 | if (uart_circ_empty(xmit)) | ||
268 | break; | ||
269 | } | ||
270 | |||
271 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | ||
272 | uart_write_wakeup(&sport->port); | ||
273 | |||
274 | if (uart_circ_empty(xmit)) | ||
275 | pnx8xxx_stop_tx(&sport->port); | ||
276 | } | ||
277 | |||
278 | static irqreturn_t pnx8xxx_int(int irq, void *dev_id) | ||
279 | { | ||
280 | struct pnx8xxx_port *sport = dev_id; | ||
281 | unsigned int status; | ||
282 | |||
283 | spin_lock(&sport->port.lock); | ||
284 | /* Get the interrupts */ | ||
285 | status = serial_in(sport, PNX8XXX_ISTAT) & serial_in(sport, PNX8XXX_IEN); | ||
286 | |||
287 | /* Break signal received */ | ||
288 | if (status & PNX8XXX_UART_INT_BREAK) { | ||
289 | sport->port.icount.brk++; | ||
290 | uart_handle_break(&sport->port); | ||
291 | } | ||
292 | |||
293 | /* Byte received */ | ||
294 | if (status & PNX8XXX_UART_INT_RX) | ||
295 | pnx8xxx_rx_chars(sport); | ||
296 | |||
297 | /* TX holding register empty - transmit a byte */ | ||
298 | if (status & PNX8XXX_UART_INT_TX) | ||
299 | pnx8xxx_tx_chars(sport); | ||
300 | |||
301 | /* Clear the ISTAT register */ | ||
302 | serial_out(sport, PNX8XXX_ICLR, status); | ||
303 | |||
304 | spin_unlock(&sport->port.lock); | ||
305 | return IRQ_HANDLED; | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | * Return TIOCSER_TEMT when transmitter is not busy. | ||
310 | */ | ||
311 | static unsigned int pnx8xxx_tx_empty(struct uart_port *port) | ||
312 | { | ||
313 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
314 | |||
315 | return serial_in(sport, PNX8XXX_FIFO) & PNX8XXX_UART_FIFO_TXFIFO_STA ? 0 : TIOCSER_TEMT; | ||
316 | } | ||
317 | |||
318 | static unsigned int pnx8xxx_get_mctrl(struct uart_port *port) | ||
319 | { | ||
320 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
321 | unsigned int mctrl = TIOCM_DSR; | ||
322 | unsigned int msr; | ||
323 | |||
324 | /* REVISIT */ | ||
325 | |||
326 | msr = serial_in(sport, PNX8XXX_MCR); | ||
327 | |||
328 | mctrl |= msr & PNX8XXX_UART_MCR_CTS ? TIOCM_CTS : 0; | ||
329 | mctrl |= msr & PNX8XXX_UART_MCR_DCD ? TIOCM_CAR : 0; | ||
330 | |||
331 | return mctrl; | ||
332 | } | ||
333 | |||
334 | static void pnx8xxx_set_mctrl(struct uart_port *port, unsigned int mctrl) | ||
335 | { | ||
336 | #if 0 /* FIXME */ | ||
337 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
338 | unsigned int msr; | ||
339 | #endif | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * Interrupts always disabled. | ||
344 | */ | ||
345 | static void pnx8xxx_break_ctl(struct uart_port *port, int break_state) | ||
346 | { | ||
347 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
348 | unsigned long flags; | ||
349 | unsigned int lcr; | ||
350 | |||
351 | spin_lock_irqsave(&sport->port.lock, flags); | ||
352 | lcr = serial_in(sport, PNX8XXX_LCR); | ||
353 | if (break_state == -1) | ||
354 | lcr |= PNX8XXX_UART_LCR_TXBREAK; | ||
355 | else | ||
356 | lcr &= ~PNX8XXX_UART_LCR_TXBREAK; | ||
357 | serial_out(sport, PNX8XXX_LCR, lcr); | ||
358 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
359 | } | ||
360 | |||
361 | static int pnx8xxx_startup(struct uart_port *port) | ||
362 | { | ||
363 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
364 | int retval; | ||
365 | |||
366 | /* | ||
367 | * Allocate the IRQ | ||
368 | */ | ||
369 | retval = request_irq(sport->port.irq, pnx8xxx_int, 0, | ||
370 | "pnx8xxx-uart", sport); | ||
371 | if (retval) | ||
372 | return retval; | ||
373 | |||
374 | /* | ||
375 | * Finally, clear and enable interrupts | ||
376 | */ | ||
377 | |||
378 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLRX | | ||
379 | PNX8XXX_UART_INT_ALLTX); | ||
380 | |||
381 | serial_out(sport, PNX8XXX_IEN, serial_in(sport, PNX8XXX_IEN) | | ||
382 | PNX8XXX_UART_INT_ALLRX | | ||
383 | PNX8XXX_UART_INT_ALLTX); | ||
384 | |||
385 | /* | ||
386 | * Enable modem status interrupts | ||
387 | */ | ||
388 | spin_lock_irq(&sport->port.lock); | ||
389 | pnx8xxx_enable_ms(&sport->port); | ||
390 | spin_unlock_irq(&sport->port.lock); | ||
391 | |||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | static void pnx8xxx_shutdown(struct uart_port *port) | ||
396 | { | ||
397 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
398 | int lcr; | ||
399 | |||
400 | /* | ||
401 | * Stop our timer. | ||
402 | */ | ||
403 | del_timer_sync(&sport->timer); | ||
404 | |||
405 | /* | ||
406 | * Disable all interrupts | ||
407 | */ | ||
408 | serial_out(sport, PNX8XXX_IEN, 0); | ||
409 | |||
410 | /* | ||
411 | * Reset the Tx and Rx FIFOS, disable the break condition | ||
412 | */ | ||
413 | lcr = serial_in(sport, PNX8XXX_LCR); | ||
414 | lcr &= ~PNX8XXX_UART_LCR_TXBREAK; | ||
415 | lcr |= PNX8XXX_UART_LCR_TX_RST | PNX8XXX_UART_LCR_RX_RST; | ||
416 | serial_out(sport, PNX8XXX_LCR, lcr); | ||
417 | |||
418 | /* | ||
419 | * Clear all interrupts | ||
420 | */ | ||
421 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_ALLRX | | ||
422 | PNX8XXX_UART_INT_ALLTX); | ||
423 | |||
424 | /* | ||
425 | * Free the interrupt | ||
426 | */ | ||
427 | free_irq(sport->port.irq, sport); | ||
428 | } | ||
429 | |||
430 | static void | ||
431 | pnx8xxx_set_termios(struct uart_port *port, struct ktermios *termios, | ||
432 | struct ktermios *old) | ||
433 | { | ||
434 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
435 | unsigned long flags; | ||
436 | unsigned int lcr_fcr, old_ien, baud, quot; | ||
437 | unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; | ||
438 | |||
439 | /* | ||
440 | * We only support CS7 and CS8. | ||
441 | */ | ||
442 | while ((termios->c_cflag & CSIZE) != CS7 && | ||
443 | (termios->c_cflag & CSIZE) != CS8) { | ||
444 | termios->c_cflag &= ~CSIZE; | ||
445 | termios->c_cflag |= old_csize; | ||
446 | old_csize = CS8; | ||
447 | } | ||
448 | |||
449 | if ((termios->c_cflag & CSIZE) == CS8) | ||
450 | lcr_fcr = PNX8XXX_UART_LCR_8BIT; | ||
451 | else | ||
452 | lcr_fcr = 0; | ||
453 | |||
454 | if (termios->c_cflag & CSTOPB) | ||
455 | lcr_fcr |= PNX8XXX_UART_LCR_2STOPB; | ||
456 | if (termios->c_cflag & PARENB) { | ||
457 | lcr_fcr |= PNX8XXX_UART_LCR_PAREN; | ||
458 | if (!(termios->c_cflag & PARODD)) | ||
459 | lcr_fcr |= PNX8XXX_UART_LCR_PAREVN; | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | * Ask the core to calculate the divisor for us. | ||
464 | */ | ||
465 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); | ||
466 | quot = uart_get_divisor(port, baud); | ||
467 | |||
468 | spin_lock_irqsave(&sport->port.lock, flags); | ||
469 | |||
470 | sport->port.read_status_mask = ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN) | | ||
471 | ISTAT_TO_SM(PNX8XXX_UART_INT_EMPTY) | | ||
472 | ISTAT_TO_SM(PNX8XXX_UART_INT_RX); | ||
473 | if (termios->c_iflag & INPCK) | ||
474 | sport->port.read_status_mask |= | ||
475 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) | | ||
476 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR); | ||
477 | if (termios->c_iflag & (BRKINT | PARMRK)) | ||
478 | sport->port.read_status_mask |= | ||
479 | ISTAT_TO_SM(PNX8XXX_UART_INT_BREAK); | ||
480 | |||
481 | /* | ||
482 | * Characters to ignore | ||
483 | */ | ||
484 | sport->port.ignore_status_mask = 0; | ||
485 | if (termios->c_iflag & IGNPAR) | ||
486 | sport->port.ignore_status_mask |= | ||
487 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) | | ||
488 | FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR); | ||
489 | if (termios->c_iflag & IGNBRK) { | ||
490 | sport->port.ignore_status_mask |= | ||
491 | ISTAT_TO_SM(PNX8XXX_UART_INT_BREAK); | ||
492 | /* | ||
493 | * If we're ignoring parity and break indicators, | ||
494 | * ignore overruns too (for real raw support). | ||
495 | */ | ||
496 | if (termios->c_iflag & IGNPAR) | ||
497 | sport->port.ignore_status_mask |= | ||
498 | ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN); | ||
499 | } | ||
500 | |||
501 | /* | ||
502 | * ignore all characters if CREAD is not set | ||
503 | */ | ||
504 | if ((termios->c_cflag & CREAD) == 0) | ||
505 | sport->port.ignore_status_mask |= | ||
506 | ISTAT_TO_SM(PNX8XXX_UART_INT_RX); | ||
507 | |||
508 | del_timer_sync(&sport->timer); | ||
509 | |||
510 | /* | ||
511 | * Update the per-port timeout. | ||
512 | */ | ||
513 | uart_update_timeout(port, termios->c_cflag, baud); | ||
514 | |||
515 | /* | ||
516 | * disable interrupts and drain transmitter | ||
517 | */ | ||
518 | old_ien = serial_in(sport, PNX8XXX_IEN); | ||
519 | serial_out(sport, PNX8XXX_IEN, old_ien & ~(PNX8XXX_UART_INT_ALLTX | | ||
520 | PNX8XXX_UART_INT_ALLRX)); | ||
521 | |||
522 | while (serial_in(sport, PNX8XXX_FIFO) & PNX8XXX_UART_FIFO_TXFIFO_STA) | ||
523 | barrier(); | ||
524 | |||
525 | /* then, disable everything */ | ||
526 | serial_out(sport, PNX8XXX_IEN, 0); | ||
527 | |||
528 | /* Reset the Rx and Tx FIFOs too */ | ||
529 | lcr_fcr |= PNX8XXX_UART_LCR_TX_RST; | ||
530 | lcr_fcr |= PNX8XXX_UART_LCR_RX_RST; | ||
531 | |||
532 | /* set the parity, stop bits and data size */ | ||
533 | serial_out(sport, PNX8XXX_LCR, lcr_fcr); | ||
534 | |||
535 | /* set the baud rate */ | ||
536 | quot -= 1; | ||
537 | serial_out(sport, PNX8XXX_BAUD, quot); | ||
538 | |||
539 | serial_out(sport, PNX8XXX_ICLR, -1); | ||
540 | |||
541 | serial_out(sport, PNX8XXX_IEN, old_ien); | ||
542 | |||
543 | if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) | ||
544 | pnx8xxx_enable_ms(&sport->port); | ||
545 | |||
546 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
547 | } | ||
548 | |||
549 | static const char *pnx8xxx_type(struct uart_port *port) | ||
550 | { | ||
551 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
552 | |||
553 | return sport->port.type == PORT_PNX8XXX ? "PNX8XXX" : NULL; | ||
554 | } | ||
555 | |||
556 | /* | ||
557 | * Release the memory region(s) being used by 'port'. | ||
558 | */ | ||
559 | static void pnx8xxx_release_port(struct uart_port *port) | ||
560 | { | ||
561 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
562 | |||
563 | release_mem_region(sport->port.mapbase, UART_PORT_SIZE); | ||
564 | } | ||
565 | |||
566 | /* | ||
567 | * Request the memory region(s) being used by 'port'. | ||
568 | */ | ||
569 | static int pnx8xxx_request_port(struct uart_port *port) | ||
570 | { | ||
571 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
572 | return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, | ||
573 | "pnx8xxx-uart") != NULL ? 0 : -EBUSY; | ||
574 | } | ||
575 | |||
576 | /* | ||
577 | * Configure/autoconfigure the port. | ||
578 | */ | ||
579 | static void pnx8xxx_config_port(struct uart_port *port, int flags) | ||
580 | { | ||
581 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
582 | |||
583 | if (flags & UART_CONFIG_TYPE && | ||
584 | pnx8xxx_request_port(&sport->port) == 0) | ||
585 | sport->port.type = PORT_PNX8XXX; | ||
586 | } | ||
587 | |||
588 | /* | ||
589 | * Verify the new serial_struct (for TIOCSSERIAL). | ||
590 | * The only change we allow are to the flags and type, and | ||
591 | * even then only between PORT_PNX8XXX and PORT_UNKNOWN | ||
592 | */ | ||
593 | static int | ||
594 | pnx8xxx_verify_port(struct uart_port *port, struct serial_struct *ser) | ||
595 | { | ||
596 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
597 | int ret = 0; | ||
598 | |||
599 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_PNX8XXX) | ||
600 | ret = -EINVAL; | ||
601 | if (sport->port.irq != ser->irq) | ||
602 | ret = -EINVAL; | ||
603 | if (ser->io_type != SERIAL_IO_MEM) | ||
604 | ret = -EINVAL; | ||
605 | if (sport->port.uartclk / 16 != ser->baud_base) | ||
606 | ret = -EINVAL; | ||
607 | if ((void *)sport->port.mapbase != ser->iomem_base) | ||
608 | ret = -EINVAL; | ||
609 | if (sport->port.iobase != ser->port) | ||
610 | ret = -EINVAL; | ||
611 | if (ser->hub6 != 0) | ||
612 | ret = -EINVAL; | ||
613 | return ret; | ||
614 | } | ||
615 | |||
616 | static struct uart_ops pnx8xxx_pops = { | ||
617 | .tx_empty = pnx8xxx_tx_empty, | ||
618 | .set_mctrl = pnx8xxx_set_mctrl, | ||
619 | .get_mctrl = pnx8xxx_get_mctrl, | ||
620 | .stop_tx = pnx8xxx_stop_tx, | ||
621 | .start_tx = pnx8xxx_start_tx, | ||
622 | .stop_rx = pnx8xxx_stop_rx, | ||
623 | .enable_ms = pnx8xxx_enable_ms, | ||
624 | .break_ctl = pnx8xxx_break_ctl, | ||
625 | .startup = pnx8xxx_startup, | ||
626 | .shutdown = pnx8xxx_shutdown, | ||
627 | .set_termios = pnx8xxx_set_termios, | ||
628 | .type = pnx8xxx_type, | ||
629 | .release_port = pnx8xxx_release_port, | ||
630 | .request_port = pnx8xxx_request_port, | ||
631 | .config_port = pnx8xxx_config_port, | ||
632 | .verify_port = pnx8xxx_verify_port, | ||
633 | }; | ||
634 | |||
635 | |||
636 | /* | ||
637 | * Setup the PNX8XXX serial ports. | ||
638 | * | ||
639 | * Note also that we support "console=ttySx" where "x" is either 0 or 1. | ||
640 | */ | ||
641 | static void __init pnx8xxx_init_ports(void) | ||
642 | { | ||
643 | static int first = 1; | ||
644 | int i; | ||
645 | |||
646 | if (!first) | ||
647 | return; | ||
648 | first = 0; | ||
649 | |||
650 | for (i = 0; i < NR_PORTS; i++) { | ||
651 | init_timer(&pnx8xxx_ports[i].timer); | ||
652 | pnx8xxx_ports[i].timer.function = pnx8xxx_timeout; | ||
653 | pnx8xxx_ports[i].timer.data = (unsigned long)&pnx8xxx_ports[i]; | ||
654 | pnx8xxx_ports[i].port.ops = &pnx8xxx_pops; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | #ifdef CONFIG_SERIAL_PNX8XXX_CONSOLE | ||
659 | |||
660 | static void pnx8xxx_console_putchar(struct uart_port *port, int ch) | ||
661 | { | ||
662 | struct pnx8xxx_port *sport = (struct pnx8xxx_port *)port; | ||
663 | int status; | ||
664 | |||
665 | do { | ||
666 | /* Wait for UART_TX register to empty */ | ||
667 | status = serial_in(sport, PNX8XXX_FIFO); | ||
668 | } while (status & PNX8XXX_UART_FIFO_TXFIFO); | ||
669 | serial_out(sport, PNX8XXX_FIFO, ch); | ||
670 | } | ||
671 | |||
672 | /* | ||
673 | * Interrupts are disabled on entering | ||
674 | */static void | ||
675 | pnx8xxx_console_write(struct console *co, const char *s, unsigned int count) | ||
676 | { | ||
677 | struct pnx8xxx_port *sport = &pnx8xxx_ports[co->index]; | ||
678 | unsigned int old_ien, status; | ||
679 | |||
680 | /* | ||
681 | * First, save IEN and then disable interrupts | ||
682 | */ | ||
683 | old_ien = serial_in(sport, PNX8XXX_IEN); | ||
684 | serial_out(sport, PNX8XXX_IEN, old_ien & ~(PNX8XXX_UART_INT_ALLTX | | ||
685 | PNX8XXX_UART_INT_ALLRX)); | ||
686 | |||
687 | uart_console_write(&sport->port, s, count, pnx8xxx_console_putchar); | ||
688 | |||
689 | /* | ||
690 | * Finally, wait for transmitter to become empty | ||
691 | * and restore IEN | ||
692 | */ | ||
693 | do { | ||
694 | /* Wait for UART_TX register to empty */ | ||
695 | status = serial_in(sport, PNX8XXX_FIFO); | ||
696 | } while (status & PNX8XXX_UART_FIFO_TXFIFO); | ||
697 | |||
698 | /* Clear TX and EMPTY interrupt */ | ||
699 | serial_out(sport, PNX8XXX_ICLR, PNX8XXX_UART_INT_TX | | ||
700 | PNX8XXX_UART_INT_EMPTY); | ||
701 | |||
702 | serial_out(sport, PNX8XXX_IEN, old_ien); | ||
703 | } | ||
704 | |||
705 | static int __init | ||
706 | pnx8xxx_console_setup(struct console *co, char *options) | ||
707 | { | ||
708 | struct pnx8xxx_port *sport; | ||
709 | int baud = 38400; | ||
710 | int bits = 8; | ||
711 | int parity = 'n'; | ||
712 | int flow = 'n'; | ||
713 | |||
714 | /* | ||
715 | * Check whether an invalid uart number has been specified, and | ||
716 | * if so, search for the first available port that does have | ||
717 | * console support. | ||
718 | */ | ||
719 | if (co->index == -1 || co->index >= NR_PORTS) | ||
720 | co->index = 0; | ||
721 | sport = &pnx8xxx_ports[co->index]; | ||
722 | |||
723 | if (options) | ||
724 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
725 | |||
726 | return uart_set_options(&sport->port, co, baud, parity, bits, flow); | ||
727 | } | ||
728 | |||
729 | static struct uart_driver pnx8xxx_reg; | ||
730 | static struct console pnx8xxx_console = { | ||
731 | .name = "ttyS", | ||
732 | .write = pnx8xxx_console_write, | ||
733 | .device = uart_console_device, | ||
734 | .setup = pnx8xxx_console_setup, | ||
735 | .flags = CON_PRINTBUFFER, | ||
736 | .index = -1, | ||
737 | .data = &pnx8xxx_reg, | ||
738 | }; | ||
739 | |||
740 | static int __init pnx8xxx_rs_console_init(void) | ||
741 | { | ||
742 | pnx8xxx_init_ports(); | ||
743 | register_console(&pnx8xxx_console); | ||
744 | return 0; | ||
745 | } | ||
746 | console_initcall(pnx8xxx_rs_console_init); | ||
747 | |||
748 | #define PNX8XXX_CONSOLE &pnx8xxx_console | ||
749 | #else | ||
750 | #define PNX8XXX_CONSOLE NULL | ||
751 | #endif | ||
752 | |||
753 | static struct uart_driver pnx8xxx_reg = { | ||
754 | .owner = THIS_MODULE, | ||
755 | .driver_name = "ttyS", | ||
756 | .dev_name = "ttyS", | ||
757 | .major = SERIAL_PNX8XXX_MAJOR, | ||
758 | .minor = MINOR_START, | ||
759 | .nr = NR_PORTS, | ||
760 | .cons = PNX8XXX_CONSOLE, | ||
761 | }; | ||
762 | |||
763 | static int pnx8xxx_serial_suspend(struct platform_device *pdev, pm_message_t state) | ||
764 | { | ||
765 | struct pnx8xxx_port *sport = platform_get_drvdata(pdev); | ||
766 | |||
767 | return uart_suspend_port(&pnx8xxx_reg, &sport->port); | ||
768 | } | ||
769 | |||
770 | static int pnx8xxx_serial_resume(struct platform_device *pdev) | ||
771 | { | ||
772 | struct pnx8xxx_port *sport = platform_get_drvdata(pdev); | ||
773 | |||
774 | return uart_resume_port(&pnx8xxx_reg, &sport->port); | ||
775 | } | ||
776 | |||
777 | static int pnx8xxx_serial_probe(struct platform_device *pdev) | ||
778 | { | ||
779 | struct resource *res = pdev->resource; | ||
780 | int i; | ||
781 | |||
782 | for (i = 0; i < pdev->num_resources; i++, res++) { | ||
783 | if (!(res->flags & IORESOURCE_MEM)) | ||
784 | continue; | ||
785 | |||
786 | for (i = 0; i < NR_PORTS; i++) { | ||
787 | if (pnx8xxx_ports[i].port.mapbase != res->start) | ||
788 | continue; | ||
789 | |||
790 | pnx8xxx_ports[i].port.dev = &pdev->dev; | ||
791 | uart_add_one_port(&pnx8xxx_reg, &pnx8xxx_ports[i].port); | ||
792 | platform_set_drvdata(pdev, &pnx8xxx_ports[i]); | ||
793 | break; | ||
794 | } | ||
795 | } | ||
796 | |||
797 | return 0; | ||
798 | } | ||
799 | |||
800 | static int pnx8xxx_serial_remove(struct platform_device *pdev) | ||
801 | { | ||
802 | struct pnx8xxx_port *sport = platform_get_drvdata(pdev); | ||
803 | |||
804 | platform_set_drvdata(pdev, NULL); | ||
805 | |||
806 | if (sport) | ||
807 | uart_remove_one_port(&pnx8xxx_reg, &sport->port); | ||
808 | |||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | static struct platform_driver pnx8xxx_serial_driver = { | ||
813 | .driver = { | ||
814 | .name = "pnx8xxx-uart", | ||
815 | .owner = THIS_MODULE, | ||
816 | }, | ||
817 | .probe = pnx8xxx_serial_probe, | ||
818 | .remove = pnx8xxx_serial_remove, | ||
819 | .suspend = pnx8xxx_serial_suspend, | ||
820 | .resume = pnx8xxx_serial_resume, | ||
821 | }; | ||
822 | |||
823 | static int __init pnx8xxx_serial_init(void) | ||
824 | { | ||
825 | int ret; | ||
826 | |||
827 | printk(KERN_INFO "Serial: PNX8XXX driver $Revision: 1.2 $\n"); | ||
828 | |||
829 | pnx8xxx_init_ports(); | ||
830 | |||
831 | ret = uart_register_driver(&pnx8xxx_reg); | ||
832 | if (ret == 0) { | ||
833 | ret = platform_driver_register(&pnx8xxx_serial_driver); | ||
834 | if (ret) | ||
835 | uart_unregister_driver(&pnx8xxx_reg); | ||
836 | } | ||
837 | return ret; | ||
838 | } | ||
839 | |||
840 | static void __exit pnx8xxx_serial_exit(void) | ||
841 | { | ||
842 | platform_driver_unregister(&pnx8xxx_serial_driver); | ||
843 | uart_unregister_driver(&pnx8xxx_reg); | ||
844 | } | ||
845 | |||
846 | module_init(pnx8xxx_serial_init); | ||
847 | module_exit(pnx8xxx_serial_exit); | ||
848 | |||
849 | MODULE_AUTHOR("Embedded Alley Solutions, Inc."); | ||
850 | MODULE_DESCRIPTION("PNX8XXX SoCs serial port driver"); | ||
851 | MODULE_LICENSE("GPL"); | ||
852 | MODULE_ALIAS_CHARDEV_MAJOR(SERIAL_PNX8XXX_MAJOR); | ||
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index f84982e508c7..0422c0f1f852 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1523,9 +1523,8 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1523 | } | 1523 | } |
1524 | 1524 | ||
1525 | if (!state->info) { | 1525 | if (!state->info) { |
1526 | state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL); | 1526 | state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL); |
1527 | if (state->info) { | 1527 | if (state->info) { |
1528 | memset(state->info, 0, sizeof(struct uart_info)); | ||
1529 | init_waitqueue_head(&state->info->open_wait); | 1528 | init_waitqueue_head(&state->info->open_wait); |
1530 | init_waitqueue_head(&state->info->delta_msr_wait); | 1529 | init_waitqueue_head(&state->info->delta_msr_wait); |
1531 | 1530 | ||
@@ -1660,6 +1659,7 @@ static const char *uart_type(struct uart_port *port) | |||
1660 | static int uart_line_info(char *buf, struct uart_driver *drv, int i) | 1659 | static int uart_line_info(char *buf, struct uart_driver *drv, int i) |
1661 | { | 1660 | { |
1662 | struct uart_state *state = drv->state + i; | 1661 | struct uart_state *state = drv->state + i; |
1662 | int pm_state; | ||
1663 | struct uart_port *port = state->port; | 1663 | struct uart_port *port = state->port; |
1664 | char stat_buf[32]; | 1664 | char stat_buf[32]; |
1665 | unsigned int status; | 1665 | unsigned int status; |
@@ -1682,9 +1682,16 @@ static int uart_line_info(char *buf, struct uart_driver *drv, int i) | |||
1682 | 1682 | ||
1683 | if(capable(CAP_SYS_ADMIN)) | 1683 | if(capable(CAP_SYS_ADMIN)) |
1684 | { | 1684 | { |
1685 | mutex_lock(&state->mutex); | ||
1686 | pm_state = state->pm_state; | ||
1687 | if (pm_state) | ||
1688 | uart_change_pm(state, 0); | ||
1685 | spin_lock_irq(&port->lock); | 1689 | spin_lock_irq(&port->lock); |
1686 | status = port->ops->get_mctrl(port); | 1690 | status = port->ops->get_mctrl(port); |
1687 | spin_unlock_irq(&port->lock); | 1691 | spin_unlock_irq(&port->lock); |
1692 | if (pm_state) | ||
1693 | uart_change_pm(state, pm_state); | ||
1694 | mutex_unlock(&state->mutex); | ||
1688 | 1695 | ||
1689 | ret += sprintf(buf + ret, " tx:%d rx:%d", | 1696 | ret += sprintf(buf + ret, " tx:%d rx:%d", |
1690 | port->icount.tx, port->icount.rx); | 1697 | port->icount.tx, port->icount.rx); |
@@ -2100,6 +2107,9 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, | |||
2100 | 2107 | ||
2101 | uart_report_port(drv, port); | 2108 | uart_report_port(drv, port); |
2102 | 2109 | ||
2110 | /* Power up port for set_mctrl() */ | ||
2111 | uart_change_pm(state, 0); | ||
2112 | |||
2103 | /* | 2113 | /* |
2104 | * Ensure that the modem control lines are de-activated. | 2114 | * Ensure that the modem control lines are de-activated. |
2105 | * We probably don't need a spinlock around this, but | 2115 | * We probably don't need a spinlock around this, but |
@@ -2167,13 +2177,11 @@ int uart_register_driver(struct uart_driver *drv) | |||
2167 | * Maybe we should be using a slab cache for this, especially if | 2177 | * Maybe we should be using a slab cache for this, especially if |
2168 | * we have a large number of ports to handle. | 2178 | * we have a large number of ports to handle. |
2169 | */ | 2179 | */ |
2170 | drv->state = kmalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); | 2180 | drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); |
2171 | retval = -ENOMEM; | 2181 | retval = -ENOMEM; |
2172 | if (!drv->state) | 2182 | if (!drv->state) |
2173 | goto out; | 2183 | goto out; |
2174 | 2184 | ||
2175 | memset(drv->state, 0, sizeof(struct uart_state) * drv->nr); | ||
2176 | |||
2177 | normal = alloc_tty_driver(drv->nr); | 2185 | normal = alloc_tty_driver(drv->nr); |
2178 | if (!normal) | 2186 | if (!normal) |
2179 | goto out; | 2187 | goto out; |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 431433f4dd6d..6b76babc7fbf 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/moduleparam.h> | 35 | #include <linux/moduleparam.h> |
36 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/sched.h> | ||
39 | #include <linux/ptrace.h> | 38 | #include <linux/ptrace.h> |
40 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
41 | #include <linux/string.h> | 40 | #include <linux/string.h> |
@@ -249,6 +248,10 @@ static const struct serial_quirk quirks[] = { | |||
249 | .multi = 2, | 248 | .multi = 2, |
250 | }, { | 249 | }, { |
251 | .manfid = MANFID_QUATECH, | 250 | .manfid = MANFID_QUATECH, |
251 | .prodid = PRODID_QUATECH_DUAL_RS232_G, | ||
252 | .multi = 2, | ||
253 | }, { | ||
254 | .manfid = MANFID_QUATECH, | ||
252 | .prodid = PRODID_QUATECH_QUAD_RS232, | 255 | .prodid = PRODID_QUATECH_QUAD_RS232, |
253 | .multi = 4, | 256 | .multi = 4, |
254 | }, { | 257 | }, { |
@@ -334,10 +337,9 @@ static int serial_probe(struct pcmcia_device *link) | |||
334 | DEBUG(0, "serial_attach()\n"); | 337 | DEBUG(0, "serial_attach()\n"); |
335 | 338 | ||
336 | /* Create new serial device */ | 339 | /* Create new serial device */ |
337 | info = kmalloc(sizeof (*info), GFP_KERNEL); | 340 | info = kzalloc(sizeof (*info), GFP_KERNEL); |
338 | if (!info) | 341 | if (!info) |
339 | return -ENOMEM; | 342 | return -ENOMEM; |
340 | memset(info, 0, sizeof (*info)); | ||
341 | info->p_dev = link; | 343 | info->p_dev = link; |
342 | link->priv = info; | 344 | link->priv = info; |
343 | 345 | ||
@@ -893,6 +895,7 @@ static struct pcmcia_device_id serial_ids[] = { | |||
893 | PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a), | 895 | PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a), |
894 | PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), | 896 | PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), |
895 | PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), | 897 | PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), |
898 | PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d), | ||
896 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), | 899 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), |
897 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), | 900 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), |
898 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), | 901 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), |
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index 7186a82c4759..f4440d329310 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c | |||
@@ -37,6 +37,7 @@ | |||
37 | * 1.06 Do not insert a char caused previous overrun. | 37 | * 1.06 Do not insert a char caused previous overrun. |
38 | * Fix some spin_locks. | 38 | * Fix some spin_locks. |
39 | * Do not call uart_add_one_port for absent ports. | 39 | * Do not call uart_add_one_port for absent ports. |
40 | * 1.07 Use CONFIG_SERIAL_TXX9_NR_UARTS. Cleanup. | ||
40 | */ | 41 | */ |
41 | 42 | ||
42 | #if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 43 | #if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
@@ -58,9 +59,8 @@ | |||
58 | #include <linux/mutex.h> | 59 | #include <linux/mutex.h> |
59 | 60 | ||
60 | #include <asm/io.h> | 61 | #include <asm/io.h> |
61 | #include <asm/irq.h> | ||
62 | 62 | ||
63 | static char *serial_version = "1.06"; | 63 | static char *serial_version = "1.07"; |
64 | static char *serial_name = "TX39/49 Serial driver"; | 64 | static char *serial_name = "TX39/49 Serial driver"; |
65 | 65 | ||
66 | #define PASS_LIMIT 256 | 66 | #define PASS_LIMIT 256 |
@@ -88,12 +88,7 @@ static char *serial_name = "TX39/49 Serial driver"; | |||
88 | /* | 88 | /* |
89 | * Number of serial ports | 89 | * Number of serial ports |
90 | */ | 90 | */ |
91 | #ifdef ENABLE_SERIAL_TXX9_PCI | 91 | #define UART_NR CONFIG_SERIAL_TXX9_NR_UARTS |
92 | #define NR_PCI_BOARDS 4 | ||
93 | #define UART_NR (4 + NR_PCI_BOARDS) | ||
94 | #else | ||
95 | #define UART_NR 4 | ||
96 | #endif | ||
97 | 92 | ||
98 | #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) | 93 | #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) |
99 | 94 | ||
@@ -987,6 +982,7 @@ int __init early_serial_txx9_setup(struct uart_port *port) | |||
987 | } | 982 | } |
988 | 983 | ||
989 | #ifdef ENABLE_SERIAL_TXX9_PCI | 984 | #ifdef ENABLE_SERIAL_TXX9_PCI |
985 | #ifdef CONFIG_PM | ||
990 | /** | 986 | /** |
991 | * serial_txx9_suspend_port - suspend one serial port | 987 | * serial_txx9_suspend_port - suspend one serial port |
992 | * @line: serial line number | 988 | * @line: serial line number |
@@ -1008,6 +1004,7 @@ static void serial_txx9_resume_port(int line) | |||
1008 | { | 1004 | { |
1009 | uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); | 1005 | uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); |
1010 | } | 1006 | } |
1007 | #endif | ||
1011 | 1008 | ||
1012 | static DEFINE_MUTEX(serial_txx9_mutex); | 1009 | static DEFINE_MUTEX(serial_txx9_mutex); |
1013 | 1010 | ||
@@ -1118,6 +1115,7 @@ static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev) | |||
1118 | } | 1115 | } |
1119 | } | 1116 | } |
1120 | 1117 | ||
1118 | #ifdef CONFIG_PM | ||
1121 | static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state) | 1119 | static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state) |
1122 | { | 1120 | { |
1123 | int line = (int)(long)pci_get_drvdata(dev); | 1121 | int line = (int)(long)pci_get_drvdata(dev); |
@@ -1142,11 +1140,10 @@ static int pciserial_txx9_resume_one(struct pci_dev *dev) | |||
1142 | } | 1140 | } |
1143 | return 0; | 1141 | return 0; |
1144 | } | 1142 | } |
1143 | #endif | ||
1145 | 1144 | ||
1146 | static struct pci_device_id serial_txx9_pci_tbl[] = { | 1145 | static const struct pci_device_id serial_txx9_pci_tbl[] = { |
1147 | { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC, | 1146 | { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC) }, |
1148 | PCI_ANY_ID, PCI_ANY_ID, | ||
1149 | 0, 0, 0 }, | ||
1150 | { 0, } | 1147 | { 0, } |
1151 | }; | 1148 | }; |
1152 | 1149 | ||
@@ -1154,8 +1151,10 @@ static struct pci_driver serial_txx9_pci_driver = { | |||
1154 | .name = "serial_txx9", | 1151 | .name = "serial_txx9", |
1155 | .probe = pciserial_txx9_init_one, | 1152 | .probe = pciserial_txx9_init_one, |
1156 | .remove = __devexit_p(pciserial_txx9_remove_one), | 1153 | .remove = __devexit_p(pciserial_txx9_remove_one), |
1154 | #ifdef CONFIG_PM | ||
1157 | .suspend = pciserial_txx9_suspend_one, | 1155 | .suspend = pciserial_txx9_suspend_one, |
1158 | .resume = pciserial_txx9_resume_one, | 1156 | .resume = pciserial_txx9_resume_one, |
1157 | #endif | ||
1159 | .id_table = serial_txx9_pci_tbl, | 1158 | .id_table = serial_txx9_pci_tbl, |
1160 | }; | 1159 | }; |
1161 | 1160 | ||
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index 145d6236954b..deb9ab4b5a0b 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
22 | #include <linux/tty.h> | 21 | #include <linux/tty.h> |
23 | #include <linux/tty_flip.h> | 22 | #include <linux/tty_flip.h> |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 3ec3df21816b..96a852aa1903 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
22 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
23 | #include <linux/tty.h> | 22 | #include <linux/tty.h> |
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 244f796dc625..da73205e54cd 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | ||
18 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
19 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
20 | #include <linux/tty.h> | 19 | #include <linux/tty.h> |
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c index db8607e3d531..f5051cf1a0c8 100644 --- a/drivers/serial/uartlite.c +++ b/drivers/serial/uartlite.c | |||
@@ -256,7 +256,7 @@ static void ulite_release_port(struct uart_port *port) | |||
256 | { | 256 | { |
257 | release_mem_region(port->mapbase, ULITE_REGION); | 257 | release_mem_region(port->mapbase, ULITE_REGION); |
258 | iounmap(port->membase); | 258 | iounmap(port->membase); |
259 | port->membase = 0; | 259 | port->membase = NULL; |
260 | } | 260 | } |
261 | 261 | ||
262 | static int ulite_request_port(struct uart_port *port) | 262 | static int ulite_request_port(struct uart_port *port) |
@@ -438,7 +438,7 @@ static int __devinit ulite_probe(struct platform_device *pdev) | |||
438 | port->iotype = UPIO_MEM; | 438 | port->iotype = UPIO_MEM; |
439 | port->iobase = 1; /* mark port in use */ | 439 | port->iobase = 1; /* mark port in use */ |
440 | port->mapbase = res->start; | 440 | port->mapbase = res->start; |
441 | port->membase = 0; | 441 | port->membase = NULL; |
442 | port->ops = &ulite_ops; | 442 | port->ops = &ulite_ops; |
443 | port->irq = res2->start; | 443 | port->irq = res2->start; |
444 | port->flags = UPF_BOOT_AUTOCONF; | 444 | port->flags = UPF_BOOT_AUTOCONF; |
@@ -462,7 +462,7 @@ static int ulite_remove(struct platform_device *pdev) | |||
462 | uart_remove_one_port(&ulite_uart_driver, port); | 462 | uart_remove_one_port(&ulite_uart_driver, port); |
463 | 463 | ||
464 | /* mark port as free */ | 464 | /* mark port as free */ |
465 | port->membase = 0; | 465 | port->membase = NULL; |
466 | 466 | ||
467 | return 0; | 467 | return 0; |
468 | } | 468 | } |