diff options
Diffstat (limited to 'drivers/tty/serial/8250/8250.c')
-rw-r--r-- | drivers/tty/serial/8250/8250.c | 132 |
1 files changed, 49 insertions, 83 deletions
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index f9320437a649..0efc815a4968 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c | |||
@@ -239,13 +239,6 @@ static const struct serial8250_config uart_config[] = { | |||
239 | .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, | 239 | .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, |
240 | .flags = UART_CAP_FIFO | UART_CAP_UUE | UART_CAP_RTOIE, | 240 | .flags = UART_CAP_FIFO | UART_CAP_UUE | UART_CAP_RTOIE, |
241 | }, | 241 | }, |
242 | [PORT_RM9000] = { | ||
243 | .name = "RM9000", | ||
244 | .fifo_size = 16, | ||
245 | .tx_loadsz = 16, | ||
246 | .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, | ||
247 | .flags = UART_CAP_FIFO, | ||
248 | }, | ||
249 | [PORT_OCTEON] = { | 242 | [PORT_OCTEON] = { |
250 | .name = "OCTEON", | 243 | .name = "OCTEON", |
251 | .fifo_size = 64, | 244 | .fifo_size = 64, |
@@ -324,9 +317,9 @@ static void default_serial_dl_write(struct uart_8250_port *up, int value) | |||
324 | serial_out(up, UART_DLM, value >> 8 & 0xff); | 317 | serial_out(up, UART_DLM, value >> 8 & 0xff); |
325 | } | 318 | } |
326 | 319 | ||
327 | #ifdef CONFIG_MIPS_ALCHEMY | 320 | #if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X) |
328 | 321 | ||
329 | /* Au1x00 UART hardware has a weird register layout */ | 322 | /* Au1x00/RT288x UART hardware has a weird register layout */ |
330 | static const u8 au_io_in_map[] = { | 323 | static const u8 au_io_in_map[] = { |
331 | [UART_RX] = 0, | 324 | [UART_RX] = 0, |
332 | [UART_IER] = 2, | 325 | [UART_IER] = 2, |
@@ -370,56 +363,6 @@ static void au_serial_dl_write(struct uart_8250_port *up, int value) | |||
370 | 363 | ||
371 | #endif | 364 | #endif |
372 | 365 | ||
373 | #ifdef CONFIG_SERIAL_8250_RM9K | ||
374 | |||
375 | static const u8 | ||
376 | regmap_in[8] = { | ||
377 | [UART_RX] = 0x00, | ||
378 | [UART_IER] = 0x0c, | ||
379 | [UART_IIR] = 0x14, | ||
380 | [UART_LCR] = 0x1c, | ||
381 | [UART_MCR] = 0x20, | ||
382 | [UART_LSR] = 0x24, | ||
383 | [UART_MSR] = 0x28, | ||
384 | [UART_SCR] = 0x2c | ||
385 | }, | ||
386 | regmap_out[8] = { | ||
387 | [UART_TX] = 0x04, | ||
388 | [UART_IER] = 0x0c, | ||
389 | [UART_FCR] = 0x18, | ||
390 | [UART_LCR] = 0x1c, | ||
391 | [UART_MCR] = 0x20, | ||
392 | [UART_LSR] = 0x24, | ||
393 | [UART_MSR] = 0x28, | ||
394 | [UART_SCR] = 0x2c | ||
395 | }; | ||
396 | |||
397 | static unsigned int rm9k_serial_in(struct uart_port *p, int offset) | ||
398 | { | ||
399 | offset = regmap_in[offset] << p->regshift; | ||
400 | return readl(p->membase + offset); | ||
401 | } | ||
402 | |||
403 | static void rm9k_serial_out(struct uart_port *p, int offset, int value) | ||
404 | { | ||
405 | offset = regmap_out[offset] << p->regshift; | ||
406 | writel(value, p->membase + offset); | ||
407 | } | ||
408 | |||
409 | static int rm9k_serial_dl_read(struct uart_8250_port *up) | ||
410 | { | ||
411 | return ((__raw_readl(up->port.membase + 0x10) << 8) | | ||
412 | (__raw_readl(up->port.membase + 0x08) & 0xff)) & 0xffff; | ||
413 | } | ||
414 | |||
415 | static void rm9k_serial_dl_write(struct uart_8250_port *up, int value) | ||
416 | { | ||
417 | __raw_writel(value, up->port.membase + 0x08); | ||
418 | __raw_writel(value >> 8, up->port.membase + 0x10); | ||
419 | } | ||
420 | |||
421 | #endif | ||
422 | |||
423 | static unsigned int hub6_serial_in(struct uart_port *p, int offset) | 366 | static unsigned int hub6_serial_in(struct uart_port *p, int offset) |
424 | { | 367 | { |
425 | offset = offset << p->regshift; | 368 | offset = offset << p->regshift; |
@@ -497,16 +440,7 @@ static void set_io_from_upio(struct uart_port *p) | |||
497 | p->serial_out = mem32_serial_out; | 440 | p->serial_out = mem32_serial_out; |
498 | break; | 441 | break; |
499 | 442 | ||
500 | #ifdef CONFIG_SERIAL_8250_RM9K | 443 | #if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X) |
501 | case UPIO_RM9000: | ||
502 | p->serial_in = rm9k_serial_in; | ||
503 | p->serial_out = rm9k_serial_out; | ||
504 | up->dl_read = rm9k_serial_dl_read; | ||
505 | up->dl_write = rm9k_serial_dl_write; | ||
506 | break; | ||
507 | #endif | ||
508 | |||
509 | #ifdef CONFIG_MIPS_ALCHEMY | ||
510 | case UPIO_AU: | 444 | case UPIO_AU: |
511 | p->serial_in = au_serial_in; | 445 | p->serial_in = au_serial_in; |
512 | p->serial_out = au_serial_out; | 446 | p->serial_out = au_serial_out; |
@@ -1341,7 +1275,9 @@ static void serial8250_start_tx(struct uart_port *port) | |||
1341 | struct uart_8250_port *up = | 1275 | struct uart_8250_port *up = |
1342 | container_of(port, struct uart_8250_port, port); | 1276 | container_of(port, struct uart_8250_port, port); |
1343 | 1277 | ||
1344 | if (!(up->ier & UART_IER_THRI)) { | 1278 | if (up->dma && !serial8250_tx_dma(up)) { |
1279 | return; | ||
1280 | } else if (!(up->ier & UART_IER_THRI)) { | ||
1345 | up->ier |= UART_IER_THRI; | 1281 | up->ier |= UART_IER_THRI; |
1346 | serial_port_out(port, UART_IER, up->ier); | 1282 | serial_port_out(port, UART_IER, up->ier); |
1347 | 1283 | ||
@@ -1349,9 +1285,7 @@ static void serial8250_start_tx(struct uart_port *port) | |||
1349 | unsigned char lsr; | 1285 | unsigned char lsr; |
1350 | lsr = serial_in(up, UART_LSR); | 1286 | lsr = serial_in(up, UART_LSR); |
1351 | up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; | 1287 | up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; |
1352 | if ((port->type == PORT_RM9000) ? | 1288 | if (lsr & UART_LSR_TEMT) |
1353 | (lsr & UART_LSR_THRE) : | ||
1354 | (lsr & UART_LSR_TEMT)) | ||
1355 | serial8250_tx_chars(up); | 1289 | serial8250_tx_chars(up); |
1356 | } | 1290 | } |
1357 | } | 1291 | } |
@@ -1397,7 +1331,6 @@ unsigned char | |||
1397 | serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) | 1331 | serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) |
1398 | { | 1332 | { |
1399 | struct uart_port *port = &up->port; | 1333 | struct uart_port *port = &up->port; |
1400 | struct tty_struct *tty = port->state->port.tty; | ||
1401 | unsigned char ch; | 1334 | unsigned char ch; |
1402 | int max_count = 256; | 1335 | int max_count = 256; |
1403 | char flag; | 1336 | char flag; |
@@ -1462,7 +1395,7 @@ ignore_char: | |||
1462 | lsr = serial_in(up, UART_LSR); | 1395 | lsr = serial_in(up, UART_LSR); |
1463 | } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); | 1396 | } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); |
1464 | spin_unlock(&port->lock); | 1397 | spin_unlock(&port->lock); |
1465 | tty_flip_buffer_push(tty); | 1398 | tty_flip_buffer_push(&port->state->port); |
1466 | spin_lock(&port->lock); | 1399 | spin_lock(&port->lock); |
1467 | return lsr; | 1400 | return lsr; |
1468 | } | 1401 | } |
@@ -1547,6 +1480,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) | |||
1547 | unsigned long flags; | 1480 | unsigned long flags; |
1548 | struct uart_8250_port *up = | 1481 | struct uart_8250_port *up = |
1549 | container_of(port, struct uart_8250_port, port); | 1482 | container_of(port, struct uart_8250_port, port); |
1483 | int dma_err = 0; | ||
1550 | 1484 | ||
1551 | if (iir & UART_IIR_NO_INT) | 1485 | if (iir & UART_IIR_NO_INT) |
1552 | return 0; | 1486 | return 0; |
@@ -1557,8 +1491,13 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) | |||
1557 | 1491 | ||
1558 | DEBUG_INTR("status = %x...", status); | 1492 | DEBUG_INTR("status = %x...", status); |
1559 | 1493 | ||
1560 | if (status & (UART_LSR_DR | UART_LSR_BI)) | 1494 | if (status & (UART_LSR_DR | UART_LSR_BI)) { |
1561 | status = serial8250_rx_chars(up, status); | 1495 | if (up->dma) |
1496 | dma_err = serial8250_rx_dma(up, iir); | ||
1497 | |||
1498 | if (!up->dma || dma_err) | ||
1499 | status = serial8250_rx_chars(up, status); | ||
1500 | } | ||
1562 | serial8250_modem_status(up); | 1501 | serial8250_modem_status(up); |
1563 | if (status & UART_LSR_THRE) | 1502 | if (status & UART_LSR_THRE) |
1564 | serial8250_tx_chars(up); | 1503 | serial8250_tx_chars(up); |
@@ -1991,9 +1930,12 @@ static int serial8250_startup(struct uart_port *port) | |||
1991 | if (port->type == PORT_8250_CIR) | 1930 | if (port->type == PORT_8250_CIR) |
1992 | return -ENODEV; | 1931 | return -ENODEV; |
1993 | 1932 | ||
1994 | port->fifosize = uart_config[up->port.type].fifo_size; | 1933 | if (!port->fifosize) |
1995 | up->tx_loadsz = uart_config[up->port.type].tx_loadsz; | 1934 | port->fifosize = uart_config[port->type].fifo_size; |
1996 | up->capabilities = uart_config[up->port.type].flags; | 1935 | if (!up->tx_loadsz) |
1936 | up->tx_loadsz = uart_config[port->type].tx_loadsz; | ||
1937 | if (!up->capabilities) | ||
1938 | up->capabilities = uart_config[port->type].flags; | ||
1997 | up->mcr = 0; | 1939 | up->mcr = 0; |
1998 | 1940 | ||
1999 | if (port->iotype != up->cur_iotype) | 1941 | if (port->iotype != up->cur_iotype) |
@@ -2198,6 +2140,18 @@ dont_test_tx_en: | |||
2198 | up->msr_saved_flags = 0; | 2140 | up->msr_saved_flags = 0; |
2199 | 2141 | ||
2200 | /* | 2142 | /* |
2143 | * Request DMA channels for both RX and TX. | ||
2144 | */ | ||
2145 | if (up->dma) { | ||
2146 | retval = serial8250_request_dma(up); | ||
2147 | if (retval) { | ||
2148 | pr_warn_ratelimited("ttyS%d - failed to request DMA\n", | ||
2149 | serial_index(port)); | ||
2150 | up->dma = NULL; | ||
2151 | } | ||
2152 | } | ||
2153 | |||
2154 | /* | ||
2201 | * Finally, enable interrupts. Note: Modem status interrupts | 2155 | * Finally, enable interrupts. Note: Modem status interrupts |
2202 | * are set via set_termios(), which will be occurring imminently | 2156 | * are set via set_termios(), which will be occurring imminently |
2203 | * anyway, so we don't enable them here. | 2157 | * anyway, so we don't enable them here. |
@@ -2230,6 +2184,9 @@ static void serial8250_shutdown(struct uart_port *port) | |||
2230 | up->ier = 0; | 2184 | up->ier = 0; |
2231 | serial_port_out(port, UART_IER, 0); | 2185 | serial_port_out(port, UART_IER, 0); |
2232 | 2186 | ||
2187 | if (up->dma) | ||
2188 | serial8250_release_dma(up); | ||
2189 | |||
2233 | spin_lock_irqsave(&port->lock, flags); | 2190 | spin_lock_irqsave(&port->lock, flags); |
2234 | if (port->flags & UPF_FOURPORT) { | 2191 | if (port->flags & UPF_FOURPORT) { |
2235 | /* reset interrupts on the AST Fourport board */ | 2192 | /* reset interrupts on the AST Fourport board */ |
@@ -2826,9 +2783,12 @@ static void | |||
2826 | serial8250_init_fixed_type_port(struct uart_8250_port *up, unsigned int type) | 2783 | serial8250_init_fixed_type_port(struct uart_8250_port *up, unsigned int type) |
2827 | { | 2784 | { |
2828 | up->port.type = type; | 2785 | up->port.type = type; |
2829 | up->port.fifosize = uart_config[type].fifo_size; | 2786 | if (!up->port.fifosize) |
2830 | up->capabilities = uart_config[type].flags; | 2787 | up->port.fifosize = uart_config[type].fifo_size; |
2831 | up->tx_loadsz = uart_config[type].tx_loadsz; | 2788 | if (!up->tx_loadsz) |
2789 | up->tx_loadsz = uart_config[type].tx_loadsz; | ||
2790 | if (!up->capabilities) | ||
2791 | up->capabilities = uart_config[type].flags; | ||
2832 | } | 2792 | } |
2833 | 2793 | ||
2834 | static void __init | 2794 | static void __init |
@@ -3262,6 +3222,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
3262 | uart->bugs = up->bugs; | 3222 | uart->bugs = up->bugs; |
3263 | uart->port.mapbase = up->port.mapbase; | 3223 | uart->port.mapbase = up->port.mapbase; |
3264 | uart->port.private_data = up->port.private_data; | 3224 | uart->port.private_data = up->port.private_data; |
3225 | uart->port.fifosize = up->port.fifosize; | ||
3226 | uart->tx_loadsz = up->tx_loadsz; | ||
3227 | uart->capabilities = up->capabilities; | ||
3228 | |||
3265 | if (up->port.dev) | 3229 | if (up->port.dev) |
3266 | uart->port.dev = up->port.dev; | 3230 | uart->port.dev = up->port.dev; |
3267 | 3231 | ||
@@ -3287,6 +3251,8 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
3287 | uart->dl_read = up->dl_read; | 3251 | uart->dl_read = up->dl_read; |
3288 | if (up->dl_write) | 3252 | if (up->dl_write) |
3289 | uart->dl_write = up->dl_write; | 3253 | uart->dl_write = up->dl_write; |
3254 | if (up->dma) | ||
3255 | uart->dma = up->dma; | ||
3290 | 3256 | ||
3291 | if (serial8250_isa_config != NULL) | 3257 | if (serial8250_isa_config != NULL) |
3292 | serial8250_isa_config(0, &uart->port, | 3258 | serial8250_isa_config(0, &uart->port, |