aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/8250.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/8250.c')
-rw-r--r--drivers/serial/8250.c109
1 files changed, 79 insertions, 30 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index ee74c934de89..b25e6e490530 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -454,21 +454,40 @@ static void tsi_serial_out(struct uart_port *p, int offset, int value)
454 writeb(value, p->membase + offset); 454 writeb(value, p->membase + offset);
455} 455}
456 456
457/* Save the LCR value so it can be re-written when a Busy Detect IRQ occurs. */
458static inline void dwapb_save_out_value(struct uart_port *p, int offset,
459 int value)
460{
461 struct uart_8250_port *up =
462 container_of(p, struct uart_8250_port, port);
463
464 if (offset == UART_LCR)
465 up->lcr = value;
466}
467
468/* Read the IER to ensure any interrupt is cleared before returning from ISR. */
469static inline void dwapb_check_clear_ier(struct uart_port *p, int offset)
470{
471 if (offset == UART_TX || offset == UART_IER)
472 p->serial_in(p, UART_IER);
473}
474
457static void dwapb_serial_out(struct uart_port *p, int offset, int value) 475static void dwapb_serial_out(struct uart_port *p, int offset, int value)
458{ 476{
459 int save_offset = offset; 477 int save_offset = offset;
460 offset = map_8250_out_reg(p, offset) << p->regshift; 478 offset = map_8250_out_reg(p, offset) << p->regshift;
461 /* Save the LCR value so it can be re-written when a 479 dwapb_save_out_value(p, save_offset, value);
462 * Busy Detect interrupt occurs. */
463 if (save_offset == UART_LCR) {
464 struct uart_8250_port *up = (struct uart_8250_port *)p;
465 up->lcr = value;
466 }
467 writeb(value, p->membase + offset); 480 writeb(value, p->membase + offset);
468 /* Read the IER to ensure any interrupt is cleared before 481 dwapb_check_clear_ier(p, save_offset);
469 * returning from ISR. */ 482}
470 if (save_offset == UART_TX || save_offset == UART_IER) 483
471 value = p->serial_in(p, UART_IER); 484static void dwapb32_serial_out(struct uart_port *p, int offset, int value)
485{
486 int save_offset = offset;
487 offset = map_8250_out_reg(p, offset) << p->regshift;
488 dwapb_save_out_value(p, save_offset, value);
489 writel(value, p->membase + offset);
490 dwapb_check_clear_ier(p, save_offset);
472} 491}
473 492
474static unsigned int io_serial_in(struct uart_port *p, int offset) 493static unsigned int io_serial_in(struct uart_port *p, int offset)
@@ -485,7 +504,8 @@ static void io_serial_out(struct uart_port *p, int offset, int value)
485 504
486static void set_io_from_upio(struct uart_port *p) 505static void set_io_from_upio(struct uart_port *p)
487{ 506{
488 struct uart_8250_port *up = (struct uart_8250_port *)p; 507 struct uart_8250_port *up =
508 container_of(p, struct uart_8250_port, port);
489 switch (p->iotype) { 509 switch (p->iotype) {
490 case UPIO_HUB6: 510 case UPIO_HUB6:
491 p->serial_in = hub6_serial_in; 511 p->serial_in = hub6_serial_in;
@@ -518,6 +538,11 @@ static void set_io_from_upio(struct uart_port *p)
518 p->serial_out = dwapb_serial_out; 538 p->serial_out = dwapb_serial_out;
519 break; 539 break;
520 540
541 case UPIO_DWAPB32:
542 p->serial_in = mem32_serial_in;
543 p->serial_out = dwapb32_serial_out;
544 break;
545
521 default: 546 default:
522 p->serial_in = io_serial_in; 547 p->serial_in = io_serial_in;
523 p->serial_out = io_serial_out; 548 p->serial_out = io_serial_out;
@@ -536,6 +561,7 @@ serial_out_sync(struct uart_8250_port *up, int offset, int value)
536 case UPIO_MEM32: 561 case UPIO_MEM32:
537 case UPIO_AU: 562 case UPIO_AU:
538 case UPIO_DWAPB: 563 case UPIO_DWAPB:
564 case UPIO_DWAPB32:
539 p->serial_out(p, offset, value); 565 p->serial_out(p, offset, value);
540 p->serial_in(p, UART_LCR); /* safe, no side-effects */ 566 p->serial_in(p, UART_LCR); /* safe, no side-effects */
541 break; 567 break;
@@ -1319,7 +1345,8 @@ static inline void __stop_tx(struct uart_8250_port *p)
1319 1345
1320static void serial8250_stop_tx(struct uart_port *port) 1346static void serial8250_stop_tx(struct uart_port *port)
1321{ 1347{
1322 struct uart_8250_port *up = (struct uart_8250_port *)port; 1348 struct uart_8250_port *up =
1349 container_of(port, struct uart_8250_port, port);
1323 1350
1324 __stop_tx(up); 1351 __stop_tx(up);
1325 1352
@@ -1336,7 +1363,8 @@ static void transmit_chars(struct uart_8250_port *up);
1336 1363
1337static void serial8250_start_tx(struct uart_port *port) 1364static void serial8250_start_tx(struct uart_port *port)
1338{ 1365{
1339 struct uart_8250_port *up = (struct uart_8250_port *)port; 1366 struct uart_8250_port *up =
1367 container_of(port, struct uart_8250_port, port);
1340 1368
1341 if (!(up->ier & UART_IER_THRI)) { 1369 if (!(up->ier & UART_IER_THRI)) {
1342 up->ier |= UART_IER_THRI; 1370 up->ier |= UART_IER_THRI;
@@ -1364,7 +1392,8 @@ static void serial8250_start_tx(struct uart_port *port)
1364 1392
1365static void serial8250_stop_rx(struct uart_port *port) 1393static void serial8250_stop_rx(struct uart_port *port)
1366{ 1394{
1367 struct uart_8250_port *up = (struct uart_8250_port *)port; 1395 struct uart_8250_port *up =
1396 container_of(port, struct uart_8250_port, port);
1368 1397
1369 up->ier &= ~UART_IER_RLSI; 1398 up->ier &= ~UART_IER_RLSI;
1370 up->port.read_status_mask &= ~UART_LSR_DR; 1399 up->port.read_status_mask &= ~UART_LSR_DR;
@@ -1373,7 +1402,8 @@ static void serial8250_stop_rx(struct uart_port *port)
1373 1402
1374static void serial8250_enable_ms(struct uart_port *port) 1403static void serial8250_enable_ms(struct uart_port *port)
1375{ 1404{
1376 struct uart_8250_port *up = (struct uart_8250_port *)port; 1405 struct uart_8250_port *up =
1406 container_of(port, struct uart_8250_port, port);
1377 1407
1378 /* no MSR capabilities */ 1408 /* no MSR capabilities */
1379 if (up->bugs & UART_BUG_NOMSR) 1409 if (up->bugs & UART_BUG_NOMSR)
@@ -1581,7 +1611,8 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id)
1581 handled = 1; 1611 handled = 1;
1582 1612
1583 end = NULL; 1613 end = NULL;
1584 } else if (up->port.iotype == UPIO_DWAPB && 1614 } else if ((up->port.iotype == UPIO_DWAPB ||
1615 up->port.iotype == UPIO_DWAPB32) &&
1585 (iir & UART_IIR_BUSY) == UART_IIR_BUSY) { 1616 (iir & UART_IIR_BUSY) == UART_IIR_BUSY) {
1586 /* The DesignWare APB UART has an Busy Detect (0x07) 1617 /* The DesignWare APB UART has an Busy Detect (0x07)
1587 * interrupt meaning an LCR write attempt occured while the 1618 * interrupt meaning an LCR write attempt occured while the
@@ -1781,7 +1812,8 @@ static void serial8250_backup_timeout(unsigned long data)
1781 1812
1782static unsigned int serial8250_tx_empty(struct uart_port *port) 1813static unsigned int serial8250_tx_empty(struct uart_port *port)
1783{ 1814{
1784 struct uart_8250_port *up = (struct uart_8250_port *)port; 1815 struct uart_8250_port *up =
1816 container_of(port, struct uart_8250_port, port);
1785 unsigned long flags; 1817 unsigned long flags;
1786 unsigned int lsr; 1818 unsigned int lsr;
1787 1819
@@ -1795,7 +1827,8 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
1795 1827
1796static unsigned int serial8250_get_mctrl(struct uart_port *port) 1828static unsigned int serial8250_get_mctrl(struct uart_port *port)
1797{ 1829{
1798 struct uart_8250_port *up = (struct uart_8250_port *)port; 1830 struct uart_8250_port *up =
1831 container_of(port, struct uart_8250_port, port);
1799 unsigned int status; 1832 unsigned int status;
1800 unsigned int ret; 1833 unsigned int ret;
1801 1834
@@ -1815,7 +1848,8 @@ static unsigned int serial8250_get_mctrl(struct uart_port *port)
1815 1848
1816static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl) 1849static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
1817{ 1850{
1818 struct uart_8250_port *up = (struct uart_8250_port *)port; 1851 struct uart_8250_port *up =
1852 container_of(port, struct uart_8250_port, port);
1819 unsigned char mcr = 0; 1853 unsigned char mcr = 0;
1820 1854
1821 if (mctrl & TIOCM_RTS) 1855 if (mctrl & TIOCM_RTS)
@@ -1836,7 +1870,8 @@ static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
1836 1870
1837static void serial8250_break_ctl(struct uart_port *port, int break_state) 1871static void serial8250_break_ctl(struct uart_port *port, int break_state)
1838{ 1872{
1839 struct uart_8250_port *up = (struct uart_8250_port *)port; 1873 struct uart_8250_port *up =
1874 container_of(port, struct uart_8250_port, port);
1840 unsigned long flags; 1875 unsigned long flags;
1841 1876
1842 spin_lock_irqsave(&up->port.lock, flags); 1877 spin_lock_irqsave(&up->port.lock, flags);
@@ -1890,7 +1925,8 @@ static void wait_for_xmitr(struct uart_8250_port *up, int bits)
1890 1925
1891static int serial8250_get_poll_char(struct uart_port *port) 1926static int serial8250_get_poll_char(struct uart_port *port)
1892{ 1927{
1893 struct uart_8250_port *up = (struct uart_8250_port *)port; 1928 struct uart_8250_port *up =
1929 container_of(port, struct uart_8250_port, port);
1894 unsigned char lsr = serial_inp(up, UART_LSR); 1930 unsigned char lsr = serial_inp(up, UART_LSR);
1895 1931
1896 if (!(lsr & UART_LSR_DR)) 1932 if (!(lsr & UART_LSR_DR))
@@ -1904,7 +1940,8 @@ static void serial8250_put_poll_char(struct uart_port *port,
1904 unsigned char c) 1940 unsigned char c)
1905{ 1941{
1906 unsigned int ier; 1942 unsigned int ier;
1907 struct uart_8250_port *up = (struct uart_8250_port *)port; 1943 struct uart_8250_port *up =
1944 container_of(port, struct uart_8250_port, port);
1908 1945
1909 /* 1946 /*
1910 * First save the IER then disable the interrupts 1947 * First save the IER then disable the interrupts
@@ -1938,11 +1975,14 @@ static void serial8250_put_poll_char(struct uart_port *port,
1938 1975
1939static int serial8250_startup(struct uart_port *port) 1976static int serial8250_startup(struct uart_port *port)
1940{ 1977{
1941 struct uart_8250_port *up = (struct uart_8250_port *)port; 1978 struct uart_8250_port *up =
1979 container_of(port, struct uart_8250_port, port);
1942 unsigned long flags; 1980 unsigned long flags;
1943 unsigned char lsr, iir; 1981 unsigned char lsr, iir;
1944 int retval; 1982 int retval;
1945 1983
1984 up->port.fifosize = uart_config[up->port.type].fifo_size;
1985 up->tx_loadsz = uart_config[up->port.type].tx_loadsz;
1946 up->capabilities = uart_config[up->port.type].flags; 1986 up->capabilities = uart_config[up->port.type].flags;
1947 up->mcr = 0; 1987 up->mcr = 0;
1948 1988
@@ -2166,7 +2206,8 @@ dont_test_tx_en:
2166 2206
2167static void serial8250_shutdown(struct uart_port *port) 2207static void serial8250_shutdown(struct uart_port *port)
2168{ 2208{
2169 struct uart_8250_port *up = (struct uart_8250_port *)port; 2209 struct uart_8250_port *up =
2210 container_of(port, struct uart_8250_port, port);
2170 unsigned long flags; 2211 unsigned long flags;
2171 2212
2172 /* 2213 /*
@@ -2235,7 +2276,8 @@ void
2235serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, 2276serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2236 struct ktermios *old) 2277 struct ktermios *old)
2237{ 2278{
2238 struct uart_8250_port *up = (struct uart_8250_port *)port; 2279 struct uart_8250_port *up =
2280 container_of(port, struct uart_8250_port, port);
2239 unsigned char cval, fcr = 0; 2281 unsigned char cval, fcr = 0;
2240 unsigned long flags; 2282 unsigned long flags;
2241 unsigned int baud, quot; 2283 unsigned int baud, quot;
@@ -2435,7 +2477,8 @@ serial8250_set_ldisc(struct uart_port *port, int new)
2435void serial8250_do_pm(struct uart_port *port, unsigned int state, 2477void serial8250_do_pm(struct uart_port *port, unsigned int state,
2436 unsigned int oldstate) 2478 unsigned int oldstate)
2437{ 2479{
2438 struct uart_8250_port *p = (struct uart_8250_port *)port; 2480 struct uart_8250_port *p =
2481 container_of(port, struct uart_8250_port, port);
2439 2482
2440 serial8250_set_sleep(p, state != 0); 2483 serial8250_set_sleep(p, state != 0);
2441} 2484}
@@ -2476,6 +2519,7 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
2476 case UPIO_MEM32: 2519 case UPIO_MEM32:
2477 case UPIO_MEM: 2520 case UPIO_MEM:
2478 case UPIO_DWAPB: 2521 case UPIO_DWAPB:
2522 case UPIO_DWAPB32:
2479 if (!up->port.mapbase) 2523 if (!up->port.mapbase)
2480 break; 2524 break;
2481 2525
@@ -2513,6 +2557,7 @@ static void serial8250_release_std_resource(struct uart_8250_port *up)
2513 case UPIO_MEM32: 2557 case UPIO_MEM32:
2514 case UPIO_MEM: 2558 case UPIO_MEM:
2515 case UPIO_DWAPB: 2559 case UPIO_DWAPB:
2560 case UPIO_DWAPB32:
2516 if (!up->port.mapbase) 2561 if (!up->port.mapbase)
2517 break; 2562 break;
2518 2563
@@ -2566,7 +2611,8 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up)
2566 2611
2567static void serial8250_release_port(struct uart_port *port) 2612static void serial8250_release_port(struct uart_port *port)
2568{ 2613{
2569 struct uart_8250_port *up = (struct uart_8250_port *)port; 2614 struct uart_8250_port *up =
2615 container_of(port, struct uart_8250_port, port);
2570 2616
2571 serial8250_release_std_resource(up); 2617 serial8250_release_std_resource(up);
2572 if (up->port.type == PORT_RSA) 2618 if (up->port.type == PORT_RSA)
@@ -2575,7 +2621,8 @@ static void serial8250_release_port(struct uart_port *port)
2575 2621
2576static int serial8250_request_port(struct uart_port *port) 2622static int serial8250_request_port(struct uart_port *port)
2577{ 2623{
2578 struct uart_8250_port *up = (struct uart_8250_port *)port; 2624 struct uart_8250_port *up =
2625 container_of(port, struct uart_8250_port, port);
2579 int ret = 0; 2626 int ret = 0;
2580 2627
2581 ret = serial8250_request_std_resource(up); 2628 ret = serial8250_request_std_resource(up);
@@ -2590,7 +2637,8 @@ static int serial8250_request_port(struct uart_port *port)
2590 2637
2591static void serial8250_config_port(struct uart_port *port, int flags) 2638static void serial8250_config_port(struct uart_port *port, int flags)
2592{ 2639{
2593 struct uart_8250_port *up = (struct uart_8250_port *)port; 2640 struct uart_8250_port *up =
2641 container_of(port, struct uart_8250_port, port);
2594 int probeflags = PROBE_ANY; 2642 int probeflags = PROBE_ANY;
2595 int ret; 2643 int ret;
2596 2644
@@ -2771,7 +2819,8 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
2771 2819
2772static void serial8250_console_putchar(struct uart_port *port, int ch) 2820static void serial8250_console_putchar(struct uart_port *port, int ch)
2773{ 2821{
2774 struct uart_8250_port *up = (struct uart_8250_port *)port; 2822 struct uart_8250_port *up =
2823 container_of(port, struct uart_8250_port, port);
2775 2824
2776 wait_for_xmitr(up, UART_LSR_THRE); 2825 wait_for_xmitr(up, UART_LSR_THRE);
2777 serial_out(up, UART_TX, ch); 2826 serial_out(up, UART_TX, ch);