diff options
Diffstat (limited to 'drivers/serial')
43 files changed, 3751 insertions, 1645 deletions
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c index b5cf39468d18..221999bcf8fe 100644 --- a/drivers/serial/21285.c +++ b/drivers/serial/21285.c | |||
@@ -94,15 +94,6 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id, struct pt_regs *r | |||
94 | 94 | ||
95 | status = *CSR_UARTFLG; | 95 | status = *CSR_UARTFLG; |
96 | while (!(status & 0x10) && max_count--) { | 96 | while (!(status & 0x10) && max_count--) { |
97 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | ||
98 | if (tty->low_latency) | ||
99 | tty_flip_buffer_push(tty); | ||
100 | /* | ||
101 | * If this failed then we will throw away the | ||
102 | * bytes but must do so to clear interrupts | ||
103 | */ | ||
104 | } | ||
105 | |||
106 | ch = *CSR_UARTDR; | 97 | ch = *CSR_UARTDR; |
107 | flag = TTY_NORMAL; | 98 | flag = TTY_NORMAL; |
108 | port->icount.rx++; | 99 | port->icount.rx++; |
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c index 67e9afa000c1..8cbf0fc5a225 100644 --- a/drivers/serial/68328serial.c +++ b/drivers/serial/68328serial.c | |||
@@ -143,7 +143,6 @@ static int m68328_console_cbaud = DEFAULT_CBAUD; | |||
143 | * memory if large numbers of serial ports are open. | 143 | * memory if large numbers of serial ports are open. |
144 | */ | 144 | */ |
145 | static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */ | 145 | static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */ |
146 | DECLARE_MUTEX(tmp_buf_sem); | ||
147 | 146 | ||
148 | static inline int serial_paranoia_check(struct m68k_serial *info, | 147 | static inline int serial_paranoia_check(struct m68k_serial *info, |
149 | char *name, const char *routine) | 148 | char *name, const char *routine) |
@@ -294,7 +293,7 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg | |||
294 | { | 293 | { |
295 | struct tty_struct *tty = info->tty; | 294 | struct tty_struct *tty = info->tty; |
296 | m68328_uart *uart = &uart_addr[info->line]; | 295 | m68328_uart *uart = &uart_addr[info->line]; |
297 | unsigned char ch; | 296 | unsigned char ch, flag; |
298 | 297 | ||
299 | /* | 298 | /* |
300 | * This do { } while() loop will get ALL chars out of Rx FIFO | 299 | * This do { } while() loop will get ALL chars out of Rx FIFO |
@@ -332,26 +331,24 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg | |||
332 | /* | 331 | /* |
333 | * Make sure that we do not overflow the buffer | 332 | * Make sure that we do not overflow the buffer |
334 | */ | 333 | */ |
335 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | 334 | if (tty_request_buffer_room(tty, 1) == 0) { |
336 | schedule_work(&tty->flip.work); | 335 | schedule_work(&tty->flip.work); |
337 | return; | 336 | return; |
338 | } | 337 | } |
339 | 338 | ||
339 | flag = TTY_NORMAL; | ||
340 | |||
340 | if(rx & URX_PARITY_ERROR) { | 341 | if(rx & URX_PARITY_ERROR) { |
341 | *tty->flip.flag_buf_ptr++ = TTY_PARITY; | 342 | flag = TTY_PARITY; |
342 | status_handle(info, rx); | 343 | status_handle(info, rx); |
343 | } else if(rx & URX_OVRUN) { | 344 | } else if(rx & URX_OVRUN) { |
344 | *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; | 345 | flag = TTY_OVERRUN; |
345 | status_handle(info, rx); | 346 | status_handle(info, rx); |
346 | } else if(rx & URX_FRAME_ERROR) { | 347 | } else if(rx & URX_FRAME_ERROR) { |
347 | *tty->flip.flag_buf_ptr++ = TTY_FRAME; | 348 | flag = TTY_FRAME; |
348 | status_handle(info, rx); | 349 | status_handle(info, rx); |
349 | } else { | ||
350 | *tty->flip.flag_buf_ptr++ = 0; /* XXX */ | ||
351 | } | 350 | } |
352 | *tty->flip.char_buf_ptr++ = ch; | 351 | tty_insert_flip_char(tty, ch, flag); |
353 | tty->flip.count++; | ||
354 | |||
355 | #ifndef CONFIG_XCOPILOT_BUGS | 352 | #ifndef CONFIG_XCOPILOT_BUGS |
356 | } while((rx = uart->urx.w) & URX_DATA_READY); | 353 | } while((rx = uart->urx.w) & URX_DATA_READY); |
357 | #endif | 354 | #endif |
diff --git a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c index 170c9d2a749c..60f5a5dc17f1 100644 --- a/drivers/serial/68360serial.c +++ b/drivers/serial/68360serial.c | |||
@@ -394,7 +394,7 @@ static void rs_360_start(struct tty_struct *tty) | |||
394 | static _INLINE_ void receive_chars(ser_info_t *info) | 394 | static _INLINE_ void receive_chars(ser_info_t *info) |
395 | { | 395 | { |
396 | struct tty_struct *tty = info->tty; | 396 | struct tty_struct *tty = info->tty; |
397 | unsigned char ch, *cp; | 397 | unsigned char ch, flag, *cp; |
398 | /*int ignored = 0;*/ | 398 | /*int ignored = 0;*/ |
399 | int i; | 399 | int i; |
400 | ushort status; | 400 | ushort status; |
@@ -438,24 +438,15 @@ static _INLINE_ void receive_chars(ser_info_t *info) | |||
438 | cp = (char *)bdp->buf; | 438 | cp = (char *)bdp->buf; |
439 | status = bdp->status; | 439 | status = bdp->status; |
440 | 440 | ||
441 | /* Check to see if there is room in the tty buffer for | ||
442 | * the characters in our BD buffer. If not, we exit | ||
443 | * now, leaving the BD with the characters. We'll pick | ||
444 | * them up again on the next receive interrupt (which could | ||
445 | * be a timeout). | ||
446 | */ | ||
447 | if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE) | ||
448 | break; | ||
449 | |||
450 | while (i-- > 0) { | 441 | while (i-- > 0) { |
451 | ch = *cp++; | 442 | ch = *cp++; |
452 | *tty->flip.char_buf_ptr = ch; | ||
453 | icount->rx++; | 443 | icount->rx++; |
454 | 444 | ||
455 | #ifdef SERIAL_DEBUG_INTR | 445 | #ifdef SERIAL_DEBUG_INTR |
456 | printk("DR%02x:%02x...", ch, status); | 446 | printk("DR%02x:%02x...", ch, status); |
457 | #endif | 447 | #endif |
458 | *tty->flip.flag_buf_ptr = 0; | 448 | flag = TTY_NORMAL; |
449 | |||
459 | if (status & (BD_SC_BR | BD_SC_FR | | 450 | if (status & (BD_SC_BR | BD_SC_FR | |
460 | BD_SC_PR | BD_SC_OV)) { | 451 | BD_SC_PR | BD_SC_OV)) { |
461 | /* | 452 | /* |
@@ -490,30 +481,18 @@ static _INLINE_ void receive_chars(ser_info_t *info) | |||
490 | if (info->flags & ASYNC_SAK) | 481 | if (info->flags & ASYNC_SAK) |
491 | do_SAK(tty); | 482 | do_SAK(tty); |
492 | } else if (status & BD_SC_PR) | 483 | } else if (status & BD_SC_PR) |
493 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 484 | flag = TTY_PARITY; |
494 | else if (status & BD_SC_FR) | 485 | else if (status & BD_SC_FR) |
495 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 486 | flag = TTY_FRAME; |
496 | if (status & BD_SC_OV) { | ||
497 | /* | ||
498 | * Overrun is special, since it's | ||
499 | * reported immediately, and doesn't | ||
500 | * affect the current character | ||
501 | */ | ||
502 | if (tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
503 | tty->flip.count++; | ||
504 | tty->flip.flag_buf_ptr++; | ||
505 | tty->flip.char_buf_ptr++; | ||
506 | *tty->flip.flag_buf_ptr = | ||
507 | TTY_OVERRUN; | ||
508 | } | ||
509 | } | ||
510 | } | 487 | } |
511 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | 488 | tty_insert_flip_char(tty, ch, flag); |
512 | break; | 489 | if (status & BD_SC_OV) |
513 | 490 | /* | |
514 | tty->flip.flag_buf_ptr++; | 491 | * Overrun is special, since it's |
515 | tty->flip.char_buf_ptr++; | 492 | * reported immediately, and doesn't |
516 | tty->flip.count++; | 493 | * affect the current character |
494 | */ | ||
495 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | ||
517 | } | 496 | } |
518 | 497 | ||
519 | /* This BD is ready to be used again. Clear status. | 498 | /* This BD is ready to be used again. Clear status. |
@@ -541,12 +520,7 @@ static _INLINE_ void receive_break(ser_info_t *info) | |||
541 | /* Check to see if there is room in the tty buffer for | 520 | /* Check to see if there is room in the tty buffer for |
542 | * the break. If not, we exit now, losing the break. FIXME | 521 | * the break. If not, we exit now, losing the break. FIXME |
543 | */ | 522 | */ |
544 | if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE) | 523 | tty_insert_flip_char(tty, 0, TTY_BREAK); |
545 | return; | ||
546 | *(tty->flip.flag_buf_ptr++) = TTY_BREAK; | ||
547 | *(tty->flip.char_buf_ptr++) = 0; | ||
548 | tty->flip.count++; | ||
549 | |||
550 | schedule_work(&tty->flip.work); | 524 | schedule_work(&tty->flip.work); |
551 | } | 525 | } |
552 | 526 | ||
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index d2bcd1f87cd6..bc36edff2058 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/serial.h> | 41 | #include <linux/serial.h> |
42 | #include <linux/serial_8250.h> | 42 | #include <linux/serial_8250.h> |
43 | #include <linux/nmi.h> | 43 | #include <linux/nmi.h> |
44 | #include <linux/mutex.h> | ||
44 | 45 | ||
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include <asm/irq.h> | 47 | #include <asm/irq.h> |
@@ -54,6 +55,8 @@ | |||
54 | */ | 55 | */ |
55 | static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; | 56 | static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; |
56 | 57 | ||
58 | static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; | ||
59 | |||
57 | /* | 60 | /* |
58 | * Debugging. | 61 | * Debugging. |
59 | */ | 62 | */ |
@@ -296,7 +299,7 @@ static inline int map_8250_out_reg(struct uart_8250_port *up, int offset) | |||
296 | 299 | ||
297 | #endif | 300 | #endif |
298 | 301 | ||
299 | static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset) | 302 | static unsigned int serial_in(struct uart_8250_port *up, int offset) |
300 | { | 303 | { |
301 | offset = map_8250_in_reg(up, offset) << up->port.regshift; | 304 | offset = map_8250_in_reg(up, offset) << up->port.regshift; |
302 | 305 | ||
@@ -321,7 +324,7 @@ static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset) | |||
321 | } | 324 | } |
322 | } | 325 | } |
323 | 326 | ||
324 | static _INLINE_ void | 327 | static void |
325 | serial_out(struct uart_8250_port *up, int offset, int value) | 328 | serial_out(struct uart_8250_port *up, int offset, int value) |
326 | { | 329 | { |
327 | offset = map_8250_out_reg(up, offset) << up->port.regshift; | 330 | offset = map_8250_out_reg(up, offset) << up->port.regshift; |
@@ -1131,7 +1134,7 @@ static void serial8250_enable_ms(struct uart_port *port) | |||
1131 | serial_out(up, UART_IER, up->ier); | 1134 | serial_out(up, UART_IER, up->ier); |
1132 | } | 1135 | } |
1133 | 1136 | ||
1134 | static _INLINE_ void | 1137 | static void |
1135 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | 1138 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) |
1136 | { | 1139 | { |
1137 | struct tty_struct *tty = up->port.info->tty; | 1140 | struct tty_struct *tty = up->port.info->tty; |
@@ -1140,19 +1143,6 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | |||
1140 | char flag; | 1143 | char flag; |
1141 | 1144 | ||
1142 | do { | 1145 | do { |
1143 | /* The following is not allowed by the tty layer and | ||
1144 | unsafe. It should be fixed ASAP */ | ||
1145 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
1146 | if (tty->low_latency) { | ||
1147 | spin_unlock(&up->port.lock); | ||
1148 | tty_flip_buffer_push(tty); | ||
1149 | spin_lock(&up->port.lock); | ||
1150 | } | ||
1151 | /* | ||
1152 | * If this failed then we will throw away the | ||
1153 | * bytes but must do so to clear interrupts | ||
1154 | */ | ||
1155 | } | ||
1156 | ch = serial_inp(up, UART_RX); | 1146 | ch = serial_inp(up, UART_RX); |
1157 | flag = TTY_NORMAL; | 1147 | flag = TTY_NORMAL; |
1158 | up->port.icount.rx++; | 1148 | up->port.icount.rx++; |
@@ -1217,7 +1207,7 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | |||
1217 | *status = lsr; | 1207 | *status = lsr; |
1218 | } | 1208 | } |
1219 | 1209 | ||
1220 | static _INLINE_ void transmit_chars(struct uart_8250_port *up) | 1210 | static void transmit_chars(struct uart_8250_port *up) |
1221 | { | 1211 | { |
1222 | struct circ_buf *xmit = &up->port.info->xmit; | 1212 | struct circ_buf *xmit = &up->port.info->xmit; |
1223 | int count; | 1213 | int count; |
@@ -1255,25 +1245,24 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up) | |||
1255 | __stop_tx(up); | 1245 | __stop_tx(up); |
1256 | } | 1246 | } |
1257 | 1247 | ||
1258 | static _INLINE_ void check_modem_status(struct uart_8250_port *up) | 1248 | static unsigned int check_modem_status(struct uart_8250_port *up) |
1259 | { | 1249 | { |
1260 | int status; | 1250 | unsigned int status = serial_in(up, UART_MSR); |
1261 | |||
1262 | status = serial_in(up, UART_MSR); | ||
1263 | 1251 | ||
1264 | if ((status & UART_MSR_ANY_DELTA) == 0) | 1252 | if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI) { |
1265 | return; | 1253 | if (status & UART_MSR_TERI) |
1254 | up->port.icount.rng++; | ||
1255 | if (status & UART_MSR_DDSR) | ||
1256 | up->port.icount.dsr++; | ||
1257 | if (status & UART_MSR_DDCD) | ||
1258 | uart_handle_dcd_change(&up->port, status & UART_MSR_DCD); | ||
1259 | if (status & UART_MSR_DCTS) | ||
1260 | uart_handle_cts_change(&up->port, status & UART_MSR_CTS); | ||
1266 | 1261 | ||
1267 | if (status & UART_MSR_TERI) | 1262 | wake_up_interruptible(&up->port.info->delta_msr_wait); |
1268 | up->port.icount.rng++; | 1263 | } |
1269 | if (status & UART_MSR_DDSR) | ||
1270 | up->port.icount.dsr++; | ||
1271 | if (status & UART_MSR_DDCD) | ||
1272 | uart_handle_dcd_change(&up->port, status & UART_MSR_DCD); | ||
1273 | if (status & UART_MSR_DCTS) | ||
1274 | uart_handle_cts_change(&up->port, status & UART_MSR_CTS); | ||
1275 | 1264 | ||
1276 | wake_up_interruptible(&up->port.info->delta_msr_wait); | 1265 | return status; |
1277 | } | 1266 | } |
1278 | 1267 | ||
1279 | /* | 1268 | /* |
@@ -1282,7 +1271,11 @@ static _INLINE_ void check_modem_status(struct uart_8250_port *up) | |||
1282 | static inline void | 1271 | static inline void |
1283 | serial8250_handle_port(struct uart_8250_port *up, struct pt_regs *regs) | 1272 | serial8250_handle_port(struct uart_8250_port *up, struct pt_regs *regs) |
1284 | { | 1273 | { |
1285 | unsigned int status = serial_inp(up, UART_LSR); | 1274 | unsigned int status; |
1275 | |||
1276 | spin_lock(&up->port.lock); | ||
1277 | |||
1278 | status = serial_inp(up, UART_LSR); | ||
1286 | 1279 | ||
1287 | DEBUG_INTR("status = %x...", status); | 1280 | DEBUG_INTR("status = %x...", status); |
1288 | 1281 | ||
@@ -1291,6 +1284,8 @@ serial8250_handle_port(struct uart_8250_port *up, struct pt_regs *regs) | |||
1291 | check_modem_status(up); | 1284 | check_modem_status(up); |
1292 | if (status & UART_LSR_THRE) | 1285 | if (status & UART_LSR_THRE) |
1293 | transmit_chars(up); | 1286 | transmit_chars(up); |
1287 | |||
1288 | spin_unlock(&up->port.lock); | ||
1294 | } | 1289 | } |
1295 | 1290 | ||
1296 | /* | 1291 | /* |
@@ -1326,9 +1321,7 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id, struct pt_regs *r | |||
1326 | 1321 | ||
1327 | iir = serial_in(up, UART_IIR); | 1322 | iir = serial_in(up, UART_IIR); |
1328 | if (!(iir & UART_IIR_NO_INT)) { | 1323 | if (!(iir & UART_IIR_NO_INT)) { |
1329 | spin_lock(&up->port.lock); | ||
1330 | serial8250_handle_port(up, regs); | 1324 | serial8250_handle_port(up, regs); |
1331 | spin_unlock(&up->port.lock); | ||
1332 | 1325 | ||
1333 | handled = 1; | 1326 | handled = 1; |
1334 | 1327 | ||
@@ -1427,11 +1420,8 @@ static void serial8250_timeout(unsigned long data) | |||
1427 | unsigned int iir; | 1420 | unsigned int iir; |
1428 | 1421 | ||
1429 | iir = serial_in(up, UART_IIR); | 1422 | iir = serial_in(up, UART_IIR); |
1430 | if (!(iir & UART_IIR_NO_INT)) { | 1423 | if (!(iir & UART_IIR_NO_INT)) |
1431 | spin_lock(&up->port.lock); | ||
1432 | serial8250_handle_port(up, NULL); | 1424 | serial8250_handle_port(up, NULL); |
1433 | spin_unlock(&up->port.lock); | ||
1434 | } | ||
1435 | 1425 | ||
1436 | timeout = up->port.timeout; | 1426 | timeout = up->port.timeout; |
1437 | timeout = timeout > 6 ? (timeout / 2 - 2) : 1; | 1427 | timeout = timeout > 6 ? (timeout / 2 - 2) : 1; |
@@ -1454,10 +1444,10 @@ static unsigned int serial8250_tx_empty(struct uart_port *port) | |||
1454 | static unsigned int serial8250_get_mctrl(struct uart_port *port) | 1444 | static unsigned int serial8250_get_mctrl(struct uart_port *port) |
1455 | { | 1445 | { |
1456 | struct uart_8250_port *up = (struct uart_8250_port *)port; | 1446 | struct uart_8250_port *up = (struct uart_8250_port *)port; |
1457 | unsigned char status; | 1447 | unsigned int status; |
1458 | unsigned int ret; | 1448 | unsigned int ret; |
1459 | 1449 | ||
1460 | status = serial_in(up, UART_MSR); | 1450 | status = check_modem_status(up); |
1461 | 1451 | ||
1462 | ret = 0; | 1452 | ret = 0; |
1463 | if (status & UART_MSR_DCD) | 1453 | if (status & UART_MSR_DCD) |
@@ -2118,7 +2108,7 @@ static void __init serial8250_isa_init_ports(void) | |||
2118 | return; | 2108 | return; |
2119 | first = 0; | 2109 | first = 0; |
2120 | 2110 | ||
2121 | for (i = 0; i < UART_NR; i++) { | 2111 | for (i = 0; i < nr_uarts; i++) { |
2122 | struct uart_8250_port *up = &serial8250_ports[i]; | 2112 | struct uart_8250_port *up = &serial8250_ports[i]; |
2123 | 2113 | ||
2124 | up->port.line = i; | 2114 | up->port.line = i; |
@@ -2137,7 +2127,7 @@ static void __init serial8250_isa_init_ports(void) | |||
2137 | } | 2127 | } |
2138 | 2128 | ||
2139 | for (i = 0, up = serial8250_ports; | 2129 | for (i = 0, up = serial8250_ports; |
2140 | i < ARRAY_SIZE(old_serial_port) && i < UART_NR; | 2130 | i < ARRAY_SIZE(old_serial_port) && i < nr_uarts; |
2141 | i++, up++) { | 2131 | i++, up++) { |
2142 | up->port.iobase = old_serial_port[i].port; | 2132 | up->port.iobase = old_serial_port[i].port; |
2143 | up->port.irq = irq_canonicalize(old_serial_port[i].irq); | 2133 | up->port.irq = irq_canonicalize(old_serial_port[i].irq); |
@@ -2159,7 +2149,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) | |||
2159 | 2149 | ||
2160 | serial8250_isa_init_ports(); | 2150 | serial8250_isa_init_ports(); |
2161 | 2151 | ||
2162 | for (i = 0; i < UART_NR; i++) { | 2152 | for (i = 0; i < nr_uarts; i++) { |
2163 | struct uart_8250_port *up = &serial8250_ports[i]; | 2153 | struct uart_8250_port *up = &serial8250_ports[i]; |
2164 | 2154 | ||
2165 | up->port.dev = dev; | 2155 | up->port.dev = dev; |
@@ -2262,7 +2252,7 @@ static int serial8250_console_setup(struct console *co, char *options) | |||
2262 | * if so, search for the first available port that does have | 2252 | * if so, search for the first available port that does have |
2263 | * console support. | 2253 | * console support. |
2264 | */ | 2254 | */ |
2265 | if (co->index >= UART_NR) | 2255 | if (co->index >= nr_uarts) |
2266 | co->index = 0; | 2256 | co->index = 0; |
2267 | port = &serial8250_ports[co->index].port; | 2257 | port = &serial8250_ports[co->index].port; |
2268 | if (!port->iobase && !port->membase) | 2258 | if (!port->iobase && !port->membase) |
@@ -2298,11 +2288,9 @@ static int __init find_port(struct uart_port *p) | |||
2298 | int line; | 2288 | int line; |
2299 | struct uart_port *port; | 2289 | struct uart_port *port; |
2300 | 2290 | ||
2301 | for (line = 0; line < UART_NR; line++) { | 2291 | for (line = 0; line < nr_uarts; line++) { |
2302 | port = &serial8250_ports[line].port; | 2292 | port = &serial8250_ports[line].port; |
2303 | if (p->iotype == port->iotype && | 2293 | if (uart_match_port(p, port)) |
2304 | p->iobase == port->iobase && | ||
2305 | p->membase == port->membase) | ||
2306 | return line; | 2294 | return line; |
2307 | } | 2295 | } |
2308 | return -ENODEV; | 2296 | return -ENODEV; |
@@ -2422,7 +2410,7 @@ static int __devexit serial8250_remove(struct platform_device *dev) | |||
2422 | { | 2410 | { |
2423 | int i; | 2411 | int i; |
2424 | 2412 | ||
2425 | for (i = 0; i < UART_NR; i++) { | 2413 | for (i = 0; i < nr_uarts; i++) { |
2426 | struct uart_8250_port *up = &serial8250_ports[i]; | 2414 | struct uart_8250_port *up = &serial8250_ports[i]; |
2427 | 2415 | ||
2428 | if (up->port.dev == &dev->dev) | 2416 | if (up->port.dev == &dev->dev) |
@@ -2466,6 +2454,7 @@ static struct platform_driver serial8250_isa_driver = { | |||
2466 | .resume = serial8250_resume, | 2454 | .resume = serial8250_resume, |
2467 | .driver = { | 2455 | .driver = { |
2468 | .name = "serial8250", | 2456 | .name = "serial8250", |
2457 | .owner = THIS_MODULE, | ||
2469 | }, | 2458 | }, |
2470 | }; | 2459 | }; |
2471 | 2460 | ||
@@ -2480,7 +2469,7 @@ static struct platform_device *serial8250_isa_devs; | |||
2480 | * 16x50 serial ports to be configured at run-time, to support PCMCIA | 2469 | * 16x50 serial ports to be configured at run-time, to support PCMCIA |
2481 | * modems and PCI multiport cards. | 2470 | * modems and PCI multiport cards. |
2482 | */ | 2471 | */ |
2483 | static DECLARE_MUTEX(serial_sem); | 2472 | static DEFINE_MUTEX(serial_mutex); |
2484 | 2473 | ||
2485 | static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port) | 2474 | static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port) |
2486 | { | 2475 | { |
@@ -2489,7 +2478,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
2489 | /* | 2478 | /* |
2490 | * First, find a port entry which matches. | 2479 | * First, find a port entry which matches. |
2491 | */ | 2480 | */ |
2492 | for (i = 0; i < UART_NR; i++) | 2481 | for (i = 0; i < nr_uarts; i++) |
2493 | if (uart_match_port(&serial8250_ports[i].port, port)) | 2482 | if (uart_match_port(&serial8250_ports[i].port, port)) |
2494 | return &serial8250_ports[i]; | 2483 | return &serial8250_ports[i]; |
2495 | 2484 | ||
@@ -2498,7 +2487,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
2498 | * free entry. We look for one which hasn't been previously | 2487 | * free entry. We look for one which hasn't been previously |
2499 | * used (indicated by zero iobase). | 2488 | * used (indicated by zero iobase). |
2500 | */ | 2489 | */ |
2501 | for (i = 0; i < UART_NR; i++) | 2490 | for (i = 0; i < nr_uarts; i++) |
2502 | if (serial8250_ports[i].port.type == PORT_UNKNOWN && | 2491 | if (serial8250_ports[i].port.type == PORT_UNKNOWN && |
2503 | serial8250_ports[i].port.iobase == 0) | 2492 | serial8250_ports[i].port.iobase == 0) |
2504 | return &serial8250_ports[i]; | 2493 | return &serial8250_ports[i]; |
@@ -2507,7 +2496,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
2507 | * That also failed. Last resort is to find any entry which | 2496 | * That also failed. Last resort is to find any entry which |
2508 | * doesn't have a real port associated with it. | 2497 | * doesn't have a real port associated with it. |
2509 | */ | 2498 | */ |
2510 | for (i = 0; i < UART_NR; i++) | 2499 | for (i = 0; i < nr_uarts; i++) |
2511 | if (serial8250_ports[i].port.type == PORT_UNKNOWN) | 2500 | if (serial8250_ports[i].port.type == PORT_UNKNOWN) |
2512 | return &serial8250_ports[i]; | 2501 | return &serial8250_ports[i]; |
2513 | 2502 | ||
@@ -2535,7 +2524,7 @@ int serial8250_register_port(struct uart_port *port) | |||
2535 | if (port->uartclk == 0) | 2524 | if (port->uartclk == 0) |
2536 | return -EINVAL; | 2525 | return -EINVAL; |
2537 | 2526 | ||
2538 | down(&serial_sem); | 2527 | mutex_lock(&serial_mutex); |
2539 | 2528 | ||
2540 | uart = serial8250_find_match_or_unused(port); | 2529 | uart = serial8250_find_match_or_unused(port); |
2541 | if (uart) { | 2530 | if (uart) { |
@@ -2557,7 +2546,7 @@ int serial8250_register_port(struct uart_port *port) | |||
2557 | if (ret == 0) | 2546 | if (ret == 0) |
2558 | ret = uart->port.line; | 2547 | ret = uart->port.line; |
2559 | } | 2548 | } |
2560 | up(&serial_sem); | 2549 | mutex_unlock(&serial_mutex); |
2561 | 2550 | ||
2562 | return ret; | 2551 | return ret; |
2563 | } | 2552 | } |
@@ -2574,7 +2563,7 @@ void serial8250_unregister_port(int line) | |||
2574 | { | 2563 | { |
2575 | struct uart_8250_port *uart = &serial8250_ports[line]; | 2564 | struct uart_8250_port *uart = &serial8250_ports[line]; |
2576 | 2565 | ||
2577 | down(&serial_sem); | 2566 | mutex_lock(&serial_mutex); |
2578 | uart_remove_one_port(&serial8250_reg, &uart->port); | 2567 | uart_remove_one_port(&serial8250_reg, &uart->port); |
2579 | if (serial8250_isa_devs) { | 2568 | if (serial8250_isa_devs) { |
2580 | uart->port.flags &= ~UPF_BOOT_AUTOCONF; | 2569 | uart->port.flags &= ~UPF_BOOT_AUTOCONF; |
@@ -2584,7 +2573,7 @@ void serial8250_unregister_port(int line) | |||
2584 | } else { | 2573 | } else { |
2585 | uart->port.dev = NULL; | 2574 | uart->port.dev = NULL; |
2586 | } | 2575 | } |
2587 | up(&serial_sem); | 2576 | mutex_unlock(&serial_mutex); |
2588 | } | 2577 | } |
2589 | EXPORT_SYMBOL(serial8250_unregister_port); | 2578 | EXPORT_SYMBOL(serial8250_unregister_port); |
2590 | 2579 | ||
@@ -2592,8 +2581,11 @@ static int __init serial8250_init(void) | |||
2592 | { | 2581 | { |
2593 | int ret, i; | 2582 | int ret, i; |
2594 | 2583 | ||
2584 | if (nr_uarts > UART_NR) | ||
2585 | nr_uarts = UART_NR; | ||
2586 | |||
2595 | printk(KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ " | 2587 | printk(KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ " |
2596 | "%d ports, IRQ sharing %sabled\n", (int) UART_NR, | 2588 | "%d ports, IRQ sharing %sabled\n", nr_uarts, |
2597 | share_irqs ? "en" : "dis"); | 2589 | share_irqs ? "en" : "dis"); |
2598 | 2590 | ||
2599 | for (i = 0; i < NR_IRQS; i++) | 2591 | for (i = 0; i < NR_IRQS; i++) |
@@ -2603,21 +2595,27 @@ static int __init serial8250_init(void) | |||
2603 | if (ret) | 2595 | if (ret) |
2604 | goto out; | 2596 | goto out; |
2605 | 2597 | ||
2606 | serial8250_isa_devs = platform_device_register_simple("serial8250", | 2598 | serial8250_isa_devs = platform_device_alloc("serial8250", |
2607 | PLAT8250_DEV_LEGACY, NULL, 0); | 2599 | PLAT8250_DEV_LEGACY); |
2608 | if (IS_ERR(serial8250_isa_devs)) { | 2600 | if (!serial8250_isa_devs) { |
2609 | ret = PTR_ERR(serial8250_isa_devs); | 2601 | ret = -ENOMEM; |
2610 | goto unreg; | 2602 | goto unreg_uart_drv; |
2611 | } | 2603 | } |
2612 | 2604 | ||
2605 | ret = platform_device_add(serial8250_isa_devs); | ||
2606 | if (ret) | ||
2607 | goto put_dev; | ||
2608 | |||
2613 | serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev); | 2609 | serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev); |
2614 | 2610 | ||
2615 | ret = platform_driver_register(&serial8250_isa_driver); | 2611 | ret = platform_driver_register(&serial8250_isa_driver); |
2616 | if (ret == 0) | 2612 | if (ret == 0) |
2617 | goto out; | 2613 | goto out; |
2618 | 2614 | ||
2619 | platform_device_unregister(serial8250_isa_devs); | 2615 | platform_device_del(serial8250_isa_devs); |
2620 | unreg: | 2616 | put_dev: |
2617 | platform_device_put(serial8250_isa_devs); | ||
2618 | unreg_uart_drv: | ||
2621 | uart_unregister_driver(&serial8250_reg); | 2619 | uart_unregister_driver(&serial8250_reg); |
2622 | out: | 2620 | out: |
2623 | return ret; | 2621 | return ret; |
@@ -2653,6 +2651,9 @@ module_param(share_irqs, uint, 0644); | |||
2653 | MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices" | 2651 | MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices" |
2654 | " (unsafe)"); | 2652 | " (unsafe)"); |
2655 | 2653 | ||
2654 | module_param(nr_uarts, uint, 0644); | ||
2655 | MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")"); | ||
2656 | |||
2656 | #ifdef CONFIG_SERIAL_8250_RSA | 2657 | #ifdef CONFIG_SERIAL_8250_RSA |
2657 | module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444); | 2658 | module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444); |
2658 | MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); | 2659 | MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); |
diff --git a/drivers/serial/8250.h b/drivers/serial/8250.h index a607b98016db..490606b87095 100644 --- a/drivers/serial/8250.h +++ b/drivers/serial/8250.h | |||
@@ -51,12 +51,6 @@ struct serial8250_config { | |||
51 | #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ | 51 | #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ |
52 | #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */ | 52 | #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */ |
53 | 53 | ||
54 | #if defined(__i386__) && (defined(CONFIG_M386) || defined(CONFIG_M486)) | ||
55 | #define _INLINE_ inline | ||
56 | #else | ||
57 | #define _INLINE_ | ||
58 | #endif | ||
59 | |||
60 | #define PROBE_RSA (1 << 0) | 54 | #define PROBE_RSA (1 << 0) |
61 | #define PROBE_ANY (~0) | 55 | #define PROBE_ANY (~0) |
62 | 56 | ||
diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c index a802bdce6e5d..809f89ab965c 100644 --- a/drivers/serial/8250_acpi.c +++ b/drivers/serial/8250_acpi.c | |||
@@ -27,7 +27,7 @@ struct serial_private { | |||
27 | static acpi_status acpi_serial_mmio(struct uart_port *port, | 27 | static acpi_status acpi_serial_mmio(struct uart_port *port, |
28 | struct acpi_resource_address64 *addr) | 28 | struct acpi_resource_address64 *addr) |
29 | { | 29 | { |
30 | port->mapbase = addr->min_address_range; | 30 | port->mapbase = addr->minimum; |
31 | port->iotype = UPIO_MEM; | 31 | port->iotype = UPIO_MEM; |
32 | port->flags |= UPF_IOREMAP; | 32 | port->flags |= UPF_IOREMAP; |
33 | return AE_OK; | 33 | return AE_OK; |
@@ -36,8 +36,8 @@ static acpi_status acpi_serial_mmio(struct uart_port *port, | |||
36 | static acpi_status acpi_serial_port(struct uart_port *port, | 36 | static acpi_status acpi_serial_port(struct uart_port *port, |
37 | struct acpi_resource_io *io) | 37 | struct acpi_resource_io *io) |
38 | { | 38 | { |
39 | if (io->range_length) { | 39 | if (io->address_length) { |
40 | port->iobase = io->min_base_address; | 40 | port->iobase = io->minimum; |
41 | port->iotype = UPIO_PORT; | 41 | port->iotype = UPIO_PORT; |
42 | } else | 42 | } else |
43 | printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__); | 43 | printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__); |
@@ -45,13 +45,13 @@ static acpi_status acpi_serial_port(struct uart_port *port, | |||
45 | } | 45 | } |
46 | 46 | ||
47 | static acpi_status acpi_serial_ext_irq(struct uart_port *port, | 47 | static acpi_status acpi_serial_ext_irq(struct uart_port *port, |
48 | struct acpi_resource_ext_irq *ext_irq) | 48 | struct acpi_resource_extended_irq *ext_irq) |
49 | { | 49 | { |
50 | int rc; | 50 | int rc; |
51 | 51 | ||
52 | if (ext_irq->number_of_interrupts > 0) { | 52 | if (ext_irq->interrupt_count > 0) { |
53 | rc = acpi_register_gsi(ext_irq->interrupts[0], | 53 | rc = acpi_register_gsi(ext_irq->interrupts[0], |
54 | ext_irq->edge_level, ext_irq->active_high_low); | 54 | ext_irq->triggering, ext_irq->polarity); |
55 | if (rc < 0) | 55 | if (rc < 0) |
56 | return AE_ERROR; | 56 | return AE_ERROR; |
57 | port->irq = rc; | 57 | port->irq = rc; |
@@ -64,9 +64,9 @@ static acpi_status acpi_serial_irq(struct uart_port *port, | |||
64 | { | 64 | { |
65 | int rc; | 65 | int rc; |
66 | 66 | ||
67 | if (irq->number_of_interrupts > 0) { | 67 | if (irq->interrupt_count > 0) { |
68 | rc = acpi_register_gsi(irq->interrupts[0], | 68 | rc = acpi_register_gsi(irq->interrupts[0], |
69 | irq->edge_level, irq->active_high_low); | 69 | irq->triggering, irq->polarity); |
70 | if (rc < 0) | 70 | if (rc < 0) |
71 | return AE_ERROR; | 71 | return AE_ERROR; |
72 | port->irq = rc; | 72 | port->irq = rc; |
@@ -83,11 +83,11 @@ static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data) | |||
83 | status = acpi_resource_to_address64(res, &addr); | 83 | status = acpi_resource_to_address64(res, &addr); |
84 | if (ACPI_SUCCESS(status)) | 84 | if (ACPI_SUCCESS(status)) |
85 | return acpi_serial_mmio(port, &addr); | 85 | return acpi_serial_mmio(port, &addr); |
86 | else if (res->id == ACPI_RSTYPE_IO) | 86 | else if (res->type == ACPI_RESOURCE_TYPE_IO) |
87 | return acpi_serial_port(port, &res->data.io); | 87 | return acpi_serial_port(port, &res->data.io); |
88 | else if (res->id == ACPI_RSTYPE_EXT_IRQ) | 88 | else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) |
89 | return acpi_serial_ext_irq(port, &res->data.extended_irq); | 89 | return acpi_serial_ext_irq(port, &res->data.extended_irq); |
90 | else if (res->id == ACPI_RSTYPE_IRQ) | 90 | else if (res->type == ACPI_RESOURCE_TYPE_IRQ) |
91 | return acpi_serial_irq(port, &res->data.irq); | 91 | return acpi_serial_irq(port, &res->data.irq); |
92 | return AE_OK; | 92 | return AE_OK; |
93 | } | 93 | } |
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 8d92adfbb8bd..2a912153321e 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -516,7 +516,7 @@ pci_timedia_setup(struct serial_private *priv, struct pciserial_board *board, | |||
516 | break; | 516 | break; |
517 | case 3: | 517 | case 3: |
518 | offset = board->uart_offset; | 518 | offset = board->uart_offset; |
519 | bar = 1; | 519 | /* FALLTHROUGH */ |
520 | case 4: /* BAR 2 */ | 520 | case 4: /* BAR 2 */ |
521 | case 5: /* BAR 3 */ | 521 | case 5: /* BAR 3 */ |
522 | case 6: /* BAR 4 */ | 522 | case 6: /* BAR 4 */ |
@@ -837,8 +837,8 @@ static struct pci_serial_quirk *find_quirk(struct pci_dev *dev) | |||
837 | return quirk; | 837 | return quirk; |
838 | } | 838 | } |
839 | 839 | ||
840 | static _INLINE_ int | 840 | static inline int get_pci_irq(struct pci_dev *dev, |
841 | get_pci_irq(struct pci_dev *dev, struct pciserial_board *board) | 841 | struct pciserial_board *board) |
842 | { | 842 | { |
843 | if (board->flags & FL_NOIRQ) | 843 | if (board->flags & FL_NOIRQ) |
844 | return 0; | 844 | return 0; |
@@ -853,14 +853,15 @@ get_pci_irq(struct pci_dev *dev, struct pciserial_board *board) | |||
853 | * driver_data member. | 853 | * driver_data member. |
854 | * | 854 | * |
855 | * The makeup of these names are: | 855 | * The makeup of these names are: |
856 | * pbn_bn{_bt}_n_baud | 856 | * pbn_bn{_bt}_n_baud{_offsetinhex} |
857 | * | 857 | * |
858 | * bn = PCI BAR number | 858 | * bn = PCI BAR number |
859 | * bt = Index using PCI BARs | 859 | * bt = Index using PCI BARs |
860 | * n = number of serial ports | 860 | * n = number of serial ports |
861 | * baud = baud rate | 861 | * baud = baud rate |
862 | * offsetinhex = offset for each sequential port (in hex) | ||
862 | * | 863 | * |
863 | * This table is sorted by (in order): baud, bt, bn, n. | 864 | * This table is sorted by (in order): bn, bt, baud, offsetindex, n. |
864 | * | 865 | * |
865 | * Please note: in theory if n = 1, _bt infix should make no difference. | 866 | * Please note: in theory if n = 1, _bt infix should make no difference. |
866 | * ie, pbn_b0_1_115200 is the same as pbn_b0_bt_1_115200 | 867 | * ie, pbn_b0_1_115200 is the same as pbn_b0_bt_1_115200 |
@@ -881,6 +882,13 @@ enum pci_board_num_t { | |||
881 | 882 | ||
882 | pbn_b0_4_1152000, | 883 | pbn_b0_4_1152000, |
883 | 884 | ||
885 | pbn_b0_2_1843200, | ||
886 | pbn_b0_4_1843200, | ||
887 | |||
888 | pbn_b0_2_1843200_200, | ||
889 | pbn_b0_4_1843200_200, | ||
890 | pbn_b0_8_1843200_200, | ||
891 | |||
884 | pbn_b0_bt_1_115200, | 892 | pbn_b0_bt_1_115200, |
885 | pbn_b0_bt_2_115200, | 893 | pbn_b0_bt_2_115200, |
886 | pbn_b0_bt_8_115200, | 894 | pbn_b0_bt_8_115200, |
@@ -904,6 +912,8 @@ enum pci_board_num_t { | |||
904 | pbn_b1_4_921600, | 912 | pbn_b1_4_921600, |
905 | pbn_b1_8_921600, | 913 | pbn_b1_8_921600, |
906 | 914 | ||
915 | pbn_b1_2_1250000, | ||
916 | |||
907 | pbn_b1_bt_2_921600, | 917 | pbn_b1_bt_2_921600, |
908 | 918 | ||
909 | pbn_b1_1_1382400, | 919 | pbn_b1_1_1382400, |
@@ -930,6 +940,7 @@ enum pci_board_num_t { | |||
930 | pbn_b2_bt_2_921600, | 940 | pbn_b2_bt_2_921600, |
931 | pbn_b2_bt_4_921600, | 941 | pbn_b2_bt_4_921600, |
932 | 942 | ||
943 | pbn_b3_2_115200, | ||
933 | pbn_b3_4_115200, | 944 | pbn_b3_4_115200, |
934 | pbn_b3_8_115200, | 945 | pbn_b3_8_115200, |
935 | 946 | ||
@@ -1029,6 +1040,38 @@ static struct pciserial_board pci_boards[] __devinitdata = { | |||
1029 | .uart_offset = 8, | 1040 | .uart_offset = 8, |
1030 | }, | 1041 | }, |
1031 | 1042 | ||
1043 | [pbn_b0_2_1843200] = { | ||
1044 | .flags = FL_BASE0, | ||
1045 | .num_ports = 2, | ||
1046 | .base_baud = 1843200, | ||
1047 | .uart_offset = 8, | ||
1048 | }, | ||
1049 | [pbn_b0_4_1843200] = { | ||
1050 | .flags = FL_BASE0, | ||
1051 | .num_ports = 4, | ||
1052 | .base_baud = 1843200, | ||
1053 | .uart_offset = 8, | ||
1054 | }, | ||
1055 | |||
1056 | [pbn_b0_2_1843200_200] = { | ||
1057 | .flags = FL_BASE0, | ||
1058 | .num_ports = 2, | ||
1059 | .base_baud = 1843200, | ||
1060 | .uart_offset = 0x200, | ||
1061 | }, | ||
1062 | [pbn_b0_4_1843200_200] = { | ||
1063 | .flags = FL_BASE0, | ||
1064 | .num_ports = 4, | ||
1065 | .base_baud = 1843200, | ||
1066 | .uart_offset = 0x200, | ||
1067 | }, | ||
1068 | [pbn_b0_8_1843200_200] = { | ||
1069 | .flags = FL_BASE0, | ||
1070 | .num_ports = 8, | ||
1071 | .base_baud = 1843200, | ||
1072 | .uart_offset = 0x200, | ||
1073 | }, | ||
1074 | |||
1032 | [pbn_b0_bt_1_115200] = { | 1075 | [pbn_b0_bt_1_115200] = { |
1033 | .flags = FL_BASE0|FL_BASE_BARS, | 1076 | .flags = FL_BASE0|FL_BASE_BARS, |
1034 | .num_ports = 1, | 1077 | .num_ports = 1, |
@@ -1141,6 +1184,12 @@ static struct pciserial_board pci_boards[] __devinitdata = { | |||
1141 | .base_baud = 921600, | 1184 | .base_baud = 921600, |
1142 | .uart_offset = 8, | 1185 | .uart_offset = 8, |
1143 | }, | 1186 | }, |
1187 | [pbn_b1_2_1250000] = { | ||
1188 | .flags = FL_BASE1, | ||
1189 | .num_ports = 2, | ||
1190 | .base_baud = 1250000, | ||
1191 | .uart_offset = 8, | ||
1192 | }, | ||
1144 | 1193 | ||
1145 | [pbn_b1_bt_2_921600] = { | 1194 | [pbn_b1_bt_2_921600] = { |
1146 | .flags = FL_BASE1|FL_BASE_BARS, | 1195 | .flags = FL_BASE1|FL_BASE_BARS, |
@@ -1263,6 +1312,12 @@ static struct pciserial_board pci_boards[] __devinitdata = { | |||
1263 | .uart_offset = 8, | 1312 | .uart_offset = 8, |
1264 | }, | 1313 | }, |
1265 | 1314 | ||
1315 | [pbn_b3_2_115200] = { | ||
1316 | .flags = FL_BASE3, | ||
1317 | .num_ports = 2, | ||
1318 | .base_baud = 115200, | ||
1319 | .uart_offset = 8, | ||
1320 | }, | ||
1266 | [pbn_b3_4_115200] = { | 1321 | [pbn_b3_4_115200] = { |
1267 | .flags = FL_BASE3, | 1322 | .flags = FL_BASE3, |
1268 | .num_ports = 4, | 1323 | .num_ports = 4, |
@@ -1801,6 +1856,66 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
1801 | PCI_SUBVENDOR_ID_CONNECT_TECH, | 1856 | PCI_SUBVENDOR_ID_CONNECT_TECH, |
1802 | PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1, 0, 0, | 1857 | PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1, 0, 0, |
1803 | pbn_b1_4_921600 }, | 1858 | pbn_b1_4_921600 }, |
1859 | { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351, | ||
1860 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1861 | PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_20MHZ, 0, 0, | ||
1862 | pbn_b1_2_1250000 }, | ||
1863 | { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954, | ||
1864 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1865 | PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_2, 0, 0, | ||
1866 | pbn_b0_2_1843200 }, | ||
1867 | { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954, | ||
1868 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1869 | PCI_SUBDEVICE_ID_CONNECT_TECH_TITAN_4, 0, 0, | ||
1870 | pbn_b0_4_1843200 }, | ||
1871 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C152, | ||
1872 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1873 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_232, 0, 0, | ||
1874 | pbn_b0_2_1843200_200 }, | ||
1875 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C154, | ||
1876 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1877 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_232, 0, 0, | ||
1878 | pbn_b0_4_1843200_200 }, | ||
1879 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C158, | ||
1880 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1881 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_232, 0, 0, | ||
1882 | pbn_b0_8_1843200_200 }, | ||
1883 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C152, | ||
1884 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1885 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1, 0, 0, | ||
1886 | pbn_b0_2_1843200_200 }, | ||
1887 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C154, | ||
1888 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1889 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2, 0, 0, | ||
1890 | pbn_b0_4_1843200_200 }, | ||
1891 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C158, | ||
1892 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1893 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4, 0, 0, | ||
1894 | pbn_b0_8_1843200_200 }, | ||
1895 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C152, | ||
1896 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1897 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2, 0, 0, | ||
1898 | pbn_b0_2_1843200_200 }, | ||
1899 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C154, | ||
1900 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1901 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4, 0, 0, | ||
1902 | pbn_b0_4_1843200_200 }, | ||
1903 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C158, | ||
1904 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1905 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8, 0, 0, | ||
1906 | pbn_b0_8_1843200_200 }, | ||
1907 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C152, | ||
1908 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1909 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_485, 0, 0, | ||
1910 | pbn_b0_2_1843200_200 }, | ||
1911 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C154, | ||
1912 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1913 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_485, 0, 0, | ||
1914 | pbn_b0_4_1843200_200 }, | ||
1915 | { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17C158, | ||
1916 | PCI_SUBVENDOR_ID_CONNECT_TECH, | ||
1917 | PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_485, 0, 0, | ||
1918 | pbn_b0_8_1843200_200 }, | ||
1804 | 1919 | ||
1805 | { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_U530, | 1920 | { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_U530, |
1806 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 1921 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
@@ -2164,6 +2279,9 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
2164 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 2279 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
2165 | pbn_nec_nile4 }, | 2280 | pbn_nec_nile4 }, |
2166 | 2281 | ||
2282 | { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM2, | ||
2283 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
2284 | pbn_b3_2_115200 }, | ||
2167 | { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM4, | 2285 | { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM4, |
2168 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | 2286 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
2169 | pbn_b3_4_115200 }, | 2287 | pbn_b3_4_115200 }, |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index ad47c1b84c3f..9fd1925de361 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -10,7 +10,7 @@ menu "Serial drivers" | |||
10 | # The new 8250/16550 serial drivers | 10 | # The new 8250/16550 serial drivers |
11 | config SERIAL_8250 | 11 | config SERIAL_8250 |
12 | tristate "8250/16550 and compatible serial support" | 12 | tristate "8250/16550 and compatible serial support" |
13 | depends on (BROKEN || !(SPARC64 || SPARC32)) | 13 | depends on (BROKEN || !SPARC) |
14 | select SERIAL_CORE | 14 | select SERIAL_CORE |
15 | ---help--- | 15 | ---help--- |
16 | This selects whether you want to include the driver for the standard | 16 | This selects whether you want to include the driver for the standard |
@@ -95,6 +95,16 @@ config SERIAL_8250_NR_UARTS | |||
95 | PCI enumeration and any ports that may be added at run-time | 95 | PCI enumeration and any ports that may be added at run-time |
96 | via hot-plug, or any ISA multi-port serial cards. | 96 | via hot-plug, or any ISA multi-port serial cards. |
97 | 97 | ||
98 | config SERIAL_8250_RUNTIME_UARTS | ||
99 | int "Number of 8250/16550 serial ports to register at runtime" | ||
100 | depends on SERIAL_8250 | ||
101 | default "4" | ||
102 | help | ||
103 | Set this to the maximum number of serial ports you want | ||
104 | the kernel to register at boot time. This can be overriden | ||
105 | with the module parameter "nr_uarts", or boot-time parameter | ||
106 | 8250.nr_uarts | ||
107 | |||
98 | config SERIAL_8250_EXTENDED | 108 | config SERIAL_8250_EXTENDED |
99 | bool "Extended 8250/16550 serial driver options" | 109 | bool "Extended 8250/16550 serial driver options" |
100 | depends on SERIAL_8250 | 110 | depends on SERIAL_8250 |
@@ -180,7 +190,6 @@ config SERIAL_8250_BOCA | |||
180 | To compile this driver as a module, choose M here: the module | 190 | To compile this driver as a module, choose M here: the module |
181 | will be called 8250_boca. | 191 | will be called 8250_boca. |
182 | 192 | ||
183 | |||
184 | config SERIAL_8250_HUB6 | 193 | config SERIAL_8250_HUB6 |
185 | tristate "Support Hub6 cards" | 194 | tristate "Support Hub6 cards" |
186 | depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS | 195 | depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS |
@@ -270,6 +279,40 @@ config SERIAL_AMBA_PL011_CONSOLE | |||
270 | your boot loader (lilo or loadlin) about how to pass options to the | 279 | your boot loader (lilo or loadlin) about how to pass options to the |
271 | kernel at boot time.) | 280 | kernel at boot time.) |
272 | 281 | ||
282 | config SERIAL_AT91 | ||
283 | bool "AT91RM9200 serial port support" | ||
284 | depends on ARM && ARCH_AT91RM9200 | ||
285 | select SERIAL_CORE | ||
286 | help | ||
287 | This enables the driver for the on-chip UARTs of the AT91RM9200 | ||
288 | processor. | ||
289 | |||
290 | config SERIAL_AT91_CONSOLE | ||
291 | bool "Support for console on AT91RM9200 serial port" | ||
292 | depends on SERIAL_AT91=y | ||
293 | select SERIAL_CORE_CONSOLE | ||
294 | help | ||
295 | Say Y here if you wish to use a UART on the AT91RM9200 as the system | ||
296 | console (the system console is the device which receives all kernel | ||
297 | messages and warnings and which allows logins in single user mode). | ||
298 | |||
299 | config SERIAL_AT91_TTYAT | ||
300 | bool "Install as device ttyAT0-4 instead of ttyS0-4" | ||
301 | depends on SERIAL_AT91=y | ||
302 | help | ||
303 | Say Y here if you wish to have the five internal AT91RM9200 UARTs | ||
304 | appear as /dev/ttyAT0-4 (major 204, minor 154-158) instead of the | ||
305 | normal /dev/ttyS0-4 (major 4, minor 64-68). This is necessary if | ||
306 | you also want other UARTs, such as external 8250/16C550 compatible | ||
307 | UARTs. | ||
308 | The ttySn nodes are legally reserved for the 8250 serial driver | ||
309 | but are often misused by other serial drivers. | ||
310 | |||
311 | To use this, you should create suitable ttyATn device nodes in | ||
312 | /dev/, and pass "console=ttyATn" to the kernel. | ||
313 | |||
314 | Say Y if you have an external 8250/16C550 UART. If unsure, say N. | ||
315 | |||
273 | config SERIAL_CLPS711X | 316 | config SERIAL_CLPS711X |
274 | tristate "CLPS711X serial port support" | 317 | tristate "CLPS711X serial port support" |
275 | depends on ARM && ARCH_CLPS711X | 318 | depends on ARM && ARCH_CLPS711X |
@@ -359,29 +402,6 @@ config SERIAL_21285_CONSOLE | |||
359 | your boot loader (lilo or loadlin) about how to pass options to the | 402 | your boot loader (lilo or loadlin) about how to pass options to the |
360 | kernel at boot time.) | 403 | kernel at boot time.) |
361 | 404 | ||
362 | config SERIAL_UART00 | ||
363 | bool "Excalibur serial port (uart00) support" | ||
364 | depends on ARM && ARCH_CAMELOT | ||
365 | select SERIAL_CORE | ||
366 | help | ||
367 | Say Y here if you want to use the hard logic uart on Excalibur. This | ||
368 | driver also supports soft logic implementations of this uart core. | ||
369 | |||
370 | config SERIAL_UART00_CONSOLE | ||
371 | bool "Support for console on Excalibur serial port" | ||
372 | depends on SERIAL_UART00 | ||
373 | select SERIAL_CORE_CONSOLE | ||
374 | help | ||
375 | Say Y here if you want to support a serial console on an Excalibur | ||
376 | hard logic uart or uart00 IP core. | ||
377 | |||
378 | Even if you say Y here, the currently visible virtual console | ||
379 | (/dev/tty0) will still be used as the system console by default, but | ||
380 | you can alter that using a kernel command line option such as | ||
381 | "console=ttyS1". (Try "man bootparam" or see the documentation of | ||
382 | your boot loader (lilo or loadlin) about how to pass options to the | ||
383 | kernel at boot time.) | ||
384 | |||
385 | config SERIAL_MPSC | 405 | config SERIAL_MPSC |
386 | bool "Marvell MPSC serial port support" | 406 | bool "Marvell MPSC serial port support" |
387 | depends on PPC32 && MV64X60 | 407 | depends on PPC32 && MV64X60 |
@@ -469,14 +489,14 @@ config SERIAL_IMX_CONSOLE | |||
469 | 489 | ||
470 | config SERIAL_SUNCORE | 490 | config SERIAL_SUNCORE |
471 | bool | 491 | bool |
472 | depends on SPARC32 || SPARC64 | 492 | depends on SPARC |
473 | select SERIAL_CORE | 493 | select SERIAL_CORE |
474 | select SERIAL_CORE_CONSOLE | 494 | select SERIAL_CORE_CONSOLE |
475 | default y | 495 | default y |
476 | 496 | ||
477 | config SERIAL_SUNZILOG | 497 | config SERIAL_SUNZILOG |
478 | tristate "Sun Zilog8530 serial support" | 498 | tristate "Sun Zilog8530 serial support" |
479 | depends on SPARC32 || SPARC64 | 499 | depends on SPARC |
480 | help | 500 | help |
481 | This driver supports the Zilog8530 serial ports found on many Sparc | 501 | This driver supports the Zilog8530 serial ports found on many Sparc |
482 | systems. Say Y or M if you want to be able to these serial ports. | 502 | systems. Say Y or M if you want to be able to these serial ports. |
@@ -491,7 +511,7 @@ config SERIAL_SUNZILOG_CONSOLE | |||
491 | 511 | ||
492 | config SERIAL_SUNSU | 512 | config SERIAL_SUNSU |
493 | tristate "Sun SU serial support" | 513 | tristate "Sun SU serial support" |
494 | depends on (SPARC32 || SPARC64) && PCI | 514 | depends on SPARC && PCI |
495 | help | 515 | help |
496 | This driver supports the 8250 serial ports that run the keyboard and | 516 | This driver supports the 8250 serial ports that run the keyboard and |
497 | mouse on (PCI) UltraSPARC systems. Say Y or M if you want to be able | 517 | mouse on (PCI) UltraSPARC systems. Say Y or M if you want to be able |
@@ -547,7 +567,7 @@ config PDC_CONSOLE | |||
547 | 567 | ||
548 | config SERIAL_SUNSAB | 568 | config SERIAL_SUNSAB |
549 | tristate "Sun Siemens SAB82532 serial support" | 569 | tristate "Sun Siemens SAB82532 serial support" |
550 | depends on (SPARC32 || SPARC64) && PCI | 570 | depends on SPARC && PCI |
551 | help | 571 | help |
552 | This driver supports the Siemens SAB82532 DUSCC serial ports on newer | 572 | This driver supports the Siemens SAB82532 DUSCC serial ports on newer |
553 | (PCI) UltraSPARC systems. Say Y or M if you want to be able to these | 573 | (PCI) UltraSPARC systems. Say Y or M if you want to be able to these |
@@ -827,7 +847,7 @@ config SERIAL_M32R_SIO_CONSOLE | |||
827 | 847 | ||
828 | config SERIAL_M32R_PLDSIO | 848 | config SERIAL_M32R_PLDSIO |
829 | bool "M32R SIO I/F on a PLD" | 849 | bool "M32R SIO I/F on a PLD" |
830 | depends on SERIAL_M32R_SIO=y && (PLAT_OPSPUT || PALT_USRV || PLAT_M32700UT) | 850 | depends on SERIAL_M32R_SIO=y && (PLAT_OPSPUT || PLAT_USRV || PLAT_M32700UT) |
831 | default n | 851 | default n |
832 | help | 852 | help |
833 | Say Y here if you want to use the M32R serial controller | 853 | Say Y here if you want to use the M32R serial controller |
@@ -873,7 +893,7 @@ config SERIAL_VR41XX_CONSOLE | |||
873 | 893 | ||
874 | config SERIAL_JSM | 894 | config SERIAL_JSM |
875 | tristate "Digi International NEO PCI Support" | 895 | tristate "Digi International NEO PCI Support" |
876 | depends on PCI | 896 | depends on PCI && BROKEN |
877 | select SERIAL_CORE | 897 | select SERIAL_CORE |
878 | help | 898 | help |
879 | This is a driver for Digi International's Neo series | 899 | This is a driver for Digi International's Neo series |
@@ -896,4 +916,12 @@ config SERIAL_SGI_IOC4 | |||
896 | and wish to use the serial ports on this card, say Y. | 916 | and wish to use the serial ports on this card, say Y. |
897 | Otherwise, say N. | 917 | Otherwise, say N. |
898 | 918 | ||
919 | config SERIAL_SGI_IOC3 | ||
920 | tristate "SGI Altix IOC3 serial support" | ||
921 | depends on (IA64_GENERIC || IA64_SGI_SN2) && SGI_IOC3 | ||
922 | select SERIAL_CORE | ||
923 | help | ||
924 | If you have an SGI Altix with an IOC3 serial card, | ||
925 | say Y or M. Otherwise, say N. | ||
926 | |||
899 | endmenu | 927 | endmenu |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index d7c7c7180e33..eaf8e01db198 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -29,7 +29,6 @@ obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o | |||
29 | obj-$(CONFIG_SERIAL_PXA) += pxa.o | 29 | obj-$(CONFIG_SERIAL_PXA) += pxa.o |
30 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o | 30 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o |
31 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o | 31 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o |
32 | obj-$(CONFIG_SERIAL_UART00) += uart00.o | ||
33 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o | 32 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o |
34 | obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o | 33 | obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o |
35 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o | 34 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o |
@@ -57,3 +56,5 @@ obj-$(CONFIG_SERIAL_JSM) += jsm/ | |||
57 | obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o | 56 | obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o |
58 | obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o | 57 | obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o |
59 | obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o | 58 | obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o |
59 | obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o | ||
60 | obj-$(CONFIG_SERIAL_AT91) += at91_serial.o | ||
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c index ddd0307fece2..3490022e9fdc 100644 --- a/drivers/serial/amba-pl010.c +++ b/drivers/serial/amba-pl010.c | |||
@@ -47,12 +47,12 @@ | |||
47 | #include <linux/tty_flip.h> | 47 | #include <linux/tty_flip.h> |
48 | #include <linux/serial_core.h> | 48 | #include <linux/serial_core.h> |
49 | #include <linux/serial.h> | 49 | #include <linux/serial.h> |
50 | #include <linux/amba/bus.h> | ||
51 | #include <linux/amba/serial.h> | ||
50 | 52 | ||
51 | #include <asm/io.h> | 53 | #include <asm/io.h> |
52 | #include <asm/irq.h> | 54 | #include <asm/irq.h> |
53 | #include <asm/hardware.h> | 55 | #include <asm/hardware.h> |
54 | #include <asm/hardware/amba.h> | ||
55 | #include <asm/hardware/amba_serial.h> | ||
56 | 56 | ||
57 | #define UART_NR 2 | 57 | #define UART_NR 2 |
58 | 58 | ||
@@ -154,15 +154,6 @@ pl010_rx_chars(struct uart_port *port) | |||
154 | 154 | ||
155 | status = UART_GET_FR(port); | 155 | status = UART_GET_FR(port); |
156 | while (UART_RX_DATA(status) && max_count--) { | 156 | while (UART_RX_DATA(status) && max_count--) { |
157 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | ||
158 | if (tty->low_latency) | ||
159 | tty_flip_buffer_push(tty); | ||
160 | /* | ||
161 | * If this failed then we will throw away the | ||
162 | * bytes but must do so to clear interrupts. | ||
163 | */ | ||
164 | } | ||
165 | |||
166 | ch = UART_GET_CHAR(port); | 157 | ch = UART_GET_CHAR(port); |
167 | flag = TTY_NORMAL; | 158 | flag = TTY_NORMAL; |
168 | 159 | ||
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 89d7bd3eaee3..034a029e356e 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c | |||
@@ -47,12 +47,12 @@ | |||
47 | #include <linux/tty_flip.h> | 47 | #include <linux/tty_flip.h> |
48 | #include <linux/serial_core.h> | 48 | #include <linux/serial_core.h> |
49 | #include <linux/serial.h> | 49 | #include <linux/serial.h> |
50 | #include <linux/amba/bus.h> | ||
51 | #include <linux/amba/serial.h> | ||
52 | #include <linux/clk.h> | ||
50 | 53 | ||
51 | #include <asm/io.h> | 54 | #include <asm/io.h> |
52 | #include <asm/sizes.h> | 55 | #include <asm/sizes.h> |
53 | #include <asm/hardware/amba.h> | ||
54 | #include <asm/hardware/clock.h> | ||
55 | #include <asm/hardware/amba_serial.h> | ||
56 | 56 | ||
57 | #define UART_NR 14 | 57 | #define UART_NR 14 |
58 | 58 | ||
@@ -120,15 +120,6 @@ pl011_rx_chars(struct uart_amba_port *uap) | |||
120 | 120 | ||
121 | status = readw(uap->port.membase + UART01x_FR); | 121 | status = readw(uap->port.membase + UART01x_FR); |
122 | while ((status & UART01x_FR_RXFE) == 0 && max_count--) { | 122 | while ((status & UART01x_FR_RXFE) == 0 && max_count--) { |
123 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | ||
124 | if (tty->low_latency) | ||
125 | tty_flip_buffer_push(tty); | ||
126 | /* | ||
127 | * If this failed then we will throw away the | ||
128 | * bytes but must do so to clear interrupts | ||
129 | */ | ||
130 | } | ||
131 | |||
132 | ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX; | 123 | ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX; |
133 | flag = TTY_NORMAL; | 124 | flag = TTY_NORMAL; |
134 | uap->port.icount.rx++; | 125 | uap->port.icount.rx++; |
@@ -160,7 +151,7 @@ pl011_rx_chars(struct uart_amba_port *uap) | |||
160 | flag = TTY_FRAME; | 151 | flag = TTY_FRAME; |
161 | } | 152 | } |
162 | 153 | ||
163 | if (uart_handle_sysrq_char(&uap->port, ch, regs)) | 154 | if (uart_handle_sysrq_char(&uap->port, ch & 255, regs)) |
164 | goto ignore_char; | 155 | goto ignore_char; |
165 | 156 | ||
166 | uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag); | 157 | uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag); |
@@ -761,10 +752,6 @@ static int pl011_probe(struct amba_device *dev, void *id) | |||
761 | goto unmap; | 752 | goto unmap; |
762 | } | 753 | } |
763 | 754 | ||
764 | ret = clk_use(uap->clk); | ||
765 | if (ret) | ||
766 | goto putclk; | ||
767 | |||
768 | uap->port.dev = &dev->dev; | 755 | uap->port.dev = &dev->dev; |
769 | uap->port.mapbase = dev->res.start; | 756 | uap->port.mapbase = dev->res.start; |
770 | uap->port.membase = base; | 757 | uap->port.membase = base; |
@@ -782,8 +769,6 @@ static int pl011_probe(struct amba_device *dev, void *id) | |||
782 | if (ret) { | 769 | if (ret) { |
783 | amba_set_drvdata(dev, NULL); | 770 | amba_set_drvdata(dev, NULL); |
784 | amba_ports[i] = NULL; | 771 | amba_ports[i] = NULL; |
785 | clk_unuse(uap->clk); | ||
786 | putclk: | ||
787 | clk_put(uap->clk); | 772 | clk_put(uap->clk); |
788 | unmap: | 773 | unmap: |
789 | iounmap(base); | 774 | iounmap(base); |
@@ -808,7 +793,6 @@ static int pl011_remove(struct amba_device *dev) | |||
808 | amba_ports[i] = NULL; | 793 | amba_ports[i] = NULL; |
809 | 794 | ||
810 | iounmap(uap->port.membase); | 795 | iounmap(uap->port.membase); |
811 | clk_unuse(uap->clk); | ||
812 | clk_put(uap->clk); | 796 | clk_put(uap->clk); |
813 | kfree(uap); | 797 | kfree(uap); |
814 | return 0; | 798 | return 0; |
diff --git a/drivers/serial/at91_serial.c b/drivers/serial/at91_serial.c new file mode 100644 index 000000000000..2113feb75c39 --- /dev/null +++ b/drivers/serial/at91_serial.c | |||
@@ -0,0 +1,892 @@ | |||
1 | /* | ||
2 | * linux/drivers/char/at91_serial.c | ||
3 | * | ||
4 | * Driver for Atmel AT91RM9200 Serial ports | ||
5 | * | ||
6 | * Copyright (C) 2003 Rick Bronson | ||
7 | * | ||
8 | * Based on drivers/char/serial_sa1100.c, by Deep Blue Solutions Ltd. | ||
9 | * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | * | ||
25 | */ | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/tty.h> | ||
29 | #include <linux/ioport.h> | ||
30 | #include <linux/slab.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/serial.h> | ||
33 | #include <linux/console.h> | ||
34 | #include <linux/sysrq.h> | ||
35 | #include <linux/tty_flip.h> | ||
36 | |||
37 | #include <asm/io.h> | ||
38 | |||
39 | #include <asm/arch/at91rm9200_usart.h> | ||
40 | #include <asm/mach/serial_at91rm9200.h> | ||
41 | #include <asm/arch/board.h> | ||
42 | #include <asm/arch/pio.h> | ||
43 | |||
44 | |||
45 | #if defined(CONFIG_SERIAL_AT91_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | ||
46 | #define SUPPORT_SYSRQ | ||
47 | #endif | ||
48 | |||
49 | #include <linux/serial_core.h> | ||
50 | |||
51 | #ifdef CONFIG_SERIAL_AT91_TTYAT | ||
52 | |||
53 | /* Use device name ttyAT, major 204 and minor 154-169. This is necessary if we | ||
54 | * should coexist with the 8250 driver, such as if we have an external 16C550 | ||
55 | * UART. */ | ||
56 | #define SERIAL_AT91_MAJOR 204 | ||
57 | #define MINOR_START 154 | ||
58 | #define AT91_DEVICENAME "ttyAT" | ||
59 | |||
60 | #else | ||
61 | |||
62 | /* Use device name ttyS, major 4, minor 64-68. This is the usual serial port | ||
63 | * name, but it is legally reserved for the 8250 driver. */ | ||
64 | #define SERIAL_AT91_MAJOR TTY_MAJOR | ||
65 | #define MINOR_START 64 | ||
66 | #define AT91_DEVICENAME "ttyS" | ||
67 | |||
68 | #endif | ||
69 | |||
70 | #define AT91_VA_BASE_DBGU ((unsigned long) AT91_VA_BASE_SYS + AT91_DBGU) | ||
71 | #define AT91_ISR_PASS_LIMIT 256 | ||
72 | |||
73 | #define UART_PUT_CR(port,v) writel(v, (port)->membase + AT91_US_CR) | ||
74 | #define UART_GET_MR(port) readl((port)->membase + AT91_US_MR) | ||
75 | #define UART_PUT_MR(port,v) writel(v, (port)->membase + AT91_US_MR) | ||
76 | #define UART_PUT_IER(port,v) writel(v, (port)->membase + AT91_US_IER) | ||
77 | #define UART_PUT_IDR(port,v) writel(v, (port)->membase + AT91_US_IDR) | ||
78 | #define UART_GET_IMR(port) readl((port)->membase + AT91_US_IMR) | ||
79 | #define UART_GET_CSR(port) readl((port)->membase + AT91_US_CSR) | ||
80 | #define UART_GET_CHAR(port) readl((port)->membase + AT91_US_RHR) | ||
81 | #define UART_PUT_CHAR(port,v) writel(v, (port)->membase + AT91_US_THR) | ||
82 | #define UART_GET_BRGR(port) readl((port)->membase + AT91_US_BRGR) | ||
83 | #define UART_PUT_BRGR(port,v) writel(v, (port)->membase + AT91_US_BRGR) | ||
84 | #define UART_PUT_RTOR(port,v) writel(v, (port)->membase + AT91_US_RTOR) | ||
85 | |||
86 | // #define UART_GET_CR(port) readl((port)->membase + AT91_US_CR) // is write-only | ||
87 | |||
88 | /* PDC registers */ | ||
89 | #define UART_PUT_PTCR(port,v) writel(v, (port)->membase + AT91_PDC_PTCR) | ||
90 | #define UART_PUT_RPR(port,v) writel(v, (port)->membase + AT91_PDC_RPR) | ||
91 | #define UART_PUT_RCR(port,v) writel(v, (port)->membase + AT91_PDC_RCR) | ||
92 | #define UART_GET_RCR(port) readl((port)->membase + AT91_PDC_RCR) | ||
93 | #define UART_PUT_RNPR(port,v) writel(v, (port)->membase + AT91_PDC_RNPR) | ||
94 | #define UART_PUT_RNCR(port,v) writel(v, (port)->membase + AT91_PDC_RNCR) | ||
95 | |||
96 | |||
97 | static int (*at91_open)(struct uart_port *); | ||
98 | static void (*at91_close)(struct uart_port *); | ||
99 | |||
100 | #ifdef SUPPORT_SYSRQ | ||
101 | static struct console at91_console; | ||
102 | #endif | ||
103 | |||
104 | /* | ||
105 | * Return TIOCSER_TEMT when transmitter FIFO and Shift register is empty. | ||
106 | */ | ||
107 | static u_int at91_tx_empty(struct uart_port *port) | ||
108 | { | ||
109 | return (UART_GET_CSR(port) & AT91_US_TXEMPTY) ? TIOCSER_TEMT : 0; | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * Set state of the modem control output lines | ||
114 | */ | ||
115 | static void at91_set_mctrl(struct uart_port *port, u_int mctrl) | ||
116 | { | ||
117 | unsigned int control = 0; | ||
118 | |||
119 | /* | ||
120 | * Errata #39: RTS0 is not internally connected to PA21. We need to drive | ||
121 | * the pin manually. | ||
122 | */ | ||
123 | if (port->mapbase == AT91_VA_BASE_US0) { | ||
124 | if (mctrl & TIOCM_RTS) | ||
125 | at91_sys_write(AT91_PIOA + PIO_CODR, AT91_PA21_RTS0); | ||
126 | else | ||
127 | at91_sys_write(AT91_PIOA + PIO_SODR, AT91_PA21_RTS0); | ||
128 | } | ||
129 | |||
130 | if (mctrl & TIOCM_RTS) | ||
131 | control |= AT91_US_RTSEN; | ||
132 | else | ||
133 | control |= AT91_US_RTSDIS; | ||
134 | |||
135 | if (mctrl & TIOCM_DTR) | ||
136 | control |= AT91_US_DTREN; | ||
137 | else | ||
138 | control |= AT91_US_DTRDIS; | ||
139 | |||
140 | UART_PUT_CR(port,control); | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | * Get state of the modem control input lines | ||
145 | */ | ||
146 | static u_int at91_get_mctrl(struct uart_port *port) | ||
147 | { | ||
148 | unsigned int status, ret = 0; | ||
149 | |||
150 | status = UART_GET_CSR(port); | ||
151 | |||
152 | /* | ||
153 | * The control signals are active low. | ||
154 | */ | ||
155 | if (!(status & AT91_US_DCD)) | ||
156 | ret |= TIOCM_CD; | ||
157 | if (!(status & AT91_US_CTS)) | ||
158 | ret |= TIOCM_CTS; | ||
159 | if (!(status & AT91_US_DSR)) | ||
160 | ret |= TIOCM_DSR; | ||
161 | if (!(status & AT91_US_RI)) | ||
162 | ret |= TIOCM_RI; | ||
163 | |||
164 | return ret; | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | * Stop transmitting. | ||
169 | */ | ||
170 | static void at91_stop_tx(struct uart_port *port) | ||
171 | { | ||
172 | UART_PUT_IDR(port, AT91_US_TXRDY); | ||
173 | port->read_status_mask &= ~AT91_US_TXRDY; | ||
174 | } | ||
175 | |||
176 | /* | ||
177 | * Start transmitting. | ||
178 | */ | ||
179 | static void at91_start_tx(struct uart_port *port) | ||
180 | { | ||
181 | port->read_status_mask |= AT91_US_TXRDY; | ||
182 | UART_PUT_IER(port, AT91_US_TXRDY); | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | * Stop receiving - port is in process of being closed. | ||
187 | */ | ||
188 | static void at91_stop_rx(struct uart_port *port) | ||
189 | { | ||
190 | UART_PUT_IDR(port, AT91_US_RXRDY); | ||
191 | } | ||
192 | |||
193 | /* | ||
194 | * Enable modem status interrupts | ||
195 | */ | ||
196 | static void at91_enable_ms(struct uart_port *port) | ||
197 | { | ||
198 | port->read_status_mask |= (AT91_US_RIIC | AT91_US_DSRIC | AT91_US_DCDIC | AT91_US_CTSIC); | ||
199 | UART_PUT_IER(port, AT91_US_RIIC | AT91_US_DSRIC | AT91_US_DCDIC | AT91_US_CTSIC); | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * Control the transmission of a break signal | ||
204 | */ | ||
205 | static void at91_break_ctl(struct uart_port *port, int break_state) | ||
206 | { | ||
207 | if (break_state != 0) | ||
208 | UART_PUT_CR(port, AT91_US_STTBRK); /* start break */ | ||
209 | else | ||
210 | UART_PUT_CR(port, AT91_US_STPBRK); /* stop break */ | ||
211 | } | ||
212 | |||
213 | /* | ||
214 | * Characters received (called from interrupt handler) | ||
215 | */ | ||
216 | static void at91_rx_chars(struct uart_port *port, struct pt_regs *regs) | ||
217 | { | ||
218 | struct tty_struct *tty = port->info->tty; | ||
219 | unsigned int status, ch, flg; | ||
220 | |||
221 | status = UART_GET_CSR(port) & port->read_status_mask; | ||
222 | while (status & (AT91_US_RXRDY)) { | ||
223 | ch = UART_GET_CHAR(port); | ||
224 | |||
225 | port->icount.rx++; | ||
226 | |||
227 | flg = TTY_NORMAL; | ||
228 | |||
229 | /* | ||
230 | * note that the error handling code is | ||
231 | * out of the main execution path | ||
232 | */ | ||
233 | if (unlikely(status & (AT91_US_PARE | AT91_US_FRAME | AT91_US_OVRE))) { | ||
234 | UART_PUT_CR(port, AT91_US_RSTSTA); /* clear error */ | ||
235 | if (status & (AT91_US_PARE)) | ||
236 | port->icount.parity++; | ||
237 | if (status & (AT91_US_FRAME)) | ||
238 | port->icount.frame++; | ||
239 | if (status & (AT91_US_OVRE)) | ||
240 | port->icount.overrun++; | ||
241 | |||
242 | if (status & AT91_US_PARE) | ||
243 | flg = TTY_PARITY; | ||
244 | else if (status & AT91_US_FRAME) | ||
245 | flg = TTY_FRAME; | ||
246 | if (status & AT91_US_OVRE) { | ||
247 | /* | ||
248 | * overrun does *not* affect the character | ||
249 | * we read from the FIFO | ||
250 | */ | ||
251 | tty_insert_flip_char(tty, ch, flg); | ||
252 | ch = 0; | ||
253 | flg = TTY_OVERRUN; | ||
254 | } | ||
255 | #ifdef SUPPORT_SYSRQ | ||
256 | port->sysrq = 0; | ||
257 | #endif | ||
258 | } | ||
259 | |||
260 | if (uart_handle_sysrq_char(port, ch, regs)) | ||
261 | goto ignore_char; | ||
262 | |||
263 | tty_insert_flip_char(tty, ch, flg); | ||
264 | |||
265 | ignore_char: | ||
266 | status = UART_GET_CSR(port) & port->read_status_mask; | ||
267 | } | ||
268 | |||
269 | tty_flip_buffer_push(tty); | ||
270 | } | ||
271 | |||
272 | /* | ||
273 | * Transmit characters (called from interrupt handler) | ||
274 | */ | ||
275 | static void at91_tx_chars(struct uart_port *port) | ||
276 | { | ||
277 | struct circ_buf *xmit = &port->info->xmit; | ||
278 | |||
279 | if (port->x_char) { | ||
280 | UART_PUT_CHAR(port, port->x_char); | ||
281 | port->icount.tx++; | ||
282 | port->x_char = 0; | ||
283 | return; | ||
284 | } | ||
285 | if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { | ||
286 | at91_stop_tx(port); | ||
287 | return; | ||
288 | } | ||
289 | |||
290 | while (UART_GET_CSR(port) & AT91_US_TXRDY) { | ||
291 | UART_PUT_CHAR(port, xmit->buf[xmit->tail]); | ||
292 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
293 | port->icount.tx++; | ||
294 | if (uart_circ_empty(xmit)) | ||
295 | break; | ||
296 | } | ||
297 | |||
298 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | ||
299 | uart_write_wakeup(port); | ||
300 | |||
301 | if (uart_circ_empty(xmit)) | ||
302 | at91_stop_tx(port); | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * Interrupt handler | ||
307 | */ | ||
308 | static irqreturn_t at91_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
309 | { | ||
310 | struct uart_port *port = dev_id; | ||
311 | unsigned int status, pending, pass_counter = 0; | ||
312 | |||
313 | status = UART_GET_CSR(port); | ||
314 | pending = status & port->read_status_mask; | ||
315 | if (pending) { | ||
316 | do { | ||
317 | if (pending & AT91_US_RXRDY) | ||
318 | at91_rx_chars(port, regs); | ||
319 | |||
320 | /* Clear the relevent break bits */ | ||
321 | if (pending & AT91_US_RXBRK) { | ||
322 | UART_PUT_CR(port, AT91_US_RSTSTA); | ||
323 | port->icount.brk++; | ||
324 | uart_handle_break(port); | ||
325 | } | ||
326 | |||
327 | // TODO: All reads to CSR will clear these interrupts! | ||
328 | if (pending & AT91_US_RIIC) port->icount.rng++; | ||
329 | if (pending & AT91_US_DSRIC) port->icount.dsr++; | ||
330 | if (pending & AT91_US_DCDIC) | ||
331 | uart_handle_dcd_change(port, !(status & AT91_US_DCD)); | ||
332 | if (pending & AT91_US_CTSIC) | ||
333 | uart_handle_cts_change(port, !(status & AT91_US_CTS)); | ||
334 | if (pending & (AT91_US_RIIC | AT91_US_DSRIC | AT91_US_DCDIC | AT91_US_CTSIC)) | ||
335 | wake_up_interruptible(&port->info->delta_msr_wait); | ||
336 | |||
337 | if (pending & AT91_US_TXRDY) | ||
338 | at91_tx_chars(port); | ||
339 | if (pass_counter++ > AT91_ISR_PASS_LIMIT) | ||
340 | break; | ||
341 | |||
342 | status = UART_GET_CSR(port); | ||
343 | pending = status & port->read_status_mask; | ||
344 | } while (pending); | ||
345 | } | ||
346 | return IRQ_HANDLED; | ||
347 | } | ||
348 | |||
349 | /* | ||
350 | * Perform initialization and enable port for reception | ||
351 | */ | ||
352 | static int at91_startup(struct uart_port *port) | ||
353 | { | ||
354 | int retval; | ||
355 | |||
356 | /* | ||
357 | * Ensure that no interrupts are enabled otherwise when | ||
358 | * request_irq() is called we could get stuck trying to | ||
359 | * handle an unexpected interrupt | ||
360 | */ | ||
361 | UART_PUT_IDR(port, -1); | ||
362 | |||
363 | /* | ||
364 | * Allocate the IRQ | ||
365 | */ | ||
366 | retval = request_irq(port->irq, at91_interrupt, SA_SHIRQ, "at91_serial", port); | ||
367 | if (retval) { | ||
368 | printk("at91_serial: at91_startup - Can't get irq\n"); | ||
369 | return retval; | ||
370 | } | ||
371 | |||
372 | /* | ||
373 | * If there is a specific "open" function (to register | ||
374 | * control line interrupts) | ||
375 | */ | ||
376 | if (at91_open) { | ||
377 | retval = at91_open(port); | ||
378 | if (retval) { | ||
379 | free_irq(port->irq, port); | ||
380 | return retval; | ||
381 | } | ||
382 | } | ||
383 | |||
384 | port->read_status_mask = AT91_US_RXRDY | AT91_US_TXRDY | AT91_US_OVRE | ||
385 | | AT91_US_FRAME | AT91_US_PARE | AT91_US_RXBRK; | ||
386 | /* | ||
387 | * Finally, enable the serial port | ||
388 | */ | ||
389 | UART_PUT_CR(port, AT91_US_RSTSTA | AT91_US_RSTRX); | ||
390 | UART_PUT_CR(port, AT91_US_TXEN | AT91_US_RXEN); /* enable xmit & rcvr */ | ||
391 | UART_PUT_IER(port, AT91_US_RXRDY); /* do receive only */ | ||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | /* | ||
396 | * Disable the port | ||
397 | */ | ||
398 | static void at91_shutdown(struct uart_port *port) | ||
399 | { | ||
400 | /* | ||
401 | * Disable all interrupts, port and break condition. | ||
402 | */ | ||
403 | UART_PUT_CR(port, AT91_US_RSTSTA); | ||
404 | UART_PUT_IDR(port, -1); | ||
405 | |||
406 | /* | ||
407 | * Free the interrupt | ||
408 | */ | ||
409 | free_irq(port->irq, port); | ||
410 | |||
411 | /* | ||
412 | * If there is a specific "close" function (to unregister | ||
413 | * control line interrupts) | ||
414 | */ | ||
415 | if (at91_close) | ||
416 | at91_close(port); | ||
417 | } | ||
418 | |||
419 | /* | ||
420 | * Power / Clock management. | ||
421 | */ | ||
422 | static void at91_serial_pm(struct uart_port *port, unsigned int state, unsigned int oldstate) | ||
423 | { | ||
424 | switch (state) { | ||
425 | case 0: | ||
426 | /* | ||
427 | * Enable the peripheral clock for this serial port. | ||
428 | * This is called on uart_open() or a resume event. | ||
429 | */ | ||
430 | at91_sys_write(AT91_PMC_PCER, 1 << port->irq); | ||
431 | break; | ||
432 | case 3: | ||
433 | /* | ||
434 | * Disable the peripheral clock for this serial port. | ||
435 | * This is called on uart_close() or a suspend event. | ||
436 | */ | ||
437 | if (port->irq != AT91_ID_SYS) /* is this a shared clock? */ | ||
438 | at91_sys_write(AT91_PMC_PCDR, 1 << port->irq); | ||
439 | break; | ||
440 | default: | ||
441 | printk(KERN_ERR "at91_serial: unknown pm %d\n", state); | ||
442 | } | ||
443 | } | ||
444 | |||
445 | /* | ||
446 | * Change the port parameters | ||
447 | */ | ||
448 | static void at91_set_termios(struct uart_port *port, struct termios * termios, struct termios * old) | ||
449 | { | ||
450 | unsigned long flags; | ||
451 | unsigned int mode, imr, quot, baud; | ||
452 | |||
453 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); | ||
454 | quot = uart_get_divisor(port, baud); | ||
455 | |||
456 | /* Get current mode register */ | ||
457 | mode = UART_GET_MR(port) & ~(AT91_US_CHRL | AT91_US_NBSTOP | AT91_US_PAR); | ||
458 | |||
459 | /* byte size */ | ||
460 | switch (termios->c_cflag & CSIZE) { | ||
461 | case CS5: | ||
462 | mode |= AT91_US_CHRL_5; | ||
463 | break; | ||
464 | case CS6: | ||
465 | mode |= AT91_US_CHRL_6; | ||
466 | break; | ||
467 | case CS7: | ||
468 | mode |= AT91_US_CHRL_7; | ||
469 | break; | ||
470 | default: | ||
471 | mode |= AT91_US_CHRL_8; | ||
472 | break; | ||
473 | } | ||
474 | |||
475 | /* stop bits */ | ||
476 | if (termios->c_cflag & CSTOPB) | ||
477 | mode |= AT91_US_NBSTOP_2; | ||
478 | |||
479 | /* parity */ | ||
480 | if (termios->c_cflag & PARENB) { | ||
481 | if (termios->c_cflag & CMSPAR) { /* Mark or Space parity */ | ||
482 | if (termios->c_cflag & PARODD) | ||
483 | mode |= AT91_US_PAR_MARK; | ||
484 | else | ||
485 | mode |= AT91_US_PAR_SPACE; | ||
486 | } | ||
487 | else if (termios->c_cflag & PARODD) | ||
488 | mode |= AT91_US_PAR_ODD; | ||
489 | else | ||
490 | mode |= AT91_US_PAR_EVEN; | ||
491 | } | ||
492 | else | ||
493 | mode |= AT91_US_PAR_NONE; | ||
494 | |||
495 | spin_lock_irqsave(&port->lock, flags); | ||
496 | |||
497 | port->read_status_mask |= AT91_US_OVRE; | ||
498 | if (termios->c_iflag & INPCK) | ||
499 | port->read_status_mask |= AT91_US_FRAME | AT91_US_PARE; | ||
500 | if (termios->c_iflag & (BRKINT | PARMRK)) | ||
501 | port->read_status_mask |= AT91_US_RXBRK; | ||
502 | |||
503 | /* | ||
504 | * Characters to ignore | ||
505 | */ | ||
506 | port->ignore_status_mask = 0; | ||
507 | if (termios->c_iflag & IGNPAR) | ||
508 | port->ignore_status_mask |= (AT91_US_FRAME | AT91_US_PARE); | ||
509 | if (termios->c_iflag & IGNBRK) { | ||
510 | port->ignore_status_mask |= AT91_US_RXBRK; | ||
511 | /* | ||
512 | * If we're ignoring parity and break indicators, | ||
513 | * ignore overruns too (for real raw support). | ||
514 | */ | ||
515 | if (termios->c_iflag & IGNPAR) | ||
516 | port->ignore_status_mask |= AT91_US_OVRE; | ||
517 | } | ||
518 | |||
519 | // TODO: Ignore all characters if CREAD is set. | ||
520 | |||
521 | /* update the per-port timeout */ | ||
522 | uart_update_timeout(port, termios->c_cflag, baud); | ||
523 | |||
524 | /* disable interrupts and drain transmitter */ | ||
525 | imr = UART_GET_IMR(port); /* get interrupt mask */ | ||
526 | UART_PUT_IDR(port, -1); /* disable all interrupts */ | ||
527 | while (!(UART_GET_CSR(port) & AT91_US_TXEMPTY)) { barrier(); } | ||
528 | |||
529 | /* disable receiver and transmitter */ | ||
530 | UART_PUT_CR(port, AT91_US_TXDIS | AT91_US_RXDIS); | ||
531 | |||
532 | /* set the parity, stop bits and data size */ | ||
533 | UART_PUT_MR(port, mode); | ||
534 | |||
535 | /* set the baud rate */ | ||
536 | UART_PUT_BRGR(port, quot); | ||
537 | UART_PUT_CR(port, AT91_US_RSTSTA | AT91_US_RSTRX); | ||
538 | UART_PUT_CR(port, AT91_US_TXEN | AT91_US_RXEN); | ||
539 | |||
540 | /* restore interrupts */ | ||
541 | UART_PUT_IER(port, imr); | ||
542 | |||
543 | /* CTS flow-control and modem-status interrupts */ | ||
544 | if (UART_ENABLE_MS(port, termios->c_cflag)) | ||
545 | port->ops->enable_ms(port); | ||
546 | |||
547 | spin_unlock_irqrestore(&port->lock, flags); | ||
548 | } | ||
549 | |||
550 | /* | ||
551 | * Return string describing the specified port | ||
552 | */ | ||
553 | static const char *at91_type(struct uart_port *port) | ||
554 | { | ||
555 | return (port->type == PORT_AT91RM9200) ? "AT91_SERIAL" : NULL; | ||
556 | } | ||
557 | |||
558 | /* | ||
559 | * Release the memory region(s) being used by 'port'. | ||
560 | */ | ||
561 | static void at91_release_port(struct uart_port *port) | ||
562 | { | ||
563 | release_mem_region(port->mapbase, | ||
564 | (port->mapbase == AT91_VA_BASE_DBGU) ? 512 : SZ_16K); | ||
565 | } | ||
566 | |||
567 | /* | ||
568 | * Request the memory region(s) being used by 'port'. | ||
569 | */ | ||
570 | static int at91_request_port(struct uart_port *port) | ||
571 | { | ||
572 | return request_mem_region(port->mapbase, | ||
573 | (port->mapbase == AT91_VA_BASE_DBGU) ? 512 : SZ_16K, | ||
574 | "at91_serial") != NULL ? 0 : -EBUSY; | ||
575 | |||
576 | } | ||
577 | |||
578 | /* | ||
579 | * Configure/autoconfigure the port. | ||
580 | */ | ||
581 | static void at91_config_port(struct uart_port *port, int flags) | ||
582 | { | ||
583 | if (flags & UART_CONFIG_TYPE) { | ||
584 | port->type = PORT_AT91RM9200; | ||
585 | at91_request_port(port); | ||
586 | } | ||
587 | } | ||
588 | |||
589 | /* | ||
590 | * Verify the new serial_struct (for TIOCSSERIAL). | ||
591 | */ | ||
592 | static int at91_verify_port(struct uart_port *port, struct serial_struct *ser) | ||
593 | { | ||
594 | int ret = 0; | ||
595 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_AT91RM9200) | ||
596 | ret = -EINVAL; | ||
597 | if (port->irq != ser->irq) | ||
598 | ret = -EINVAL; | ||
599 | if (ser->io_type != SERIAL_IO_MEM) | ||
600 | ret = -EINVAL; | ||
601 | if (port->uartclk / 16 != ser->baud_base) | ||
602 | ret = -EINVAL; | ||
603 | if ((void *)port->mapbase != ser->iomem_base) | ||
604 | ret = -EINVAL; | ||
605 | if (port->iobase != ser->port) | ||
606 | ret = -EINVAL; | ||
607 | if (ser->hub6 != 0) | ||
608 | ret = -EINVAL; | ||
609 | return ret; | ||
610 | } | ||
611 | |||
612 | static struct uart_ops at91_pops = { | ||
613 | .tx_empty = at91_tx_empty, | ||
614 | .set_mctrl = at91_set_mctrl, | ||
615 | .get_mctrl = at91_get_mctrl, | ||
616 | .stop_tx = at91_stop_tx, | ||
617 | .start_tx = at91_start_tx, | ||
618 | .stop_rx = at91_stop_rx, | ||
619 | .enable_ms = at91_enable_ms, | ||
620 | .break_ctl = at91_break_ctl, | ||
621 | .startup = at91_startup, | ||
622 | .shutdown = at91_shutdown, | ||
623 | .set_termios = at91_set_termios, | ||
624 | .type = at91_type, | ||
625 | .release_port = at91_release_port, | ||
626 | .request_port = at91_request_port, | ||
627 | .config_port = at91_config_port, | ||
628 | .verify_port = at91_verify_port, | ||
629 | .pm = at91_serial_pm, | ||
630 | }; | ||
631 | |||
632 | static struct uart_port at91_ports[AT91_NR_UART]; | ||
633 | |||
634 | void __init at91_init_ports(void) | ||
635 | { | ||
636 | static int first = 1; | ||
637 | int i; | ||
638 | |||
639 | if (!first) | ||
640 | return; | ||
641 | first = 0; | ||
642 | |||
643 | for (i = 0; i < AT91_NR_UART; i++) { | ||
644 | at91_ports[i].iotype = UPIO_MEM; | ||
645 | at91_ports[i].flags = UPF_BOOT_AUTOCONF; | ||
646 | at91_ports[i].uartclk = at91_master_clock; | ||
647 | at91_ports[i].ops = &at91_pops; | ||
648 | at91_ports[i].fifosize = 1; | ||
649 | at91_ports[i].line = i; | ||
650 | } | ||
651 | } | ||
652 | |||
653 | void __init at91_register_uart_fns(struct at91rm9200_port_fns *fns) | ||
654 | { | ||
655 | if (fns->enable_ms) | ||
656 | at91_pops.enable_ms = fns->enable_ms; | ||
657 | if (fns->get_mctrl) | ||
658 | at91_pops.get_mctrl = fns->get_mctrl; | ||
659 | if (fns->set_mctrl) | ||
660 | at91_pops.set_mctrl = fns->set_mctrl; | ||
661 | at91_open = fns->open; | ||
662 | at91_close = fns->close; | ||
663 | at91_pops.pm = fns->pm; | ||
664 | at91_pops.set_wake = fns->set_wake; | ||
665 | } | ||
666 | |||
667 | /* | ||
668 | * Setup ports. | ||
669 | */ | ||
670 | void __init at91_register_uart(int idx, int port) | ||
671 | { | ||
672 | if ((idx < 0) || (idx >= AT91_NR_UART)) { | ||
673 | printk(KERN_ERR "%s: bad index number %d\n", __FUNCTION__, idx); | ||
674 | return; | ||
675 | } | ||
676 | |||
677 | switch (port) { | ||
678 | case 0: | ||
679 | at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US0; | ||
680 | at91_ports[idx].mapbase = AT91_VA_BASE_US0; | ||
681 | at91_ports[idx].irq = AT91_ID_US0; | ||
682 | AT91_CfgPIO_USART0(); | ||
683 | break; | ||
684 | case 1: | ||
685 | at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US1; | ||
686 | at91_ports[idx].mapbase = AT91_VA_BASE_US1; | ||
687 | at91_ports[idx].irq = AT91_ID_US1; | ||
688 | AT91_CfgPIO_USART1(); | ||
689 | break; | ||
690 | case 2: | ||
691 | at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US2; | ||
692 | at91_ports[idx].mapbase = AT91_VA_BASE_US2; | ||
693 | at91_ports[idx].irq = AT91_ID_US2; | ||
694 | AT91_CfgPIO_USART2(); | ||
695 | break; | ||
696 | case 3: | ||
697 | at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_US3; | ||
698 | at91_ports[idx].mapbase = AT91_VA_BASE_US3; | ||
699 | at91_ports[idx].irq = AT91_ID_US3; | ||
700 | AT91_CfgPIO_USART3(); | ||
701 | break; | ||
702 | case 4: | ||
703 | at91_ports[idx].membase = (void __iomem *) AT91_VA_BASE_DBGU; | ||
704 | at91_ports[idx].mapbase = AT91_VA_BASE_DBGU; | ||
705 | at91_ports[idx].irq = AT91_ID_SYS; | ||
706 | AT91_CfgPIO_DBGU(); | ||
707 | break; | ||
708 | default: | ||
709 | printk(KERN_ERR "%s : bad port number %d\n", __FUNCTION__, port); | ||
710 | } | ||
711 | } | ||
712 | |||
713 | #ifdef CONFIG_SERIAL_AT91_CONSOLE | ||
714 | |||
715 | /* | ||
716 | * Interrupts are disabled on entering | ||
717 | */ | ||
718 | static void at91_console_write(struct console *co, const char *s, u_int count) | ||
719 | { | ||
720 | struct uart_port *port = at91_ports + co->index; | ||
721 | unsigned int status, i, imr; | ||
722 | |||
723 | /* | ||
724 | * First, save IMR and then disable interrupts | ||
725 | */ | ||
726 | imr = UART_GET_IMR(port); /* get interrupt mask */ | ||
727 | UART_PUT_IDR(port, AT91_US_RXRDY | AT91_US_TXRDY); | ||
728 | |||
729 | /* | ||
730 | * Now, do each character | ||
731 | */ | ||
732 | for (i = 0; i < count; i++) { | ||
733 | do { | ||
734 | status = UART_GET_CSR(port); | ||
735 | } while (!(status & AT91_US_TXRDY)); | ||
736 | UART_PUT_CHAR(port, s[i]); | ||
737 | if (s[i] == '\n') { | ||
738 | do { | ||
739 | status = UART_GET_CSR(port); | ||
740 | } while (!(status & AT91_US_TXRDY)); | ||
741 | UART_PUT_CHAR(port, '\r'); | ||
742 | } | ||
743 | } | ||
744 | |||
745 | /* | ||
746 | * Finally, wait for transmitter to become empty | ||
747 | * and restore IMR | ||
748 | */ | ||
749 | do { | ||
750 | status = UART_GET_CSR(port); | ||
751 | } while (!(status & AT91_US_TXRDY)); | ||
752 | UART_PUT_IER(port, imr); /* set interrupts back the way they were */ | ||
753 | } | ||
754 | |||
755 | /* | ||
756 | * If the port was already initialised (eg, by a boot loader), try to determine | ||
757 | * the current setup. | ||
758 | */ | ||
759 | static void __init at91_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits) | ||
760 | { | ||
761 | unsigned int mr, quot; | ||
762 | |||
763 | // TODO: CR is a write-only register | ||
764 | // unsigned int cr; | ||
765 | // | ||
766 | // cr = UART_GET_CR(port) & (AT91_US_RXEN | AT91_US_TXEN); | ||
767 | // if (cr == (AT91_US_RXEN | AT91_US_TXEN)) { | ||
768 | // /* ok, the port was enabled */ | ||
769 | // } | ||
770 | |||
771 | mr = UART_GET_MR(port) & AT91_US_CHRL; | ||
772 | if (mr == AT91_US_CHRL_8) | ||
773 | *bits = 8; | ||
774 | else | ||
775 | *bits = 7; | ||
776 | |||
777 | mr = UART_GET_MR(port) & AT91_US_PAR; | ||
778 | if (mr == AT91_US_PAR_EVEN) | ||
779 | *parity = 'e'; | ||
780 | else if (mr == AT91_US_PAR_ODD) | ||
781 | *parity = 'o'; | ||
782 | |||
783 | quot = UART_GET_BRGR(port); | ||
784 | *baud = port->uartclk / (16 * (quot)); | ||
785 | } | ||
786 | |||
787 | static int __init at91_console_setup(struct console *co, char *options) | ||
788 | { | ||
789 | struct uart_port *port; | ||
790 | int baud = 115200; | ||
791 | int bits = 8; | ||
792 | int parity = 'n'; | ||
793 | int flow = 'n'; | ||
794 | |||
795 | /* | ||
796 | * Check whether an invalid uart number has been specified, and | ||
797 | * if so, search for the first available port that does have | ||
798 | * console support. | ||
799 | */ | ||
800 | port = uart_get_console(at91_ports, AT91_NR_UART, co); | ||
801 | |||
802 | /* | ||
803 | * Enable the serial console, in-case bootloader did not do it. | ||
804 | */ | ||
805 | at91_sys_write(AT91_PMC_PCER, 1 << port->irq); /* enable clock */ | ||
806 | UART_PUT_IDR(port, -1); /* disable interrupts */ | ||
807 | UART_PUT_CR(port, AT91_US_RSTSTA | AT91_US_RSTRX); | ||
808 | UART_PUT_CR(port, AT91_US_TXEN | AT91_US_RXEN); | ||
809 | |||
810 | if (options) | ||
811 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
812 | else | ||
813 | at91_console_get_options(port, &baud, &parity, &bits); | ||
814 | |||
815 | return uart_set_options(port, co, baud, parity, bits, flow); | ||
816 | } | ||
817 | |||
818 | static struct uart_driver at91_uart; | ||
819 | |||
820 | static struct console at91_console = { | ||
821 | .name = AT91_DEVICENAME, | ||
822 | .write = at91_console_write, | ||
823 | .device = uart_console_device, | ||
824 | .setup = at91_console_setup, | ||
825 | .flags = CON_PRINTBUFFER, | ||
826 | .index = -1, | ||
827 | .data = &at91_uart, | ||
828 | }; | ||
829 | |||
830 | #define AT91_CONSOLE_DEVICE &at91_console | ||
831 | |||
832 | static int __init at91_console_init(void) | ||
833 | { | ||
834 | at91_init_ports(); | ||
835 | |||
836 | at91_console.index = at91_console_port; | ||
837 | register_console(&at91_console); | ||
838 | return 0; | ||
839 | } | ||
840 | console_initcall(at91_console_init); | ||
841 | |||
842 | #else | ||
843 | #define AT91_CONSOLE_DEVICE NULL | ||
844 | #endif | ||
845 | |||
846 | static struct uart_driver at91_uart = { | ||
847 | .owner = THIS_MODULE, | ||
848 | .driver_name = AT91_DEVICENAME, | ||
849 | .dev_name = AT91_DEVICENAME, | ||
850 | .devfs_name = AT91_DEVICENAME, | ||
851 | .major = SERIAL_AT91_MAJOR, | ||
852 | .minor = MINOR_START, | ||
853 | .nr = AT91_NR_UART, | ||
854 | .cons = AT91_CONSOLE_DEVICE, | ||
855 | }; | ||
856 | |||
857 | static int __init at91_serial_init(void) | ||
858 | { | ||
859 | int ret, i; | ||
860 | |||
861 | at91_init_ports(); | ||
862 | |||
863 | ret = uart_register_driver(&at91_uart); | ||
864 | if (ret) | ||
865 | return ret; | ||
866 | |||
867 | for (i = 0; i < AT91_NR_UART; i++) { | ||
868 | if (at91_serial_map[i] >= 0) | ||
869 | uart_add_one_port(&at91_uart, &at91_ports[i]); | ||
870 | } | ||
871 | |||
872 | return 0; | ||
873 | } | ||
874 | |||
875 | static void __exit at91_serial_exit(void) | ||
876 | { | ||
877 | int i; | ||
878 | |||
879 | for (i = 0; i < AT91_NR_UART; i++) { | ||
880 | if (at91_serial_map[i] >= 0) | ||
881 | uart_remove_one_port(&at91_uart, &at91_ports[i]); | ||
882 | } | ||
883 | |||
884 | uart_unregister_driver(&at91_uart); | ||
885 | } | ||
886 | |||
887 | module_init(at91_serial_init); | ||
888 | module_exit(at91_serial_exit); | ||
889 | |||
890 | MODULE_AUTHOR("Rick Bronson"); | ||
891 | MODULE_DESCRIPTION("AT91 generic serial port driver"); | ||
892 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c index a274ebf256a1..ceb5d7f37bbd 100644 --- a/drivers/serial/au1x00_uart.c +++ b/drivers/serial/au1x00_uart.c | |||
@@ -241,18 +241,12 @@ static _INLINE_ void | |||
241 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | 241 | receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) |
242 | { | 242 | { |
243 | struct tty_struct *tty = up->port.info->tty; | 243 | struct tty_struct *tty = up->port.info->tty; |
244 | unsigned char ch; | 244 | unsigned char ch, flag; |
245 | int max_count = 256; | 245 | int max_count = 256; |
246 | 246 | ||
247 | do { | 247 | do { |
248 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
249 | tty->flip.work.func((void *)tty); | ||
250 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
251 | return; // if TTY_DONT_FLIP is set | ||
252 | } | ||
253 | ch = serial_inp(up, UART_RX); | 248 | ch = serial_inp(up, UART_RX); |
254 | *tty->flip.char_buf_ptr = ch; | 249 | flag = TTY_NORMAL; |
255 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
256 | up->port.icount.rx++; | 250 | up->port.icount.rx++; |
257 | 251 | ||
258 | if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | | 252 | if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | |
@@ -292,30 +286,23 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs) | |||
292 | #endif | 286 | #endif |
293 | if (*status & UART_LSR_BI) { | 287 | if (*status & UART_LSR_BI) { |
294 | DEBUG_INTR("handling break...."); | 288 | DEBUG_INTR("handling break...."); |
295 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 289 | flag = TTY_BREAK; |
296 | } else if (*status & UART_LSR_PE) | 290 | } else if (*status & UART_LSR_PE) |
297 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 291 | flag = TTY_PARITY; |
298 | else if (*status & UART_LSR_FE) | 292 | else if (*status & UART_LSR_FE) |
299 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 293 | flag = TTY_FRAME; |
300 | } | 294 | } |
301 | if (uart_handle_sysrq_char(&up->port, ch, regs)) | 295 | if (uart_handle_sysrq_char(&up->port, ch, regs)) |
302 | goto ignore_char; | 296 | goto ignore_char; |
303 | if ((*status & up->port.ignore_status_mask) == 0) { | 297 | if ((*status & up->port.ignore_status_mask) == 0) |
304 | tty->flip.flag_buf_ptr++; | 298 | tty_insert_flip_char(tty, ch, flag); |
305 | tty->flip.char_buf_ptr++; | 299 | if (*status & UART_LSR_OE) |
306 | tty->flip.count++; | ||
307 | } | ||
308 | if ((*status & UART_LSR_OE) && | ||
309 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
310 | /* | 300 | /* |
311 | * Overrun is special, since it's reported | 301 | * Overrun is special, since it's reported |
312 | * immediately, and doesn't affect the current | 302 | * immediately, and doesn't affect the current |
313 | * character. | 303 | * character. |
314 | */ | 304 | */ |
315 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | 305 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
316 | tty->flip.flag_buf_ptr++; | ||
317 | tty->flip.char_buf_ptr++; | ||
318 | tty->flip.count++; | ||
319 | } | 306 | } |
320 | ignore_char: | 307 | ignore_char: |
321 | *status = serial_inp(up, UART_LSR); | 308 | *status = serial_inp(up, UART_LSR); |
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c index 87ef368384fb..8ef999481f93 100644 --- a/drivers/serial/clps711x.c +++ b/drivers/serial/clps711x.c | |||
@@ -104,8 +104,6 @@ static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *re | |||
104 | while (!(status & SYSFLG_URXFE)) { | 104 | while (!(status & SYSFLG_URXFE)) { |
105 | ch = clps_readl(UARTDR(port)); | 105 | ch = clps_readl(UARTDR(port)); |
106 | 106 | ||
107 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
108 | goto ignore_char; | ||
109 | port->icount.rx++; | 107 | port->icount.rx++; |
110 | 108 | ||
111 | flg = TTY_NORMAL; | 109 | flg = TTY_NORMAL; |
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index 987d22b53c22..16af5626c243 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -608,7 +608,7 @@ static int cpm_uart_tx_pump(struct uart_port *port) | |||
608 | 608 | ||
609 | p = cpm2cpu_addr(bdp->cbd_bufaddr); | 609 | p = cpm2cpu_addr(bdp->cbd_bufaddr); |
610 | 610 | ||
611 | *p++ = xmit->buf[xmit->tail]; | 611 | *p++ = port->x_char; |
612 | bdp->cbd_datlen = 1; | 612 | bdp->cbd_datlen = 1; |
613 | bdp->cbd_sc |= BD_SC_READY; | 613 | bdp->cbd_sc |= BD_SC_READY; |
614 | /* Get next BD. */ | 614 | /* Get next BD. */ |
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 08c42c000188..be12623d8544 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -442,6 +442,7 @@ static char *serial_version = "$Revision: 1.25 $"; | |||
442 | #include <linux/init.h> | 442 | #include <linux/init.h> |
443 | #include <asm/uaccess.h> | 443 | #include <asm/uaccess.h> |
444 | #include <linux/kernel.h> | 444 | #include <linux/kernel.h> |
445 | #include <linux/mutex.h> | ||
445 | 446 | ||
446 | #include <asm/io.h> | 447 | #include <asm/io.h> |
447 | #include <asm/irq.h> | 448 | #include <asm/irq.h> |
@@ -1315,11 +1316,7 @@ static const struct control_pins e100_modem_pins[NR_PORTS] = | |||
1315 | * memory if large numbers of serial ports are open. | 1316 | * memory if large numbers of serial ports are open. |
1316 | */ | 1317 | */ |
1317 | static unsigned char *tmp_buf; | 1318 | static unsigned char *tmp_buf; |
1318 | #ifdef DECLARE_MUTEX | 1319 | static DEFINE_MUTEX(tmp_buf_mutex); |
1319 | static DECLARE_MUTEX(tmp_buf_sem); | ||
1320 | #else | ||
1321 | static struct semaphore tmp_buf_sem = MUTEX; | ||
1322 | #endif | ||
1323 | 1320 | ||
1324 | /* Calculate the chartime depending on baudrate, numbor of bits etc. */ | 1321 | /* Calculate the chartime depending on baudrate, numbor of bits etc. */ |
1325 | static void update_char_time(struct e100_serial * info) | 1322 | static void update_char_time(struct e100_serial * info) |
@@ -3661,7 +3658,7 @@ rs_raw_write(struct tty_struct * tty, int from_user, | |||
3661 | * design. | 3658 | * design. |
3662 | */ | 3659 | */ |
3663 | if (from_user) { | 3660 | if (from_user) { |
3664 | down(&tmp_buf_sem); | 3661 | mutex_lock(&tmp_buf_mutex); |
3665 | while (1) { | 3662 | while (1) { |
3666 | int c1; | 3663 | int c1; |
3667 | c = CIRC_SPACE_TO_END(info->xmit.head, | 3664 | c = CIRC_SPACE_TO_END(info->xmit.head, |
@@ -3692,7 +3689,7 @@ rs_raw_write(struct tty_struct * tty, int from_user, | |||
3692 | count -= c; | 3689 | count -= c; |
3693 | ret += c; | 3690 | ret += c; |
3694 | } | 3691 | } |
3695 | up(&tmp_buf_sem); | 3692 | mutex_unlock(&tmp_buf_mutex); |
3696 | } else { | 3693 | } else { |
3697 | cli(); | 3694 | cli(); |
3698 | while (count) { | 3695 | while (count) { |
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c index 4d8516d1bb71..a64ba26a94e8 100644 --- a/drivers/serial/dz.c +++ b/drivers/serial/dz.c | |||
@@ -216,8 +216,6 @@ static inline void dz_receive_chars(struct dz_port *dport) | |||
216 | 216 | ||
217 | if (!tty) | 217 | if (!tty) |
218 | break; | 218 | break; |
219 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
220 | break; | ||
221 | 219 | ||
222 | icount->rx++; | 220 | icount->rx++; |
223 | 221 | ||
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c index eb31125c6a30..144a7a352b28 100644 --- a/drivers/serial/icom.c +++ b/drivers/serial/icom.c | |||
@@ -729,19 +729,20 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) | |||
729 | unsigned short int status; | 729 | unsigned short int status; |
730 | struct uart_icount *icount; | 730 | struct uart_icount *icount; |
731 | unsigned long offset; | 731 | unsigned long offset; |
732 | unsigned char flag; | ||
732 | 733 | ||
733 | trace(icom_port, "RCV_COMPLETE", 0); | 734 | trace(icom_port, "RCV_COMPLETE", 0); |
734 | rcv_buff = icom_port->next_rcv; | 735 | rcv_buff = icom_port->next_rcv; |
735 | 736 | ||
736 | status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); | 737 | status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); |
737 | while (status & SA_FL_RCV_DONE) { | 738 | while (status & SA_FL_RCV_DONE) { |
739 | int first = -1; | ||
738 | 740 | ||
739 | trace(icom_port, "FID_STATUS", status); | 741 | trace(icom_port, "FID_STATUS", status); |
740 | count = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].leLength); | 742 | count = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].leLength); |
741 | 743 | ||
744 | count = tty_buffer_request_room(tty, count); | ||
742 | trace(icom_port, "RCV_COUNT", count); | 745 | trace(icom_port, "RCV_COUNT", count); |
743 | if (count > (TTY_FLIPBUF_SIZE - tty->flip.count)) | ||
744 | count = TTY_FLIPBUF_SIZE - tty->flip.count; | ||
745 | 746 | ||
746 | trace(icom_port, "REAL_COUNT", count); | 747 | trace(icom_port, "REAL_COUNT", count); |
747 | 748 | ||
@@ -749,15 +750,10 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) | |||
749 | cpu_to_le32(icom_port->statStg->rcv[rcv_buff].leBuffer) - | 750 | cpu_to_le32(icom_port->statStg->rcv[rcv_buff].leBuffer) - |
750 | icom_port->recv_buf_pci; | 751 | icom_port->recv_buf_pci; |
751 | 752 | ||
752 | memcpy(tty->flip.char_buf_ptr,(unsigned char *) | 753 | /* Block copy all but the last byte as this may have status */ |
753 | ((unsigned long)icom_port->recv_buf + offset), count); | ||
754 | |||
755 | if (count > 0) { | 754 | if (count > 0) { |
756 | tty->flip.count += count - 1; | 755 | first = icom_port->recv_buf[offset]; |
757 | tty->flip.char_buf_ptr += count - 1; | 756 | tty_insert_flip_string(tty, icom_port->recv_buf + offset, count - 1); |
758 | |||
759 | memset(tty->flip.flag_buf_ptr, 0, count); | ||
760 | tty->flip.flag_buf_ptr += count - 1; | ||
761 | } | 757 | } |
762 | 758 | ||
763 | icount = &icom_port->uart_port.icount; | 759 | icount = &icom_port->uart_port.icount; |
@@ -765,12 +761,14 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) | |||
765 | 761 | ||
766 | /* Break detect logic */ | 762 | /* Break detect logic */ |
767 | if ((status & SA_FLAGS_FRAME_ERROR) | 763 | if ((status & SA_FLAGS_FRAME_ERROR) |
768 | && (tty->flip.char_buf_ptr[0] == 0x00)) { | 764 | && first == 0) { |
769 | status &= ~SA_FLAGS_FRAME_ERROR; | 765 | status &= ~SA_FLAGS_FRAME_ERROR; |
770 | status |= SA_FLAGS_BREAK_DET; | 766 | status |= SA_FLAGS_BREAK_DET; |
771 | trace(icom_port, "BREAK_DET", 0); | 767 | trace(icom_port, "BREAK_DET", 0); |
772 | } | 768 | } |
773 | 769 | ||
770 | flag = TTY_NORMAL; | ||
771 | |||
774 | if (status & | 772 | if (status & |
775 | (SA_FLAGS_BREAK_DET | SA_FLAGS_PARITY_ERROR | | 773 | (SA_FLAGS_BREAK_DET | SA_FLAGS_PARITY_ERROR | |
776 | SA_FLAGS_FRAME_ERROR | SA_FLAGS_OVERRUN)) { | 774 | SA_FLAGS_FRAME_ERROR | SA_FLAGS_OVERRUN)) { |
@@ -797,33 +795,26 @@ static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port) | |||
797 | status &= icom_port->read_status_mask; | 795 | status &= icom_port->read_status_mask; |
798 | 796 | ||
799 | if (status & SA_FLAGS_BREAK_DET) { | 797 | if (status & SA_FLAGS_BREAK_DET) { |
800 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 798 | flag = TTY_BREAK; |
801 | } else if (status & SA_FLAGS_PARITY_ERROR) { | 799 | } else if (status & SA_FLAGS_PARITY_ERROR) { |
802 | trace(icom_port, "PARITY_ERROR", 0); | 800 | trace(icom_port, "PARITY_ERROR", 0); |
803 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 801 | flag = TTY_PARITY; |
804 | } else if (status & SA_FLAGS_FRAME_ERROR) | 802 | } else if (status & SA_FLAGS_FRAME_ERROR) |
805 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 803 | flag = TTY_FRAME; |
806 | 804 | ||
807 | if (status & SA_FLAGS_OVERRUN) { | ||
808 | /* | ||
809 | * Overrun is special, since it's | ||
810 | * reported immediately, and doesn't | ||
811 | * affect the current character | ||
812 | */ | ||
813 | if (tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
814 | tty->flip.count++; | ||
815 | tty->flip.flag_buf_ptr++; | ||
816 | tty->flip.char_buf_ptr++; | ||
817 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | ||
818 | } | ||
819 | } | ||
820 | } | 805 | } |
821 | 806 | ||
822 | tty->flip.flag_buf_ptr++; | 807 | tty_insert_flip_char(tty, *(icom_port->recv_buf + offset + count - 1), flag); |
823 | tty->flip.char_buf_ptr++; | 808 | |
824 | tty->flip.count++; | 809 | if (status & SA_FLAGS_OVERRUN) |
825 | ignore_char: | 810 | /* |
826 | icom_port->statStg->rcv[rcv_buff].flags = 0; | 811 | * Overrun is special, since it's |
812 | * reported immediately, and doesn't | ||
813 | * affect the current character | ||
814 | */ | ||
815 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | ||
816 | ignore_char: | ||
817 | icom_port->statStg->rcv[rcv_buff].flags = 0; | ||
827 | icom_port->statStg->rcv[rcv_buff].leLength = 0; | 818 | icom_port->statStg->rcv[rcv_buff].leLength = 0; |
828 | icom_port->statStg->rcv[rcv_buff].WorkingLength = | 819 | icom_port->statStg->rcv[rcv_buff].WorkingLength = |
829 | (unsigned short int) cpu_to_le16(RCV_BUFF_SZ); | 820 | (unsigned short int) cpu_to_le16(RCV_BUFF_SZ); |
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index 83c4c1216587..587cc6a95114 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c | |||
@@ -256,9 +256,6 @@ static irqreturn_t imx_rxint(int irq, void *dev_id, struct pt_regs *regs) | |||
256 | error_return: | 256 | error_return: |
257 | tty_insert_flip_char(tty, rx, flg); | 257 | tty_insert_flip_char(tty, rx, flg); |
258 | 258 | ||
259 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
260 | goto out; | ||
261 | |||
262 | ignore_char: | 259 | ignore_char: |
263 | rx = URXD0((u32)sport->port.membase); | 260 | rx = URXD0((u32)sport->port.membase); |
264 | } while(rx & URXD_CHARRDY); | 261 | } while(rx & URXD_CHARRDY); |
@@ -502,7 +499,7 @@ imx_set_termios(struct uart_port *port, struct termios *termios, | |||
502 | ucr2 |= UCR2_STPB; | 499 | ucr2 |= UCR2_STPB; |
503 | if (termios->c_cflag & PARENB) { | 500 | if (termios->c_cflag & PARENB) { |
504 | ucr2 |= UCR2_PREN; | 501 | ucr2 |= UCR2_PREN; |
505 | if (!(termios->c_cflag & PARODD)) | 502 | if (termios->c_cflag & PARODD) |
506 | ucr2 |= UCR2_PROE; | 503 | ucr2 |= UCR2_PROE; |
507 | } | 504 | } |
508 | 505 | ||
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c new file mode 100644 index 000000000000..8097cd91f16b --- /dev/null +++ b/drivers/serial/ioc3_serial.c | |||
@@ -0,0 +1,2197 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. | ||
7 | */ | ||
8 | |||
9 | /* | ||
10 | * This file contains a module version of the ioc3 serial driver. This | ||
11 | * includes all the support functions needed (support functions, etc.) | ||
12 | * and the serial driver itself. | ||
13 | */ | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/tty.h> | ||
16 | #include <linux/serial.h> | ||
17 | #include <linux/circ_buf.h> | ||
18 | #include <linux/serial_reg.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/serial_core.h> | ||
22 | #include <linux/ioc3.h> | ||
23 | |||
24 | /* | ||
25 | * Interesting things about the ioc3 | ||
26 | */ | ||
27 | |||
28 | #define LOGICAL_PORTS 2 /* rs232(0) and rs422(1) */ | ||
29 | #define PORTS_PER_CARD 2 | ||
30 | #define LOGICAL_PORTS_PER_CARD (PORTS_PER_CARD * LOGICAL_PORTS) | ||
31 | #define MAX_CARDS 8 | ||
32 | #define MAX_LOGICAL_PORTS (LOGICAL_PORTS_PER_CARD * MAX_CARDS) | ||
33 | |||
34 | /* determine given the sio_ir what port it applies to */ | ||
35 | #define GET_PORT_FROM_SIO_IR(_x) (_x & SIO_IR_SA) ? 0 : 1 | ||
36 | |||
37 | |||
38 | /* | ||
39 | * we have 2 logical ports (rs232, rs422) for each physical port | ||
40 | * evens are rs232, odds are rs422 | ||
41 | */ | ||
42 | #define GET_PHYSICAL_PORT(_x) ((_x) >> 1) | ||
43 | #define GET_LOGICAL_PORT(_x) ((_x) & 1) | ||
44 | #define IS_PHYSICAL_PORT(_x) !((_x) & 1) | ||
45 | #define IS_RS232(_x) !((_x) & 1) | ||
46 | |||
47 | static unsigned int Num_of_ioc3_cards; | ||
48 | static unsigned int Submodule_slot; | ||
49 | |||
50 | /* defining this will get you LOTS of great debug info */ | ||
51 | //#define DEBUG_INTERRUPTS | ||
52 | #define DPRINT_CONFIG(_x...) ; | ||
53 | //#define DPRINT_CONFIG(_x...) printk _x | ||
54 | #define NOT_PROGRESS() ; | ||
55 | //#define NOT_PROGRESS() printk("%s : fails %d\n", __FUNCTION__, __LINE__) | ||
56 | |||
57 | /* number of characters we want to transmit to the lower level at a time */ | ||
58 | #define MAX_CHARS 256 | ||
59 | #define FIFO_SIZE (MAX_CHARS-1) /* it's a uchar */ | ||
60 | |||
61 | /* Device name we're using */ | ||
62 | #define DEVICE_NAME "ttySIOC" | ||
63 | #define DEVICE_MAJOR 204 | ||
64 | #define DEVICE_MINOR 116 | ||
65 | |||
66 | /* flags for next_char_state */ | ||
67 | #define NCS_BREAK 0x1 | ||
68 | #define NCS_PARITY 0x2 | ||
69 | #define NCS_FRAMING 0x4 | ||
70 | #define NCS_OVERRUN 0x8 | ||
71 | |||
72 | /* cause we need SOME parameters ... */ | ||
73 | #define MIN_BAUD_SUPPORTED 1200 | ||
74 | #define MAX_BAUD_SUPPORTED 115200 | ||
75 | |||
76 | /* protocol types supported */ | ||
77 | #define PROTO_RS232 0 | ||
78 | #define PROTO_RS422 1 | ||
79 | |||
80 | /* Notification types */ | ||
81 | #define N_DATA_READY 0x01 | ||
82 | #define N_OUTPUT_LOWAT 0x02 | ||
83 | #define N_BREAK 0x04 | ||
84 | #define N_PARITY_ERROR 0x08 | ||
85 | #define N_FRAMING_ERROR 0x10 | ||
86 | #define N_OVERRUN_ERROR 0x20 | ||
87 | #define N_DDCD 0x40 | ||
88 | #define N_DCTS 0x80 | ||
89 | |||
90 | #define N_ALL_INPUT (N_DATA_READY | N_BREAK \ | ||
91 | | N_PARITY_ERROR | N_FRAMING_ERROR \ | ||
92 | | N_OVERRUN_ERROR | N_DDCD | N_DCTS) | ||
93 | |||
94 | #define N_ALL_OUTPUT N_OUTPUT_LOWAT | ||
95 | |||
96 | #define N_ALL_ERRORS (N_PARITY_ERROR | N_FRAMING_ERROR \ | ||
97 | | N_OVERRUN_ERROR) | ||
98 | |||
99 | #define N_ALL (N_DATA_READY | N_OUTPUT_LOWAT | N_BREAK \ | ||
100 | | N_PARITY_ERROR | N_FRAMING_ERROR \ | ||
101 | | N_OVERRUN_ERROR | N_DDCD | N_DCTS) | ||
102 | |||
103 | #define SER_CLK_SPEED(prediv) ((22000000 << 1) / prediv) | ||
104 | #define SER_DIVISOR(x, clk) (((clk) + (x) * 8) / ((x) * 16)) | ||
105 | #define DIVISOR_TO_BAUD(div, clk) ((clk) / 16 / (div)) | ||
106 | |||
107 | /* Some masks */ | ||
108 | #define LCR_MASK_BITS_CHAR (UART_LCR_WLEN5 | UART_LCR_WLEN6 \ | ||
109 | | UART_LCR_WLEN7 | UART_LCR_WLEN8) | ||
110 | #define LCR_MASK_STOP_BITS (UART_LCR_STOP) | ||
111 | |||
112 | #define PENDING(_a, _p) (readl(&(_p)->vma->sio_ir) & (_a)->ic_enable) | ||
113 | |||
114 | #define RING_BUF_SIZE 4096 | ||
115 | #define BUF_SIZE_BIT SBBR_L_SIZE | ||
116 | #define PROD_CONS_MASK PROD_CONS_PTR_4K | ||
117 | |||
118 | #define TOTAL_RING_BUF_SIZE (RING_BUF_SIZE * 4) | ||
119 | |||
120 | /* driver specific - one per card */ | ||
121 | struct ioc3_card { | ||
122 | struct { | ||
123 | /* uart ports are allocated here */ | ||
124 | struct uart_port icp_uart_port[LOGICAL_PORTS]; | ||
125 | /* the ioc3_port used for this port */ | ||
126 | struct ioc3_port *icp_port; | ||
127 | } ic_port[PORTS_PER_CARD]; | ||
128 | /* currently enabled interrupts */ | ||
129 | uint32_t ic_enable; | ||
130 | }; | ||
131 | |||
132 | /* Local port info for each IOC3 serial port */ | ||
133 | struct ioc3_port { | ||
134 | /* handy reference material */ | ||
135 | struct uart_port *ip_port; | ||
136 | struct ioc3_card *ip_card; | ||
137 | struct ioc3_driver_data *ip_idd; | ||
138 | struct ioc3_submodule *ip_is; | ||
139 | |||
140 | /* pci mem addresses for this port */ | ||
141 | struct ioc3_serialregs __iomem *ip_serial_regs; | ||
142 | struct ioc3_uartregs __iomem *ip_uart_regs; | ||
143 | |||
144 | /* Ring buffer page for this port */ | ||
145 | dma_addr_t ip_dma_ringbuf; | ||
146 | /* vaddr of ring buffer */ | ||
147 | struct ring_buffer *ip_cpu_ringbuf; | ||
148 | |||
149 | /* Rings for this port */ | ||
150 | struct ring *ip_inring; | ||
151 | struct ring *ip_outring; | ||
152 | |||
153 | /* Hook to port specific values */ | ||
154 | struct port_hooks *ip_hooks; | ||
155 | |||
156 | spinlock_t ip_lock; | ||
157 | |||
158 | /* Various rx/tx parameters */ | ||
159 | int ip_baud; | ||
160 | int ip_tx_lowat; | ||
161 | int ip_rx_timeout; | ||
162 | |||
163 | /* Copy of notification bits */ | ||
164 | int ip_notify; | ||
165 | |||
166 | /* Shadow copies of various registers so we don't need to PIO | ||
167 | * read them constantly | ||
168 | */ | ||
169 | uint32_t ip_sscr; | ||
170 | uint32_t ip_tx_prod; | ||
171 | uint32_t ip_rx_cons; | ||
172 | unsigned char ip_flags; | ||
173 | }; | ||
174 | |||
175 | /* tx low water mark. We need to notify the driver whenever tx is getting | ||
176 | * close to empty so it can refill the tx buffer and keep things going. | ||
177 | * Let's assume that if we interrupt 1 ms before the tx goes idle, we'll | ||
178 | * have no trouble getting in more chars in time (I certainly hope so). | ||
179 | */ | ||
180 | #define TX_LOWAT_LATENCY 1000 | ||
181 | #define TX_LOWAT_HZ (1000000 / TX_LOWAT_LATENCY) | ||
182 | #define TX_LOWAT_CHARS(baud) (baud / 10 / TX_LOWAT_HZ) | ||
183 | |||
184 | /* Flags per port */ | ||
185 | #define INPUT_HIGH 0x01 | ||
186 | /* used to signify that we have turned off the rx_high | ||
187 | * temporarily - we need to drain the fifo and don't | ||
188 | * want to get blasted with interrupts. | ||
189 | */ | ||
190 | #define DCD_ON 0x02 | ||
191 | /* DCD state is on */ | ||
192 | #define LOWAT_WRITTEN 0x04 | ||
193 | #define READ_ABORTED 0x08 | ||
194 | /* the read was aborted - used to avaoid infinate looping | ||
195 | * in the interrupt handler | ||
196 | */ | ||
197 | #define INPUT_ENABLE 0x10 | ||
198 | |||
199 | /* Since each port has different register offsets and bitmasks | ||
200 | * for everything, we'll store those that we need in tables so we | ||
201 | * don't have to be constantly checking the port we are dealing with. | ||
202 | */ | ||
203 | struct port_hooks { | ||
204 | uint32_t intr_delta_dcd; | ||
205 | uint32_t intr_delta_cts; | ||
206 | uint32_t intr_tx_mt; | ||
207 | uint32_t intr_rx_timer; | ||
208 | uint32_t intr_rx_high; | ||
209 | uint32_t intr_tx_explicit; | ||
210 | uint32_t intr_clear; | ||
211 | uint32_t intr_all; | ||
212 | char rs422_select_pin; | ||
213 | }; | ||
214 | |||
215 | static struct port_hooks hooks_array[PORTS_PER_CARD] = { | ||
216 | /* values for port A */ | ||
217 | { | ||
218 | .intr_delta_dcd = SIO_IR_SA_DELTA_DCD, | ||
219 | .intr_delta_cts = SIO_IR_SA_DELTA_CTS, | ||
220 | .intr_tx_mt = SIO_IR_SA_TX_MT, | ||
221 | .intr_rx_timer = SIO_IR_SA_RX_TIMER, | ||
222 | .intr_rx_high = SIO_IR_SA_RX_HIGH, | ||
223 | .intr_tx_explicit = SIO_IR_SA_TX_EXPLICIT, | ||
224 | .intr_clear = (SIO_IR_SA_TX_MT | SIO_IR_SA_RX_FULL | ||
225 | | SIO_IR_SA_RX_HIGH | ||
226 | | SIO_IR_SA_RX_TIMER | ||
227 | | SIO_IR_SA_DELTA_DCD | ||
228 | | SIO_IR_SA_DELTA_CTS | ||
229 | | SIO_IR_SA_INT | ||
230 | | SIO_IR_SA_TX_EXPLICIT | ||
231 | | SIO_IR_SA_MEMERR), | ||
232 | .intr_all = SIO_IR_SA, | ||
233 | .rs422_select_pin = GPPR_UARTA_MODESEL_PIN, | ||
234 | }, | ||
235 | |||
236 | /* values for port B */ | ||
237 | { | ||
238 | .intr_delta_dcd = SIO_IR_SB_DELTA_DCD, | ||
239 | .intr_delta_cts = SIO_IR_SB_DELTA_CTS, | ||
240 | .intr_tx_mt = SIO_IR_SB_TX_MT, | ||
241 | .intr_rx_timer = SIO_IR_SB_RX_TIMER, | ||
242 | .intr_rx_high = SIO_IR_SB_RX_HIGH, | ||
243 | .intr_tx_explicit = SIO_IR_SB_TX_EXPLICIT, | ||
244 | .intr_clear = (SIO_IR_SB_TX_MT | SIO_IR_SB_RX_FULL | ||
245 | | SIO_IR_SB_RX_HIGH | ||
246 | | SIO_IR_SB_RX_TIMER | ||
247 | | SIO_IR_SB_DELTA_DCD | ||
248 | | SIO_IR_SB_DELTA_CTS | ||
249 | | SIO_IR_SB_INT | ||
250 | | SIO_IR_SB_TX_EXPLICIT | ||
251 | | SIO_IR_SB_MEMERR), | ||
252 | .intr_all = SIO_IR_SB, | ||
253 | .rs422_select_pin = GPPR_UARTB_MODESEL_PIN, | ||
254 | } | ||
255 | }; | ||
256 | |||
257 | struct ring_entry { | ||
258 | union { | ||
259 | struct { | ||
260 | uint32_t alldata; | ||
261 | uint32_t allsc; | ||
262 | } all; | ||
263 | struct { | ||
264 | char data[4]; /* data bytes */ | ||
265 | char sc[4]; /* status/control */ | ||
266 | } s; | ||
267 | } u; | ||
268 | }; | ||
269 | |||
270 | /* Test the valid bits in any of the 4 sc chars using "allsc" member */ | ||
271 | #define RING_ANY_VALID \ | ||
272 | ((uint32_t)(RXSB_MODEM_VALID | RXSB_DATA_VALID) * 0x01010101) | ||
273 | |||
274 | #define ring_sc u.s.sc | ||
275 | #define ring_data u.s.data | ||
276 | #define ring_allsc u.all.allsc | ||
277 | |||
278 | /* Number of entries per ring buffer. */ | ||
279 | #define ENTRIES_PER_RING (RING_BUF_SIZE / (int) sizeof(struct ring_entry)) | ||
280 | |||
281 | /* An individual ring */ | ||
282 | struct ring { | ||
283 | struct ring_entry entries[ENTRIES_PER_RING]; | ||
284 | }; | ||
285 | |||
286 | /* The whole enchilada */ | ||
287 | struct ring_buffer { | ||
288 | struct ring TX_A; | ||
289 | struct ring RX_A; | ||
290 | struct ring TX_B; | ||
291 | struct ring RX_B; | ||
292 | }; | ||
293 | |||
294 | /* Get a ring from a port struct */ | ||
295 | #define RING(_p, _wh) &(((struct ring_buffer *)((_p)->ip_cpu_ringbuf))->_wh) | ||
296 | |||
297 | /* for Infinite loop detection */ | ||
298 | #define MAXITER 10000000 | ||
299 | |||
300 | |||
301 | /** | ||
302 | * set_baud - Baud rate setting code | ||
303 | * @port: port to set | ||
304 | * @baud: baud rate to use | ||
305 | */ | ||
306 | static int set_baud(struct ioc3_port *port, int baud) | ||
307 | { | ||
308 | int divisor; | ||
309 | int actual_baud; | ||
310 | int diff; | ||
311 | int lcr, prediv; | ||
312 | struct ioc3_uartregs __iomem *uart; | ||
313 | |||
314 | for (prediv = 6; prediv < 64; prediv++) { | ||
315 | divisor = SER_DIVISOR(baud, SER_CLK_SPEED(prediv)); | ||
316 | if (!divisor) | ||
317 | continue; /* invalid divisor */ | ||
318 | actual_baud = DIVISOR_TO_BAUD(divisor, SER_CLK_SPEED(prediv)); | ||
319 | |||
320 | diff = actual_baud - baud; | ||
321 | if (diff < 0) | ||
322 | diff = -diff; | ||
323 | |||
324 | /* if we're within 1% we've found a match */ | ||
325 | if (diff * 100 <= actual_baud) | ||
326 | break; | ||
327 | } | ||
328 | |||
329 | /* if the above loop completed, we didn't match | ||
330 | * the baud rate. give up. | ||
331 | */ | ||
332 | if (prediv == 64) { | ||
333 | NOT_PROGRESS(); | ||
334 | return 1; | ||
335 | } | ||
336 | |||
337 | uart = port->ip_uart_regs; | ||
338 | lcr = readb(&uart->iu_lcr); | ||
339 | |||
340 | writeb(lcr | UART_LCR_DLAB, &uart->iu_lcr); | ||
341 | writeb((unsigned char)divisor, &uart->iu_dll); | ||
342 | writeb((unsigned char)(divisor >> 8), &uart->iu_dlm); | ||
343 | writeb((unsigned char)prediv, &uart->iu_scr); | ||
344 | writeb((unsigned char)lcr, &uart->iu_lcr); | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * get_ioc3_port - given a uart port, return the control structure | ||
351 | * @the_port: uart port to find | ||
352 | */ | ||
353 | static struct ioc3_port *get_ioc3_port(struct uart_port *the_port) | ||
354 | { | ||
355 | struct ioc3_driver_data *idd = dev_get_drvdata(the_port->dev); | ||
356 | struct ioc3_card *card_ptr = idd->data[Submodule_slot]; | ||
357 | int ii, jj; | ||
358 | |||
359 | if (!card_ptr) { | ||
360 | NOT_PROGRESS(); | ||
361 | return NULL; | ||
362 | } | ||
363 | for (ii = 0; ii < PORTS_PER_CARD; ii++) { | ||
364 | for (jj = 0; jj < LOGICAL_PORTS; jj++) { | ||
365 | if (the_port == &card_ptr->ic_port[ii].icp_uart_port[jj]) | ||
366 | return card_ptr->ic_port[ii].icp_port; | ||
367 | } | ||
368 | } | ||
369 | NOT_PROGRESS(); | ||
370 | return NULL; | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * port_init - Initialize the sio and ioc3 hardware for a given port | ||
375 | * called per port from attach... | ||
376 | * @port: port to initialize | ||
377 | */ | ||
378 | static int inline port_init(struct ioc3_port *port) | ||
379 | { | ||
380 | uint32_t sio_cr; | ||
381 | struct port_hooks *hooks = port->ip_hooks; | ||
382 | struct ioc3_uartregs __iomem *uart; | ||
383 | int reset_loop_counter = 0xfffff; | ||
384 | struct ioc3_driver_data *idd = port->ip_idd; | ||
385 | |||
386 | /* Idle the IOC3 serial interface */ | ||
387 | writel(SSCR_RESET, &port->ip_serial_regs->sscr); | ||
388 | |||
389 | /* Wait until any pending bus activity for this port has ceased */ | ||
390 | do { | ||
391 | sio_cr = readl(&idd->vma->sio_cr); | ||
392 | if (reset_loop_counter-- <= 0) { | ||
393 | printk(KERN_WARNING | ||
394 | "IOC3 unable to come out of reset" | ||
395 | " scr 0x%x\n", sio_cr); | ||
396 | return -1; | ||
397 | } | ||
398 | } while (!(sio_cr & SIO_CR_ARB_DIAG_IDLE) && | ||
399 | (((sio_cr &= SIO_CR_ARB_DIAG) == SIO_CR_ARB_DIAG_TXA) | ||
400 | || sio_cr == SIO_CR_ARB_DIAG_TXB | ||
401 | || sio_cr == SIO_CR_ARB_DIAG_RXA | ||
402 | || sio_cr == SIO_CR_ARB_DIAG_RXB)); | ||
403 | |||
404 | /* Finish reset sequence */ | ||
405 | writel(0, &port->ip_serial_regs->sscr); | ||
406 | |||
407 | /* Once RESET is done, reload cached tx_prod and rx_cons values | ||
408 | * and set rings to empty by making prod == cons | ||
409 | */ | ||
410 | port->ip_tx_prod = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK; | ||
411 | writel(port->ip_tx_prod, &port->ip_serial_regs->stpir); | ||
412 | port->ip_rx_cons = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK; | ||
413 | writel(port->ip_rx_cons | SRCIR_ARM, &port->ip_serial_regs->srcir); | ||
414 | |||
415 | /* Disable interrupts for this 16550 */ | ||
416 | uart = port->ip_uart_regs; | ||
417 | writeb(0, &uart->iu_lcr); | ||
418 | writeb(0, &uart->iu_ier); | ||
419 | |||
420 | /* Set the default baud */ | ||
421 | set_baud(port, port->ip_baud); | ||
422 | |||
423 | /* Set line control to 8 bits no parity */ | ||
424 | writeb(UART_LCR_WLEN8 | 0, &uart->iu_lcr); | ||
425 | /* UART_LCR_STOP == 1 stop */ | ||
426 | |||
427 | /* Enable the FIFOs */ | ||
428 | writeb(UART_FCR_ENABLE_FIFO, &uart->iu_fcr); | ||
429 | /* then reset 16550 FIFOs */ | ||
430 | writeb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, | ||
431 | &uart->iu_fcr); | ||
432 | |||
433 | /* Clear modem control register */ | ||
434 | writeb(0, &uart->iu_mcr); | ||
435 | |||
436 | /* Clear deltas in modem status register */ | ||
437 | writel(0, &port->ip_serial_regs->shadow); | ||
438 | |||
439 | /* Only do this once per port pair */ | ||
440 | if (port->ip_hooks == &hooks_array[0]) { | ||
441 | unsigned long ring_pci_addr; | ||
442 | uint32_t __iomem *sbbr_l, *sbbr_h; | ||
443 | |||
444 | sbbr_l = &idd->vma->sbbr_l; | ||
445 | sbbr_h = &idd->vma->sbbr_h; | ||
446 | ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf; | ||
447 | DPRINT_CONFIG(("%s: ring_pci_addr 0x%p\n", | ||
448 | __FUNCTION__, (void *)ring_pci_addr)); | ||
449 | |||
450 | writel((unsigned int)((uint64_t) ring_pci_addr >> 32), sbbr_h); | ||
451 | writel((unsigned int)ring_pci_addr | BUF_SIZE_BIT, sbbr_l); | ||
452 | } | ||
453 | |||
454 | /* Set the receive timeout value to 10 msec */ | ||
455 | writel(SRTR_HZ / 100, &port->ip_serial_regs->srtr); | ||
456 | |||
457 | /* Set rx threshold, enable DMA */ | ||
458 | /* Set high water mark at 3/4 of full ring */ | ||
459 | port->ip_sscr = (ENTRIES_PER_RING * 3 / 4); | ||
460 | |||
461 | /* uart experiences pauses at high baud rate reducing actual | ||
462 | * throughput by 10% or so unless we enable high speed polling | ||
463 | * XXX when this hardware bug is resolved we should revert to | ||
464 | * normal polling speed | ||
465 | */ | ||
466 | port->ip_sscr |= SSCR_HIGH_SPD; | ||
467 | |||
468 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
469 | |||
470 | /* Disable and clear all serial related interrupt bits */ | ||
471 | port->ip_card->ic_enable &= ~hooks->intr_clear; | ||
472 | ioc3_disable(port->ip_is, idd, hooks->intr_clear); | ||
473 | ioc3_ack(port->ip_is, idd, hooks->intr_clear); | ||
474 | return 0; | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * enable_intrs - enable interrupts | ||
479 | * @port: port to enable | ||
480 | * @mask: mask to use | ||
481 | */ | ||
482 | static void enable_intrs(struct ioc3_port *port, uint32_t mask) | ||
483 | { | ||
484 | if ((port->ip_card->ic_enable & mask) != mask) { | ||
485 | port->ip_card->ic_enable |= mask; | ||
486 | ioc3_enable(port->ip_is, port->ip_idd, mask); | ||
487 | } | ||
488 | } | ||
489 | |||
490 | /** | ||
491 | * local_open - local open a port | ||
492 | * @port: port to open | ||
493 | */ | ||
494 | static inline int local_open(struct ioc3_port *port) | ||
495 | { | ||
496 | int spiniter = 0; | ||
497 | |||
498 | port->ip_flags = INPUT_ENABLE; | ||
499 | |||
500 | /* Pause the DMA interface if necessary */ | ||
501 | if (port->ip_sscr & SSCR_DMA_EN) { | ||
502 | writel(port->ip_sscr | SSCR_DMA_PAUSE, | ||
503 | &port->ip_serial_regs->sscr); | ||
504 | while ((readl(&port->ip_serial_regs->sscr) | ||
505 | & SSCR_PAUSE_STATE) == 0) { | ||
506 | spiniter++; | ||
507 | if (spiniter > MAXITER) { | ||
508 | NOT_PROGRESS(); | ||
509 | return -1; | ||
510 | } | ||
511 | } | ||
512 | } | ||
513 | |||
514 | /* Reset the input fifo. If the uart received chars while the port | ||
515 | * was closed and DMA is not enabled, the uart may have a bunch of | ||
516 | * chars hanging around in its rx fifo which will not be discarded | ||
517 | * by rclr in the upper layer. We must get rid of them here. | ||
518 | */ | ||
519 | writeb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR, | ||
520 | &port->ip_uart_regs->iu_fcr); | ||
521 | |||
522 | writeb(UART_LCR_WLEN8, &port->ip_uart_regs->iu_lcr); | ||
523 | /* UART_LCR_STOP == 1 stop */ | ||
524 | |||
525 | /* Re-enable DMA, set default threshold to intr whenever there is | ||
526 | * data available. | ||
527 | */ | ||
528 | port->ip_sscr &= ~SSCR_RX_THRESHOLD; | ||
529 | port->ip_sscr |= 1; /* default threshold */ | ||
530 | |||
531 | /* Plug in the new sscr. This implicitly clears the DMA_PAUSE | ||
532 | * flag if it was set above | ||
533 | */ | ||
534 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
535 | port->ip_tx_lowat = 1; | ||
536 | return 0; | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * set_rx_timeout - Set rx timeout and threshold values. | ||
541 | * @port: port to use | ||
542 | * @timeout: timeout value in ticks | ||
543 | */ | ||
544 | static inline int set_rx_timeout(struct ioc3_port *port, int timeout) | ||
545 | { | ||
546 | int threshold; | ||
547 | |||
548 | port->ip_rx_timeout = timeout; | ||
549 | |||
550 | /* Timeout is in ticks. Let's figure out how many chars we | ||
551 | * can receive at the current baud rate in that interval | ||
552 | * and set the rx threshold to that amount. There are 4 chars | ||
553 | * per ring entry, so we'll divide the number of chars that will | ||
554 | * arrive in timeout by 4. | ||
555 | * So .... timeout * baud / 10 / HZ / 4, with HZ = 100. | ||
556 | */ | ||
557 | threshold = timeout * port->ip_baud / 4000; | ||
558 | if (threshold == 0) | ||
559 | threshold = 1; /* otherwise we'll intr all the time! */ | ||
560 | |||
561 | if ((unsigned)threshold > (unsigned)SSCR_RX_THRESHOLD) | ||
562 | return 1; | ||
563 | |||
564 | port->ip_sscr &= ~SSCR_RX_THRESHOLD; | ||
565 | port->ip_sscr |= threshold; | ||
566 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
567 | |||
568 | /* Now set the rx timeout to the given value | ||
569 | * again timeout * SRTR_HZ / HZ | ||
570 | */ | ||
571 | timeout = timeout * SRTR_HZ / 100; | ||
572 | if (timeout > SRTR_CNT) | ||
573 | timeout = SRTR_CNT; | ||
574 | writel(timeout, &port->ip_serial_regs->srtr); | ||
575 | return 0; | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * config_port - config the hardware | ||
580 | * @port: port to config | ||
581 | * @baud: baud rate for the port | ||
582 | * @byte_size: data size | ||
583 | * @stop_bits: number of stop bits | ||
584 | * @parenb: parity enable ? | ||
585 | * @parodd: odd parity ? | ||
586 | */ | ||
587 | static inline int | ||
588 | config_port(struct ioc3_port *port, | ||
589 | int baud, int byte_size, int stop_bits, int parenb, int parodd) | ||
590 | { | ||
591 | char lcr, sizebits; | ||
592 | int spiniter = 0; | ||
593 | |||
594 | DPRINT_CONFIG(("%s: line %d baud %d byte_size %d stop %d parenb %d " | ||
595 | "parodd %d\n", | ||
596 | __FUNCTION__, ((struct uart_port *)port->ip_port)->line, | ||
597 | baud, byte_size, stop_bits, parenb, parodd)); | ||
598 | |||
599 | if (set_baud(port, baud)) | ||
600 | return 1; | ||
601 | |||
602 | switch (byte_size) { | ||
603 | case 5: | ||
604 | sizebits = UART_LCR_WLEN5; | ||
605 | break; | ||
606 | case 6: | ||
607 | sizebits = UART_LCR_WLEN6; | ||
608 | break; | ||
609 | case 7: | ||
610 | sizebits = UART_LCR_WLEN7; | ||
611 | break; | ||
612 | case 8: | ||
613 | sizebits = UART_LCR_WLEN8; | ||
614 | break; | ||
615 | default: | ||
616 | return 1; | ||
617 | } | ||
618 | |||
619 | /* Pause the DMA interface if necessary */ | ||
620 | if (port->ip_sscr & SSCR_DMA_EN) { | ||
621 | writel(port->ip_sscr | SSCR_DMA_PAUSE, | ||
622 | &port->ip_serial_regs->sscr); | ||
623 | while ((readl(&port->ip_serial_regs->sscr) | ||
624 | & SSCR_PAUSE_STATE) == 0) { | ||
625 | spiniter++; | ||
626 | if (spiniter > MAXITER) | ||
627 | return -1; | ||
628 | } | ||
629 | } | ||
630 | |||
631 | /* Clear relevant fields in lcr */ | ||
632 | lcr = readb(&port->ip_uart_regs->iu_lcr); | ||
633 | lcr &= ~(LCR_MASK_BITS_CHAR | UART_LCR_EPAR | | ||
634 | UART_LCR_PARITY | LCR_MASK_STOP_BITS); | ||
635 | |||
636 | /* Set byte size in lcr */ | ||
637 | lcr |= sizebits; | ||
638 | |||
639 | /* Set parity */ | ||
640 | if (parenb) { | ||
641 | lcr |= UART_LCR_PARITY; | ||
642 | if (!parodd) | ||
643 | lcr |= UART_LCR_EPAR; | ||
644 | } | ||
645 | |||
646 | /* Set stop bits */ | ||
647 | if (stop_bits) | ||
648 | lcr |= UART_LCR_STOP /* 2 stop bits */ ; | ||
649 | |||
650 | writeb(lcr, &port->ip_uart_regs->iu_lcr); | ||
651 | |||
652 | /* Re-enable the DMA interface if necessary */ | ||
653 | if (port->ip_sscr & SSCR_DMA_EN) { | ||
654 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
655 | } | ||
656 | port->ip_baud = baud; | ||
657 | |||
658 | /* When we get within this number of ring entries of filling the | ||
659 | * entire ring on tx, place an EXPLICIT intr to generate a lowat | ||
660 | * notification when output has drained. | ||
661 | */ | ||
662 | port->ip_tx_lowat = (TX_LOWAT_CHARS(baud) + 3) / 4; | ||
663 | if (port->ip_tx_lowat == 0) | ||
664 | port->ip_tx_lowat = 1; | ||
665 | |||
666 | set_rx_timeout(port, 2); | ||
667 | return 0; | ||
668 | } | ||
669 | |||
670 | /** | ||
671 | * do_write - Write bytes to the port. Returns the number of bytes | ||
672 | * actually written. Called from transmit_chars | ||
673 | * @port: port to use | ||
674 | * @buf: the stuff to write | ||
675 | * @len: how many bytes in 'buf' | ||
676 | */ | ||
677 | static inline int do_write(struct ioc3_port *port, char *buf, int len) | ||
678 | { | ||
679 | int prod_ptr, cons_ptr, total = 0; | ||
680 | struct ring *outring; | ||
681 | struct ring_entry *entry; | ||
682 | struct port_hooks *hooks = port->ip_hooks; | ||
683 | |||
684 | BUG_ON(!(len >= 0)); | ||
685 | |||
686 | prod_ptr = port->ip_tx_prod; | ||
687 | cons_ptr = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK; | ||
688 | outring = port->ip_outring; | ||
689 | |||
690 | /* Maintain a 1-entry red-zone. The ring buffer is full when | ||
691 | * (cons - prod) % ring_size is 1. Rather than do this subtraction | ||
692 | * in the body of the loop, I'll do it now. | ||
693 | */ | ||
694 | cons_ptr = (cons_ptr - (int)sizeof(struct ring_entry)) & PROD_CONS_MASK; | ||
695 | |||
696 | /* Stuff the bytes into the output */ | ||
697 | while ((prod_ptr != cons_ptr) && (len > 0)) { | ||
698 | int xx; | ||
699 | |||
700 | /* Get 4 bytes (one ring entry) at a time */ | ||
701 | entry = (struct ring_entry *)((caddr_t) outring + prod_ptr); | ||
702 | |||
703 | /* Invalidate all entries */ | ||
704 | entry->ring_allsc = 0; | ||
705 | |||
706 | /* Copy in some bytes */ | ||
707 | for (xx = 0; (xx < 4) && (len > 0); xx++) { | ||
708 | entry->ring_data[xx] = *buf++; | ||
709 | entry->ring_sc[xx] = TXCB_VALID; | ||
710 | len--; | ||
711 | total++; | ||
712 | } | ||
713 | |||
714 | /* If we are within some small threshold of filling up the | ||
715 | * entire ring buffer, we must place an EXPLICIT intr here | ||
716 | * to generate a lowat interrupt in case we subsequently | ||
717 | * really do fill up the ring and the caller goes to sleep. | ||
718 | * No need to place more than one though. | ||
719 | */ | ||
720 | if (!(port->ip_flags & LOWAT_WRITTEN) && | ||
721 | ((cons_ptr - prod_ptr) & PROD_CONS_MASK) | ||
722 | <= port->ip_tx_lowat * (int)sizeof(struct ring_entry)) { | ||
723 | port->ip_flags |= LOWAT_WRITTEN; | ||
724 | entry->ring_sc[0] |= TXCB_INT_WHEN_DONE; | ||
725 | } | ||
726 | |||
727 | /* Go on to next entry */ | ||
728 | prod_ptr += sizeof(struct ring_entry); | ||
729 | prod_ptr &= PROD_CONS_MASK; | ||
730 | } | ||
731 | |||
732 | /* If we sent something, start DMA if necessary */ | ||
733 | if (total > 0 && !(port->ip_sscr & SSCR_DMA_EN)) { | ||
734 | port->ip_sscr |= SSCR_DMA_EN; | ||
735 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
736 | } | ||
737 | |||
738 | /* Store the new producer pointer. If tx is disabled, we stuff the | ||
739 | * data into the ring buffer, but we don't actually start tx. | ||
740 | */ | ||
741 | if (!uart_tx_stopped(port->ip_port)) { | ||
742 | writel(prod_ptr, &port->ip_serial_regs->stpir); | ||
743 | |||
744 | /* If we are now transmitting, enable tx_mt interrupt so we | ||
745 | * can disable DMA if necessary when the tx finishes. | ||
746 | */ | ||
747 | if (total > 0) | ||
748 | enable_intrs(port, hooks->intr_tx_mt); | ||
749 | } | ||
750 | port->ip_tx_prod = prod_ptr; | ||
751 | |||
752 | return total; | ||
753 | } | ||
754 | |||
755 | /** | ||
756 | * disable_intrs - disable interrupts | ||
757 | * @port: port to enable | ||
758 | * @mask: mask to use | ||
759 | */ | ||
760 | static inline void disable_intrs(struct ioc3_port *port, uint32_t mask) | ||
761 | { | ||
762 | if (port->ip_card->ic_enable & mask) { | ||
763 | ioc3_disable(port->ip_is, port->ip_idd, mask); | ||
764 | port->ip_card->ic_enable &= ~mask; | ||
765 | } | ||
766 | } | ||
767 | |||
768 | /** | ||
769 | * set_notification - Modify event notification | ||
770 | * @port: port to use | ||
771 | * @mask: events mask | ||
772 | * @set_on: set ? | ||
773 | */ | ||
774 | static int set_notification(struct ioc3_port *port, int mask, int set_on) | ||
775 | { | ||
776 | struct port_hooks *hooks = port->ip_hooks; | ||
777 | uint32_t intrbits, sscrbits; | ||
778 | |||
779 | BUG_ON(!mask); | ||
780 | |||
781 | intrbits = sscrbits = 0; | ||
782 | |||
783 | if (mask & N_DATA_READY) | ||
784 | intrbits |= (hooks->intr_rx_timer | hooks->intr_rx_high); | ||
785 | if (mask & N_OUTPUT_LOWAT) | ||
786 | intrbits |= hooks->intr_tx_explicit; | ||
787 | if (mask & N_DDCD) { | ||
788 | intrbits |= hooks->intr_delta_dcd; | ||
789 | sscrbits |= SSCR_RX_RING_DCD; | ||
790 | } | ||
791 | if (mask & N_DCTS) | ||
792 | intrbits |= hooks->intr_delta_cts; | ||
793 | |||
794 | if (set_on) { | ||
795 | enable_intrs(port, intrbits); | ||
796 | port->ip_notify |= mask; | ||
797 | port->ip_sscr |= sscrbits; | ||
798 | } else { | ||
799 | disable_intrs(port, intrbits); | ||
800 | port->ip_notify &= ~mask; | ||
801 | port->ip_sscr &= ~sscrbits; | ||
802 | } | ||
803 | |||
804 | /* We require DMA if either DATA_READY or DDCD notification is | ||
805 | * currently requested. If neither of these is requested and | ||
806 | * there is currently no tx in progress, DMA may be disabled. | ||
807 | */ | ||
808 | if (port->ip_notify & (N_DATA_READY | N_DDCD)) | ||
809 | port->ip_sscr |= SSCR_DMA_EN; | ||
810 | else if (!(port->ip_card->ic_enable & hooks->intr_tx_mt)) | ||
811 | port->ip_sscr &= ~SSCR_DMA_EN; | ||
812 | |||
813 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
814 | return 0; | ||
815 | } | ||
816 | |||
817 | /** | ||
818 | * set_mcr - set the master control reg | ||
819 | * @the_port: port to use | ||
820 | * @mask1: mcr mask | ||
821 | * @mask2: shadow mask | ||
822 | */ | ||
823 | static inline int set_mcr(struct uart_port *the_port, | ||
824 | int mask1, int mask2) | ||
825 | { | ||
826 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
827 | uint32_t shadow; | ||
828 | int spiniter = 0; | ||
829 | char mcr; | ||
830 | |||
831 | if (!port) | ||
832 | return -1; | ||
833 | |||
834 | /* Pause the DMA interface if necessary */ | ||
835 | if (port->ip_sscr & SSCR_DMA_EN) { | ||
836 | writel(port->ip_sscr | SSCR_DMA_PAUSE, | ||
837 | &port->ip_serial_regs->sscr); | ||
838 | while ((readl(&port->ip_serial_regs->sscr) | ||
839 | & SSCR_PAUSE_STATE) == 0) { | ||
840 | spiniter++; | ||
841 | if (spiniter > MAXITER) | ||
842 | return -1; | ||
843 | } | ||
844 | } | ||
845 | shadow = readl(&port->ip_serial_regs->shadow); | ||
846 | mcr = (shadow & 0xff000000) >> 24; | ||
847 | |||
848 | /* Set new value */ | ||
849 | mcr |= mask1; | ||
850 | shadow |= mask2; | ||
851 | writeb(mcr, &port->ip_uart_regs->iu_mcr); | ||
852 | writel(shadow, &port->ip_serial_regs->shadow); | ||
853 | |||
854 | /* Re-enable the DMA interface if necessary */ | ||
855 | if (port->ip_sscr & SSCR_DMA_EN) { | ||
856 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
857 | } | ||
858 | return 0; | ||
859 | } | ||
860 | |||
861 | /** | ||
862 | * ioc3_set_proto - set the protocol for the port | ||
863 | * @port: port to use | ||
864 | * @proto: protocol to use | ||
865 | */ | ||
866 | static int ioc3_set_proto(struct ioc3_port *port, int proto) | ||
867 | { | ||
868 | struct port_hooks *hooks = port->ip_hooks; | ||
869 | |||
870 | switch (proto) { | ||
871 | default: | ||
872 | case PROTO_RS232: | ||
873 | /* Clear the appropriate GIO pin */ | ||
874 | DPRINT_CONFIG(("%s: rs232\n", __FUNCTION__)); | ||
875 | writel(0, (&port->ip_idd->vma->gppr[0] | ||
876 | + hooks->rs422_select_pin)); | ||
877 | break; | ||
878 | |||
879 | case PROTO_RS422: | ||
880 | /* Set the appropriate GIO pin */ | ||
881 | DPRINT_CONFIG(("%s: rs422\n", __FUNCTION__)); | ||
882 | writel(1, (&port->ip_idd->vma->gppr[0] | ||
883 | + hooks->rs422_select_pin)); | ||
884 | break; | ||
885 | } | ||
886 | return 0; | ||
887 | } | ||
888 | |||
889 | /** | ||
890 | * transmit_chars - upper level write, called with the_port->lock | ||
891 | * @the_port: port to write | ||
892 | */ | ||
893 | static void transmit_chars(struct uart_port *the_port) | ||
894 | { | ||
895 | int xmit_count, tail, head; | ||
896 | int result; | ||
897 | char *start; | ||
898 | struct tty_struct *tty; | ||
899 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
900 | struct uart_info *info; | ||
901 | |||
902 | if (!the_port) | ||
903 | return; | ||
904 | if (!port) | ||
905 | return; | ||
906 | |||
907 | info = the_port->info; | ||
908 | tty = info->tty; | ||
909 | |||
910 | if (uart_circ_empty(&info->xmit) || uart_tx_stopped(the_port)) { | ||
911 | /* Nothing to do or hw stopped */ | ||
912 | set_notification(port, N_ALL_OUTPUT, 0); | ||
913 | return; | ||
914 | } | ||
915 | |||
916 | head = info->xmit.head; | ||
917 | tail = info->xmit.tail; | ||
918 | start = (char *)&info->xmit.buf[tail]; | ||
919 | |||
920 | /* write out all the data or until the end of the buffer */ | ||
921 | xmit_count = (head < tail) ? (UART_XMIT_SIZE - tail) : (head - tail); | ||
922 | if (xmit_count > 0) { | ||
923 | result = do_write(port, start, xmit_count); | ||
924 | if (result > 0) { | ||
925 | /* booking */ | ||
926 | xmit_count -= result; | ||
927 | the_port->icount.tx += result; | ||
928 | /* advance the pointers */ | ||
929 | tail += result; | ||
930 | tail &= UART_XMIT_SIZE - 1; | ||
931 | info->xmit.tail = tail; | ||
932 | start = (char *)&info->xmit.buf[tail]; | ||
933 | } | ||
934 | } | ||
935 | if (uart_circ_chars_pending(&info->xmit) < WAKEUP_CHARS) | ||
936 | uart_write_wakeup(the_port); | ||
937 | |||
938 | if (uart_circ_empty(&info->xmit)) { | ||
939 | set_notification(port, N_OUTPUT_LOWAT, 0); | ||
940 | } else { | ||
941 | set_notification(port, N_OUTPUT_LOWAT, 1); | ||
942 | } | ||
943 | } | ||
944 | |||
945 | /** | ||
946 | * ioc3_change_speed - change the speed of the port | ||
947 | * @the_port: port to change | ||
948 | * @new_termios: new termios settings | ||
949 | * @old_termios: old termios settings | ||
950 | */ | ||
951 | static void | ||
952 | ioc3_change_speed(struct uart_port *the_port, | ||
953 | struct termios *new_termios, struct termios *old_termios) | ||
954 | { | ||
955 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
956 | unsigned int cflag; | ||
957 | int baud; | ||
958 | int new_parity = 0, new_parity_enable = 0, new_stop = 0, new_data = 8; | ||
959 | struct uart_info *info = the_port->info; | ||
960 | |||
961 | cflag = new_termios->c_cflag; | ||
962 | |||
963 | switch (cflag & CSIZE) { | ||
964 | case CS5: | ||
965 | new_data = 5; | ||
966 | break; | ||
967 | case CS6: | ||
968 | new_data = 6; | ||
969 | break; | ||
970 | case CS7: | ||
971 | new_data = 7; | ||
972 | break; | ||
973 | case CS8: | ||
974 | new_data = 8; | ||
975 | break; | ||
976 | default: | ||
977 | /* cuz we always need a default ... */ | ||
978 | new_data = 5; | ||
979 | break; | ||
980 | } | ||
981 | if (cflag & CSTOPB) { | ||
982 | new_stop = 1; | ||
983 | } | ||
984 | if (cflag & PARENB) { | ||
985 | new_parity_enable = 1; | ||
986 | if (cflag & PARODD) | ||
987 | new_parity = 1; | ||
988 | } | ||
989 | baud = uart_get_baud_rate(the_port, new_termios, old_termios, | ||
990 | MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); | ||
991 | DPRINT_CONFIG(("%s: returned baud %d for line %d\n", __FUNCTION__, baud, | ||
992 | the_port->line)); | ||
993 | |||
994 | if (!the_port->fifosize) | ||
995 | the_port->fifosize = FIFO_SIZE; | ||
996 | uart_update_timeout(the_port, cflag, baud); | ||
997 | |||
998 | the_port->ignore_status_mask = N_ALL_INPUT; | ||
999 | |||
1000 | info->tty->low_latency = 1; | ||
1001 | |||
1002 | if (I_IGNPAR(info->tty)) | ||
1003 | the_port->ignore_status_mask &= ~(N_PARITY_ERROR | ||
1004 | | N_FRAMING_ERROR); | ||
1005 | if (I_IGNBRK(info->tty)) { | ||
1006 | the_port->ignore_status_mask &= ~N_BREAK; | ||
1007 | if (I_IGNPAR(info->tty)) | ||
1008 | the_port->ignore_status_mask &= ~N_OVERRUN_ERROR; | ||
1009 | } | ||
1010 | if (!(cflag & CREAD)) { | ||
1011 | /* ignore everything */ | ||
1012 | the_port->ignore_status_mask &= ~N_DATA_READY; | ||
1013 | } | ||
1014 | |||
1015 | if (cflag & CRTSCTS) { | ||
1016 | /* enable hardware flow control */ | ||
1017 | port->ip_sscr |= SSCR_HFC_EN; | ||
1018 | } | ||
1019 | else { | ||
1020 | /* disable hardware flow control */ | ||
1021 | port->ip_sscr &= ~SSCR_HFC_EN; | ||
1022 | } | ||
1023 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
1024 | |||
1025 | /* Set the configuration and proper notification call */ | ||
1026 | DPRINT_CONFIG(("%s : port 0x%p line %d cflag 0%o " | ||
1027 | "config_port(baud %d data %d stop %d penable %d " | ||
1028 | " parity %d), notification 0x%x\n", | ||
1029 | __FUNCTION__, (void *)port, the_port->line, cflag, baud, | ||
1030 | new_data, new_stop, new_parity_enable, new_parity, | ||
1031 | the_port->ignore_status_mask)); | ||
1032 | |||
1033 | if ((config_port(port, baud, /* baud */ | ||
1034 | new_data, /* byte size */ | ||
1035 | new_stop, /* stop bits */ | ||
1036 | new_parity_enable, /* set parity */ | ||
1037 | new_parity)) >= 0) { /* parity 1==odd */ | ||
1038 | set_notification(port, the_port->ignore_status_mask, 1); | ||
1039 | } | ||
1040 | } | ||
1041 | |||
1042 | /** | ||
1043 | * ic3_startup_local - Start up the serial port - returns >= 0 if no errors | ||
1044 | * @the_port: Port to operate on | ||
1045 | */ | ||
1046 | static inline int ic3_startup_local(struct uart_port *the_port) | ||
1047 | { | ||
1048 | struct ioc3_port *port; | ||
1049 | |||
1050 | if (!the_port) { | ||
1051 | NOT_PROGRESS(); | ||
1052 | return -1; | ||
1053 | } | ||
1054 | |||
1055 | port = get_ioc3_port(the_port); | ||
1056 | if (!port) { | ||
1057 | NOT_PROGRESS(); | ||
1058 | return -1; | ||
1059 | } | ||
1060 | |||
1061 | local_open(port); | ||
1062 | |||
1063 | /* set the protocol */ | ||
1064 | ioc3_set_proto(port, IS_RS232(the_port->line) ? PROTO_RS232 : | ||
1065 | PROTO_RS422); | ||
1066 | return 0; | ||
1067 | } | ||
1068 | |||
1069 | /* | ||
1070 | * ioc3_cb_output_lowat - called when the output low water mark is hit | ||
1071 | * @port: port to output | ||
1072 | */ | ||
1073 | static void ioc3_cb_output_lowat(struct ioc3_port *port) | ||
1074 | { | ||
1075 | unsigned long pflags; | ||
1076 | |||
1077 | /* the_port->lock is set on the call here */ | ||
1078 | if (port->ip_port) { | ||
1079 | spin_lock_irqsave(&port->ip_port->lock, pflags); | ||
1080 | transmit_chars(port->ip_port); | ||
1081 | spin_unlock_irqrestore(&port->ip_port->lock, pflags); | ||
1082 | } | ||
1083 | } | ||
1084 | |||
1085 | /* | ||
1086 | * ioc3_cb_post_ncs - called for some basic errors | ||
1087 | * @port: port to use | ||
1088 | * @ncs: event | ||
1089 | */ | ||
1090 | static void ioc3_cb_post_ncs(struct uart_port *the_port, int ncs) | ||
1091 | { | ||
1092 | struct uart_icount *icount; | ||
1093 | |||
1094 | icount = &the_port->icount; | ||
1095 | |||
1096 | if (ncs & NCS_BREAK) | ||
1097 | icount->brk++; | ||
1098 | if (ncs & NCS_FRAMING) | ||
1099 | icount->frame++; | ||
1100 | if (ncs & NCS_OVERRUN) | ||
1101 | icount->overrun++; | ||
1102 | if (ncs & NCS_PARITY) | ||
1103 | icount->parity++; | ||
1104 | } | ||
1105 | |||
1106 | /** | ||
1107 | * do_read - Read in bytes from the port. Return the number of bytes | ||
1108 | * actually read. | ||
1109 | * @the_port: port to use | ||
1110 | * @buf: place to put the stuff we read | ||
1111 | * @len: how big 'buf' is | ||
1112 | */ | ||
1113 | |||
1114 | static inline int do_read(struct uart_port *the_port, char *buf, int len) | ||
1115 | { | ||
1116 | int prod_ptr, cons_ptr, total; | ||
1117 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
1118 | struct ring *inring; | ||
1119 | struct ring_entry *entry; | ||
1120 | struct port_hooks *hooks = port->ip_hooks; | ||
1121 | int byte_num; | ||
1122 | char *sc; | ||
1123 | int loop_counter; | ||
1124 | |||
1125 | BUG_ON(!(len >= 0)); | ||
1126 | BUG_ON(!port); | ||
1127 | |||
1128 | /* There is a nasty timing issue in the IOC3. When the rx_timer | ||
1129 | * expires or the rx_high condition arises, we take an interrupt. | ||
1130 | * At some point while servicing the interrupt, we read bytes from | ||
1131 | * the ring buffer and re-arm the rx_timer. However the rx_timer is | ||
1132 | * not started until the first byte is received *after* it is armed, | ||
1133 | * and any bytes pending in the rx construction buffers are not drained | ||
1134 | * to memory until either there are 4 bytes available or the rx_timer | ||
1135 | * expires. This leads to a potential situation where data is left | ||
1136 | * in the construction buffers forever - 1 to 3 bytes were received | ||
1137 | * after the interrupt was generated but before the rx_timer was | ||
1138 | * re-armed. At that point as long as no subsequent bytes are received | ||
1139 | * the timer will never be started and the bytes will remain in the | ||
1140 | * construction buffer forever. The solution is to execute a DRAIN | ||
1141 | * command after rearming the timer. This way any bytes received before | ||
1142 | * the DRAIN will be drained to memory, and any bytes received after | ||
1143 | * the DRAIN will start the TIMER and be drained when it expires. | ||
1144 | * Luckily, this only needs to be done when the DMA buffer is empty | ||
1145 | * since there is no requirement that this function return all | ||
1146 | * available data as long as it returns some. | ||
1147 | */ | ||
1148 | /* Re-arm the timer */ | ||
1149 | |||
1150 | writel(port->ip_rx_cons | SRCIR_ARM, &port->ip_serial_regs->srcir); | ||
1151 | |||
1152 | prod_ptr = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK; | ||
1153 | cons_ptr = port->ip_rx_cons; | ||
1154 | |||
1155 | if (prod_ptr == cons_ptr) { | ||
1156 | int reset_dma = 0; | ||
1157 | |||
1158 | /* Input buffer appears empty, do a flush. */ | ||
1159 | |||
1160 | /* DMA must be enabled for this to work. */ | ||
1161 | if (!(port->ip_sscr & SSCR_DMA_EN)) { | ||
1162 | port->ip_sscr |= SSCR_DMA_EN; | ||
1163 | reset_dma = 1; | ||
1164 | } | ||
1165 | |||
1166 | /* Potential race condition: we must reload the srpir after | ||
1167 | * issuing the drain command, otherwise we could think the rx | ||
1168 | * buffer is empty, then take a very long interrupt, and when | ||
1169 | * we come back it's full and we wait forever for the drain to | ||
1170 | * complete. | ||
1171 | */ | ||
1172 | writel(port->ip_sscr | SSCR_RX_DRAIN, | ||
1173 | &port->ip_serial_regs->sscr); | ||
1174 | prod_ptr = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK; | ||
1175 | |||
1176 | /* We must not wait for the DRAIN to complete unless there are | ||
1177 | * at least 8 bytes (2 ring entries) available to receive the | ||
1178 | * data otherwise the DRAIN will never complete and we'll | ||
1179 | * deadlock here. | ||
1180 | * In fact, to make things easier, I'll just ignore the flush if | ||
1181 | * there is any data at all now available. | ||
1182 | */ | ||
1183 | if (prod_ptr == cons_ptr) { | ||
1184 | loop_counter = 0; | ||
1185 | while (readl(&port->ip_serial_regs->sscr) & | ||
1186 | SSCR_RX_DRAIN) { | ||
1187 | loop_counter++; | ||
1188 | if (loop_counter > MAXITER) | ||
1189 | return -1; | ||
1190 | } | ||
1191 | |||
1192 | /* SIGH. We have to reload the prod_ptr *again* since | ||
1193 | * the drain may have caused it to change | ||
1194 | */ | ||
1195 | prod_ptr = readl(&port->ip_serial_regs->srpir) | ||
1196 | & PROD_CONS_MASK; | ||
1197 | } | ||
1198 | if (reset_dma) { | ||
1199 | port->ip_sscr &= ~SSCR_DMA_EN; | ||
1200 | writel(port->ip_sscr, &port->ip_serial_regs->sscr); | ||
1201 | } | ||
1202 | } | ||
1203 | inring = port->ip_inring; | ||
1204 | port->ip_flags &= ~READ_ABORTED; | ||
1205 | |||
1206 | total = 0; | ||
1207 | loop_counter = 0xfffff; /* to avoid hangs */ | ||
1208 | |||
1209 | /* Grab bytes from the hardware */ | ||
1210 | while ((prod_ptr != cons_ptr) && (len > 0)) { | ||
1211 | entry = (struct ring_entry *)((caddr_t) inring + cons_ptr); | ||
1212 | |||
1213 | if (loop_counter-- <= 0) { | ||
1214 | printk(KERN_WARNING "IOC3 serial: " | ||
1215 | "possible hang condition/" | ||
1216 | "port stuck on read (line %d).\n", | ||
1217 | the_port->line); | ||
1218 | break; | ||
1219 | } | ||
1220 | |||
1221 | /* According to the producer pointer, this ring entry | ||
1222 | * must contain some data. But if the PIO happened faster | ||
1223 | * than the DMA, the data may not be available yet, so let's | ||
1224 | * wait until it arrives. | ||
1225 | */ | ||
1226 | if ((entry->ring_allsc & RING_ANY_VALID) == 0) { | ||
1227 | /* Indicate the read is aborted so we don't disable | ||
1228 | * the interrupt thinking that the consumer is | ||
1229 | * congested. | ||
1230 | */ | ||
1231 | port->ip_flags |= READ_ABORTED; | ||
1232 | len = 0; | ||
1233 | break; | ||
1234 | } | ||
1235 | |||
1236 | /* Load the bytes/status out of the ring entry */ | ||
1237 | for (byte_num = 0; byte_num < 4 && len > 0; byte_num++) { | ||
1238 | sc = &(entry->ring_sc[byte_num]); | ||
1239 | |||
1240 | /* Check for change in modem state or overrun */ | ||
1241 | if ((*sc & RXSB_MODEM_VALID) | ||
1242 | && (port->ip_notify & N_DDCD)) { | ||
1243 | /* Notify upper layer if DCD dropped */ | ||
1244 | if ((port->ip_flags & DCD_ON) | ||
1245 | && !(*sc & RXSB_DCD)) { | ||
1246 | /* If we have already copied some data, | ||
1247 | * return it. We'll pick up the carrier | ||
1248 | * drop on the next pass. That way we | ||
1249 | * don't throw away the data that has | ||
1250 | * already been copied back to | ||
1251 | * the caller's buffer. | ||
1252 | */ | ||
1253 | if (total > 0) { | ||
1254 | len = 0; | ||
1255 | break; | ||
1256 | } | ||
1257 | port->ip_flags &= ~DCD_ON; | ||
1258 | |||
1259 | /* Turn off this notification so the | ||
1260 | * carrier drop protocol won't see it | ||
1261 | * again when it does a read. | ||
1262 | */ | ||
1263 | *sc &= ~RXSB_MODEM_VALID; | ||
1264 | |||
1265 | /* To keep things consistent, we need | ||
1266 | * to update the consumer pointer so | ||
1267 | * the next reader won't come in and | ||
1268 | * try to read the same ring entries | ||
1269 | * again. This must be done here before | ||
1270 | * the dcd change. | ||
1271 | */ | ||
1272 | |||
1273 | if ((entry->ring_allsc & RING_ANY_VALID) | ||
1274 | == 0) { | ||
1275 | cons_ptr += (int)sizeof | ||
1276 | (struct ring_entry); | ||
1277 | cons_ptr &= PROD_CONS_MASK; | ||
1278 | } | ||
1279 | writel(cons_ptr, | ||
1280 | &port->ip_serial_regs->srcir); | ||
1281 | port->ip_rx_cons = cons_ptr; | ||
1282 | |||
1283 | /* Notify upper layer of carrier drop */ | ||
1284 | if ((port->ip_notify & N_DDCD) | ||
1285 | && port->ip_port) { | ||
1286 | uart_handle_dcd_change | ||
1287 | (port->ip_port, 0); | ||
1288 | wake_up_interruptible | ||
1289 | (&the_port->info-> | ||
1290 | delta_msr_wait); | ||
1291 | } | ||
1292 | |||
1293 | /* If we had any data to return, we | ||
1294 | * would have returned it above. | ||
1295 | */ | ||
1296 | return 0; | ||
1297 | } | ||
1298 | } | ||
1299 | if (*sc & RXSB_MODEM_VALID) { | ||
1300 | /* Notify that an input overrun occurred */ | ||
1301 | if ((*sc & RXSB_OVERRUN) | ||
1302 | && (port->ip_notify & N_OVERRUN_ERROR)) { | ||
1303 | ioc3_cb_post_ncs(the_port, NCS_OVERRUN); | ||
1304 | } | ||
1305 | /* Don't look at this byte again */ | ||
1306 | *sc &= ~RXSB_MODEM_VALID; | ||
1307 | } | ||
1308 | |||
1309 | /* Check for valid data or RX errors */ | ||
1310 | if ((*sc & RXSB_DATA_VALID) && | ||
1311 | ((*sc & (RXSB_PAR_ERR | ||
1312 | | RXSB_FRAME_ERR | RXSB_BREAK)) | ||
1313 | && (port->ip_notify & (N_PARITY_ERROR | ||
1314 | | N_FRAMING_ERROR | ||
1315 | | N_BREAK)))) { | ||
1316 | /* There is an error condition on the next byte. | ||
1317 | * If we have already transferred some bytes, | ||
1318 | * we'll stop here. Otherwise if this is the | ||
1319 | * first byte to be read, we'll just transfer | ||
1320 | * it alone after notifying the | ||
1321 | * upper layer of its status. | ||
1322 | */ | ||
1323 | if (total > 0) { | ||
1324 | len = 0; | ||
1325 | break; | ||
1326 | } else { | ||
1327 | if ((*sc & RXSB_PAR_ERR) && | ||
1328 | (port-> | ||
1329 | ip_notify & N_PARITY_ERROR)) { | ||
1330 | ioc3_cb_post_ncs(the_port, | ||
1331 | NCS_PARITY); | ||
1332 | } | ||
1333 | if ((*sc & RXSB_FRAME_ERR) && | ||
1334 | (port-> | ||
1335 | ip_notify & N_FRAMING_ERROR)) { | ||
1336 | ioc3_cb_post_ncs(the_port, | ||
1337 | NCS_FRAMING); | ||
1338 | } | ||
1339 | if ((*sc & RXSB_BREAK) | ||
1340 | && (port->ip_notify & N_BREAK)) { | ||
1341 | ioc3_cb_post_ncs | ||
1342 | (the_port, NCS_BREAK); | ||
1343 | } | ||
1344 | len = 1; | ||
1345 | } | ||
1346 | } | ||
1347 | if (*sc & RXSB_DATA_VALID) { | ||
1348 | *sc &= ~RXSB_DATA_VALID; | ||
1349 | *buf = entry->ring_data[byte_num]; | ||
1350 | buf++; | ||
1351 | len--; | ||
1352 | total++; | ||
1353 | } | ||
1354 | } | ||
1355 | |||
1356 | /* If we used up this entry entirely, go on to the next one, | ||
1357 | * otherwise we must have run out of buffer space, so | ||
1358 | * leave the consumer pointer here for the next read in case | ||
1359 | * there are still unread bytes in this entry. | ||
1360 | */ | ||
1361 | if ((entry->ring_allsc & RING_ANY_VALID) == 0) { | ||
1362 | cons_ptr += (int)sizeof(struct ring_entry); | ||
1363 | cons_ptr &= PROD_CONS_MASK; | ||
1364 | } | ||
1365 | } | ||
1366 | |||
1367 | /* Update consumer pointer and re-arm rx timer interrupt */ | ||
1368 | writel(cons_ptr, &port->ip_serial_regs->srcir); | ||
1369 | port->ip_rx_cons = cons_ptr; | ||
1370 | |||
1371 | /* If we have now dipped below the rx high water mark and we have | ||
1372 | * rx_high interrupt turned off, we can now turn it back on again. | ||
1373 | */ | ||
1374 | if ((port->ip_flags & INPUT_HIGH) && (((prod_ptr - cons_ptr) | ||
1375 | & PROD_CONS_MASK) < | ||
1376 | ((port-> | ||
1377 | ip_sscr & | ||
1378 | SSCR_RX_THRESHOLD) | ||
1379 | << PROD_CONS_PTR_OFF))) { | ||
1380 | port->ip_flags &= ~INPUT_HIGH; | ||
1381 | enable_intrs(port, hooks->intr_rx_high); | ||
1382 | } | ||
1383 | return total; | ||
1384 | } | ||
1385 | |||
1386 | /** | ||
1387 | * receive_chars - upper level read. | ||
1388 | * @the_port: port to read from | ||
1389 | */ | ||
1390 | static int receive_chars(struct uart_port *the_port) | ||
1391 | { | ||
1392 | struct tty_struct *tty; | ||
1393 | unsigned char ch[MAX_CHARS]; | ||
1394 | int read_count = 0, read_room, flip = 0; | ||
1395 | struct uart_info *info = the_port->info; | ||
1396 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
1397 | unsigned long pflags; | ||
1398 | |||
1399 | /* Make sure all the pointers are "good" ones */ | ||
1400 | if (!info) | ||
1401 | return 0; | ||
1402 | if (!info->tty) | ||
1403 | return 0; | ||
1404 | |||
1405 | if (!(port->ip_flags & INPUT_ENABLE)) | ||
1406 | return 0; | ||
1407 | |||
1408 | spin_lock_irqsave(&the_port->lock, pflags); | ||
1409 | tty = info->tty; | ||
1410 | |||
1411 | read_count = do_read(the_port, ch, MAX_CHARS); | ||
1412 | if (read_count > 0) { | ||
1413 | flip = 1; | ||
1414 | read_room = tty_buffer_request_room(tty, read_count); | ||
1415 | tty_insert_flip_string(tty, ch, read_room); | ||
1416 | the_port->icount.rx += read_count; | ||
1417 | } | ||
1418 | spin_unlock_irqrestore(&the_port->lock, pflags); | ||
1419 | |||
1420 | if (flip) | ||
1421 | tty_flip_buffer_push(tty); | ||
1422 | |||
1423 | return read_count; | ||
1424 | } | ||
1425 | |||
1426 | /** | ||
1427 | * ioc3uart_intr_one - lowest level (per port) interrupt handler. | ||
1428 | * @is : submodule | ||
1429 | * @idd: driver data | ||
1430 | * @pending: interrupts to handle | ||
1431 | * @regs: pt_regs | ||
1432 | */ | ||
1433 | |||
1434 | static int inline | ||
1435 | ioc3uart_intr_one(struct ioc3_submodule *is, | ||
1436 | struct ioc3_driver_data *idd, | ||
1437 | unsigned int pending, struct pt_regs *regs) | ||
1438 | { | ||
1439 | int port_num = GET_PORT_FROM_SIO_IR(pending); | ||
1440 | struct port_hooks *hooks; | ||
1441 | unsigned int rx_high_rd_aborted = 0; | ||
1442 | unsigned long flags; | ||
1443 | struct uart_port *the_port; | ||
1444 | struct ioc3_port *port; | ||
1445 | int loop_counter; | ||
1446 | struct ioc3_card *card_ptr; | ||
1447 | unsigned int sio_ir; | ||
1448 | |||
1449 | card_ptr = idd->data[is->id]; | ||
1450 | port = card_ptr->ic_port[port_num].icp_port; | ||
1451 | hooks = port->ip_hooks; | ||
1452 | |||
1453 | /* Possible race condition here: The tx_mt interrupt bit may be | ||
1454 | * cleared without the intervention of the interrupt handler, | ||
1455 | * e.g. by a write. If the top level interrupt handler reads a | ||
1456 | * tx_mt, then some other processor does a write, starting up | ||
1457 | * output, then we come in here, see the tx_mt and stop DMA, the | ||
1458 | * output started by the other processor will hang. Thus we can | ||
1459 | * only rely on tx_mt being legitimate if it is read while the | ||
1460 | * port lock is held. Therefore this bit must be ignored in the | ||
1461 | * passed in interrupt mask which was read by the top level | ||
1462 | * interrupt handler since the port lock was not held at the time | ||
1463 | * it was read. We can only rely on this bit being accurate if it | ||
1464 | * is read while the port lock is held. So we'll clear it for now, | ||
1465 | * and reload it later once we have the port lock. | ||
1466 | */ | ||
1467 | |||
1468 | sio_ir = pending & ~(hooks->intr_tx_mt); | ||
1469 | spin_lock_irqsave(&port->ip_lock, flags); | ||
1470 | |||
1471 | loop_counter = MAXITER; /* to avoid hangs */ | ||
1472 | |||
1473 | do { | ||
1474 | uint32_t shadow; | ||
1475 | |||
1476 | if (loop_counter-- <= 0) { | ||
1477 | printk(KERN_WARNING "IOC3 serial: " | ||
1478 | "possible hang condition/" | ||
1479 | "port stuck on interrupt (line %d).\n", | ||
1480 | ((struct uart_port *)port->ip_port)->line); | ||
1481 | break; | ||
1482 | } | ||
1483 | /* Handle a DCD change */ | ||
1484 | if (sio_ir & hooks->intr_delta_dcd) { | ||
1485 | ioc3_ack(is, idd, hooks->intr_delta_dcd); | ||
1486 | shadow = readl(&port->ip_serial_regs->shadow); | ||
1487 | |||
1488 | if ((port->ip_notify & N_DDCD) | ||
1489 | && (shadow & SHADOW_DCD) | ||
1490 | && (port->ip_port)) { | ||
1491 | the_port = port->ip_port; | ||
1492 | uart_handle_dcd_change(the_port, | ||
1493 | shadow & SHADOW_DCD); | ||
1494 | wake_up_interruptible | ||
1495 | (&the_port->info->delta_msr_wait); | ||
1496 | } else if ((port->ip_notify & N_DDCD) | ||
1497 | && !(shadow & SHADOW_DCD)) { | ||
1498 | /* Flag delta DCD/no DCD */ | ||
1499 | uart_handle_dcd_change(port->ip_port, | ||
1500 | shadow & SHADOW_DCD); | ||
1501 | port->ip_flags |= DCD_ON; | ||
1502 | } | ||
1503 | } | ||
1504 | |||
1505 | /* Handle a CTS change */ | ||
1506 | if (sio_ir & hooks->intr_delta_cts) { | ||
1507 | ioc3_ack(is, idd, hooks->intr_delta_cts); | ||
1508 | shadow = readl(&port->ip_serial_regs->shadow); | ||
1509 | |||
1510 | if ((port->ip_notify & N_DCTS) && (port->ip_port)) { | ||
1511 | the_port = port->ip_port; | ||
1512 | uart_handle_cts_change(the_port, shadow | ||
1513 | & SHADOW_CTS); | ||
1514 | wake_up_interruptible | ||
1515 | (&the_port->info->delta_msr_wait); | ||
1516 | } | ||
1517 | } | ||
1518 | |||
1519 | /* rx timeout interrupt. Must be some data available. Put this | ||
1520 | * before the check for rx_high since servicing this condition | ||
1521 | * may cause that condition to clear. | ||
1522 | */ | ||
1523 | if (sio_ir & hooks->intr_rx_timer) { | ||
1524 | ioc3_ack(is, idd, hooks->intr_rx_timer); | ||
1525 | if ((port->ip_notify & N_DATA_READY) | ||
1526 | && (port->ip_port)) { | ||
1527 | receive_chars(port->ip_port); | ||
1528 | } | ||
1529 | } | ||
1530 | |||
1531 | /* rx high interrupt. Must be after rx_timer. */ | ||
1532 | else if (sio_ir & hooks->intr_rx_high) { | ||
1533 | /* Data available, notify upper layer */ | ||
1534 | if ((port->ip_notify & N_DATA_READY) && port->ip_port) { | ||
1535 | receive_chars(port->ip_port); | ||
1536 | } | ||
1537 | |||
1538 | /* We can't ACK this interrupt. If receive_chars didn't | ||
1539 | * cause the condition to clear, we'll have to disable | ||
1540 | * the interrupt until the data is drained. | ||
1541 | * If the read was aborted, don't disable the interrupt | ||
1542 | * as this may cause us to hang indefinitely. An | ||
1543 | * aborted read generally means that this interrupt | ||
1544 | * hasn't been delivered to the cpu yet anyway, even | ||
1545 | * though we see it as asserted when we read the sio_ir. | ||
1546 | */ | ||
1547 | if ((sio_ir = PENDING(card_ptr, idd)) | ||
1548 | & hooks->intr_rx_high) { | ||
1549 | if (port->ip_flags & READ_ABORTED) { | ||
1550 | rx_high_rd_aborted++; | ||
1551 | } | ||
1552 | else { | ||
1553 | card_ptr->ic_enable &= ~hooks->intr_rx_high; | ||
1554 | port->ip_flags |= INPUT_HIGH; | ||
1555 | } | ||
1556 | } | ||
1557 | } | ||
1558 | |||
1559 | /* We got a low water interrupt: notify upper layer to | ||
1560 | * send more data. Must come before tx_mt since servicing | ||
1561 | * this condition may cause that condition to clear. | ||
1562 | */ | ||
1563 | if (sio_ir & hooks->intr_tx_explicit) { | ||
1564 | port->ip_flags &= ~LOWAT_WRITTEN; | ||
1565 | ioc3_ack(is, idd, hooks->intr_tx_explicit); | ||
1566 | if (port->ip_notify & N_OUTPUT_LOWAT) | ||
1567 | ioc3_cb_output_lowat(port); | ||
1568 | } | ||
1569 | |||
1570 | /* Handle tx_mt. Must come after tx_explicit. */ | ||
1571 | else if (sio_ir & hooks->intr_tx_mt) { | ||
1572 | /* If we are expecting a lowat notification | ||
1573 | * and we get to this point it probably means that for | ||
1574 | * some reason the tx_explicit didn't work as expected | ||
1575 | * (that can legitimately happen if the output buffer is | ||
1576 | * filled up in just the right way). | ||
1577 | * So send the notification now. | ||
1578 | */ | ||
1579 | if (port->ip_notify & N_OUTPUT_LOWAT) { | ||
1580 | ioc3_cb_output_lowat(port); | ||
1581 | |||
1582 | /* We need to reload the sio_ir since the lowat | ||
1583 | * call may have caused another write to occur, | ||
1584 | * clearing the tx_mt condition. | ||
1585 | */ | ||
1586 | sio_ir = PENDING(card_ptr, idd); | ||
1587 | } | ||
1588 | |||
1589 | /* If the tx_mt condition still persists even after the | ||
1590 | * lowat call, we've got some work to do. | ||
1591 | */ | ||
1592 | if (sio_ir & hooks->intr_tx_mt) { | ||
1593 | /* If we are not currently expecting DMA input, | ||
1594 | * and the transmitter has just gone idle, | ||
1595 | * there is no longer any reason for DMA, so | ||
1596 | * disable it. | ||
1597 | */ | ||
1598 | if (!(port->ip_notify | ||
1599 | & (N_DATA_READY | N_DDCD))) { | ||
1600 | BUG_ON(!(port->ip_sscr | ||
1601 | & SSCR_DMA_EN)); | ||
1602 | port->ip_sscr &= ~SSCR_DMA_EN; | ||
1603 | writel(port->ip_sscr, | ||
1604 | &port->ip_serial_regs->sscr); | ||
1605 | } | ||
1606 | /* Prevent infinite tx_mt interrupt */ | ||
1607 | card_ptr->ic_enable &= ~hooks->intr_tx_mt; | ||
1608 | } | ||
1609 | } | ||
1610 | sio_ir = PENDING(card_ptr, idd); | ||
1611 | |||
1612 | /* if the read was aborted and only hooks->intr_rx_high, | ||
1613 | * clear hooks->intr_rx_high, so we do not loop forever. | ||
1614 | */ | ||
1615 | |||
1616 | if (rx_high_rd_aborted && (sio_ir == hooks->intr_rx_high)) { | ||
1617 | sio_ir &= ~hooks->intr_rx_high; | ||
1618 | } | ||
1619 | } while (sio_ir & hooks->intr_all); | ||
1620 | |||
1621 | spin_unlock_irqrestore(&port->ip_lock, flags); | ||
1622 | ioc3_enable(is, idd, card_ptr->ic_enable); | ||
1623 | return 0; | ||
1624 | } | ||
1625 | |||
1626 | /** | ||
1627 | * ioc3uart_intr - field all serial interrupts | ||
1628 | * @is : submodule | ||
1629 | * @idd: driver data | ||
1630 | * @pending: interrupts to handle | ||
1631 | * @regs: pt_regs | ||
1632 | * | ||
1633 | */ | ||
1634 | |||
1635 | static int ioc3uart_intr(struct ioc3_submodule *is, | ||
1636 | struct ioc3_driver_data *idd, | ||
1637 | unsigned int pending, struct pt_regs *regs) | ||
1638 | { | ||
1639 | int ret = 0; | ||
1640 | |||
1641 | /* | ||
1642 | * The upper level interrupt handler sends interrupts for both ports | ||
1643 | * here. So we need to call for each port with its interrupts. | ||
1644 | */ | ||
1645 | |||
1646 | if (pending & SIO_IR_SA) | ||
1647 | ret |= ioc3uart_intr_one(is, idd, pending & SIO_IR_SA, regs); | ||
1648 | if (pending & SIO_IR_SB) | ||
1649 | ret |= ioc3uart_intr_one(is, idd, pending & SIO_IR_SB, regs); | ||
1650 | |||
1651 | return ret; | ||
1652 | } | ||
1653 | |||
1654 | /** | ||
1655 | * ic3_type | ||
1656 | * @port: Port to operate with (we ignore since we only have one port) | ||
1657 | * | ||
1658 | */ | ||
1659 | static const char *ic3_type(struct uart_port *the_port) | ||
1660 | { | ||
1661 | if (IS_RS232(the_port->line)) | ||
1662 | return "SGI IOC3 Serial [rs232]"; | ||
1663 | else | ||
1664 | return "SGI IOC3 Serial [rs422]"; | ||
1665 | } | ||
1666 | |||
1667 | /** | ||
1668 | * ic3_tx_empty - Is the transmitter empty? | ||
1669 | * @port: Port to operate on | ||
1670 | * | ||
1671 | */ | ||
1672 | static unsigned int ic3_tx_empty(struct uart_port *the_port) | ||
1673 | { | ||
1674 | unsigned int ret = 0; | ||
1675 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
1676 | |||
1677 | if (readl(&port->ip_serial_regs->shadow) & SHADOW_TEMT) | ||
1678 | ret = TIOCSER_TEMT; | ||
1679 | return ret; | ||
1680 | } | ||
1681 | |||
1682 | /** | ||
1683 | * ic3_stop_tx - stop the transmitter | ||
1684 | * @port: Port to operate on | ||
1685 | * | ||
1686 | */ | ||
1687 | static void ic3_stop_tx(struct uart_port *the_port) | ||
1688 | { | ||
1689 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
1690 | |||
1691 | if (port) | ||
1692 | set_notification(port, N_OUTPUT_LOWAT, 0); | ||
1693 | } | ||
1694 | |||
1695 | /** | ||
1696 | * ic3_stop_rx - stop the receiver | ||
1697 | * @port: Port to operate on | ||
1698 | * | ||
1699 | */ | ||
1700 | static void ic3_stop_rx(struct uart_port *the_port) | ||
1701 | { | ||
1702 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
1703 | |||
1704 | if (port) | ||
1705 | port->ip_flags &= ~INPUT_ENABLE; | ||
1706 | } | ||
1707 | |||
1708 | /** | ||
1709 | * null_void_function | ||
1710 | * @port: Port to operate on | ||
1711 | * | ||
1712 | */ | ||
1713 | static void null_void_function(struct uart_port *the_port) | ||
1714 | { | ||
1715 | } | ||
1716 | |||
1717 | /** | ||
1718 | * ic3_shutdown - shut down the port - free irq and disable | ||
1719 | * @port: port to shut down | ||
1720 | * | ||
1721 | */ | ||
1722 | static void ic3_shutdown(struct uart_port *the_port) | ||
1723 | { | ||
1724 | unsigned long port_flags; | ||
1725 | struct ioc3_port *port; | ||
1726 | struct uart_info *info; | ||
1727 | |||
1728 | port = get_ioc3_port(the_port); | ||
1729 | if (!port) | ||
1730 | return; | ||
1731 | |||
1732 | info = the_port->info; | ||
1733 | wake_up_interruptible(&info->delta_msr_wait); | ||
1734 | |||
1735 | spin_lock_irqsave(&the_port->lock, port_flags); | ||
1736 | set_notification(port, N_ALL, 0); | ||
1737 | spin_unlock_irqrestore(&the_port->lock, port_flags); | ||
1738 | } | ||
1739 | |||
1740 | /** | ||
1741 | * ic3_set_mctrl - set control lines (dtr, rts, etc) | ||
1742 | * @port: Port to operate on | ||
1743 | * @mctrl: Lines to set/unset | ||
1744 | * | ||
1745 | */ | ||
1746 | static void ic3_set_mctrl(struct uart_port *the_port, unsigned int mctrl) | ||
1747 | { | ||
1748 | unsigned char mcr = 0; | ||
1749 | |||
1750 | if (mctrl & TIOCM_RTS) | ||
1751 | mcr |= UART_MCR_RTS; | ||
1752 | if (mctrl & TIOCM_DTR) | ||
1753 | mcr |= UART_MCR_DTR; | ||
1754 | if (mctrl & TIOCM_OUT1) | ||
1755 | mcr |= UART_MCR_OUT1; | ||
1756 | if (mctrl & TIOCM_OUT2) | ||
1757 | mcr |= UART_MCR_OUT2; | ||
1758 | if (mctrl & TIOCM_LOOP) | ||
1759 | mcr |= UART_MCR_LOOP; | ||
1760 | |||
1761 | set_mcr(the_port, mcr, SHADOW_DTR); | ||
1762 | } | ||
1763 | |||
1764 | /** | ||
1765 | * ic3_get_mctrl - get control line info | ||
1766 | * @port: port to operate on | ||
1767 | * | ||
1768 | */ | ||
1769 | static unsigned int ic3_get_mctrl(struct uart_port *the_port) | ||
1770 | { | ||
1771 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
1772 | uint32_t shadow; | ||
1773 | unsigned int ret = 0; | ||
1774 | |||
1775 | if (!port) | ||
1776 | return 0; | ||
1777 | |||
1778 | shadow = readl(&port->ip_serial_regs->shadow); | ||
1779 | if (shadow & SHADOW_DCD) | ||
1780 | ret |= TIOCM_CD; | ||
1781 | if (shadow & SHADOW_DR) | ||
1782 | ret |= TIOCM_DSR; | ||
1783 | if (shadow & SHADOW_CTS) | ||
1784 | ret |= TIOCM_CTS; | ||
1785 | return ret; | ||
1786 | } | ||
1787 | |||
1788 | /** | ||
1789 | * ic3_start_tx - Start transmitter. Called with the_port->lock | ||
1790 | * @port: Port to operate on | ||
1791 | * | ||
1792 | */ | ||
1793 | static void ic3_start_tx(struct uart_port *the_port) | ||
1794 | { | ||
1795 | struct ioc3_port *port = get_ioc3_port(the_port); | ||
1796 | |||
1797 | if (port) { | ||
1798 | set_notification(port, N_OUTPUT_LOWAT, 1); | ||
1799 | enable_intrs(port, port->ip_hooks->intr_tx_mt); | ||
1800 | } | ||
1801 | } | ||
1802 | |||
1803 | /** | ||
1804 | * ic3_break_ctl - handle breaks | ||
1805 | * @port: Port to operate on | ||
1806 | * @break_state: Break state | ||
1807 | * | ||
1808 | */ | ||
1809 | static void ic3_break_ctl(struct uart_port *the_port, int break_state) | ||
1810 | { | ||
1811 | } | ||
1812 | |||
1813 | /** | ||
1814 | * ic3_startup - Start up the serial port - always return 0 (We're always on) | ||
1815 | * @port: Port to operate on | ||
1816 | * | ||
1817 | */ | ||
1818 | static int ic3_startup(struct uart_port *the_port) | ||
1819 | { | ||
1820 | int retval; | ||
1821 | struct ioc3_port *port; | ||
1822 | struct ioc3_card *card_ptr; | ||
1823 | unsigned long port_flags; | ||
1824 | |||
1825 | if (!the_port) { | ||
1826 | NOT_PROGRESS(); | ||
1827 | return -ENODEV; | ||
1828 | } | ||
1829 | port = get_ioc3_port(the_port); | ||
1830 | if (!port) { | ||
1831 | NOT_PROGRESS(); | ||
1832 | return -ENODEV; | ||
1833 | } | ||
1834 | card_ptr = port->ip_card; | ||
1835 | port->ip_port = the_port; | ||
1836 | |||
1837 | if (!card_ptr) { | ||
1838 | NOT_PROGRESS(); | ||
1839 | return -ENODEV; | ||
1840 | } | ||
1841 | |||
1842 | /* Start up the serial port */ | ||
1843 | spin_lock_irqsave(&the_port->lock, port_flags); | ||
1844 | retval = ic3_startup_local(the_port); | ||
1845 | spin_unlock_irqrestore(&the_port->lock, port_flags); | ||
1846 | return retval; | ||
1847 | } | ||
1848 | |||
1849 | /** | ||
1850 | * ic3_set_termios - set termios stuff | ||
1851 | * @port: port to operate on | ||
1852 | * @termios: New settings | ||
1853 | * @termios: Old | ||
1854 | * | ||
1855 | */ | ||
1856 | static void | ||
1857 | ic3_set_termios(struct uart_port *the_port, | ||
1858 | struct termios *termios, struct termios *old_termios) | ||
1859 | { | ||
1860 | unsigned long port_flags; | ||
1861 | |||
1862 | spin_lock_irqsave(&the_port->lock, port_flags); | ||
1863 | ioc3_change_speed(the_port, termios, old_termios); | ||
1864 | spin_unlock_irqrestore(&the_port->lock, port_flags); | ||
1865 | } | ||
1866 | |||
1867 | /** | ||
1868 | * ic3_request_port - allocate resources for port - no op.... | ||
1869 | * @port: port to operate on | ||
1870 | * | ||
1871 | */ | ||
1872 | static int ic3_request_port(struct uart_port *port) | ||
1873 | { | ||
1874 | return 0; | ||
1875 | } | ||
1876 | |||
1877 | /* Associate the uart functions above - given to serial core */ | ||
1878 | static struct uart_ops ioc3_ops = { | ||
1879 | .tx_empty = ic3_tx_empty, | ||
1880 | .set_mctrl = ic3_set_mctrl, | ||
1881 | .get_mctrl = ic3_get_mctrl, | ||
1882 | .stop_tx = ic3_stop_tx, | ||
1883 | .start_tx = ic3_start_tx, | ||
1884 | .stop_rx = ic3_stop_rx, | ||
1885 | .enable_ms = null_void_function, | ||
1886 | .break_ctl = ic3_break_ctl, | ||
1887 | .startup = ic3_startup, | ||
1888 | .shutdown = ic3_shutdown, | ||
1889 | .set_termios = ic3_set_termios, | ||
1890 | .type = ic3_type, | ||
1891 | .release_port = null_void_function, | ||
1892 | .request_port = ic3_request_port, | ||
1893 | }; | ||
1894 | |||
1895 | /* | ||
1896 | * Boot-time initialization code | ||
1897 | */ | ||
1898 | |||
1899 | static struct uart_driver ioc3_uart = { | ||
1900 | .owner = THIS_MODULE, | ||
1901 | .driver_name = "ioc3_serial", | ||
1902 | .dev_name = DEVICE_NAME, | ||
1903 | .major = DEVICE_MAJOR, | ||
1904 | .minor = DEVICE_MINOR, | ||
1905 | .nr = MAX_LOGICAL_PORTS | ||
1906 | }; | ||
1907 | |||
1908 | /** | ||
1909 | * ioc3_serial_core_attach - register with serial core | ||
1910 | * This is done during pci probing | ||
1911 | * @is: submodule struct for this | ||
1912 | * @idd: handle for this card | ||
1913 | */ | ||
1914 | static inline int ioc3_serial_core_attach( struct ioc3_submodule *is, | ||
1915 | struct ioc3_driver_data *idd) | ||
1916 | { | ||
1917 | struct ioc3_port *port; | ||
1918 | struct uart_port *the_port; | ||
1919 | struct ioc3_card *card_ptr = idd->data[is->id]; | ||
1920 | int ii, phys_port; | ||
1921 | struct pci_dev *pdev = idd->pdev; | ||
1922 | |||
1923 | DPRINT_CONFIG(("%s: attach pdev 0x%p - card_ptr 0x%p\n", | ||
1924 | __FUNCTION__, pdev, (void *)card_ptr)); | ||
1925 | |||
1926 | if (!card_ptr) | ||
1927 | return -ENODEV; | ||
1928 | |||
1929 | /* once around for each logical port on this card */ | ||
1930 | for (ii = 0; ii < LOGICAL_PORTS_PER_CARD; ii++) { | ||
1931 | phys_port = GET_PHYSICAL_PORT(ii); | ||
1932 | the_port = &card_ptr->ic_port[phys_port]. | ||
1933 | icp_uart_port[GET_LOGICAL_PORT(ii)]; | ||
1934 | port = card_ptr->ic_port[phys_port].icp_port; | ||
1935 | port->ip_port = the_port; | ||
1936 | |||
1937 | DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p [%d/%d]\n", | ||
1938 | __FUNCTION__, (void *)the_port, (void *)port, | ||
1939 | phys_port, ii)); | ||
1940 | |||
1941 | /* membase, iobase and mapbase just need to be non-0 */ | ||
1942 | the_port->membase = (unsigned char __iomem *)1; | ||
1943 | the_port->iobase = (pdev->bus->number << 16) | ii; | ||
1944 | the_port->line = (Num_of_ioc3_cards << 2) | ii; | ||
1945 | the_port->mapbase = 1; | ||
1946 | the_port->type = PORT_16550A; | ||
1947 | the_port->fifosize = FIFO_SIZE; | ||
1948 | the_port->ops = &ioc3_ops; | ||
1949 | the_port->irq = idd->irq_io; | ||
1950 | the_port->dev = &pdev->dev; | ||
1951 | |||
1952 | if (uart_add_one_port(&ioc3_uart, the_port) < 0) { | ||
1953 | printk(KERN_WARNING | ||
1954 | "%s: unable to add port %d bus %d\n", | ||
1955 | __FUNCTION__, the_port->line, pdev->bus->number); | ||
1956 | } else { | ||
1957 | DPRINT_CONFIG(("IOC3 serial port %d irq %d bus %d\n", | ||
1958 | the_port->line, the_port->irq, pdev->bus->number)); | ||
1959 | } | ||
1960 | |||
1961 | /* all ports are rs232 for now */ | ||
1962 | if (IS_PHYSICAL_PORT(ii)) | ||
1963 | ioc3_set_proto(port, PROTO_RS232); | ||
1964 | } | ||
1965 | return 0; | ||
1966 | } | ||
1967 | |||
1968 | /** | ||
1969 | * ioc3uart_remove - register detach function | ||
1970 | * @is: submodule struct for this submodule | ||
1971 | * @idd: ioc3 driver data for this submodule | ||
1972 | */ | ||
1973 | |||
1974 | static int ioc3uart_remove(struct ioc3_submodule *is, | ||
1975 | struct ioc3_driver_data *idd) | ||
1976 | { | ||
1977 | struct ioc3_card *card_ptr = idd->data[is->id]; | ||
1978 | struct uart_port *the_port; | ||
1979 | struct ioc3_port *port; | ||
1980 | int ii; | ||
1981 | |||
1982 | if (card_ptr) { | ||
1983 | for (ii = 0; ii < LOGICAL_PORTS_PER_CARD; ii++) { | ||
1984 | the_port = &card_ptr->ic_port[GET_PHYSICAL_PORT(ii)]. | ||
1985 | icp_uart_port[GET_LOGICAL_PORT(ii)]; | ||
1986 | if (the_port) | ||
1987 | uart_remove_one_port(&ioc3_uart, the_port); | ||
1988 | port = card_ptr->ic_port[GET_PHYSICAL_PORT(ii)].icp_port; | ||
1989 | if (port && IS_PHYSICAL_PORT(ii) | ||
1990 | && (GET_PHYSICAL_PORT(ii) == 0)) { | ||
1991 | pci_free_consistent(port->ip_idd->pdev, | ||
1992 | TOTAL_RING_BUF_SIZE, | ||
1993 | (void *)port->ip_cpu_ringbuf, | ||
1994 | port->ip_dma_ringbuf); | ||
1995 | kfree(port); | ||
1996 | card_ptr->ic_port[GET_PHYSICAL_PORT(ii)]. | ||
1997 | icp_port = NULL; | ||
1998 | } | ||
1999 | } | ||
2000 | kfree(card_ptr); | ||
2001 | idd->data[is->id] = NULL; | ||
2002 | } | ||
2003 | return 0; | ||
2004 | } | ||
2005 | |||
2006 | /** | ||
2007 | * ioc3uart_probe - card probe function called from shim driver | ||
2008 | * @is: submodule struct for this submodule | ||
2009 | * @idd: ioc3 driver data for this card | ||
2010 | */ | ||
2011 | |||
2012 | static int __devinit | ||
2013 | ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd) | ||
2014 | { | ||
2015 | struct pci_dev *pdev = idd->pdev; | ||
2016 | struct ioc3_card *card_ptr; | ||
2017 | int ret = 0; | ||
2018 | struct ioc3_port *port; | ||
2019 | struct ioc3_port *ports[PORTS_PER_CARD]; | ||
2020 | int phys_port; | ||
2021 | |||
2022 | DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); | ||
2023 | |||
2024 | card_ptr = kmalloc(sizeof(struct ioc3_card), GFP_KERNEL); | ||
2025 | if (!card_ptr) { | ||
2026 | printk(KERN_WARNING "ioc3_attach_one" | ||
2027 | ": unable to get memory for the IOC3\n"); | ||
2028 | return -ENOMEM; | ||
2029 | } | ||
2030 | memset(card_ptr, 0, sizeof(struct ioc3_card)); | ||
2031 | idd->data[is->id] = card_ptr; | ||
2032 | Submodule_slot = is->id; | ||
2033 | |||
2034 | writel(((UARTA_BASE >> 3) << SIO_CR_SER_A_BASE_SHIFT) | | ||
2035 | ((UARTB_BASE >> 3) << SIO_CR_SER_B_BASE_SHIFT) | | ||
2036 | (0xf << SIO_CR_CMD_PULSE_SHIFT), &idd->vma->sio_cr); | ||
2037 | |||
2038 | pci_write_config_dword(pdev, PCI_LAT, 0xff00); | ||
2039 | |||
2040 | /* Enable serial port mode select generic PIO pins as outputs */ | ||
2041 | ioc3_gpcr_set(idd, GPCR_UARTA_MODESEL | GPCR_UARTB_MODESEL); | ||
2042 | |||
2043 | /* Create port structures for each port */ | ||
2044 | for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) { | ||
2045 | port = kmalloc(sizeof(struct ioc3_port), GFP_KERNEL); | ||
2046 | if (!port) { | ||
2047 | printk(KERN_WARNING | ||
2048 | "IOC3 serial memory not available for port\n"); | ||
2049 | goto out4; | ||
2050 | } | ||
2051 | memset(port, 0, sizeof(struct ioc3_port)); | ||
2052 | spin_lock_init(&port->ip_lock); | ||
2053 | |||
2054 | /* we need to remember the previous ones, to point back to | ||
2055 | * them farther down - setting up the ring buffers. | ||
2056 | */ | ||
2057 | ports[phys_port] = port; | ||
2058 | |||
2059 | /* init to something useful */ | ||
2060 | card_ptr->ic_port[phys_port].icp_port = port; | ||
2061 | port->ip_is = is; | ||
2062 | port->ip_idd = idd; | ||
2063 | port->ip_baud = 9600; | ||
2064 | port->ip_card = card_ptr; | ||
2065 | port->ip_hooks = &hooks_array[phys_port]; | ||
2066 | |||
2067 | /* Setup each port */ | ||
2068 | if (phys_port == 0) { | ||
2069 | port->ip_serial_regs = &idd->vma->port_a; | ||
2070 | port->ip_uart_regs = &idd->vma->sregs.uarta; | ||
2071 | |||
2072 | DPRINT_CONFIG(("%s : Port A ip_serial_regs 0x%p " | ||
2073 | "ip_uart_regs 0x%p\n", | ||
2074 | __FUNCTION__, | ||
2075 | (void *)port->ip_serial_regs, | ||
2076 | (void *)port->ip_uart_regs)); | ||
2077 | |||
2078 | /* setup ring buffers */ | ||
2079 | port->ip_cpu_ringbuf = pci_alloc_consistent(pdev, | ||
2080 | TOTAL_RING_BUF_SIZE, &port->ip_dma_ringbuf); | ||
2081 | |||
2082 | BUG_ON(!((((int64_t) port->ip_dma_ringbuf) & | ||
2083 | (TOTAL_RING_BUF_SIZE - 1)) == 0)); | ||
2084 | port->ip_inring = RING(port, RX_A); | ||
2085 | port->ip_outring = RING(port, TX_A); | ||
2086 | DPRINT_CONFIG(("%s : Port A ip_cpu_ringbuf 0x%p " | ||
2087 | "ip_dma_ringbuf 0x%p, ip_inring 0x%p " | ||
2088 | "ip_outring 0x%p\n", | ||
2089 | __FUNCTION__, | ||
2090 | (void *)port->ip_cpu_ringbuf, | ||
2091 | (void *)port->ip_dma_ringbuf, | ||
2092 | (void *)port->ip_inring, | ||
2093 | (void *)port->ip_outring)); | ||
2094 | } | ||
2095 | else { | ||
2096 | port->ip_serial_regs = &idd->vma->port_b; | ||
2097 | port->ip_uart_regs = &idd->vma->sregs.uartb; | ||
2098 | |||
2099 | DPRINT_CONFIG(("%s : Port B ip_serial_regs 0x%p " | ||
2100 | "ip_uart_regs 0x%p\n", | ||
2101 | __FUNCTION__, | ||
2102 | (void *)port->ip_serial_regs, | ||
2103 | (void *)port->ip_uart_regs)); | ||
2104 | |||
2105 | /* share the ring buffers */ | ||
2106 | port->ip_dma_ringbuf = | ||
2107 | ports[phys_port - 1]->ip_dma_ringbuf; | ||
2108 | port->ip_cpu_ringbuf = | ||
2109 | ports[phys_port - 1]->ip_cpu_ringbuf; | ||
2110 | port->ip_inring = RING(port, RX_B); | ||
2111 | port->ip_outring = RING(port, TX_B); | ||
2112 | DPRINT_CONFIG(("%s : Port B ip_cpu_ringbuf 0x%p " | ||
2113 | "ip_dma_ringbuf 0x%p, ip_inring 0x%p " | ||
2114 | "ip_outring 0x%p\n", | ||
2115 | __FUNCTION__, | ||
2116 | (void *)port->ip_cpu_ringbuf, | ||
2117 | (void *)port->ip_dma_ringbuf, | ||
2118 | (void *)port->ip_inring, | ||
2119 | (void *)port->ip_outring)); | ||
2120 | } | ||
2121 | |||
2122 | DPRINT_CONFIG(("%s : port %d [addr 0x%p] card_ptr 0x%p", | ||
2123 | __FUNCTION__, | ||
2124 | phys_port, (void *)port, (void *)card_ptr)); | ||
2125 | DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n", | ||
2126 | (void *)port->ip_serial_regs, | ||
2127 | (void *)port->ip_uart_regs)); | ||
2128 | |||
2129 | /* Initialize the hardware for IOC3 */ | ||
2130 | port_init(port); | ||
2131 | |||
2132 | DPRINT_CONFIG(("%s: phys_port %d port 0x%p inring 0x%p " | ||
2133 | "outring 0x%p\n", | ||
2134 | __FUNCTION__, | ||
2135 | phys_port, (void *)port, | ||
2136 | (void *)port->ip_inring, | ||
2137 | (void *)port->ip_outring)); | ||
2138 | |||
2139 | } | ||
2140 | |||
2141 | /* register port with the serial core */ | ||
2142 | |||
2143 | if ((ret = ioc3_serial_core_attach(is, idd))) | ||
2144 | goto out4; | ||
2145 | |||
2146 | Num_of_ioc3_cards++; | ||
2147 | |||
2148 | return ret; | ||
2149 | |||
2150 | /* error exits that give back resources */ | ||
2151 | out4: | ||
2152 | kfree(card_ptr); | ||
2153 | return ret; | ||
2154 | } | ||
2155 | |||
2156 | static struct ioc3_submodule ioc3uart_submodule = { | ||
2157 | .name = "IOC3uart", | ||
2158 | .probe = ioc3uart_probe, | ||
2159 | .remove = ioc3uart_remove, | ||
2160 | /* call .intr for both ports initially */ | ||
2161 | .irq_mask = SIO_IR_SA | SIO_IR_SB, | ||
2162 | .intr = ioc3uart_intr, | ||
2163 | .owner = THIS_MODULE, | ||
2164 | }; | ||
2165 | |||
2166 | /** | ||
2167 | * ioc3_detect - module init called, | ||
2168 | */ | ||
2169 | static int __devinit ioc3uart_init(void) | ||
2170 | { | ||
2171 | int ret; | ||
2172 | |||
2173 | /* register with serial core */ | ||
2174 | if ((ret = uart_register_driver(&ioc3_uart)) < 0) { | ||
2175 | printk(KERN_WARNING | ||
2176 | "%s: Couldn't register IOC3 uart serial driver\n", | ||
2177 | __FUNCTION__); | ||
2178 | return ret; | ||
2179 | } | ||
2180 | ret = ioc3_register_submodule(&ioc3uart_submodule); | ||
2181 | if (ret) | ||
2182 | uart_unregister_driver(&ioc3_uart); | ||
2183 | return ret; | ||
2184 | } | ||
2185 | |||
2186 | static void __devexit ioc3uart_exit(void) | ||
2187 | { | ||
2188 | ioc3_unregister_submodule(&ioc3uart_submodule); | ||
2189 | uart_unregister_driver(&ioc3_uart); | ||
2190 | } | ||
2191 | |||
2192 | module_init(ioc3uart_init); | ||
2193 | module_exit(ioc3uart_exit); | ||
2194 | |||
2195 | MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>"); | ||
2196 | MODULE_DESCRIPTION("Serial PCI driver module for SGI IOC3 card"); | ||
2197 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c index 771676abee60..1d85533d46d2 100644 --- a/drivers/serial/ioc4_serial.c +++ b/drivers/serial/ioc4_serial.c | |||
@@ -2327,19 +2327,13 @@ static void receive_chars(struct uart_port *the_port) | |||
2327 | spin_lock_irqsave(&the_port->lock, pflags); | 2327 | spin_lock_irqsave(&the_port->lock, pflags); |
2328 | tty = info->tty; | 2328 | tty = info->tty; |
2329 | 2329 | ||
2330 | if (request_count > TTY_FLIPBUF_SIZE - tty->flip.count) | 2330 | request_count = tty_buffer_request_room(tty, IOC4_MAX_CHARS - 2); |
2331 | request_count = TTY_FLIPBUF_SIZE - tty->flip.count; | ||
2332 | 2331 | ||
2333 | if (request_count > 0) { | 2332 | if (request_count > 0) { |
2334 | icount = &the_port->icount; | 2333 | icount = &the_port->icount; |
2335 | read_count = do_read(the_port, ch, request_count); | 2334 | read_count = do_read(the_port, ch, request_count); |
2336 | if (read_count > 0) { | 2335 | if (read_count > 0) { |
2337 | flip = 1; | 2336 | tty_insert_flip_string(tty, ch, read_count); |
2338 | memcpy(tty->flip.char_buf_ptr, ch, read_count); | ||
2339 | memset(tty->flip.flag_buf_ptr, TTY_NORMAL, read_count); | ||
2340 | tty->flip.char_buf_ptr += read_count; | ||
2341 | tty->flip.flag_buf_ptr += read_count; | ||
2342 | tty->flip.count += read_count; | ||
2343 | icount->rx += read_count; | 2337 | icount->rx += read_count; |
2344 | } | 2338 | } |
2345 | } | 2339 | } |
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c index ef132349f310..66f117d15065 100644 --- a/drivers/serial/ip22zilog.c +++ b/drivers/serial/ip22zilog.c | |||
@@ -259,13 +259,7 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, | |||
259 | struct tty_struct *tty = up->port.info->tty; /* XXX info==NULL? */ | 259 | struct tty_struct *tty = up->port.info->tty; /* XXX info==NULL? */ |
260 | 260 | ||
261 | while (1) { | 261 | while (1) { |
262 | unsigned char ch, r1; | 262 | unsigned char ch, r1, flag; |
263 | |||
264 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
265 | tty->flip.work.func((void *)tty); | ||
266 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
267 | return; /* XXX Ignores SysRq when we need it most. Fix. */ | ||
268 | } | ||
269 | 263 | ||
270 | r1 = read_zsreg(channel, R1); | 264 | r1 = read_zsreg(channel, R1); |
271 | if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) { | 265 | if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) { |
@@ -303,8 +297,7 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, | |||
303 | } | 297 | } |
304 | 298 | ||
305 | /* A real serial line, record the character and status. */ | 299 | /* A real serial line, record the character and status. */ |
306 | *tty->flip.char_buf_ptr = ch; | 300 | flag = TTY_NORMAL; |
307 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
308 | up->port.icount.rx++; | 301 | up->port.icount.rx++; |
309 | if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { | 302 | if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { |
310 | if (r1 & BRK_ABRT) { | 303 | if (r1 & BRK_ABRT) { |
@@ -321,28 +314,21 @@ static void ip22zilog_receive_chars(struct uart_ip22zilog_port *up, | |||
321 | up->port.icount.overrun++; | 314 | up->port.icount.overrun++; |
322 | r1 &= up->port.read_status_mask; | 315 | r1 &= up->port.read_status_mask; |
323 | if (r1 & BRK_ABRT) | 316 | if (r1 & BRK_ABRT) |
324 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 317 | flag = TTY_BREAK; |
325 | else if (r1 & PAR_ERR) | 318 | else if (r1 & PAR_ERR) |
326 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 319 | flag = TTY_PARITY; |
327 | else if (r1 & CRC_ERR) | 320 | else if (r1 & CRC_ERR) |
328 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 321 | flag = TTY_FRAME; |
329 | } | 322 | } |
330 | if (uart_handle_sysrq_char(&up->port, ch, regs)) | 323 | if (uart_handle_sysrq_char(&up->port, ch, regs)) |
331 | goto next_char; | 324 | goto next_char; |
332 | 325 | ||
333 | if (up->port.ignore_status_mask == 0xff || | 326 | if (up->port.ignore_status_mask == 0xff || |
334 | (r1 & up->port.ignore_status_mask) == 0) { | 327 | (r1 & up->port.ignore_status_mask) == 0) |
335 | tty->flip.flag_buf_ptr++; | 328 | tty_insert_flip_char(tty, ch, flag); |
336 | tty->flip.char_buf_ptr++; | 329 | |
337 | tty->flip.count++; | 330 | if (r1 & Rx_OVR) |
338 | } | 331 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
339 | if ((r1 & Rx_OVR) && | ||
340 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
341 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | ||
342 | tty->flip.flag_buf_ptr++; | ||
343 | tty->flip.char_buf_ptr++; | ||
344 | tty->flip.count++; | ||
345 | } | ||
346 | next_char: | 332 | next_char: |
347 | ch = readb(&channel->control); | 333 | ch = readb(&channel->control); |
348 | ZSDELAY(); | 334 | ZSDELAY(); |
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c index b0ecc7537ce5..b48066a64a7d 100644 --- a/drivers/serial/m32r_sio.c +++ b/drivers/serial/m32r_sio.c | |||
@@ -331,17 +331,12 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, | |||
331 | { | 331 | { |
332 | struct tty_struct *tty = up->port.info->tty; | 332 | struct tty_struct *tty = up->port.info->tty; |
333 | unsigned char ch; | 333 | unsigned char ch; |
334 | unsigned char flag; | ||
334 | int max_count = 256; | 335 | int max_count = 256; |
335 | 336 | ||
336 | do { | 337 | do { |
337 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
338 | tty->flip.work.func((void *)tty); | ||
339 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
340 | return; // if TTY_DONT_FLIP is set | ||
341 | } | ||
342 | ch = sio_in(up, SIORXB); | 338 | ch = sio_in(up, SIORXB); |
343 | *tty->flip.char_buf_ptr = ch; | 339 | flag = TTY_NORMAL; |
344 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
345 | up->port.icount.rx++; | 340 | up->port.icount.rx++; |
346 | 341 | ||
347 | if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | | 342 | if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | |
@@ -380,30 +375,24 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status, | |||
380 | 375 | ||
381 | if (*status & UART_LSR_BI) { | 376 | if (*status & UART_LSR_BI) { |
382 | DEBUG_INTR("handling break...."); | 377 | DEBUG_INTR("handling break...."); |
383 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 378 | flag = TTY_BREAK; |
384 | } else if (*status & UART_LSR_PE) | 379 | } else if (*status & UART_LSR_PE) |
385 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 380 | flag = TTY_PARITY; |
386 | else if (*status & UART_LSR_FE) | 381 | else if (*status & UART_LSR_FE) |
387 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 382 | flag = TTY_FRAME; |
388 | } | 383 | } |
389 | if (uart_handle_sysrq_char(&up->port, ch, regs)) | 384 | if (uart_handle_sysrq_char(&up->port, ch, regs)) |
390 | goto ignore_char; | 385 | goto ignore_char; |
391 | if ((*status & up->port.ignore_status_mask) == 0) { | 386 | if ((*status & up->port.ignore_status_mask) == 0) |
392 | tty->flip.flag_buf_ptr++; | 387 | tty_insert_flip_char(tty, ch, flag); |
393 | tty->flip.char_buf_ptr++; | 388 | |
394 | tty->flip.count++; | 389 | if (*status & UART_LSR_OE) { |
395 | } | ||
396 | if ((*status & UART_LSR_OE) && | ||
397 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
398 | /* | 390 | /* |
399 | * Overrun is special, since it's reported | 391 | * Overrun is special, since it's reported |
400 | * immediately, and doesn't affect the current | 392 | * immediately, and doesn't affect the current |
401 | * character. | 393 | * character. |
402 | */ | 394 | */ |
403 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | 395 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
404 | tty->flip.flag_buf_ptr++; | ||
405 | tty->flip.char_buf_ptr++; | ||
406 | tty->flip.count++; | ||
407 | } | 396 | } |
408 | ignore_char: | 397 | ignore_char: |
409 | *status = serial_in(up, UART_LSR); | 398 | *status = serial_in(up, UART_LSR); |
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c index 47f7404cb045..d957a3a9edf1 100644 --- a/drivers/serial/mcfserial.c +++ b/drivers/serial/mcfserial.c | |||
@@ -313,7 +313,7 @@ static inline void receive_chars(struct mcf_serial *info) | |||
313 | { | 313 | { |
314 | volatile unsigned char *uartp; | 314 | volatile unsigned char *uartp; |
315 | struct tty_struct *tty = info->tty; | 315 | struct tty_struct *tty = info->tty; |
316 | unsigned char status, ch; | 316 | unsigned char status, ch, flag; |
317 | 317 | ||
318 | if (!tty) | 318 | if (!tty) |
319 | return; | 319 | return; |
@@ -321,10 +321,6 @@ static inline void receive_chars(struct mcf_serial *info) | |||
321 | uartp = info->addr; | 321 | uartp = info->addr; |
322 | 322 | ||
323 | while ((status = uartp[MCFUART_USR]) & MCFUART_USR_RXREADY) { | 323 | while ((status = uartp[MCFUART_USR]) & MCFUART_USR_RXREADY) { |
324 | |||
325 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
326 | break; | ||
327 | |||
328 | ch = uartp[MCFUART_URB]; | 324 | ch = uartp[MCFUART_URB]; |
329 | info->stats.rx++; | 325 | info->stats.rx++; |
330 | 326 | ||
@@ -335,29 +331,24 @@ static inline void receive_chars(struct mcf_serial *info) | |||
335 | } | 331 | } |
336 | #endif | 332 | #endif |
337 | 333 | ||
338 | tty->flip.count++; | 334 | flag = TTY_NORMAL; |
339 | if (status & MCFUART_USR_RXERR) { | 335 | if (status & MCFUART_USR_RXERR) { |
340 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETERR; | 336 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETERR; |
341 | if (status & MCFUART_USR_RXBREAK) { | 337 | if (status & MCFUART_USR_RXBREAK) { |
342 | info->stats.rxbreak++; | 338 | info->stats.rxbreak++; |
343 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; | 339 | flag = TTY_BREAK; |
344 | } else if (status & MCFUART_USR_RXPARITY) { | 340 | } else if (status & MCFUART_USR_RXPARITY) { |
345 | info->stats.rxparity++; | 341 | info->stats.rxparity++; |
346 | *tty->flip.flag_buf_ptr++ = TTY_PARITY; | 342 | flag = TTY_PARITY; |
347 | } else if (status & MCFUART_USR_RXOVERRUN) { | 343 | } else if (status & MCFUART_USR_RXOVERRUN) { |
348 | info->stats.rxoverrun++; | 344 | info->stats.rxoverrun++; |
349 | *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; | 345 | flag = TTY_OVERRUN; |
350 | } else if (status & MCFUART_USR_RXFRAMING) { | 346 | } else if (status & MCFUART_USR_RXFRAMING) { |
351 | info->stats.rxframing++; | 347 | info->stats.rxframing++; |
352 | *tty->flip.flag_buf_ptr++ = TTY_FRAME; | 348 | flag = TTY_FRAME; |
353 | } else { | ||
354 | /* This should never happen... */ | ||
355 | *tty->flip.flag_buf_ptr++ = 0; | ||
356 | } | 349 | } |
357 | } else { | ||
358 | *tty->flip.flag_buf_ptr++ = 0; | ||
359 | } | 350 | } |
360 | *tty->flip.char_buf_ptr++ = ch; | 351 | tty_insert_flip_char(tty, ch, flag); |
361 | } | 352 | } |
362 | 353 | ||
363 | schedule_work(&tty->flip.work); | 354 | schedule_work(&tty->flip.work); |
@@ -1525,7 +1516,7 @@ static void mcfrs_irqinit(struct mcf_serial *info) | |||
1525 | 1516 | ||
1526 | icrp = (volatile unsigned char *) (MCF_MBAR + MCFICM_INTC0 + | 1517 | icrp = (volatile unsigned char *) (MCF_MBAR + MCFICM_INTC0 + |
1527 | MCFINTC_ICR0 + MCFINT_UART0 + info->line); | 1518 | MCFINTC_ICR0 + MCFINT_UART0 + info->line); |
1528 | *icrp = 0x33; /* UART0 with level 6, priority 3 */ | 1519 | *icrp = 0x30 + info->line; /* level 6, line based priority */ |
1529 | 1520 | ||
1530 | imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + | 1521 | imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + |
1531 | MCFINTC_IMRL); | 1522 | MCFINTC_IMRL); |
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index b8727d9bf690..61dd17d7bace 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -37,11 +37,11 @@ | |||
37 | * by the bootloader or in the platform init code. | 37 | * by the bootloader or in the platform init code. |
38 | * | 38 | * |
39 | * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, | 39 | * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, |
40 | * and so on). So the PSC1 is mapped to /dev/ttyS0, PSC2 to /dev/ttyS1 and so | 40 | * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and |
41 | * on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly for | 41 | * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly |
42 | * the console code : without this 1:1 mapping, at early boot time, when we are | 42 | * fpr the console code : without this 1:1 mapping, at early boot time, when we |
43 | * parsing the kernel args console=ttyS?, we wouldn't know wich PSC it will be | 43 | * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it |
44 | * mapped to. | 44 | * will be mapped to. |
45 | */ | 45 | */ |
46 | 46 | ||
47 | #include <linux/config.h> | 47 | #include <linux/config.h> |
@@ -65,6 +65,10 @@ | |||
65 | #include <linux/serial_core.h> | 65 | #include <linux/serial_core.h> |
66 | 66 | ||
67 | 67 | ||
68 | /* We've been assigned a range on the "Low-density serial ports" major */ | ||
69 | #define SERIAL_PSC_MAJOR 204 | ||
70 | #define SERIAL_PSC_MINOR 148 | ||
71 | |||
68 | 72 | ||
69 | #define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */ | 73 | #define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */ |
70 | 74 | ||
@@ -401,17 +405,13 @@ static inline int | |||
401 | mpc52xx_uart_int_rx_chars(struct uart_port *port, struct pt_regs *regs) | 405 | mpc52xx_uart_int_rx_chars(struct uart_port *port, struct pt_regs *regs) |
402 | { | 406 | { |
403 | struct tty_struct *tty = port->info->tty; | 407 | struct tty_struct *tty = port->info->tty; |
404 | unsigned char ch; | 408 | unsigned char ch, flag; |
405 | unsigned short status; | 409 | unsigned short status; |
406 | 410 | ||
407 | /* While we can read, do so ! */ | 411 | /* While we can read, do so ! */ |
408 | while ( (status = in_be16(&PSC(port)->mpc52xx_psc_status)) & | 412 | while ( (status = in_be16(&PSC(port)->mpc52xx_psc_status)) & |
409 | MPC52xx_PSC_SR_RXRDY) { | 413 | MPC52xx_PSC_SR_RXRDY) { |
410 | 414 | ||
411 | /* If we are full, just stop reading */ | ||
412 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
413 | break; | ||
414 | |||
415 | /* Get the char */ | 415 | /* Get the char */ |
416 | ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8); | 416 | ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8); |
417 | 417 | ||
@@ -424,45 +424,35 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port, struct pt_regs *regs) | |||
424 | #endif | 424 | #endif |
425 | 425 | ||
426 | /* Store it */ | 426 | /* Store it */ |
427 | *tty->flip.char_buf_ptr = ch; | 427 | |
428 | *tty->flip.flag_buf_ptr = 0; | 428 | flag = TTY_NORMAL; |
429 | port->icount.rx++; | 429 | port->icount.rx++; |
430 | 430 | ||
431 | if ( status & (MPC52xx_PSC_SR_PE | | 431 | if ( status & (MPC52xx_PSC_SR_PE | |
432 | MPC52xx_PSC_SR_FE | | 432 | MPC52xx_PSC_SR_FE | |
433 | MPC52xx_PSC_SR_RB | | 433 | MPC52xx_PSC_SR_RB) ) { |
434 | MPC52xx_PSC_SR_OE) ) { | ||
435 | 434 | ||
436 | if (status & MPC52xx_PSC_SR_RB) { | 435 | if (status & MPC52xx_PSC_SR_RB) { |
437 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 436 | flag = TTY_BREAK; |
438 | uart_handle_break(port); | 437 | uart_handle_break(port); |
439 | } else if (status & MPC52xx_PSC_SR_PE) | 438 | } else if (status & MPC52xx_PSC_SR_PE) |
440 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 439 | flag = TTY_PARITY; |
441 | else if (status & MPC52xx_PSC_SR_FE) | 440 | else if (status & MPC52xx_PSC_SR_FE) |
442 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 441 | flag = TTY_FRAME; |
443 | if (status & MPC52xx_PSC_SR_OE) { | ||
444 | /* | ||
445 | * Overrun is special, since it's | ||
446 | * reported immediately, and doesn't | ||
447 | * affect the current character | ||
448 | */ | ||
449 | if (tty->flip.count < (TTY_FLIPBUF_SIZE-1)) { | ||
450 | tty->flip.flag_buf_ptr++; | ||
451 | tty->flip.char_buf_ptr++; | ||
452 | tty->flip.count++; | ||
453 | } | ||
454 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | ||
455 | } | ||
456 | 442 | ||
457 | /* Clear error condition */ | 443 | /* Clear error condition */ |
458 | out_8(&PSC(port)->command,MPC52xx_PSC_RST_ERR_STAT); | 444 | out_8(&PSC(port)->command,MPC52xx_PSC_RST_ERR_STAT); |
459 | 445 | ||
460 | } | 446 | } |
461 | 447 | tty_insert_flip_char(tty, ch, flag); | |
462 | tty->flip.char_buf_ptr++; | 448 | if (status & MPC52xx_PSC_SR_OE) { |
463 | tty->flip.flag_buf_ptr++; | 449 | /* |
464 | tty->flip.count++; | 450 | * Overrun is special, since it's |
465 | 451 | * reported immediately, and doesn't | |
452 | * affect the current character | ||
453 | */ | ||
454 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | ||
455 | } | ||
466 | } | 456 | } |
467 | 457 | ||
468 | tty_flip_buffer_push(tty); | 458 | tty_flip_buffer_push(tty); |
@@ -668,15 +658,15 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
668 | } | 658 | } |
669 | 659 | ||
670 | 660 | ||
671 | extern struct uart_driver mpc52xx_uart_driver; | 661 | static struct uart_driver mpc52xx_uart_driver; |
672 | 662 | ||
673 | static struct console mpc52xx_console = { | 663 | static struct console mpc52xx_console = { |
674 | .name = "ttyS", | 664 | .name = "ttyPSC", |
675 | .write = mpc52xx_console_write, | 665 | .write = mpc52xx_console_write, |
676 | .device = uart_console_device, | 666 | .device = uart_console_device, |
677 | .setup = mpc52xx_console_setup, | 667 | .setup = mpc52xx_console_setup, |
678 | .flags = CON_PRINTBUFFER, | 668 | .flags = CON_PRINTBUFFER, |
679 | .index = -1, /* Specified on the cmdline (e.g. console=ttyS0 ) */ | 669 | .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */ |
680 | .data = &mpc52xx_uart_driver, | 670 | .data = &mpc52xx_uart_driver, |
681 | }; | 671 | }; |
682 | 672 | ||
@@ -703,10 +693,10 @@ console_initcall(mpc52xx_console_init); | |||
703 | static struct uart_driver mpc52xx_uart_driver = { | 693 | static struct uart_driver mpc52xx_uart_driver = { |
704 | .owner = THIS_MODULE, | 694 | .owner = THIS_MODULE, |
705 | .driver_name = "mpc52xx_psc_uart", | 695 | .driver_name = "mpc52xx_psc_uart", |
706 | .dev_name = "ttyS", | 696 | .dev_name = "ttyPSC", |
707 | .devfs_name = "ttyS", | 697 | .devfs_name = "ttyPSC", |
708 | .major = TTY_MAJOR, | 698 | .major = SERIAL_PSC_MAJOR, |
709 | .minor = 64, | 699 | .minor = SERIAL_PSC_MINOR, |
710 | .nr = MPC52xx_PSC_MAXNUM, | 700 | .nr = MPC52xx_PSC_MAXNUM, |
711 | .cons = MPC52xx_PSC_CONSOLE, | 701 | .cons = MPC52xx_PSC_CONSOLE, |
712 | }; | 702 | }; |
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c index 8f83e4007ecd..0ca83ac31d07 100644 --- a/drivers/serial/mpsc.c +++ b/drivers/serial/mpsc.c | |||
@@ -769,12 +769,12 @@ mpsc_rx_intr(struct mpsc_port_info *pi, struct pt_regs *regs) | |||
769 | bytes_in = be16_to_cpu(rxre->bytecnt); | 769 | bytes_in = be16_to_cpu(rxre->bytecnt); |
770 | 770 | ||
771 | /* Following use of tty struct directly is deprecated */ | 771 | /* Following use of tty struct directly is deprecated */ |
772 | if (unlikely((tty->flip.count + bytes_in) >= TTY_FLIPBUF_SIZE)){ | 772 | if (unlikely(tty_buffer_request_room(tty, bytes_in) < bytes_in)) { |
773 | if (tty->low_latency) | 773 | if (tty->low_latency) |
774 | tty_flip_buffer_push(tty); | 774 | tty_flip_buffer_push(tty); |
775 | /* | 775 | /* |
776 | * If this failed then we will throw awa the bytes | 776 | * If this failed then we will throw away the bytes |
777 | * but mst do so to clear interrupts. | 777 | * but must do so to clear interrupts. |
778 | */ | 778 | */ |
779 | } | 779 | } |
780 | 780 | ||
diff --git a/drivers/serial/mux.c b/drivers/serial/mux.c index 7633132a10aa..4e49168c3176 100644 --- a/drivers/serial/mux.c +++ b/drivers/serial/mux.c | |||
@@ -223,11 +223,6 @@ static void mux_read(struct uart_port *port) | |||
223 | if (MUX_EOFIFO(data)) | 223 | if (MUX_EOFIFO(data)) |
224 | break; | 224 | break; |
225 | 225 | ||
226 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
227 | continue; | ||
228 | |||
229 | *tty->flip.char_buf_ptr = data & 0xffu; | ||
230 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
231 | port->icount.rx++; | 226 | port->icount.rx++; |
232 | 227 | ||
233 | if (MUX_BREAK(data)) { | 228 | if (MUX_BREAK(data)) { |
@@ -239,9 +234,7 @@ static void mux_read(struct uart_port *port) | |||
239 | if (uart_handle_sysrq_char(port, data & 0xffu, NULL)) | 234 | if (uart_handle_sysrq_char(port, data & 0xffu, NULL)) |
240 | continue; | 235 | continue; |
241 | 236 | ||
242 | tty->flip.flag_buf_ptr++; | 237 | tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL); |
243 | tty->flip.char_buf_ptr++; | ||
244 | tty->flip.count++; | ||
245 | } | 238 | } |
246 | 239 | ||
247 | if (start_count != port->icount.rx) { | 240 | if (start_count != port->icount.rx) { |
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c index 5ddd8ab1f108..4e03a87f3fb4 100644 --- a/drivers/serial/pmac_zilog.c +++ b/drivers/serial/pmac_zilog.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/pmu.h> | 60 | #include <linux/pmu.h> |
61 | #include <linux/bitops.h> | 61 | #include <linux/bitops.h> |
62 | #include <linux/sysrq.h> | 62 | #include <linux/sysrq.h> |
63 | #include <linux/mutex.h> | ||
63 | #include <asm/sections.h> | 64 | #include <asm/sections.h> |
64 | #include <asm/io.h> | 65 | #include <asm/io.h> |
65 | #include <asm/irq.h> | 66 | #include <asm/irq.h> |
@@ -68,7 +69,6 @@ | |||
68 | #include <asm/pmac_feature.h> | 69 | #include <asm/pmac_feature.h> |
69 | #include <asm/dbdma.h> | 70 | #include <asm/dbdma.h> |
70 | #include <asm/macio.h> | 71 | #include <asm/macio.h> |
71 | #include <asm/semaphore.h> | ||
72 | 72 | ||
73 | #if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 73 | #if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
74 | #define SUPPORT_SYSRQ | 74 | #define SUPPORT_SYSRQ |
@@ -96,7 +96,7 @@ MODULE_LICENSE("GPL"); | |||
96 | */ | 96 | */ |
97 | static struct uart_pmac_port pmz_ports[MAX_ZS_PORTS]; | 97 | static struct uart_pmac_port pmz_ports[MAX_ZS_PORTS]; |
98 | static int pmz_ports_count; | 98 | static int pmz_ports_count; |
99 | static DECLARE_MUTEX(pmz_irq_sem); | 99 | static DEFINE_MUTEX(pmz_irq_mutex); |
100 | 100 | ||
101 | static struct uart_driver pmz_uart_reg = { | 101 | static struct uart_driver pmz_uart_reg = { |
102 | .owner = THIS_MODULE, | 102 | .owner = THIS_MODULE, |
@@ -210,10 +210,9 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, | |||
210 | struct pt_regs *regs) | 210 | struct pt_regs *regs) |
211 | { | 211 | { |
212 | struct tty_struct *tty = NULL; | 212 | struct tty_struct *tty = NULL; |
213 | unsigned char ch, r1, drop, error; | 213 | unsigned char ch, r1, drop, error, flag; |
214 | int loops = 0; | 214 | int loops = 0; |
215 | 215 | ||
216 | retry: | ||
217 | /* The interrupt can be enabled when the port isn't open, typically | 216 | /* The interrupt can be enabled when the port isn't open, typically |
218 | * that happens when using one port is open and the other closed (stale | 217 | * that happens when using one port is open and the other closed (stale |
219 | * interrupt) or when one port is used as a console. | 218 | * interrupt) or when one port is used as a console. |
@@ -246,20 +245,6 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, | |||
246 | error = 0; | 245 | error = 0; |
247 | drop = 0; | 246 | drop = 0; |
248 | 247 | ||
249 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
250 | /* Have to drop the lock here */ | ||
251 | pmz_debug("pmz: flip overflow\n"); | ||
252 | spin_unlock(&uap->port.lock); | ||
253 | tty->flip.work.func((void *)tty); | ||
254 | spin_lock(&uap->port.lock); | ||
255 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
256 | drop = 1; | ||
257 | if (ZS_IS_ASLEEP(uap)) | ||
258 | return NULL; | ||
259 | if (!ZS_IS_OPEN(uap)) | ||
260 | goto retry; | ||
261 | } | ||
262 | |||
263 | r1 = read_zsreg(uap, R1); | 248 | r1 = read_zsreg(uap, R1); |
264 | ch = read_zsdata(uap); | 249 | ch = read_zsdata(uap); |
265 | 250 | ||
@@ -295,8 +280,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, | |||
295 | if (drop) | 280 | if (drop) |
296 | goto next_char; | 281 | goto next_char; |
297 | 282 | ||
298 | *tty->flip.char_buf_ptr = ch; | 283 | flag = TTY_NORMAL; |
299 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
300 | uap->port.icount.rx++; | 284 | uap->port.icount.rx++; |
301 | 285 | ||
302 | if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | BRK_ABRT)) { | 286 | if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | BRK_ABRT)) { |
@@ -316,26 +300,19 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap, | |||
316 | uap->port.icount.overrun++; | 300 | uap->port.icount.overrun++; |
317 | r1 &= uap->port.read_status_mask; | 301 | r1 &= uap->port.read_status_mask; |
318 | if (r1 & BRK_ABRT) | 302 | if (r1 & BRK_ABRT) |
319 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 303 | flag = TTY_BREAK; |
320 | else if (r1 & PAR_ERR) | 304 | else if (r1 & PAR_ERR) |
321 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 305 | flag = TTY_PARITY; |
322 | else if (r1 & CRC_ERR) | 306 | else if (r1 & CRC_ERR) |
323 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 307 | flag = TTY_FRAME; |
324 | } | 308 | } |
325 | 309 | ||
326 | if (uap->port.ignore_status_mask == 0xff || | 310 | if (uap->port.ignore_status_mask == 0xff || |
327 | (r1 & uap->port.ignore_status_mask) == 0) { | 311 | (r1 & uap->port.ignore_status_mask) == 0) { |
328 | tty->flip.flag_buf_ptr++; | 312 | tty_insert_flip_char(tty, ch, flag); |
329 | tty->flip.char_buf_ptr++; | ||
330 | tty->flip.count++; | ||
331 | } | ||
332 | if ((r1 & Rx_OVR) && | ||
333 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
334 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | ||
335 | tty->flip.flag_buf_ptr++; | ||
336 | tty->flip.char_buf_ptr++; | ||
337 | tty->flip.count++; | ||
338 | } | 313 | } |
314 | if (r1 & Rx_OVR) | ||
315 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | ||
339 | next_char: | 316 | next_char: |
340 | /* We can get stuck in an infinite loop getting char 0 when the | 317 | /* We can get stuck in an infinite loop getting char 0 when the |
341 | * line is in a wrong HW state, we break that here. | 318 | * line is in a wrong HW state, we break that here. |
@@ -945,7 +922,7 @@ static int pmz_startup(struct uart_port *port) | |||
945 | if (uap->node == NULL) | 922 | if (uap->node == NULL) |
946 | return -ENODEV; | 923 | return -ENODEV; |
947 | 924 | ||
948 | down(&pmz_irq_sem); | 925 | mutex_lock(&pmz_irq_mutex); |
949 | 926 | ||
950 | uap->flags |= PMACZILOG_FLAG_IS_OPEN; | 927 | uap->flags |= PMACZILOG_FLAG_IS_OPEN; |
951 | 928 | ||
@@ -963,11 +940,11 @@ static int pmz_startup(struct uart_port *port) | |||
963 | dev_err(&uap->dev->ofdev.dev, | 940 | dev_err(&uap->dev->ofdev.dev, |
964 | "Unable to register zs interrupt handler.\n"); | 941 | "Unable to register zs interrupt handler.\n"); |
965 | pmz_set_scc_power(uap, 0); | 942 | pmz_set_scc_power(uap, 0); |
966 | up(&pmz_irq_sem); | 943 | mutex_unlock(&pmz_irq_mutex); |
967 | return -ENXIO; | 944 | return -ENXIO; |
968 | } | 945 | } |
969 | 946 | ||
970 | up(&pmz_irq_sem); | 947 | mutex_unlock(&pmz_irq_mutex); |
971 | 948 | ||
972 | /* Right now, we deal with delay by blocking here, I'll be | 949 | /* Right now, we deal with delay by blocking here, I'll be |
973 | * smarter later on | 950 | * smarter later on |
@@ -1004,7 +981,7 @@ static void pmz_shutdown(struct uart_port *port) | |||
1004 | if (uap->node == NULL) | 981 | if (uap->node == NULL) |
1005 | return; | 982 | return; |
1006 | 983 | ||
1007 | down(&pmz_irq_sem); | 984 | mutex_lock(&pmz_irq_mutex); |
1008 | 985 | ||
1009 | /* Release interrupt handler */ | 986 | /* Release interrupt handler */ |
1010 | free_irq(uap->port.irq, uap); | 987 | free_irq(uap->port.irq, uap); |
@@ -1025,7 +1002,7 @@ static void pmz_shutdown(struct uart_port *port) | |||
1025 | 1002 | ||
1026 | if (ZS_IS_CONS(uap) || ZS_IS_ASLEEP(uap)) { | 1003 | if (ZS_IS_CONS(uap) || ZS_IS_ASLEEP(uap)) { |
1027 | spin_unlock_irqrestore(&port->lock, flags); | 1004 | spin_unlock_irqrestore(&port->lock, flags); |
1028 | up(&pmz_irq_sem); | 1005 | mutex_unlock(&pmz_irq_mutex); |
1029 | return; | 1006 | return; |
1030 | } | 1007 | } |
1031 | 1008 | ||
@@ -1042,7 +1019,7 @@ static void pmz_shutdown(struct uart_port *port) | |||
1042 | 1019 | ||
1043 | spin_unlock_irqrestore(&port->lock, flags); | 1020 | spin_unlock_irqrestore(&port->lock, flags); |
1044 | 1021 | ||
1045 | up(&pmz_irq_sem); | 1022 | mutex_unlock(&pmz_irq_mutex); |
1046 | 1023 | ||
1047 | pmz_debug("pmz: shutdown() done.\n"); | 1024 | pmz_debug("pmz: shutdown() done.\n"); |
1048 | } | 1025 | } |
@@ -1431,11 +1408,14 @@ static int __init pmz_init_port(struct uart_pmac_port *uap) | |||
1431 | char name[1]; | 1408 | char name[1]; |
1432 | } *slots; | 1409 | } *slots; |
1433 | int len; | 1410 | int len; |
1411 | struct resource r_ports, r_rxdma, r_txdma; | ||
1434 | 1412 | ||
1435 | /* | 1413 | /* |
1436 | * Request & map chip registers | 1414 | * Request & map chip registers |
1437 | */ | 1415 | */ |
1438 | uap->port.mapbase = np->addrs[0].address; | 1416 | if (of_address_to_resource(np, 0, &r_ports)) |
1417 | return -ENODEV; | ||
1418 | uap->port.mapbase = r_ports.start; | ||
1439 | uap->port.membase = ioremap(uap->port.mapbase, 0x1000); | 1419 | uap->port.membase = ioremap(uap->port.mapbase, 0x1000); |
1440 | 1420 | ||
1441 | uap->control_reg = uap->port.membase; | 1421 | uap->control_reg = uap->port.membase; |
@@ -1445,16 +1425,20 @@ static int __init pmz_init_port(struct uart_pmac_port *uap) | |||
1445 | * Request & map DBDMA registers | 1425 | * Request & map DBDMA registers |
1446 | */ | 1426 | */ |
1447 | #ifdef HAS_DBDMA | 1427 | #ifdef HAS_DBDMA |
1448 | if (np->n_addrs >= 3 && np->n_intrs >= 3) | 1428 | if (of_address_to_resource(np, 1, &r_txdma) == 0 && |
1429 | of_address_to_resource(np, 2, &r_rxdma) == 0) | ||
1449 | uap->flags |= PMACZILOG_FLAG_HAS_DMA; | 1430 | uap->flags |= PMACZILOG_FLAG_HAS_DMA; |
1431 | #else | ||
1432 | memset(&r_txdma, 0, sizeof(struct resource)); | ||
1433 | memset(&r_rxdma, 0, sizeof(struct resource)); | ||
1450 | #endif | 1434 | #endif |
1451 | if (ZS_HAS_DMA(uap)) { | 1435 | if (ZS_HAS_DMA(uap)) { |
1452 | uap->tx_dma_regs = ioremap(np->addrs[np->n_addrs - 2].address, 0x1000); | 1436 | uap->tx_dma_regs = ioremap(r_txdma.start, 0x100); |
1453 | if (uap->tx_dma_regs == NULL) { | 1437 | if (uap->tx_dma_regs == NULL) { |
1454 | uap->flags &= ~PMACZILOG_FLAG_HAS_DMA; | 1438 | uap->flags &= ~PMACZILOG_FLAG_HAS_DMA; |
1455 | goto no_dma; | 1439 | goto no_dma; |
1456 | } | 1440 | } |
1457 | uap->rx_dma_regs = ioremap(np->addrs[np->n_addrs - 1].address, 0x1000); | 1441 | uap->rx_dma_regs = ioremap(r_rxdma.start, 0x100); |
1458 | if (uap->rx_dma_regs == NULL) { | 1442 | if (uap->rx_dma_regs == NULL) { |
1459 | iounmap(uap->tx_dma_regs); | 1443 | iounmap(uap->tx_dma_regs); |
1460 | uap->tx_dma_regs = NULL; | 1444 | uap->tx_dma_regs = NULL; |
@@ -1607,8 +1591,8 @@ static int pmz_suspend(struct macio_dev *mdev, pm_message_t pm_state) | |||
1607 | 1591 | ||
1608 | state = pmz_uart_reg.state + uap->port.line; | 1592 | state = pmz_uart_reg.state + uap->port.line; |
1609 | 1593 | ||
1610 | down(&pmz_irq_sem); | 1594 | mutex_lock(&pmz_irq_mutex); |
1611 | down(&state->sem); | 1595 | mutex_lock(&state->mutex); |
1612 | 1596 | ||
1613 | spin_lock_irqsave(&uap->port.lock, flags); | 1597 | spin_lock_irqsave(&uap->port.lock, flags); |
1614 | 1598 | ||
@@ -1639,8 +1623,8 @@ static int pmz_suspend(struct macio_dev *mdev, pm_message_t pm_state) | |||
1639 | /* Shut the chip down */ | 1623 | /* Shut the chip down */ |
1640 | pmz_set_scc_power(uap, 0); | 1624 | pmz_set_scc_power(uap, 0); |
1641 | 1625 | ||
1642 | up(&state->sem); | 1626 | mutex_unlock(&state->mutex); |
1643 | up(&pmz_irq_sem); | 1627 | mutex_unlock(&pmz_irq_mutex); |
1644 | 1628 | ||
1645 | pmz_debug("suspend, switching complete\n"); | 1629 | pmz_debug("suspend, switching complete\n"); |
1646 | 1630 | ||
@@ -1667,8 +1651,8 @@ static int pmz_resume(struct macio_dev *mdev) | |||
1667 | 1651 | ||
1668 | state = pmz_uart_reg.state + uap->port.line; | 1652 | state = pmz_uart_reg.state + uap->port.line; |
1669 | 1653 | ||
1670 | down(&pmz_irq_sem); | 1654 | mutex_lock(&pmz_irq_mutex); |
1671 | down(&state->sem); | 1655 | mutex_lock(&state->mutex); |
1672 | 1656 | ||
1673 | spin_lock_irqsave(&uap->port.lock, flags); | 1657 | spin_lock_irqsave(&uap->port.lock, flags); |
1674 | if (!ZS_IS_OPEN(uap) && !ZS_IS_CONS(uap)) { | 1658 | if (!ZS_IS_OPEN(uap) && !ZS_IS_CONS(uap)) { |
@@ -1700,8 +1684,8 @@ static int pmz_resume(struct macio_dev *mdev) | |||
1700 | } | 1684 | } |
1701 | 1685 | ||
1702 | bail: | 1686 | bail: |
1703 | up(&state->sem); | 1687 | mutex_unlock(&state->mutex); |
1704 | up(&pmz_irq_sem); | 1688 | mutex_unlock(&pmz_irq_mutex); |
1705 | 1689 | ||
1706 | /* Right now, we deal with delay by blocking here, I'll be | 1690 | /* Right now, we deal with delay by blocking here, I'll be |
1707 | * smarter later on | 1691 | * smarter later on |
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c index ff5e6309d682..10535f00301f 100644 --- a/drivers/serial/pxa.c +++ b/drivers/serial/pxa.c | |||
@@ -107,14 +107,6 @@ receive_chars(struct uart_pxa_port *up, int *status, struct pt_regs *regs) | |||
107 | int max_count = 256; | 107 | int max_count = 256; |
108 | 108 | ||
109 | do { | 109 | do { |
110 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
111 | if (tty->low_latency) | ||
112 | tty_flip_buffer_push(tty); | ||
113 | /* | ||
114 | * If this failed then we will throw away the | ||
115 | * bytes but must do so to clear interrupts | ||
116 | */ | ||
117 | } | ||
118 | ch = serial_in(up, UART_RX); | 110 | ch = serial_in(up, UART_RX); |
119 | flag = TTY_NORMAL; | 111 | flag = TTY_NORMAL; |
120 | up->port.icount.rx++; | 112 | up->port.icount.rx++; |
@@ -361,7 +353,7 @@ static int serial_pxa_startup(struct uart_port *port) | |||
361 | if (port->line == 3) /* HWUART */ | 353 | if (port->line == 3) /* HWUART */ |
362 | up->mcr |= UART_MCR_AFE; | 354 | up->mcr |= UART_MCR_AFE; |
363 | else | 355 | else |
364 | up->mcr = 0; | 356 | up->mcr = 0; |
365 | 357 | ||
366 | /* | 358 | /* |
367 | * Allocate the IRQ | 359 | * Allocate the IRQ |
@@ -641,7 +633,7 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count) | |||
641 | int i; | 633 | int i; |
642 | 634 | ||
643 | /* | 635 | /* |
644 | * First save the UER then disable the interrupts | 636 | * First save the IER then disable the interrupts |
645 | */ | 637 | */ |
646 | ier = serial_in(up, UART_IER); | 638 | ier = serial_in(up, UART_IER); |
647 | serial_out(up, UART_IER, UART_IER_UUE); | 639 | serial_out(up, UART_IER, UART_IER_UUE); |
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index 47681c4654e4..eb4883efb7c6 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c | |||
@@ -72,12 +72,12 @@ | |||
72 | #include <linux/serial_core.h> | 72 | #include <linux/serial_core.h> |
73 | #include <linux/serial.h> | 73 | #include <linux/serial.h> |
74 | #include <linux/delay.h> | 74 | #include <linux/delay.h> |
75 | #include <linux/clk.h> | ||
75 | 76 | ||
76 | #include <asm/io.h> | 77 | #include <asm/io.h> |
77 | #include <asm/irq.h> | 78 | #include <asm/irq.h> |
78 | 79 | ||
79 | #include <asm/hardware.h> | 80 | #include <asm/hardware.h> |
80 | #include <asm/hardware/clock.h> | ||
81 | 81 | ||
82 | #include <asm/arch/regs-serial.h> | 82 | #include <asm/arch/regs-serial.h> |
83 | #include <asm/arch/regs-gpio.h> | 83 | #include <asm/arch/regs-gpio.h> |
@@ -323,16 +323,6 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs) | |||
323 | if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0) | 323 | if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0) |
324 | break; | 324 | break; |
325 | 325 | ||
326 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | ||
327 | if (tty->low_latency) | ||
328 | tty_flip_buffer_push(tty); | ||
329 | |||
330 | /* | ||
331 | * If this failed then we will throw away the | ||
332 | * bytes but must do so to clear interrupts | ||
333 | */ | ||
334 | } | ||
335 | |||
336 | uerstat = rd_regl(port, S3C2410_UERSTAT); | 326 | uerstat = rd_regl(port, S3C2410_UERSTAT); |
337 | ch = rd_regb(port, S3C2410_URXH); | 327 | ch = rd_regb(port, S3C2410_URXH); |
338 | 328 | ||
@@ -782,11 +772,9 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, | |||
782 | 772 | ||
783 | if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) { | 773 | if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) { |
784 | clk_disable(ourport->baudclk); | 774 | clk_disable(ourport->baudclk); |
785 | clk_unuse(ourport->baudclk); | ||
786 | ourport->baudclk = NULL; | 775 | ourport->baudclk = NULL; |
787 | } | 776 | } |
788 | 777 | ||
789 | clk_use(clk); | ||
790 | clk_enable(clk); | 778 | clk_enable(clk); |
791 | 779 | ||
792 | ourport->clksrc = clksrc; | 780 | ourport->clksrc = clksrc; |
@@ -1077,9 +1065,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, | |||
1077 | 1065 | ||
1078 | ourport->clk = clk_get(&platdev->dev, "uart"); | 1066 | ourport->clk = clk_get(&platdev->dev, "uart"); |
1079 | 1067 | ||
1080 | if (ourport->clk != NULL && !IS_ERR(ourport->clk)) | ||
1081 | clk_use(ourport->clk); | ||
1082 | |||
1083 | dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n", | 1068 | dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n", |
1084 | port->mapbase, port->membase, port->irq, port->uartclk); | 1069 | port->mapbase, port->membase, port->irq, port->uartclk); |
1085 | 1070 | ||
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c index 25a086458ab9..1bd93168f504 100644 --- a/drivers/serial/sa1100.c +++ b/drivers/serial/sa1100.c | |||
@@ -201,8 +201,6 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs) | |||
201 | while (status & UTSR1_TO_SM(UTSR1_RNE)) { | 201 | while (status & UTSR1_TO_SM(UTSR1_RNE)) { |
202 | ch = UART_GET_CHAR(sport); | 202 | ch = UART_GET_CHAR(sport); |
203 | 203 | ||
204 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
205 | goto ignore_char; | ||
206 | sport->port.icount.rx++; | 204 | sport->port.icount.rx++; |
207 | 205 | ||
208 | flg = TTY_NORMAL; | 206 | flg = TTY_NORMAL; |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index c17d680e3f04..943770470b9d 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/device.h> | 33 | #include <linux/device.h> |
34 | #include <linux/serial.h> /* for serial_state and serial_icounter_struct */ | 34 | #include <linux/serial.h> /* for serial_state and serial_icounter_struct */ |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
38 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
@@ -47,7 +48,7 @@ | |||
47 | /* | 48 | /* |
48 | * This is used to lock changes in serial line configuration. | 49 | * This is used to lock changes in serial line configuration. |
49 | */ | 50 | */ |
50 | static DECLARE_MUTEX(port_sem); | 51 | static DEFINE_MUTEX(port_mutex); |
51 | 52 | ||
52 | #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) | 53 | #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) |
53 | 54 | ||
@@ -637,7 +638,7 @@ static int uart_set_info(struct uart_state *state, | |||
637 | * module insertion/removal doesn't change anything | 638 | * module insertion/removal doesn't change anything |
638 | * under us. | 639 | * under us. |
639 | */ | 640 | */ |
640 | down(&state->sem); | 641 | mutex_lock(&state->mutex); |
641 | 642 | ||
642 | change_irq = new_serial.irq != port->irq; | 643 | change_irq = new_serial.irq != port->irq; |
643 | 644 | ||
@@ -796,7 +797,7 @@ static int uart_set_info(struct uart_state *state, | |||
796 | } else | 797 | } else |
797 | retval = uart_startup(state, 1); | 798 | retval = uart_startup(state, 1); |
798 | exit: | 799 | exit: |
799 | up(&state->sem); | 800 | mutex_unlock(&state->mutex); |
800 | return retval; | 801 | return retval; |
801 | } | 802 | } |
802 | 803 | ||
@@ -833,7 +834,7 @@ static int uart_tiocmget(struct tty_struct *tty, struct file *file) | |||
833 | struct uart_port *port = state->port; | 834 | struct uart_port *port = state->port; |
834 | int result = -EIO; | 835 | int result = -EIO; |
835 | 836 | ||
836 | down(&state->sem); | 837 | mutex_lock(&state->mutex); |
837 | if ((!file || !tty_hung_up_p(file)) && | 838 | if ((!file || !tty_hung_up_p(file)) && |
838 | !(tty->flags & (1 << TTY_IO_ERROR))) { | 839 | !(tty->flags & (1 << TTY_IO_ERROR))) { |
839 | result = port->mctrl; | 840 | result = port->mctrl; |
@@ -842,7 +843,7 @@ static int uart_tiocmget(struct tty_struct *tty, struct file *file) | |||
842 | result |= port->ops->get_mctrl(port); | 843 | result |= port->ops->get_mctrl(port); |
843 | spin_unlock_irq(&port->lock); | 844 | spin_unlock_irq(&port->lock); |
844 | } | 845 | } |
845 | up(&state->sem); | 846 | mutex_unlock(&state->mutex); |
846 | 847 | ||
847 | return result; | 848 | return result; |
848 | } | 849 | } |
@@ -855,13 +856,13 @@ uart_tiocmset(struct tty_struct *tty, struct file *file, | |||
855 | struct uart_port *port = state->port; | 856 | struct uart_port *port = state->port; |
856 | int ret = -EIO; | 857 | int ret = -EIO; |
857 | 858 | ||
858 | down(&state->sem); | 859 | mutex_lock(&state->mutex); |
859 | if ((!file || !tty_hung_up_p(file)) && | 860 | if ((!file || !tty_hung_up_p(file)) && |
860 | !(tty->flags & (1 << TTY_IO_ERROR))) { | 861 | !(tty->flags & (1 << TTY_IO_ERROR))) { |
861 | uart_update_mctrl(port, set, clear); | 862 | uart_update_mctrl(port, set, clear); |
862 | ret = 0; | 863 | ret = 0; |
863 | } | 864 | } |
864 | up(&state->sem); | 865 | mutex_unlock(&state->mutex); |
865 | return ret; | 866 | return ret; |
866 | } | 867 | } |
867 | 868 | ||
@@ -872,12 +873,12 @@ static void uart_break_ctl(struct tty_struct *tty, int break_state) | |||
872 | 873 | ||
873 | BUG_ON(!kernel_locked()); | 874 | BUG_ON(!kernel_locked()); |
874 | 875 | ||
875 | down(&state->sem); | 876 | mutex_lock(&state->mutex); |
876 | 877 | ||
877 | if (port->type != PORT_UNKNOWN) | 878 | if (port->type != PORT_UNKNOWN) |
878 | port->ops->break_ctl(port, break_state); | 879 | port->ops->break_ctl(port, break_state); |
879 | 880 | ||
880 | up(&state->sem); | 881 | mutex_unlock(&state->mutex); |
881 | } | 882 | } |
882 | 883 | ||
883 | static int uart_do_autoconfig(struct uart_state *state) | 884 | static int uart_do_autoconfig(struct uart_state *state) |
@@ -893,7 +894,7 @@ static int uart_do_autoconfig(struct uart_state *state) | |||
893 | * changing, and hence any extra opens of the port while | 894 | * changing, and hence any extra opens of the port while |
894 | * we're auto-configuring. | 895 | * we're auto-configuring. |
895 | */ | 896 | */ |
896 | if (down_interruptible(&state->sem)) | 897 | if (mutex_lock_interruptible(&state->mutex)) |
897 | return -ERESTARTSYS; | 898 | return -ERESTARTSYS; |
898 | 899 | ||
899 | ret = -EBUSY; | 900 | ret = -EBUSY; |
@@ -919,7 +920,7 @@ static int uart_do_autoconfig(struct uart_state *state) | |||
919 | 920 | ||
920 | ret = uart_startup(state, 1); | 921 | ret = uart_startup(state, 1); |
921 | } | 922 | } |
922 | up(&state->sem); | 923 | mutex_unlock(&state->mutex); |
923 | return ret; | 924 | return ret; |
924 | } | 925 | } |
925 | 926 | ||
@@ -1073,7 +1074,7 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, | |||
1073 | if (ret != -ENOIOCTLCMD) | 1074 | if (ret != -ENOIOCTLCMD) |
1074 | goto out; | 1075 | goto out; |
1075 | 1076 | ||
1076 | down(&state->sem); | 1077 | mutex_lock(&state->mutex); |
1077 | 1078 | ||
1078 | if (tty_hung_up_p(filp)) { | 1079 | if (tty_hung_up_p(filp)) { |
1079 | ret = -EIO; | 1080 | ret = -EIO; |
@@ -1097,7 +1098,7 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, | |||
1097 | } | 1098 | } |
1098 | } | 1099 | } |
1099 | out_up: | 1100 | out_up: |
1100 | up(&state->sem); | 1101 | mutex_unlock(&state->mutex); |
1101 | out: | 1102 | out: |
1102 | return ret; | 1103 | return ret; |
1103 | } | 1104 | } |
@@ -1185,7 +1186,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) | |||
1185 | 1186 | ||
1186 | DPRINTK("uart_close(%d) called\n", port->line); | 1187 | DPRINTK("uart_close(%d) called\n", port->line); |
1187 | 1188 | ||
1188 | down(&state->sem); | 1189 | mutex_lock(&state->mutex); |
1189 | 1190 | ||
1190 | if (tty_hung_up_p(filp)) | 1191 | if (tty_hung_up_p(filp)) |
1191 | goto done; | 1192 | goto done; |
@@ -1259,7 +1260,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) | |||
1259 | wake_up_interruptible(&state->info->open_wait); | 1260 | wake_up_interruptible(&state->info->open_wait); |
1260 | 1261 | ||
1261 | done: | 1262 | done: |
1262 | up(&state->sem); | 1263 | mutex_unlock(&state->mutex); |
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | static void uart_wait_until_sent(struct tty_struct *tty, int timeout) | 1266 | static void uart_wait_until_sent(struct tty_struct *tty, int timeout) |
@@ -1333,7 +1334,7 @@ static void uart_hangup(struct tty_struct *tty) | |||
1333 | BUG_ON(!kernel_locked()); | 1334 | BUG_ON(!kernel_locked()); |
1334 | DPRINTK("uart_hangup(%d)\n", state->port->line); | 1335 | DPRINTK("uart_hangup(%d)\n", state->port->line); |
1335 | 1336 | ||
1336 | down(&state->sem); | 1337 | mutex_lock(&state->mutex); |
1337 | if (state->info && state->info->flags & UIF_NORMAL_ACTIVE) { | 1338 | if (state->info && state->info->flags & UIF_NORMAL_ACTIVE) { |
1338 | uart_flush_buffer(tty); | 1339 | uart_flush_buffer(tty); |
1339 | uart_shutdown(state); | 1340 | uart_shutdown(state); |
@@ -1343,7 +1344,7 @@ static void uart_hangup(struct tty_struct *tty) | |||
1343 | wake_up_interruptible(&state->info->open_wait); | 1344 | wake_up_interruptible(&state->info->open_wait); |
1344 | wake_up_interruptible(&state->info->delta_msr_wait); | 1345 | wake_up_interruptible(&state->info->delta_msr_wait); |
1345 | } | 1346 | } |
1346 | up(&state->sem); | 1347 | mutex_unlock(&state->mutex); |
1347 | } | 1348 | } |
1348 | 1349 | ||
1349 | /* | 1350 | /* |
@@ -1440,14 +1441,15 @@ uart_block_til_ready(struct file *filp, struct uart_state *state) | |||
1440 | * modem is ready for us. | 1441 | * modem is ready for us. |
1441 | */ | 1442 | */ |
1442 | spin_lock_irq(&port->lock); | 1443 | spin_lock_irq(&port->lock); |
1444 | port->ops->enable_ms(port); | ||
1443 | mctrl = port->ops->get_mctrl(port); | 1445 | mctrl = port->ops->get_mctrl(port); |
1444 | spin_unlock_irq(&port->lock); | 1446 | spin_unlock_irq(&port->lock); |
1445 | if (mctrl & TIOCM_CAR) | 1447 | if (mctrl & TIOCM_CAR) |
1446 | break; | 1448 | break; |
1447 | 1449 | ||
1448 | up(&state->sem); | 1450 | mutex_unlock(&state->mutex); |
1449 | schedule(); | 1451 | schedule(); |
1450 | down(&state->sem); | 1452 | mutex_lock(&state->mutex); |
1451 | 1453 | ||
1452 | if (signal_pending(current)) | 1454 | if (signal_pending(current)) |
1453 | break; | 1455 | break; |
@@ -1471,9 +1473,9 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1471 | { | 1473 | { |
1472 | struct uart_state *state; | 1474 | struct uart_state *state; |
1473 | 1475 | ||
1474 | down(&port_sem); | 1476 | mutex_lock(&port_mutex); |
1475 | state = drv->state + line; | 1477 | state = drv->state + line; |
1476 | if (down_interruptible(&state->sem)) { | 1478 | if (mutex_lock_interruptible(&state->mutex)) { |
1477 | state = ERR_PTR(-ERESTARTSYS); | 1479 | state = ERR_PTR(-ERESTARTSYS); |
1478 | goto out; | 1480 | goto out; |
1479 | } | 1481 | } |
@@ -1481,7 +1483,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1481 | state->count++; | 1483 | state->count++; |
1482 | if (!state->port) { | 1484 | if (!state->port) { |
1483 | state->count--; | 1485 | state->count--; |
1484 | up(&state->sem); | 1486 | mutex_unlock(&state->mutex); |
1485 | state = ERR_PTR(-ENXIO); | 1487 | state = ERR_PTR(-ENXIO); |
1486 | goto out; | 1488 | goto out; |
1487 | } | 1489 | } |
@@ -1502,13 +1504,13 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1502 | (unsigned long)state); | 1504 | (unsigned long)state); |
1503 | } else { | 1505 | } else { |
1504 | state->count--; | 1506 | state->count--; |
1505 | up(&state->sem); | 1507 | mutex_unlock(&state->mutex); |
1506 | state = ERR_PTR(-ENOMEM); | 1508 | state = ERR_PTR(-ENOMEM); |
1507 | } | 1509 | } |
1508 | } | 1510 | } |
1509 | 1511 | ||
1510 | out: | 1512 | out: |
1511 | up(&port_sem); | 1513 | mutex_unlock(&port_mutex); |
1512 | return state; | 1514 | return state; |
1513 | } | 1515 | } |
1514 | 1516 | ||
@@ -1569,7 +1571,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) | |||
1569 | if (tty_hung_up_p(filp)) { | 1571 | if (tty_hung_up_p(filp)) { |
1570 | retval = -EAGAIN; | 1572 | retval = -EAGAIN; |
1571 | state->count--; | 1573 | state->count--; |
1572 | up(&state->sem); | 1574 | mutex_unlock(&state->mutex); |
1573 | goto fail; | 1575 | goto fail; |
1574 | } | 1576 | } |
1575 | 1577 | ||
@@ -1589,7 +1591,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) | |||
1589 | */ | 1591 | */ |
1590 | if (retval == 0) | 1592 | if (retval == 0) |
1591 | retval = uart_block_til_ready(filp, state); | 1593 | retval = uart_block_til_ready(filp, state); |
1592 | up(&state->sem); | 1594 | mutex_unlock(&state->mutex); |
1593 | 1595 | ||
1594 | /* | 1596 | /* |
1595 | * If this is the first open to succeed, adjust things to suit. | 1597 | * If this is the first open to succeed, adjust things to suit. |
@@ -1865,7 +1867,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port) | |||
1865 | { | 1867 | { |
1866 | struct uart_state *state = drv->state + port->line; | 1868 | struct uart_state *state = drv->state + port->line; |
1867 | 1869 | ||
1868 | down(&state->sem); | 1870 | mutex_lock(&state->mutex); |
1869 | 1871 | ||
1870 | if (state->info && state->info->flags & UIF_INITIALIZED) { | 1872 | if (state->info && state->info->flags & UIF_INITIALIZED) { |
1871 | struct uart_ops *ops = port->ops; | 1873 | struct uart_ops *ops = port->ops; |
@@ -1894,7 +1896,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port) | |||
1894 | 1896 | ||
1895 | uart_change_pm(state, 3); | 1897 | uart_change_pm(state, 3); |
1896 | 1898 | ||
1897 | up(&state->sem); | 1899 | mutex_unlock(&state->mutex); |
1898 | 1900 | ||
1899 | return 0; | 1901 | return 0; |
1900 | } | 1902 | } |
@@ -1903,7 +1905,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port) | |||
1903 | { | 1905 | { |
1904 | struct uart_state *state = drv->state + port->line; | 1906 | struct uart_state *state = drv->state + port->line; |
1905 | 1907 | ||
1906 | down(&state->sem); | 1908 | mutex_lock(&state->mutex); |
1907 | 1909 | ||
1908 | uart_change_pm(state, 0); | 1910 | uart_change_pm(state, 0); |
1909 | 1911 | ||
@@ -1952,7 +1954,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port) | |||
1952 | } | 1954 | } |
1953 | } | 1955 | } |
1954 | 1956 | ||
1955 | up(&state->sem); | 1957 | mutex_unlock(&state->mutex); |
1956 | 1958 | ||
1957 | return 0; | 1959 | return 0; |
1958 | } | 1960 | } |
@@ -2047,7 +2049,7 @@ uart_unconfigure_port(struct uart_driver *drv, struct uart_state *state) | |||
2047 | if (info && info->tty) | 2049 | if (info && info->tty) |
2048 | tty_vhangup(info->tty); | 2050 | tty_vhangup(info->tty); |
2049 | 2051 | ||
2050 | down(&state->sem); | 2052 | mutex_lock(&state->mutex); |
2051 | 2053 | ||
2052 | state->info = NULL; | 2054 | state->info = NULL; |
2053 | 2055 | ||
@@ -2070,7 +2072,7 @@ uart_unconfigure_port(struct uart_driver *drv, struct uart_state *state) | |||
2070 | kfree(info); | 2072 | kfree(info); |
2071 | } | 2073 | } |
2072 | 2074 | ||
2073 | up(&state->sem); | 2075 | mutex_unlock(&state->mutex); |
2074 | } | 2076 | } |
2075 | 2077 | ||
2076 | static struct tty_operations uart_ops = { | 2078 | static struct tty_operations uart_ops = { |
@@ -2159,7 +2161,7 @@ int uart_register_driver(struct uart_driver *drv) | |||
2159 | state->close_delay = 500; /* .5 seconds */ | 2161 | state->close_delay = 500; /* .5 seconds */ |
2160 | state->closing_wait = 30000; /* 30 seconds */ | 2162 | state->closing_wait = 30000; /* 30 seconds */ |
2161 | 2163 | ||
2162 | init_MUTEX(&state->sem); | 2164 | mutex_init(&state->mutex); |
2163 | } | 2165 | } |
2164 | 2166 | ||
2165 | retval = tty_register_driver(normal); | 2167 | retval = tty_register_driver(normal); |
@@ -2218,7 +2220,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2218 | 2220 | ||
2219 | state = drv->state + port->line; | 2221 | state = drv->state + port->line; |
2220 | 2222 | ||
2221 | down(&port_sem); | 2223 | mutex_lock(&port_mutex); |
2222 | if (state->port) { | 2224 | if (state->port) { |
2223 | ret = -EINVAL; | 2225 | ret = -EINVAL; |
2224 | goto out; | 2226 | goto out; |
@@ -2254,7 +2256,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2254 | register_console(port->cons); | 2256 | register_console(port->cons); |
2255 | 2257 | ||
2256 | out: | 2258 | out: |
2257 | up(&port_sem); | 2259 | mutex_unlock(&port_mutex); |
2258 | 2260 | ||
2259 | return ret; | 2261 | return ret; |
2260 | } | 2262 | } |
@@ -2278,7 +2280,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2278 | printk(KERN_ALERT "Removing wrong port: %p != %p\n", | 2280 | printk(KERN_ALERT "Removing wrong port: %p != %p\n", |
2279 | state->port, port); | 2281 | state->port, port); |
2280 | 2282 | ||
2281 | down(&port_sem); | 2283 | mutex_lock(&port_mutex); |
2282 | 2284 | ||
2283 | /* | 2285 | /* |
2284 | * Remove the devices from devfs | 2286 | * Remove the devices from devfs |
@@ -2287,7 +2289,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2287 | 2289 | ||
2288 | uart_unconfigure_port(drv, state); | 2290 | uart_unconfigure_port(drv, state); |
2289 | state->port = NULL; | 2291 | state->port = NULL; |
2290 | up(&port_sem); | 2292 | mutex_unlock(&port_mutex); |
2291 | 2293 | ||
2292 | return 0; | 2294 | return 0; |
2293 | } | 2295 | } |
@@ -2307,7 +2309,7 @@ int uart_match_port(struct uart_port *port1, struct uart_port *port2) | |||
2307 | return (port1->iobase == port2->iobase) && | 2309 | return (port1->iobase == port2->iobase) && |
2308 | (port1->hub6 == port2->hub6); | 2310 | (port1->hub6 == port2->hub6); |
2309 | case UPIO_MEM: | 2311 | case UPIO_MEM: |
2310 | return (port1->membase == port2->membase); | 2312 | return (port1->mapbase == port2->mapbase); |
2311 | } | 2313 | } |
2312 | return 0; | 2314 | return 0; |
2313 | } | 2315 | } |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 7ce0c7e66d37..c30333694fde 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c | |||
@@ -114,15 +114,7 @@ struct serial_cfg_mem { | |||
114 | 114 | ||
115 | 115 | ||
116 | static void serial_config(dev_link_t * link); | 116 | static void serial_config(dev_link_t * link); |
117 | static int serial_event(event_t event, int priority, | ||
118 | event_callback_args_t * args); | ||
119 | 117 | ||
120 | static dev_info_t dev_info = "serial_cs"; | ||
121 | |||
122 | static dev_link_t *serial_attach(void); | ||
123 | static void serial_detach(dev_link_t *); | ||
124 | |||
125 | static dev_link_t *dev_list = NULL; | ||
126 | 118 | ||
127 | /*====================================================================== | 119 | /*====================================================================== |
128 | 120 | ||
@@ -159,8 +151,9 @@ static void serial_remove(dev_link_t *link) | |||
159 | } | 151 | } |
160 | } | 152 | } |
161 | 153 | ||
162 | static void serial_suspend(dev_link_t *link) | 154 | static int serial_suspend(struct pcmcia_device *dev) |
163 | { | 155 | { |
156 | dev_link_t *link = dev_to_instance(dev); | ||
164 | link->state |= DEV_SUSPEND; | 157 | link->state |= DEV_SUSPEND; |
165 | 158 | ||
166 | if (link->state & DEV_CONFIG) { | 159 | if (link->state & DEV_CONFIG) { |
@@ -173,10 +166,13 @@ static void serial_suspend(dev_link_t *link) | |||
173 | if (!info->slave) | 166 | if (!info->slave) |
174 | pcmcia_release_configuration(link->handle); | 167 | pcmcia_release_configuration(link->handle); |
175 | } | 168 | } |
169 | |||
170 | return 0; | ||
176 | } | 171 | } |
177 | 172 | ||
178 | static void serial_resume(dev_link_t *link) | 173 | static int serial_resume(struct pcmcia_device *dev) |
179 | { | 174 | { |
175 | dev_link_t *link = dev_to_instance(dev); | ||
180 | link->state &= ~DEV_SUSPEND; | 176 | link->state &= ~DEV_SUSPEND; |
181 | 177 | ||
182 | if (DEV_OK(link)) { | 178 | if (DEV_OK(link)) { |
@@ -189,6 +185,8 @@ static void serial_resume(dev_link_t *link) | |||
189 | for (i = 0; i < info->ndev; i++) | 185 | for (i = 0; i < info->ndev; i++) |
190 | serial8250_resume_port(info->line[i]); | 186 | serial8250_resume_port(info->line[i]); |
191 | } | 187 | } |
188 | |||
189 | return 0; | ||
192 | } | 190 | } |
193 | 191 | ||
194 | /*====================================================================== | 192 | /*====================================================================== |
@@ -199,19 +197,17 @@ static void serial_resume(dev_link_t *link) | |||
199 | 197 | ||
200 | ======================================================================*/ | 198 | ======================================================================*/ |
201 | 199 | ||
202 | static dev_link_t *serial_attach(void) | 200 | static int serial_probe(struct pcmcia_device *p_dev) |
203 | { | 201 | { |
204 | struct serial_info *info; | 202 | struct serial_info *info; |
205 | client_reg_t client_reg; | ||
206 | dev_link_t *link; | 203 | dev_link_t *link; |
207 | int ret; | ||
208 | 204 | ||
209 | DEBUG(0, "serial_attach()\n"); | 205 | DEBUG(0, "serial_attach()\n"); |
210 | 206 | ||
211 | /* Create new serial device */ | 207 | /* Create new serial device */ |
212 | info = kmalloc(sizeof (*info), GFP_KERNEL); | 208 | info = kmalloc(sizeof (*info), GFP_KERNEL); |
213 | if (!info) | 209 | if (!info) |
214 | return NULL; | 210 | return -ENOMEM; |
215 | memset(info, 0, sizeof (*info)); | 211 | memset(info, 0, sizeof (*info)); |
216 | link = &info->link; | 212 | link = &info->link; |
217 | link->priv = info; | 213 | link->priv = info; |
@@ -227,20 +223,12 @@ static dev_link_t *serial_attach(void) | |||
227 | } | 223 | } |
228 | link->conf.IntType = INT_MEMORY_AND_IO; | 224 | link->conf.IntType = INT_MEMORY_AND_IO; |
229 | 225 | ||
230 | /* Register with Card Services */ | 226 | link->handle = p_dev; |
231 | link->next = dev_list; | 227 | p_dev->instance = link; |
232 | dev_list = link; | 228 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
233 | client_reg.dev_info = &dev_info; | 229 | serial_config(link); |
234 | client_reg.Version = 0x0210; | ||
235 | client_reg.event_callback_args.client_data = link; | ||
236 | ret = pcmcia_register_client(&link->handle, &client_reg); | ||
237 | if (ret != CS_SUCCESS) { | ||
238 | cs_error(link->handle, RegisterClient, ret); | ||
239 | serial_detach(link); | ||
240 | return NULL; | ||
241 | } | ||
242 | 230 | ||
243 | return link; | 231 | return 0; |
244 | } | 232 | } |
245 | 233 | ||
246 | /*====================================================================== | 234 | /*====================================================================== |
@@ -252,21 +240,13 @@ static dev_link_t *serial_attach(void) | |||
252 | 240 | ||
253 | ======================================================================*/ | 241 | ======================================================================*/ |
254 | 242 | ||
255 | static void serial_detach(dev_link_t * link) | 243 | static void serial_detach(struct pcmcia_device *p_dev) |
256 | { | 244 | { |
245 | dev_link_t *link = dev_to_instance(p_dev); | ||
257 | struct serial_info *info = link->priv; | 246 | struct serial_info *info = link->priv; |
258 | dev_link_t **linkp; | ||
259 | int ret; | ||
260 | 247 | ||
261 | DEBUG(0, "serial_detach(0x%p)\n", link); | 248 | DEBUG(0, "serial_detach(0x%p)\n", link); |
262 | 249 | ||
263 | /* Locate device structure */ | ||
264 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) | ||
265 | if (*linkp == link) | ||
266 | break; | ||
267 | if (*linkp == NULL) | ||
268 | return; | ||
269 | |||
270 | /* | 250 | /* |
271 | * Ensure any outstanding scheduled tasks are completed. | 251 | * Ensure any outstanding scheduled tasks are completed. |
272 | */ | 252 | */ |
@@ -277,14 +257,7 @@ static void serial_detach(dev_link_t * link) | |||
277 | */ | 257 | */ |
278 | serial_remove(link); | 258 | serial_remove(link); |
279 | 259 | ||
280 | if (link->handle) { | 260 | /* free bits */ |
281 | ret = pcmcia_deregister_client(link->handle); | ||
282 | if (ret != CS_SUCCESS) | ||
283 | cs_error(link->handle, DeregisterClient, ret); | ||
284 | } | ||
285 | |||
286 | /* Unlink device structure, free bits */ | ||
287 | *linkp = link->next; | ||
288 | kfree(info); | 261 | kfree(info); |
289 | } | 262 | } |
290 | 263 | ||
@@ -718,54 +691,6 @@ void serial_config(dev_link_t * link) | |||
718 | kfree(cfg_mem); | 691 | kfree(cfg_mem); |
719 | } | 692 | } |
720 | 693 | ||
721 | /*====================================================================== | ||
722 | |||
723 | The card status event handler. Mostly, this schedules other | ||
724 | stuff to run after an event is received. A CARD_REMOVAL event | ||
725 | also sets some flags to discourage the serial drivers from | ||
726 | talking to the ports. | ||
727 | |||
728 | ======================================================================*/ | ||
729 | |||
730 | static int | ||
731 | serial_event(event_t event, int priority, event_callback_args_t * args) | ||
732 | { | ||
733 | dev_link_t *link = args->client_data; | ||
734 | struct serial_info *info = link->priv; | ||
735 | |||
736 | DEBUG(1, "serial_event(0x%06x)\n", event); | ||
737 | |||
738 | switch (event) { | ||
739 | case CS_EVENT_CARD_REMOVAL: | ||
740 | serial_remove(link); | ||
741 | break; | ||
742 | |||
743 | case CS_EVENT_CARD_INSERTION: | ||
744 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
745 | serial_config(link); | ||
746 | break; | ||
747 | |||
748 | case CS_EVENT_PM_SUSPEND: | ||
749 | serial_suspend(link); | ||
750 | break; | ||
751 | |||
752 | case CS_EVENT_RESET_PHYSICAL: | ||
753 | if ((link->state & DEV_CONFIG) && !info->slave) | ||
754 | pcmcia_release_configuration(link->handle); | ||
755 | break; | ||
756 | |||
757 | case CS_EVENT_PM_RESUME: | ||
758 | serial_resume(link); | ||
759 | break; | ||
760 | |||
761 | case CS_EVENT_CARD_RESET: | ||
762 | if (DEV_OK(link) && !info->slave) | ||
763 | pcmcia_request_configuration(link->handle, &link->conf); | ||
764 | break; | ||
765 | } | ||
766 | return 0; | ||
767 | } | ||
768 | |||
769 | static struct pcmcia_device_id serial_ids[] = { | 694 | static struct pcmcia_device_id serial_ids[] = { |
770 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), | 695 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), |
771 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), | 696 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), |
@@ -860,6 +785,8 @@ static struct pcmcia_device_id serial_ids[] = { | |||
860 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "3CXEM556.cis"), | 785 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "3CXEM556.cis"), |
861 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "3CXEM556.cis"), | 786 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "3CXEM556.cis"), |
862 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */ | 787 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */ |
788 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */ | ||
789 | PCMCIA_DEVICE_CIS_MANF_CARD(0x013f, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- post update */ | ||
863 | PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"), | 790 | PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"), |
864 | PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), | 791 | PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), |
865 | PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), | 792 | PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), |
@@ -877,10 +804,11 @@ static struct pcmcia_driver serial_cs_driver = { | |||
877 | .drv = { | 804 | .drv = { |
878 | .name = "serial_cs", | 805 | .name = "serial_cs", |
879 | }, | 806 | }, |
880 | .attach = serial_attach, | 807 | .probe = serial_probe, |
881 | .event = serial_event, | 808 | .remove = serial_detach, |
882 | .detach = serial_detach, | ||
883 | .id_table = serial_ids, | 809 | .id_table = serial_ids, |
810 | .suspend = serial_suspend, | ||
811 | .resume = serial_resume, | ||
884 | }; | 812 | }; |
885 | 813 | ||
886 | static int __init init_serial_cs(void) | 814 | static int __init init_serial_cs(void) |
@@ -891,7 +819,6 @@ static int __init init_serial_cs(void) | |||
891 | static void __exit exit_serial_cs(void) | 819 | static void __exit exit_serial_cs(void) |
892 | { | 820 | { |
893 | pcmcia_unregister_driver(&serial_cs_driver); | 821 | pcmcia_unregister_driver(&serial_cs_driver); |
894 | BUG_ON(dev_list != NULL); | ||
895 | } | 822 | } |
896 | 823 | ||
897 | module_init(init_serial_cs); | 824 | module_init(init_serial_cs); |
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c index d01dbe5da3b9..d4a1f0e798c1 100644 --- a/drivers/serial/serial_lh7a40x.c +++ b/drivers/serial/serial_lh7a40x.c | |||
@@ -148,15 +148,6 @@ lh7a40xuart_rx_chars (struct uart_port* port) | |||
148 | unsigned int data, flag;/* Received data and status */ | 148 | unsigned int data, flag;/* Received data and status */ |
149 | 149 | ||
150 | while (!(UR (port, UART_R_STATUS) & nRxRdy) && --cbRxMax) { | 150 | while (!(UR (port, UART_R_STATUS) & nRxRdy) && --cbRxMax) { |
151 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | ||
152 | if (tty->low_latency) | ||
153 | tty_flip_buffer_push(tty); | ||
154 | /* | ||
155 | * If this failed then we will throw away the | ||
156 | * bytes but must do so to clear interrupts | ||
157 | */ | ||
158 | } | ||
159 | |||
160 | data = UR (port, UART_R_DATA); | 151 | data = UR (port, UART_R_DATA); |
161 | flag = TTY_NORMAL; | 152 | flag = TTY_NORMAL; |
162 | ++port->icount.rx; | 153 | ++port->icount.rx; |
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index f10c86d60b64..ee98a867bc6d 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <linux/tty_flip.h> | 52 | #include <linux/tty_flip.h> |
53 | #include <linux/serial_core.h> | 53 | #include <linux/serial_core.h> |
54 | #include <linux/serial.h> | 54 | #include <linux/serial.h> |
55 | #include <linux/mutex.h> | ||
55 | 56 | ||
56 | #include <asm/io.h> | 57 | #include <asm/io.h> |
57 | #include <asm/irq.h> | 58 | #include <asm/irq.h> |
@@ -303,17 +304,6 @@ receive_chars(struct uart_txx9_port *up, unsigned int *status, struct pt_regs *r | |||
303 | char flag; | 304 | char flag; |
304 | 305 | ||
305 | do { | 306 | do { |
306 | /* The following is not allowed by the tty layer and | ||
307 | unsafe. It should be fixed ASAP */ | ||
308 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
309 | if (tty->low_latency) { | ||
310 | spin_unlock(&up->port.lock); | ||
311 | tty_flip_buffer_push(tty); | ||
312 | spin_lock(&up->port.lock); | ||
313 | } | ||
314 | /* If this failed then we will throw away the | ||
315 | bytes but must do so to clear interrupts */ | ||
316 | } | ||
317 | ch = sio_in(up, TXX9_SIRFIFO); | 307 | ch = sio_in(up, TXX9_SIRFIFO); |
318 | flag = TTY_NORMAL; | 308 | flag = TTY_NORMAL; |
319 | up->port.icount.rx++; | 309 | up->port.icount.rx++; |
@@ -1029,7 +1019,7 @@ static void serial_txx9_resume_port(int line) | |||
1029 | uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); | 1019 | uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); |
1030 | } | 1020 | } |
1031 | 1021 | ||
1032 | static DECLARE_MUTEX(serial_txx9_sem); | 1022 | static DEFINE_MUTEX(serial_txx9_mutex); |
1033 | 1023 | ||
1034 | /** | 1024 | /** |
1035 | * serial_txx9_register_port - register a serial port | 1025 | * serial_txx9_register_port - register a serial port |
@@ -1048,7 +1038,7 @@ static int __devinit serial_txx9_register_port(struct uart_port *port) | |||
1048 | struct uart_txx9_port *uart; | 1038 | struct uart_txx9_port *uart; |
1049 | int ret = -ENOSPC; | 1039 | int ret = -ENOSPC; |
1050 | 1040 | ||
1051 | down(&serial_txx9_sem); | 1041 | mutex_lock(&serial_txx9_mutex); |
1052 | for (i = 0; i < UART_NR; i++) { | 1042 | for (i = 0; i < UART_NR; i++) { |
1053 | uart = &serial_txx9_ports[i]; | 1043 | uart = &serial_txx9_ports[i]; |
1054 | if (uart->port.type == PORT_UNKNOWN) | 1044 | if (uart->port.type == PORT_UNKNOWN) |
@@ -1069,7 +1059,7 @@ static int __devinit serial_txx9_register_port(struct uart_port *port) | |||
1069 | if (ret == 0) | 1059 | if (ret == 0) |
1070 | ret = uart->port.line; | 1060 | ret = uart->port.line; |
1071 | } | 1061 | } |
1072 | up(&serial_txx9_sem); | 1062 | mutex_unlock(&serial_txx9_mutex); |
1073 | return ret; | 1063 | return ret; |
1074 | } | 1064 | } |
1075 | 1065 | ||
@@ -1084,7 +1074,7 @@ static void __devexit serial_txx9_unregister_port(int line) | |||
1084 | { | 1074 | { |
1085 | struct uart_txx9_port *uart = &serial_txx9_ports[line]; | 1075 | struct uart_txx9_port *uart = &serial_txx9_ports[line]; |
1086 | 1076 | ||
1087 | down(&serial_txx9_sem); | 1077 | mutex_lock(&serial_txx9_mutex); |
1088 | uart_remove_one_port(&serial_txx9_reg, &uart->port); | 1078 | uart_remove_one_port(&serial_txx9_reg, &uart->port); |
1089 | uart->port.flags = 0; | 1079 | uart->port.flags = 0; |
1090 | uart->port.type = PORT_UNKNOWN; | 1080 | uart->port.type = PORT_UNKNOWN; |
@@ -1093,7 +1083,7 @@ static void __devexit serial_txx9_unregister_port(int line) | |||
1093 | uart->port.membase = 0; | 1083 | uart->port.membase = 0; |
1094 | uart->port.dev = NULL; | 1084 | uart->port.dev = NULL; |
1095 | uart_add_one_port(&serial_txx9_reg, &uart->port); | 1085 | uart_add_one_port(&serial_txx9_reg, &uart->port); |
1096 | up(&serial_txx9_sem); | 1086 | mutex_unlock(&serial_txx9_mutex); |
1097 | } | 1087 | } |
1098 | 1088 | ||
1099 | /* | 1089 | /* |
@@ -1195,7 +1185,7 @@ static int __init serial_txx9_init(void) | |||
1195 | serial_txx9_register_ports(&serial_txx9_reg); | 1185 | serial_txx9_register_ports(&serial_txx9_reg); |
1196 | 1186 | ||
1197 | #ifdef ENABLE_SERIAL_TXX9_PCI | 1187 | #ifdef ENABLE_SERIAL_TXX9_PCI |
1198 | ret = pci_module_init(&serial_txx9_pci_driver); | 1188 | ret = pci_register_driver(&serial_txx9_pci_driver); |
1199 | #endif | 1189 | #endif |
1200 | } | 1190 | } |
1201 | return ret; | 1191 | return ret; |
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 430754ebac8a..a9e070759628 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -482,6 +482,7 @@ static inline void sci_receive_chars(struct uart_port *port, | |||
482 | struct tty_struct *tty = port->info->tty; | 482 | struct tty_struct *tty = port->info->tty; |
483 | int i, count, copied = 0; | 483 | int i, count, copied = 0; |
484 | unsigned short status; | 484 | unsigned short status; |
485 | unsigned char flag; | ||
485 | 486 | ||
486 | status = sci_in(port, SCxSR); | 487 | status = sci_in(port, SCxSR); |
487 | if (!(status & SCxSR_RDxF(port))) | 488 | if (!(status & SCxSR_RDxF(port))) |
@@ -499,8 +500,7 @@ static inline void sci_receive_chars(struct uart_port *port, | |||
499 | #endif | 500 | #endif |
500 | 501 | ||
501 | /* Don't copy more bytes than there is room for in the buffer */ | 502 | /* Don't copy more bytes than there is room for in the buffer */ |
502 | if (tty->flip.count + count > TTY_FLIPBUF_SIZE) | 503 | count = tty_buffer_request_room(tty, count); |
503 | count = TTY_FLIPBUF_SIZE - tty->flip.count; | ||
504 | 504 | ||
505 | /* If for any reason we can't copy more data, we're done! */ | 505 | /* If for any reason we can't copy more data, we're done! */ |
506 | if (count == 0) | 506 | if (count == 0) |
@@ -512,8 +512,7 @@ static inline void sci_receive_chars(struct uart_port *port, | |||
512 | || uart_handle_sysrq_char(port, c, regs)) { | 512 | || uart_handle_sysrq_char(port, c, regs)) { |
513 | count = 0; | 513 | count = 0; |
514 | } else { | 514 | } else { |
515 | tty->flip.char_buf_ptr[0] = c; | 515 | tty_insert_flip_char(tty, c, TTY_NORMAL); |
516 | tty->flip.flag_buf_ptr[0] = TTY_NORMAL; | ||
517 | } | 516 | } |
518 | } else { | 517 | } else { |
519 | for (i=0; i<count; i++) { | 518 | for (i=0; i<count; i++) { |
@@ -542,26 +541,21 @@ static inline void sci_receive_chars(struct uart_port *port, | |||
542 | } | 541 | } |
543 | 542 | ||
544 | /* Store data and status */ | 543 | /* Store data and status */ |
545 | tty->flip.char_buf_ptr[i] = c; | ||
546 | if (status&SCxSR_FER(port)) { | 544 | if (status&SCxSR_FER(port)) { |
547 | tty->flip.flag_buf_ptr[i] = TTY_FRAME; | 545 | flag = TTY_FRAME; |
548 | pr_debug("sci: frame error\n"); | 546 | pr_debug("sci: frame error\n"); |
549 | } else if (status&SCxSR_PER(port)) { | 547 | } else if (status&SCxSR_PER(port)) { |
550 | tty->flip.flag_buf_ptr[i] = TTY_PARITY; | 548 | flag = TTY_PARITY; |
551 | pr_debug("sci: parity error\n"); | 549 | pr_debug("sci: parity error\n"); |
552 | } else { | 550 | } else |
553 | tty->flip.flag_buf_ptr[i] = TTY_NORMAL; | 551 | flag = TTY_NORMAL; |
554 | } | 552 | tty_insert_flip_char(tty, c, flag); |
555 | } | 553 | } |
556 | } | 554 | } |
557 | 555 | ||
558 | sci_in(port, SCxSR); /* dummy read */ | 556 | sci_in(port, SCxSR); /* dummy read */ |
559 | sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); | 557 | sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); |
560 | 558 | ||
561 | /* Update the kernel buffer end */ | ||
562 | tty->flip.count += count; | ||
563 | tty->flip.char_buf_ptr += count; | ||
564 | tty->flip.flag_buf_ptr += count; | ||
565 | copied += count; | 559 | copied += count; |
566 | port->icount.rx += count; | 560 | port->icount.rx += count; |
567 | } | 561 | } |
@@ -608,48 +602,45 @@ static inline int sci_handle_errors(struct uart_port *port) | |||
608 | unsigned short status = sci_in(port, SCxSR); | 602 | unsigned short status = sci_in(port, SCxSR); |
609 | struct tty_struct *tty = port->info->tty; | 603 | struct tty_struct *tty = port->info->tty; |
610 | 604 | ||
611 | if (status&SCxSR_ORER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) { | 605 | if (status&SCxSR_ORER(port)) { |
612 | /* overrun error */ | 606 | /* overrun error */ |
613 | copied++; | 607 | if(tty_insert_flip_char(tty, 0, TTY_OVERRUN)) |
614 | *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; | 608 | copied++; |
615 | pr_debug("sci: overrun error\n"); | 609 | pr_debug("sci: overrun error\n"); |
616 | } | 610 | } |
617 | 611 | ||
618 | if (status&SCxSR_FER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) { | 612 | if (status&SCxSR_FER(port)) { |
619 | if (sci_rxd_in(port) == 0) { | 613 | if (sci_rxd_in(port) == 0) { |
620 | /* Notify of BREAK */ | 614 | /* Notify of BREAK */ |
621 | struct sci_port * sci_port = (struct sci_port *)port; | 615 | struct sci_port * sci_port = (struct sci_port *)port; |
622 | if(!sci_port->break_flag) { | 616 | if(!sci_port->break_flag) { |
623 | sci_port->break_flag = 1; | 617 | sci_port->break_flag = 1; |
624 | sci_schedule_break_timer((struct sci_port *)port); | 618 | sci_schedule_break_timer((struct sci_port *)port); |
625 | /* Do sysrq handling. */ | 619 | /* Do sysrq handling. */ |
626 | if(uart_handle_break(port)) { | 620 | if(uart_handle_break(port)) |
627 | return 0; | 621 | return 0; |
628 | } | ||
629 | pr_debug("sci: BREAK detected\n"); | 622 | pr_debug("sci: BREAK detected\n"); |
630 | copied++; | 623 | if(tty_insert_flip_char(tty, 0, TTY_BREAK)) |
631 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; | 624 | copied++; |
632 | } | 625 | } |
633 | } | 626 | } |
634 | else { | 627 | else { |
635 | /* frame error */ | 628 | /* frame error */ |
636 | copied++; | 629 | if(tty_insert_flip_char(tty, 0, TTY_FRAME)) |
637 | *tty->flip.flag_buf_ptr++ = TTY_FRAME; | 630 | copied++; |
638 | pr_debug("sci: frame error\n"); | 631 | pr_debug("sci: frame error\n"); |
639 | } | 632 | } |
640 | } | 633 | } |
641 | 634 | ||
642 | if (status&SCxSR_PER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) { | 635 | if (status&SCxSR_PER(port)) { |
636 | if(tty_insert_flip_char(tty, 0, TTY_PARITY)) | ||
637 | copied++; | ||
643 | /* parity error */ | 638 | /* parity error */ |
644 | copied++; | ||
645 | *tty->flip.flag_buf_ptr++ = TTY_PARITY; | ||
646 | pr_debug("sci: parity error\n"); | 639 | pr_debug("sci: parity error\n"); |
647 | } | 640 | } |
648 | 641 | ||
649 | if (copied) { | 642 | if (copied) |
650 | tty->flip.count += copied; | ||
651 | tty_flip_buffer_push(tty); | 643 | tty_flip_buffer_push(tty); |
652 | } | ||
653 | 644 | ||
654 | return copied; | 645 | return copied; |
655 | } | 646 | } |
@@ -661,15 +652,14 @@ static inline int sci_handle_breaks(struct uart_port *port) | |||
661 | struct tty_struct *tty = port->info->tty; | 652 | struct tty_struct *tty = port->info->tty; |
662 | struct sci_port *s = &sci_ports[port->line]; | 653 | struct sci_port *s = &sci_ports[port->line]; |
663 | 654 | ||
664 | if (!s->break_flag && status & SCxSR_BRK(port) && | 655 | if (!s->break_flag && status & SCxSR_BRK(port)) |
665 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
666 | #if defined(CONFIG_CPU_SH3) | 656 | #if defined(CONFIG_CPU_SH3) |
667 | /* Debounce break */ | 657 | /* Debounce break */ |
668 | s->break_flag = 1; | 658 | s->break_flag = 1; |
669 | #endif | 659 | #endif |
670 | /* Notify of BREAK */ | 660 | /* Notify of BREAK */ |
671 | copied++; | 661 | if(tty_insert_flip_char(tty, 0, TTY_BREAK)) |
672 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; | 662 | copied++; |
673 | pr_debug("sci: BREAK detected\n"); | 663 | pr_debug("sci: BREAK detected\n"); |
674 | } | 664 | } |
675 | 665 | ||
@@ -677,19 +667,15 @@ static inline int sci_handle_breaks(struct uart_port *port) | |||
677 | /* XXX: Handle SCIF overrun error */ | 667 | /* XXX: Handle SCIF overrun error */ |
678 | if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { | 668 | if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { |
679 | sci_out(port, SCLSR, 0); | 669 | sci_out(port, SCLSR, 0); |
680 | if(tty->flip.count<TTY_FLIPBUF_SIZE) { | 670 | if(tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { |
681 | copied++; | 671 | copied++; |
682 | *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; | ||
683 | pr_debug("sci: overrun error\n"); | 672 | pr_debug("sci: overrun error\n"); |
684 | } | 673 | } |
685 | } | 674 | } |
686 | #endif | 675 | #endif |
687 | 676 | ||
688 | if (copied) { | 677 | if (copied) |
689 | tty->flip.count += copied; | ||
690 | tty_flip_buffer_push(tty); | 678 | tty_flip_buffer_push(tty); |
691 | } | ||
692 | |||
693 | return copied; | 679 | return copied; |
694 | } | 680 | } |
695 | 681 | ||
@@ -732,12 +718,9 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
732 | struct tty_struct *tty = port->info->tty; | 718 | struct tty_struct *tty = port->info->tty; |
733 | 719 | ||
734 | sci_out(port, SCLSR, 0); | 720 | sci_out(port, SCLSR, 0); |
735 | if(tty->flip.count<TTY_FLIPBUF_SIZE) { | 721 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
736 | *tty->flip.flag_buf_ptr++ = TTY_OVERRUN; | 722 | tty_flip_buffer_push(tty); |
737 | tty->flip.count++; | 723 | pr_debug("scif: overrun error\n"); |
738 | tty_flip_buffer_push(tty); | ||
739 | pr_debug("scif: overrun error\n"); | ||
740 | } | ||
741 | } | 724 | } |
742 | #endif | 725 | #endif |
743 | sci_rx_interrupt(irq, ptr, regs); | 726 | sci_rx_interrupt(irq, ptr, regs); |
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c index 313f9df24a2d..43e67d6c29d4 100644 --- a/drivers/serial/sn_console.c +++ b/drivers/serial/sn_console.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * driver for that. | 6 | * driver for that. |
7 | * | 7 | * |
8 | * | 8 | * |
9 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. | 9 | * Copyright (c) 2004-2006 Silicon Graphics, Inc. All Rights Reserved. |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify it | 11 | * This program is free software; you can redistribute it and/or modify it |
12 | * under the terms of version 2 of the GNU General Public License | 12 | * under the terms of version 2 of the GNU General Public License |
@@ -519,11 +519,7 @@ sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs, | |||
519 | 519 | ||
520 | /* record the character to pass up to the tty layer */ | 520 | /* record the character to pass up to the tty layer */ |
521 | if (tty) { | 521 | if (tty) { |
522 | *tty->flip.char_buf_ptr = ch; | 522 | if(tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0) |
523 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
524 | tty->flip.char_buf_ptr++; | ||
525 | tty->flip.count++; | ||
526 | if (tty->flip.count == TTY_FLIPBUF_SIZE) | ||
527 | break; | 523 | break; |
528 | } | 524 | } |
529 | port->sc_port.icount.rx++; | 525 | port->sc_port.icount.rx++; |
@@ -833,8 +829,8 @@ static int __init sn_sal_module_init(void) | |||
833 | misc.name = DEVICE_NAME_DYNAMIC; | 829 | misc.name = DEVICE_NAME_DYNAMIC; |
834 | retval = misc_register(&misc); | 830 | retval = misc_register(&misc); |
835 | if (retval != 0) { | 831 | if (retval != 0) { |
836 | printk | 832 | printk(KERN_WARNING "Failed to register console " |
837 | ("Failed to register console device using misc_register.\n"); | 833 | "device using misc_register.\n"); |
838 | return -ENODEV; | 834 | return -ENODEV; |
839 | } | 835 | } |
840 | sal_console_uart.major = MISC_MAJOR; | 836 | sal_console_uart.major = MISC_MAJOR; |
@@ -946,88 +942,75 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count) | |||
946 | { | 942 | { |
947 | unsigned long flags = 0; | 943 | unsigned long flags = 0; |
948 | struct sn_cons_port *port = &sal_console_port; | 944 | struct sn_cons_port *port = &sal_console_port; |
949 | #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) | ||
950 | static int stole_lock = 0; | 945 | static int stole_lock = 0; |
951 | #endif | ||
952 | 946 | ||
953 | BUG_ON(!port->sc_is_asynch); | 947 | BUG_ON(!port->sc_is_asynch); |
954 | 948 | ||
955 | /* We can't look at the xmit buffer if we're not registered with serial core | 949 | /* We can't look at the xmit buffer if we're not registered with serial core |
956 | * yet. So only do the fancy recovery after registering | 950 | * yet. So only do the fancy recovery after registering |
957 | */ | 951 | */ |
958 | if (port->sc_port.info) { | 952 | if (!port->sc_port.info) { |
959 | 953 | /* Not yet registered with serial core - simple case */ | |
960 | /* somebody really wants this output, might be an | 954 | puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count); |
961 | * oops, kdb, panic, etc. make sure they get it. */ | 955 | return; |
962 | #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) | 956 | } |
963 | if (spin_is_locked(&port->sc_port.lock)) { | ||
964 | int lhead = port->sc_port.info->xmit.head; | ||
965 | int ltail = port->sc_port.info->xmit.tail; | ||
966 | int counter, got_lock = 0; | ||
967 | 957 | ||
968 | /* | 958 | /* somebody really wants this output, might be an |
969 | * We attempt to determine if someone has died with the | 959 | * oops, kdb, panic, etc. make sure they get it. */ |
970 | * lock. We wait ~20 secs after the head and tail ptrs | 960 | if (spin_is_locked(&port->sc_port.lock)) { |
971 | * stop moving and assume the lock holder is not functional | 961 | int lhead = port->sc_port.info->xmit.head; |
972 | * and plow ahead. If the lock is freed within the time out | 962 | int ltail = port->sc_port.info->xmit.tail; |
973 | * period we re-get the lock and go ahead normally. We also | 963 | int counter, got_lock = 0; |
974 | * remember if we have plowed ahead so that we don't have | 964 | |
975 | * to wait out the time out period again - the asumption | 965 | /* |
976 | * is that we will time out again. | 966 | * We attempt to determine if someone has died with the |
977 | */ | 967 | * lock. We wait ~20 secs after the head and tail ptrs |
968 | * stop moving and assume the lock holder is not functional | ||
969 | * and plow ahead. If the lock is freed within the time out | ||
970 | * period we re-get the lock and go ahead normally. We also | ||
971 | * remember if we have plowed ahead so that we don't have | ||
972 | * to wait out the time out period again - the asumption | ||
973 | * is that we will time out again. | ||
974 | */ | ||
978 | 975 | ||
979 | for (counter = 0; counter < 150; mdelay(125), counter++) { | 976 | for (counter = 0; counter < 150; mdelay(125), counter++) { |
980 | if (!spin_is_locked(&port->sc_port.lock) | 977 | if (!spin_is_locked(&port->sc_port.lock) |
981 | || stole_lock) { | 978 | || stole_lock) { |
982 | if (!stole_lock) { | 979 | if (!stole_lock) { |
983 | spin_lock_irqsave(&port-> | 980 | spin_lock_irqsave(&port->sc_port.lock, |
984 | sc_port.lock, | 981 | flags); |
985 | flags); | 982 | got_lock = 1; |
986 | got_lock = 1; | ||
987 | } | ||
988 | break; | ||
989 | } else { | ||
990 | /* still locked */ | ||
991 | if ((lhead != | ||
992 | port->sc_port.info->xmit.head) | ||
993 | || (ltail != | ||
994 | port->sc_port.info->xmit. | ||
995 | tail)) { | ||
996 | lhead = | ||
997 | port->sc_port.info->xmit. | ||
998 | head; | ||
999 | ltail = | ||
1000 | port->sc_port.info->xmit. | ||
1001 | tail; | ||
1002 | counter = 0; | ||
1003 | } | ||
1004 | } | 983 | } |
1005 | } | 984 | break; |
1006 | /* flush anything in the serial core xmit buffer, raw */ | ||
1007 | sn_transmit_chars(port, 1); | ||
1008 | if (got_lock) { | ||
1009 | spin_unlock_irqrestore(&port->sc_port.lock, | ||
1010 | flags); | ||
1011 | stole_lock = 0; | ||
1012 | } else { | 985 | } else { |
1013 | /* fell thru */ | 986 | /* still locked */ |
1014 | stole_lock = 1; | 987 | if ((lhead != port->sc_port.info->xmit.head) |
988 | || (ltail != | ||
989 | port->sc_port.info->xmit.tail)) { | ||
990 | lhead = | ||
991 | port->sc_port.info->xmit.head; | ||
992 | ltail = | ||
993 | port->sc_port.info->xmit.tail; | ||
994 | counter = 0; | ||
995 | } | ||
1015 | } | 996 | } |
1016 | puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count); | 997 | } |
1017 | } else { | 998 | /* flush anything in the serial core xmit buffer, raw */ |
1018 | stole_lock = 0; | 999 | sn_transmit_chars(port, 1); |
1019 | #endif | 1000 | if (got_lock) { |
1020 | spin_lock_irqsave(&port->sc_port.lock, flags); | ||
1021 | sn_transmit_chars(port, 1); | ||
1022 | spin_unlock_irqrestore(&port->sc_port.lock, flags); | 1001 | spin_unlock_irqrestore(&port->sc_port.lock, flags); |
1023 | 1002 | stole_lock = 0; | |
1024 | puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count); | 1003 | } else { |
1025 | #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) | 1004 | /* fell thru */ |
1005 | stole_lock = 1; | ||
1026 | } | 1006 | } |
1027 | #endif | 1007 | puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count); |
1028 | } | 1008 | } else { |
1029 | else { | 1009 | stole_lock = 0; |
1030 | /* Not yet registered with serial core - simple case */ | 1010 | spin_lock_irqsave(&port->sc_port.lock, flags); |
1011 | sn_transmit_chars(port, 1); | ||
1012 | spin_unlock_irqrestore(&port->sc_port.lock, flags); | ||
1013 | |||
1031 | puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count); | 1014 | puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count); |
1032 | } | 1015 | } |
1033 | } | 1016 | } |
diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c index 5fc4a62173d9..fa4ae94243c2 100644 --- a/drivers/serial/suncore.c +++ b/drivers/serial/suncore.c | |||
@@ -34,6 +34,7 @@ sunserial_console_termios(struct console *con) | |||
34 | char *mode_prop = "ttyX-mode"; | 34 | char *mode_prop = "ttyX-mode"; |
35 | char *cd_prop = "ttyX-ignore-cd"; | 35 | char *cd_prop = "ttyX-ignore-cd"; |
36 | char *dtr_prop = "ttyX-rts-dtr-off"; | 36 | char *dtr_prop = "ttyX-rts-dtr-off"; |
37 | char *ssp_console_modes_prop = "ssp-console-modes"; | ||
37 | int baud, bits, stop, cflag; | 38 | int baud, bits, stop, cflag; |
38 | char parity; | 39 | char parity; |
39 | int carrier = 0; | 40 | int carrier = 0; |
@@ -43,14 +44,39 @@ sunserial_console_termios(struct console *con) | |||
43 | if (!serial_console) | 44 | if (!serial_console) |
44 | return; | 45 | return; |
45 | 46 | ||
46 | if (serial_console == 1) { | 47 | switch (serial_console) { |
48 | case PROMDEV_OTTYA: | ||
47 | mode_prop[3] = 'a'; | 49 | mode_prop[3] = 'a'; |
48 | cd_prop[3] = 'a'; | 50 | cd_prop[3] = 'a'; |
49 | dtr_prop[3] = 'a'; | 51 | dtr_prop[3] = 'a'; |
50 | } else { | 52 | break; |
53 | |||
54 | case PROMDEV_OTTYB: | ||
51 | mode_prop[3] = 'b'; | 55 | mode_prop[3] = 'b'; |
52 | cd_prop[3] = 'b'; | 56 | cd_prop[3] = 'b'; |
53 | dtr_prop[3] = 'b'; | 57 | dtr_prop[3] = 'b'; |
58 | break; | ||
59 | |||
60 | case PROMDEV_ORSC: | ||
61 | |||
62 | nd = prom_pathtoinode("rsc"); | ||
63 | if (!nd) { | ||
64 | strcpy(mode, "115200,8,n,1,-"); | ||
65 | goto no_options; | ||
66 | } | ||
67 | |||
68 | if (!prom_node_has_property(nd, ssp_console_modes_prop)) { | ||
69 | strcpy(mode, "115200,8,n,1,-"); | ||
70 | goto no_options; | ||
71 | } | ||
72 | |||
73 | memset(mode, 0, sizeof(mode)); | ||
74 | prom_getstring(nd, ssp_console_modes_prop, mode, sizeof(mode)); | ||
75 | goto no_options; | ||
76 | |||
77 | default: | ||
78 | strcpy(mode, "9600,8,n,1,-"); | ||
79 | goto no_options; | ||
54 | } | 80 | } |
55 | 81 | ||
56 | topnd = prom_getchild(prom_root_node); | 82 | topnd = prom_getchild(prom_root_node); |
@@ -110,6 +136,10 @@ no_options: | |||
110 | case 9600: cflag |= B9600; break; | 136 | case 9600: cflag |= B9600; break; |
111 | case 19200: cflag |= B19200; break; | 137 | case 19200: cflag |= B19200; break; |
112 | case 38400: cflag |= B38400; break; | 138 | case 38400: cflag |= B38400; break; |
139 | case 57600: cflag |= B57600; break; | ||
140 | case 115200: cflag |= B115200; break; | ||
141 | case 230400: cflag |= B230400; break; | ||
142 | case 460800: cflag |= B460800; break; | ||
113 | default: baud = 9600; cflag |= B9600; break; | 143 | default: baud = 9600; cflag |= B9600; break; |
114 | } | 144 | } |
115 | 145 | ||
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index ba9381fd3f2d..8bcaebcc0ad7 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -159,21 +159,14 @@ receive_chars(struct uart_sunsab_port *up, | |||
159 | saw_console_brk = 1; | 159 | saw_console_brk = 1; |
160 | 160 | ||
161 | for (i = 0; i < count; i++) { | 161 | for (i = 0; i < count; i++) { |
162 | unsigned char ch = buf[i]; | 162 | unsigned char ch = buf[i], flag; |
163 | 163 | ||
164 | if (tty == NULL) { | 164 | if (tty == NULL) { |
165 | uart_handle_sysrq_char(&up->port, ch, regs); | 165 | uart_handle_sysrq_char(&up->port, ch, regs); |
166 | continue; | 166 | continue; |
167 | } | 167 | } |
168 | 168 | ||
169 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | 169 | flag = TTY_NORMAL; |
170 | tty->flip.work.func((void *)tty); | ||
171 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
172 | return tty; // if TTY_DONT_FLIP is set | ||
173 | } | ||
174 | |||
175 | *tty->flip.char_buf_ptr = ch; | ||
176 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
177 | up->port.icount.rx++; | 170 | up->port.icount.rx++; |
178 | 171 | ||
179 | if (unlikely(stat->sreg.isr0 & (SAB82532_ISR0_PERR | | 172 | if (unlikely(stat->sreg.isr0 & (SAB82532_ISR0_PERR | |
@@ -209,34 +202,21 @@ receive_chars(struct uart_sunsab_port *up, | |||
209 | stat->sreg.isr1 &= ((up->port.read_status_mask >> 8) & 0xff); | 202 | stat->sreg.isr1 &= ((up->port.read_status_mask >> 8) & 0xff); |
210 | 203 | ||
211 | if (stat->sreg.isr1 & SAB82532_ISR1_BRK) { | 204 | if (stat->sreg.isr1 & SAB82532_ISR1_BRK) { |
212 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 205 | flag = TTY_BREAK; |
213 | } else if (stat->sreg.isr0 & SAB82532_ISR0_PERR) | 206 | } else if (stat->sreg.isr0 & SAB82532_ISR0_PERR) |
214 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 207 | flag = TTY_PARITY; |
215 | else if (stat->sreg.isr0 & SAB82532_ISR0_FERR) | 208 | else if (stat->sreg.isr0 & SAB82532_ISR0_FERR) |
216 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 209 | flag = TTY_FRAME; |
217 | } | 210 | } |
218 | 211 | ||
219 | if (uart_handle_sysrq_char(&up->port, ch, regs)) | 212 | if (uart_handle_sysrq_char(&up->port, ch, regs)) |
220 | continue; | 213 | continue; |
221 | 214 | ||
222 | if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && | 215 | if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 && |
223 | (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0){ | 216 | (stat->sreg.isr1 & ((up->port.ignore_status_mask >> 8) & 0xff)) == 0) |
224 | tty->flip.flag_buf_ptr++; | 217 | tty_insert_flip_char(tty, ch, flag); |
225 | tty->flip.char_buf_ptr++; | 218 | if (stat->sreg.isr0 & SAB82532_ISR0_RFO) |
226 | tty->flip.count++; | 219 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
227 | } | ||
228 | if ((stat->sreg.isr0 & SAB82532_ISR0_RFO) && | ||
229 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
230 | /* | ||
231 | * Overrun is special, since it's reported | ||
232 | * immediately, and doesn't affect the current | ||
233 | * character. | ||
234 | */ | ||
235 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | ||
236 | tty->flip.flag_buf_ptr++; | ||
237 | tty->flip.char_buf_ptr++; | ||
238 | tty->flip.count++; | ||
239 | } | ||
240 | } | 220 | } |
241 | 221 | ||
242 | if (saw_console_brk) | 222 | if (saw_console_brk) |
@@ -917,9 +897,6 @@ static int sunsab_console_setup(struct console *con, char *options) | |||
917 | 897 | ||
918 | sunserial_console_termios(con); | 898 | sunserial_console_termios(con); |
919 | 899 | ||
920 | /* Firmware console speed is limited to 150-->38400 baud so | ||
921 | * this hackish cflag thing is OK. | ||
922 | */ | ||
923 | switch (con->cflag & CBAUD) { | 900 | switch (con->cflag & CBAUD) { |
924 | case B150: baud = 150; break; | 901 | case B150: baud = 150; break; |
925 | case B300: baud = 300; break; | 902 | case B300: baud = 300; break; |
@@ -930,6 +907,10 @@ static int sunsab_console_setup(struct console *con, char *options) | |||
930 | default: case B9600: baud = 9600; break; | 907 | default: case B9600: baud = 9600; break; |
931 | case B19200: baud = 19200; break; | 908 | case B19200: baud = 19200; break; |
932 | case B38400: baud = 38400; break; | 909 | case B38400: baud = 38400; break; |
910 | case B57600: baud = 57600; break; | ||
911 | case B115200: baud = 115200; break; | ||
912 | case B230400: baud = 230400; break; | ||
913 | case B460800: baud = 460800; break; | ||
933 | }; | 914 | }; |
934 | 915 | ||
935 | /* | 916 | /* |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index f0738533f39a..9a3665b34d97 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -323,19 +323,13 @@ static _INLINE_ struct tty_struct * | |||
323 | receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) | 323 | receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs) |
324 | { | 324 | { |
325 | struct tty_struct *tty = up->port.info->tty; | 325 | struct tty_struct *tty = up->port.info->tty; |
326 | unsigned char ch; | 326 | unsigned char ch, flag; |
327 | int max_count = 256; | 327 | int max_count = 256; |
328 | int saw_console_brk = 0; | 328 | int saw_console_brk = 0; |
329 | 329 | ||
330 | do { | 330 | do { |
331 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
332 | tty->flip.work.func((void *)tty); | ||
333 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
334 | return tty; // if TTY_DONT_FLIP is set | ||
335 | } | ||
336 | ch = serial_inp(up, UART_RX); | 331 | ch = serial_inp(up, UART_RX); |
337 | *tty->flip.char_buf_ptr = ch; | 332 | flag = TTY_NORMAL; |
338 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
339 | up->port.icount.rx++; | 333 | up->port.icount.rx++; |
340 | 334 | ||
341 | if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | | 335 | if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | |
@@ -377,31 +371,23 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs | |||
377 | } | 371 | } |
378 | 372 | ||
379 | if (*status & UART_LSR_BI) { | 373 | if (*status & UART_LSR_BI) { |
380 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 374 | flag = TTY_BREAK; |
381 | } else if (*status & UART_LSR_PE) | 375 | } else if (*status & UART_LSR_PE) |
382 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 376 | flag = TTY_PARITY; |
383 | else if (*status & UART_LSR_FE) | 377 | else if (*status & UART_LSR_FE) |
384 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 378 | flag = TTY_FRAME; |
385 | } | 379 | } |
386 | if (uart_handle_sysrq_char(&up->port, ch, regs)) | 380 | if (uart_handle_sysrq_char(&up->port, ch, regs)) |
387 | goto ignore_char; | 381 | goto ignore_char; |
388 | if ((*status & up->port.ignore_status_mask) == 0) { | 382 | if ((*status & up->port.ignore_status_mask) == 0) |
389 | tty->flip.flag_buf_ptr++; | 383 | tty_insert_flip_char(tty, ch, flag); |
390 | tty->flip.char_buf_ptr++; | 384 | if (*status & UART_LSR_OE) |
391 | tty->flip.count++; | ||
392 | } | ||
393 | if ((*status & UART_LSR_OE) && | ||
394 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
395 | /* | 385 | /* |
396 | * Overrun is special, since it's reported | 386 | * Overrun is special, since it's reported |
397 | * immediately, and doesn't affect the current | 387 | * immediately, and doesn't affect the current |
398 | * character. | 388 | * character. |
399 | */ | 389 | */ |
400 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | 390 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
401 | tty->flip.flag_buf_ptr++; | ||
402 | tty->flip.char_buf_ptr++; | ||
403 | tty->flip.count++; | ||
404 | } | ||
405 | ignore_char: | 391 | ignore_char: |
406 | *status = serial_inp(up, UART_LSR); | 392 | *status = serial_inp(up, UART_LSR); |
407 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); | 393 | } while ((*status & UART_LSR_DR) && (max_count-- > 0)); |
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 7653d6cf05af..3c72484adea7 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -319,7 +319,7 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, | |||
319 | struct pt_regs *regs) | 319 | struct pt_regs *regs) |
320 | { | 320 | { |
321 | struct tty_struct *tty; | 321 | struct tty_struct *tty; |
322 | unsigned char ch, r1; | 322 | unsigned char ch, r1, flag; |
323 | 323 | ||
324 | tty = NULL; | 324 | tty = NULL; |
325 | if (up->port.info != NULL && /* Unopened serial console */ | 325 | if (up->port.info != NULL && /* Unopened serial console */ |
@@ -362,19 +362,8 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, | |||
362 | continue; | 362 | continue; |
363 | } | 363 | } |
364 | 364 | ||
365 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
366 | tty->flip.work.func((void *)tty); | ||
367 | /* | ||
368 | * The 8250 bails out of the loop here, | ||
369 | * but we need to read everything, or die. | ||
370 | */ | ||
371 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
372 | continue; | ||
373 | } | ||
374 | |||
375 | /* A real serial line, record the character and status. */ | 365 | /* A real serial line, record the character and status. */ |
376 | *tty->flip.char_buf_ptr = ch; | 366 | flag = TTY_NORMAL; |
377 | *tty->flip.flag_buf_ptr = TTY_NORMAL; | ||
378 | up->port.icount.rx++; | 367 | up->port.icount.rx++; |
379 | if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { | 368 | if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) { |
380 | if (r1 & BRK_ABRT) { | 369 | if (r1 & BRK_ABRT) { |
@@ -391,28 +380,21 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up, | |||
391 | up->port.icount.overrun++; | 380 | up->port.icount.overrun++; |
392 | r1 &= up->port.read_status_mask; | 381 | r1 &= up->port.read_status_mask; |
393 | if (r1 & BRK_ABRT) | 382 | if (r1 & BRK_ABRT) |
394 | *tty->flip.flag_buf_ptr = TTY_BREAK; | 383 | flag = TTY_BREAK; |
395 | else if (r1 & PAR_ERR) | 384 | else if (r1 & PAR_ERR) |
396 | *tty->flip.flag_buf_ptr = TTY_PARITY; | 385 | flag = TTY_PARITY; |
397 | else if (r1 & CRC_ERR) | 386 | else if (r1 & CRC_ERR) |
398 | *tty->flip.flag_buf_ptr = TTY_FRAME; | 387 | flag = TTY_FRAME; |
399 | } | 388 | } |
400 | if (uart_handle_sysrq_char(&up->port, ch, regs)) | 389 | if (uart_handle_sysrq_char(&up->port, ch, regs)) |
401 | continue; | 390 | continue; |
402 | 391 | ||
403 | if (up->port.ignore_status_mask == 0xff || | 392 | if (up->port.ignore_status_mask == 0xff || |
404 | (r1 & up->port.ignore_status_mask) == 0) { | 393 | (r1 & up->port.ignore_status_mask) == 0) { |
405 | tty->flip.flag_buf_ptr++; | 394 | tty_insert_flip_char(tty, ch, flag); |
406 | tty->flip.char_buf_ptr++; | ||
407 | tty->flip.count++; | ||
408 | } | ||
409 | if ((r1 & Rx_OVR) && | ||
410 | tty->flip.count < TTY_FLIPBUF_SIZE) { | ||
411 | *tty->flip.flag_buf_ptr = TTY_OVERRUN; | ||
412 | tty->flip.flag_buf_ptr++; | ||
413 | tty->flip.char_buf_ptr++; | ||
414 | tty->flip.count++; | ||
415 | } | 395 | } |
396 | if (r1 & Rx_OVR) | ||
397 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | ||
416 | } | 398 | } |
417 | 399 | ||
418 | return tty; | 400 | return tty; |
diff --git a/drivers/serial/uart00.c b/drivers/serial/uart00.c deleted file mode 100644 index 47b504ff38b2..000000000000 --- a/drivers/serial/uart00.c +++ /dev/null | |||
@@ -1,782 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/serial/uart00.c | ||
3 | * | ||
4 | * Driver for UART00 serial ports | ||
5 | * | ||
6 | * Based on drivers/char/serial_amba.c, by ARM Limited & | ||
7 | * Deep Blue Solutions Ltd. | ||
8 | * Copyright 2001 Altera Corporation | ||
9 | * | ||
10 | * Update for 2.6.4 by Dirk Behme <dirk.behme@de.bosch.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | * | ||
26 | * $Id: uart00.c,v 1.35 2002/07/28 10:03:28 rmk Exp $ | ||
27 | * | ||
28 | */ | ||
29 | #include <linux/config.h> | ||
30 | |||
31 | #if defined(CONFIG_SERIAL_UART00_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | ||
32 | #define SUPPORT_SYSRQ | ||
33 | #endif | ||
34 | |||
35 | #include <linux/module.h> | ||
36 | #include <linux/ioport.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/console.h> | ||
39 | #include <linux/sysrq.h> | ||
40 | #include <linux/tty.h> | ||
41 | #include <linux/tty_flip.h> | ||
42 | #include <linux/serial_core.h> | ||
43 | #include <linux/serial.h> | ||
44 | |||
45 | #include <asm/io.h> | ||
46 | #include <asm/irq.h> | ||
47 | #include <asm/sizes.h> | ||
48 | |||
49 | #include <asm/arch/excalibur.h> | ||
50 | #define UART00_TYPE (volatile unsigned int*) | ||
51 | #include <asm/arch/uart00.h> | ||
52 | #include <asm/arch/int_ctrl00.h> | ||
53 | |||
54 | #define UART_NR 2 | ||
55 | |||
56 | #define SERIAL_UART00_NAME "ttyUA" | ||
57 | #define SERIAL_UART00_MAJOR 204 | ||
58 | #define SERIAL_UART00_MINOR 16 /* Temporary - will change in future */ | ||
59 | #define SERIAL_UART00_NR UART_NR | ||
60 | #define UART_PORT_SIZE 0x50 | ||
61 | |||
62 | #define UART00_ISR_PASS_LIMIT 256 | ||
63 | |||
64 | /* | ||
65 | * Access macros for the UART00 UARTs | ||
66 | */ | ||
67 | #define UART_GET_INT_STATUS(p) inl(UART_ISR((p)->membase)) | ||
68 | #define UART_PUT_IES(p, c) outl(c,UART_IES((p)->membase)) | ||
69 | #define UART_GET_IES(p) inl(UART_IES((p)->membase)) | ||
70 | #define UART_PUT_IEC(p, c) outl(c,UART_IEC((p)->membase)) | ||
71 | #define UART_GET_IEC(p) inl(UART_IEC((p)->membase)) | ||
72 | #define UART_PUT_CHAR(p, c) outl(c,UART_TD((p)->membase)) | ||
73 | #define UART_GET_CHAR(p) inl(UART_RD((p)->membase)) | ||
74 | #define UART_GET_RSR(p) inl(UART_RSR((p)->membase)) | ||
75 | #define UART_GET_RDS(p) inl(UART_RDS((p)->membase)) | ||
76 | #define UART_GET_MSR(p) inl(UART_MSR((p)->membase)) | ||
77 | #define UART_GET_MCR(p) inl(UART_MCR((p)->membase)) | ||
78 | #define UART_PUT_MCR(p, c) outl(c,UART_MCR((p)->membase)) | ||
79 | #define UART_GET_MC(p) inl(UART_MC((p)->membase)) | ||
80 | #define UART_PUT_MC(p, c) outl(c,UART_MC((p)->membase)) | ||
81 | #define UART_GET_TSR(p) inl(UART_TSR((p)->membase)) | ||
82 | #define UART_GET_DIV_HI(p) inl(UART_DIV_HI((p)->membase)) | ||
83 | #define UART_PUT_DIV_HI(p,c) outl(c,UART_DIV_HI((p)->membase)) | ||
84 | #define UART_GET_DIV_LO(p) inl(UART_DIV_LO((p)->membase)) | ||
85 | #define UART_PUT_DIV_LO(p,c) outl(c,UART_DIV_LO((p)->membase)) | ||
86 | #define UART_RX_DATA(s) ((s) & UART_RSR_RX_LEVEL_MSK) | ||
87 | #define UART_TX_READY(s) (((s) & UART_TSR_TX_LEVEL_MSK) < 15) | ||
88 | //#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & UART00_UARTFR_TMSK) == 0) | ||
89 | |||
90 | static void uart00_stop_tx(struct uart_port *port) | ||
91 | { | ||
92 | UART_PUT_IEC(port, UART_IEC_TIE_MSK); | ||
93 | } | ||
94 | |||
95 | static void uart00_stop_rx(struct uart_port *port) | ||
96 | { | ||
97 | UART_PUT_IEC(port, UART_IEC_RE_MSK); | ||
98 | } | ||
99 | |||
100 | static void uart00_enable_ms(struct uart_port *port) | ||
101 | { | ||
102 | UART_PUT_IES(port, UART_IES_ME_MSK); | ||
103 | } | ||
104 | |||
105 | static void | ||
106 | uart00_rx_chars(struct uart_port *port, struct pt_regs *regs) | ||
107 | { | ||
108 | struct tty_struct *tty = port->info->tty; | ||
109 | unsigned int status, ch, rds, flg, ignored = 0; | ||
110 | |||
111 | status = UART_GET_RSR(port); | ||
112 | while (UART_RX_DATA(status)) { | ||
113 | /* | ||
114 | * We need to read rds before reading the | ||
115 | * character from the fifo | ||
116 | */ | ||
117 | rds = UART_GET_RDS(port); | ||
118 | ch = UART_GET_CHAR(port); | ||
119 | port->icount.rx++; | ||
120 | |||
121 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
122 | goto ignore_char; | ||
123 | |||
124 | flg = TTY_NORMAL; | ||
125 | |||
126 | /* | ||
127 | * Note that the error handling code is | ||
128 | * out of the main execution path | ||
129 | */ | ||
130 | if (rds & (UART_RDS_BI_MSK |UART_RDS_FE_MSK| | ||
131 | UART_RDS_PE_MSK |UART_RDS_PE_MSK)) | ||
132 | goto handle_error; | ||
133 | if (uart_handle_sysrq_char(port, ch, regs)) | ||
134 | goto ignore_char; | ||
135 | |||
136 | error_return: | ||
137 | tty_insert_flip_char(tty, ch, flg); | ||
138 | |||
139 | ignore_char: | ||
140 | status = UART_GET_RSR(port); | ||
141 | } | ||
142 | out: | ||
143 | tty_flip_buffer_push(tty); | ||
144 | return; | ||
145 | |||
146 | handle_error: | ||
147 | if (rds & UART_RDS_BI_MSK) { | ||
148 | status &= ~(UART_RDS_FE_MSK | UART_RDS_PE_MSK); | ||
149 | port->icount.brk++; | ||
150 | if (uart_handle_break(port)) | ||
151 | goto ignore_char; | ||
152 | } else if (rds & UART_RDS_PE_MSK) | ||
153 | port->icount.parity++; | ||
154 | else if (rds & UART_RDS_FE_MSK) | ||
155 | port->icount.frame++; | ||
156 | if (rds & UART_RDS_OE_MSK) | ||
157 | port->icount.overrun++; | ||
158 | |||
159 | if (rds & port->ignore_status_mask) { | ||
160 | if (++ignored > 100) | ||
161 | goto out; | ||
162 | goto ignore_char; | ||
163 | } | ||
164 | rds &= port->read_status_mask; | ||
165 | |||
166 | if (rds & UART_RDS_BI_MSK) | ||
167 | flg = TTY_BREAK; | ||
168 | else if (rds & UART_RDS_PE_MSK) | ||
169 | flg = TTY_PARITY; | ||
170 | else if (rds & UART_RDS_FE_MSK) | ||
171 | flg = TTY_FRAME; | ||
172 | |||
173 | if (rds & UART_RDS_OE_MSK) { | ||
174 | /* | ||
175 | * CHECK: does overrun affect the current character? | ||
176 | * ASSUMPTION: it does not. | ||
177 | */ | ||
178 | tty_insert_flip_char(tty, ch, flg); | ||
179 | ch = 0; | ||
180 | flg = TTY_OVERRUN; | ||
181 | } | ||
182 | #ifdef SUPPORT_SYSRQ | ||
183 | port->sysrq = 0; | ||
184 | #endif | ||
185 | goto error_return; | ||
186 | } | ||
187 | |||
188 | static void uart00_tx_chars(struct uart_port *port) | ||
189 | { | ||
190 | struct circ_buf *xmit = &port->info->xmit; | ||
191 | int count; | ||
192 | |||
193 | if (port->x_char) { | ||
194 | while ((UART_GET_TSR(port) & UART_TSR_TX_LEVEL_MSK) == 15) | ||
195 | barrier(); | ||
196 | UART_PUT_CHAR(port, port->x_char); | ||
197 | port->icount.tx++; | ||
198 | port->x_char = 0; | ||
199 | return; | ||
200 | } | ||
201 | if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { | ||
202 | uart00_stop_tx(port); | ||
203 | return; | ||
204 | } | ||
205 | |||
206 | count = port->fifosize >> 1; | ||
207 | do { | ||
208 | while ((UART_GET_TSR(port) & UART_TSR_TX_LEVEL_MSK) == 15) | ||
209 | barrier(); | ||
210 | UART_PUT_CHAR(port, xmit->buf[xmit->tail]); | ||
211 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
212 | port->icount.tx++; | ||
213 | if (uart_circ_empty(xmit)) | ||
214 | break; | ||
215 | } while (--count > 0); | ||
216 | |||
217 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | ||
218 | uart_write_wakeup(port); | ||
219 | |||
220 | if (uart_circ_empty(xmit)) | ||
221 | uart00_stop_tx(port); | ||
222 | } | ||
223 | |||
224 | static void uart00_start_tx(struct uart_port *port) | ||
225 | { | ||
226 | UART_PUT_IES(port, UART_IES_TIE_MSK); | ||
227 | uart00_tx_chars(port); | ||
228 | } | ||
229 | |||
230 | static void uart00_modem_status(struct uart_port *port) | ||
231 | { | ||
232 | unsigned int status; | ||
233 | |||
234 | status = UART_GET_MSR(port); | ||
235 | |||
236 | if (!(status & (UART_MSR_DCTS_MSK | UART_MSR_DDSR_MSK | | ||
237 | UART_MSR_TERI_MSK | UART_MSR_DDCD_MSK))) | ||
238 | return; | ||
239 | |||
240 | if (status & UART_MSR_DDCD_MSK) | ||
241 | uart_handle_dcd_change(port, status & UART_MSR_DCD_MSK); | ||
242 | |||
243 | if (status & UART_MSR_DDSR_MSK) | ||
244 | port->icount.dsr++; | ||
245 | |||
246 | if (status & UART_MSR_DCTS_MSK) | ||
247 | uart_handle_cts_change(port, status & UART_MSR_CTS_MSK); | ||
248 | |||
249 | wake_up_interruptible(&port->info->delta_msr_wait); | ||
250 | } | ||
251 | |||
252 | static irqreturn_t uart00_int(int irq, void *dev_id, struct pt_regs *regs) | ||
253 | { | ||
254 | struct uart_port *port = dev_id; | ||
255 | unsigned int status, pass_counter = 0; | ||
256 | |||
257 | status = UART_GET_INT_STATUS(port); | ||
258 | do { | ||
259 | if (status & UART_ISR_RI_MSK) | ||
260 | uart00_rx_chars(port, regs); | ||
261 | if (status & UART_ISR_MI_MSK) | ||
262 | uart00_modem_status(port); | ||
263 | if (status & (UART_ISR_TI_MSK | UART_ISR_TII_MSK)) | ||
264 | uart00_tx_chars(port); | ||
265 | if (pass_counter++ > UART00_ISR_PASS_LIMIT) | ||
266 | break; | ||
267 | |||
268 | status = UART_GET_INT_STATUS(port); | ||
269 | } while (status); | ||
270 | |||
271 | return IRQ_HANDLED; | ||
272 | } | ||
273 | |||
274 | static unsigned int uart00_tx_empty(struct uart_port *port) | ||
275 | { | ||
276 | return UART_GET_TSR(port) & UART_TSR_TX_LEVEL_MSK? 0 : TIOCSER_TEMT; | ||
277 | } | ||
278 | |||
279 | static unsigned int uart00_get_mctrl(struct uart_port *port) | ||
280 | { | ||
281 | unsigned int result = 0; | ||
282 | unsigned int status; | ||
283 | |||
284 | status = UART_GET_MSR(port); | ||
285 | if (status & UART_MSR_DCD_MSK) | ||
286 | result |= TIOCM_CAR; | ||
287 | if (status & UART_MSR_DSR_MSK) | ||
288 | result |= TIOCM_DSR; | ||
289 | if (status & UART_MSR_CTS_MSK) | ||
290 | result |= TIOCM_CTS; | ||
291 | if (status & UART_MSR_RI_MSK) | ||
292 | result |= TIOCM_RI; | ||
293 | |||
294 | return result; | ||
295 | } | ||
296 | |||
297 | static void uart00_set_mctrl_null(struct uart_port *port, unsigned int mctrl) | ||
298 | { | ||
299 | } | ||
300 | |||
301 | static void uart00_break_ctl(struct uart_port *port, int break_state) | ||
302 | { | ||
303 | unsigned long flags; | ||
304 | unsigned int mcr; | ||
305 | |||
306 | spin_lock_irqsave(&port->lock, flags); | ||
307 | mcr = UART_GET_MCR(port); | ||
308 | if (break_state == -1) | ||
309 | mcr |= UART_MCR_BR_MSK; | ||
310 | else | ||
311 | mcr &= ~UART_MCR_BR_MSK; | ||
312 | UART_PUT_MCR(port, mcr); | ||
313 | spin_unlock_irqrestore(&port->lock, flags); | ||
314 | } | ||
315 | |||
316 | static void | ||
317 | uart00_set_termios(struct uart_port *port, struct termios *termios, | ||
318 | struct termios *old) | ||
319 | { | ||
320 | unsigned int uart_mc, old_ies, baud, quot; | ||
321 | unsigned long flags; | ||
322 | |||
323 | /* | ||
324 | * We don't support CREAD (yet) | ||
325 | */ | ||
326 | termios->c_cflag |= CREAD; | ||
327 | |||
328 | /* | ||
329 | * Ask the core to calculate the divisor for us. | ||
330 | */ | ||
331 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); | ||
332 | quot = uart_get_divisor(port, baud); | ||
333 | |||
334 | /* byte size and parity */ | ||
335 | switch (termios->c_cflag & CSIZE) { | ||
336 | case CS5: | ||
337 | uart_mc = UART_MC_CLS_CHARLEN_5; | ||
338 | break; | ||
339 | case CS6: | ||
340 | uart_mc = UART_MC_CLS_CHARLEN_6; | ||
341 | break; | ||
342 | case CS7: | ||
343 | uart_mc = UART_MC_CLS_CHARLEN_7; | ||
344 | break; | ||
345 | default: // CS8 | ||
346 | uart_mc = UART_MC_CLS_CHARLEN_8; | ||
347 | break; | ||
348 | } | ||
349 | if (termios->c_cflag & CSTOPB) | ||
350 | uart_mc|= UART_MC_ST_TWO; | ||
351 | if (termios->c_cflag & PARENB) { | ||
352 | uart_mc |= UART_MC_PE_MSK; | ||
353 | if (!(termios->c_cflag & PARODD)) | ||
354 | uart_mc |= UART_MC_EP_MSK; | ||
355 | } | ||
356 | |||
357 | spin_lock_irqsave(&port->lock, flags); | ||
358 | |||
359 | /* | ||
360 | * Update the per-port timeout. | ||
361 | */ | ||
362 | uart_update_timeout(port, termios->c_cflag, baud); | ||
363 | |||
364 | port->read_status_mask = UART_RDS_OE_MSK; | ||
365 | if (termios->c_iflag & INPCK) | ||
366 | port->read_status_mask |= UART_RDS_FE_MSK | UART_RDS_PE_MSK; | ||
367 | if (termios->c_iflag & (BRKINT | PARMRK)) | ||
368 | port->read_status_mask |= UART_RDS_BI_MSK; | ||
369 | |||
370 | /* | ||
371 | * Characters to ignore | ||
372 | */ | ||
373 | port->ignore_status_mask = 0; | ||
374 | if (termios->c_iflag & IGNPAR) | ||
375 | port->ignore_status_mask |= UART_RDS_FE_MSK | UART_RDS_PE_MSK; | ||
376 | if (termios->c_iflag & IGNBRK) { | ||
377 | port->ignore_status_mask |= UART_RDS_BI_MSK; | ||
378 | /* | ||
379 | * If we're ignoring parity and break indicators, | ||
380 | * ignore overruns to (for real raw support). | ||
381 | */ | ||
382 | if (termios->c_iflag & IGNPAR) | ||
383 | port->ignore_status_mask |= UART_RDS_OE_MSK; | ||
384 | } | ||
385 | |||
386 | /* first, disable everything */ | ||
387 | old_ies = UART_GET_IES(port); | ||
388 | |||
389 | if (UART_ENABLE_MS(port, termios->c_cflag)) | ||
390 | old_ies |= UART_IES_ME_MSK; | ||
391 | |||
392 | /* Set baud rate */ | ||
393 | UART_PUT_DIV_LO(port, (quot & 0xff)); | ||
394 | UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8)); | ||
395 | |||
396 | UART_PUT_MC(port, uart_mc); | ||
397 | UART_PUT_IES(port, old_ies); | ||
398 | |||
399 | spin_unlock_irqrestore(&port->lock, flags); | ||
400 | } | ||
401 | |||
402 | static int uart00_startup(struct uart_port *port) | ||
403 | { | ||
404 | int result; | ||
405 | |||
406 | /* | ||
407 | * Allocate the IRQ | ||
408 | */ | ||
409 | result = request_irq(port->irq, uart00_int, 0, "uart00", port); | ||
410 | if (result) { | ||
411 | printk(KERN_ERR "Request of irq %d failed\n", port->irq); | ||
412 | return result; | ||
413 | } | ||
414 | |||
415 | /* | ||
416 | * Finally, enable interrupts. Use the TII interrupt to minimise | ||
417 | * the number of interrupts generated. If higher performance is | ||
418 | * needed, consider using the TI interrupt with a suitable FIFO | ||
419 | * threshold | ||
420 | */ | ||
421 | UART_PUT_IES(port, UART_IES_RE_MSK | UART_IES_TIE_MSK); | ||
422 | |||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | static void uart00_shutdown(struct uart_port *port) | ||
427 | { | ||
428 | /* | ||
429 | * disable all interrupts, disable the port | ||
430 | */ | ||
431 | UART_PUT_IEC(port, 0xff); | ||
432 | |||
433 | /* disable break condition and fifos */ | ||
434 | UART_PUT_MCR(port, UART_GET_MCR(port) &~UART_MCR_BR_MSK); | ||
435 | |||
436 | /* | ||
437 | * Free the interrupt | ||
438 | */ | ||
439 | free_irq(port->irq, port); | ||
440 | } | ||
441 | |||
442 | static const char *uart00_type(struct uart_port *port) | ||
443 | { | ||
444 | return port->type == PORT_UART00 ? "Altera UART00" : NULL; | ||
445 | } | ||
446 | |||
447 | /* | ||
448 | * Release the memory region(s) being used by 'port' | ||
449 | */ | ||
450 | static void uart00_release_port(struct uart_port *port) | ||
451 | { | ||
452 | release_mem_region(port->mapbase, UART_PORT_SIZE); | ||
453 | |||
454 | #ifdef CONFIG_ARCH_CAMELOT | ||
455 | if (port->membase != (void*)IO_ADDRESS(EXC_UART00_BASE)) { | ||
456 | iounmap(port->membase); | ||
457 | } | ||
458 | #endif | ||
459 | } | ||
460 | |||
461 | /* | ||
462 | * Request the memory region(s) being used by 'port' | ||
463 | */ | ||
464 | static int uart00_request_port(struct uart_port *port) | ||
465 | { | ||
466 | return request_mem_region(port->mapbase, UART_PORT_SIZE, "serial_uart00") | ||
467 | != NULL ? 0 : -EBUSY; | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | * Configure/autoconfigure the port. | ||
472 | */ | ||
473 | static void uart00_config_port(struct uart_port *port, int flags) | ||
474 | { | ||
475 | |||
476 | /* | ||
477 | * Map the io memory if this is a soft uart | ||
478 | */ | ||
479 | if (!port->membase) | ||
480 | port->membase = ioremap_nocache(port->mapbase,SZ_4K); | ||
481 | |||
482 | if (!port->membase) | ||
483 | printk(KERN_ERR "serial00: cannot map io memory\n"); | ||
484 | else | ||
485 | port->type = PORT_UART00; | ||
486 | |||
487 | } | ||
488 | |||
489 | /* | ||
490 | * verify the new serial_struct (for TIOCSSERIAL). | ||
491 | */ | ||
492 | static int uart00_verify_port(struct uart_port *port, struct serial_struct *ser) | ||
493 | { | ||
494 | int ret = 0; | ||
495 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_UART00) | ||
496 | ret = -EINVAL; | ||
497 | if (ser->irq < 0 || ser->irq >= NR_IRQS) | ||
498 | ret = -EINVAL; | ||
499 | if (ser->baud_base < 9600) | ||
500 | ret = -EINVAL; | ||
501 | return ret; | ||
502 | } | ||
503 | |||
504 | static struct uart_ops uart00_pops = { | ||
505 | .tx_empty = uart00_tx_empty, | ||
506 | .set_mctrl = uart00_set_mctrl_null, | ||
507 | .get_mctrl = uart00_get_mctrl, | ||
508 | .stop_tx = uart00_stop_tx, | ||
509 | .start_tx = uart00_start_tx, | ||
510 | .stop_rx = uart00_stop_rx, | ||
511 | .enable_ms = uart00_enable_ms, | ||
512 | .break_ctl = uart00_break_ctl, | ||
513 | .startup = uart00_startup, | ||
514 | .shutdown = uart00_shutdown, | ||
515 | .set_termios = uart00_set_termios, | ||
516 | .type = uart00_type, | ||
517 | .release_port = uart00_release_port, | ||
518 | .request_port = uart00_request_port, | ||
519 | .config_port = uart00_config_port, | ||
520 | .verify_port = uart00_verify_port, | ||
521 | }; | ||
522 | |||
523 | |||
524 | #ifdef CONFIG_ARCH_CAMELOT | ||
525 | static struct uart_port epxa10db_port = { | ||
526 | .membase = (void*)IO_ADDRESS(EXC_UART00_BASE), | ||
527 | .mapbase = EXC_UART00_BASE, | ||
528 | .iotype = SERIAL_IO_MEM, | ||
529 | .irq = IRQ_UART, | ||
530 | .uartclk = EXC_AHB2_CLK_FREQUENCY, | ||
531 | .fifosize = 16, | ||
532 | .ops = &uart00_pops, | ||
533 | .flags = ASYNC_BOOT_AUTOCONF, | ||
534 | }; | ||
535 | #endif | ||
536 | |||
537 | |||
538 | #ifdef CONFIG_SERIAL_UART00_CONSOLE | ||
539 | static void uart00_console_write(struct console *co, const char *s, unsigned count) | ||
540 | { | ||
541 | #ifdef CONFIG_ARCH_CAMELOT | ||
542 | struct uart_port *port = &epxa10db_port; | ||
543 | unsigned int status, old_ies; | ||
544 | int i; | ||
545 | |||
546 | /* | ||
547 | * First save the CR then disable the interrupts | ||
548 | */ | ||
549 | old_ies = UART_GET_IES(port); | ||
550 | UART_PUT_IEC(port,0xff); | ||
551 | |||
552 | /* | ||
553 | * Now, do each character | ||
554 | */ | ||
555 | for (i = 0; i < count; i++) { | ||
556 | do { | ||
557 | status = UART_GET_TSR(port); | ||
558 | } while (!UART_TX_READY(status)); | ||
559 | UART_PUT_CHAR(port, s[i]); | ||
560 | if (s[i] == '\n') { | ||
561 | do { | ||
562 | status = UART_GET_TSR(port); | ||
563 | } while (!UART_TX_READY(status)); | ||
564 | UART_PUT_CHAR(port, '\r'); | ||
565 | } | ||
566 | } | ||
567 | |||
568 | /* | ||
569 | * Finally, wait for transmitter to become empty | ||
570 | * and restore the IES | ||
571 | */ | ||
572 | do { | ||
573 | status = UART_GET_TSR(port); | ||
574 | } while (status & UART_TSR_TX_LEVEL_MSK); | ||
575 | UART_PUT_IES(port, old_ies); | ||
576 | #endif | ||
577 | } | ||
578 | |||
579 | static void __init | ||
580 | uart00_console_get_options(struct uart_port *port, int *baud, | ||
581 | int *parity, int *bits) | ||
582 | { | ||
583 | unsigned int uart_mc, quot; | ||
584 | |||
585 | uart_mc = UART_GET_MC(port); | ||
586 | |||
587 | *parity = 'n'; | ||
588 | if (uart_mc & UART_MC_PE_MSK) { | ||
589 | if (uart_mc & UART_MC_EP_MSK) | ||
590 | *parity = 'e'; | ||
591 | else | ||
592 | *parity = 'o'; | ||
593 | } | ||
594 | |||
595 | switch (uart_mc & UART_MC_CLS_MSK) { | ||
596 | case UART_MC_CLS_CHARLEN_5: | ||
597 | *bits = 5; | ||
598 | break; | ||
599 | case UART_MC_CLS_CHARLEN_6: | ||
600 | *bits = 6; | ||
601 | break; | ||
602 | case UART_MC_CLS_CHARLEN_7: | ||
603 | *bits = 7; | ||
604 | break; | ||
605 | case UART_MC_CLS_CHARLEN_8: | ||
606 | *bits = 8; | ||
607 | break; | ||
608 | } | ||
609 | quot = UART_GET_DIV_LO(port) | (UART_GET_DIV_HI(port) << 8); | ||
610 | *baud = port->uartclk / (16 *quot ); | ||
611 | } | ||
612 | |||
613 | static int __init uart00_console_setup(struct console *co, char *options) | ||
614 | { | ||
615 | struct uart_port *port; | ||
616 | int baud = 115200; | ||
617 | int bits = 8; | ||
618 | int parity = 'n'; | ||
619 | int flow = 'n'; | ||
620 | |||
621 | #ifdef CONFIG_ARCH_CAMELOT | ||
622 | port = &epxa10db_port; ; | ||
623 | #else | ||
624 | return -ENODEV; | ||
625 | #endif | ||
626 | if (options) | ||
627 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
628 | else | ||
629 | uart00_console_get_options(port, &baud, &parity, &bits); | ||
630 | |||
631 | return uart_set_options(port, co, baud, parity, bits, flow); | ||
632 | } | ||
633 | |||
634 | extern struct uart_driver uart00_reg; | ||
635 | static struct console uart00_console = { | ||
636 | .name = SERIAL_UART00_NAME, | ||
637 | .write = uart00_console_write, | ||
638 | .device = uart_console_device, | ||
639 | .setup = uart00_console_setup, | ||
640 | .flags = CON_PRINTBUFFER, | ||
641 | .index = 0, | ||
642 | .data = &uart00_reg, | ||
643 | }; | ||
644 | |||
645 | static int __init uart00_console_init(void) | ||
646 | { | ||
647 | register_console(&uart00_console); | ||
648 | return 0; | ||
649 | } | ||
650 | console_initcall(uart00_console_init); | ||
651 | |||
652 | #define UART00_CONSOLE &uart00_console | ||
653 | #else | ||
654 | #define UART00_CONSOLE NULL | ||
655 | #endif | ||
656 | |||
657 | static struct uart_driver uart00_reg = { | ||
658 | .owner = NULL, | ||
659 | .driver_name = SERIAL_UART00_NAME, | ||
660 | .dev_name = SERIAL_UART00_NAME, | ||
661 | .major = SERIAL_UART00_MAJOR, | ||
662 | .minor = SERIAL_UART00_MINOR, | ||
663 | .nr = UART_NR, | ||
664 | .cons = UART00_CONSOLE, | ||
665 | }; | ||
666 | |||
667 | struct dev_port_entry{ | ||
668 | unsigned int base_addr; | ||
669 | struct uart_port *port; | ||
670 | }; | ||
671 | |||
672 | #ifdef CONFIG_PLD_HOTSWAP | ||
673 | |||
674 | static struct dev_port_entry dev_port_map[UART_NR]; | ||
675 | |||
676 | /* | ||
677 | * Keep a mapping of dev_info addresses -> port lines to use when | ||
678 | * removing ports dev==NULL indicates unused entry | ||
679 | */ | ||
680 | |||
681 | struct uart00_ps_data{ | ||
682 | unsigned int clk; | ||
683 | unsigned int fifosize; | ||
684 | }; | ||
685 | |||
686 | int uart00_add_device(struct pldhs_dev_info* dev_info, void* dev_ps_data) | ||
687 | { | ||
688 | struct uart00_ps_data* dev_ps=dev_ps_data; | ||
689 | struct uart_port * port; | ||
690 | int i,result; | ||
691 | |||
692 | i=0; | ||
693 | while(dev_port_map[i].port) | ||
694 | i++; | ||
695 | |||
696 | if(i==UART_NR){ | ||
697 | printk(KERN_WARNING "uart00: Maximum number of ports reached\n"); | ||
698 | return 0; | ||
699 | } | ||
700 | |||
701 | port=kmalloc(sizeof(struct uart_port),GFP_KERNEL); | ||
702 | if(!port) | ||
703 | return -ENOMEM; | ||
704 | |||
705 | printk("clk=%d fifo=%d\n",dev_ps->clk,dev_ps->fifosize); | ||
706 | port->membase=0; | ||
707 | port->mapbase=dev_info->base_addr; | ||
708 | port->iotype=SERIAL_IO_MEM; | ||
709 | port->irq=dev_info->irq; | ||
710 | port->uartclk=dev_ps->clk; | ||
711 | port->fifosize=dev_ps->fifosize; | ||
712 | port->ops=&uart00_pops; | ||
713 | port->line=i; | ||
714 | port->flags=ASYNC_BOOT_AUTOCONF; | ||
715 | |||
716 | result=uart_add_one_port(&uart00_reg, port); | ||
717 | if(result){ | ||
718 | printk("uart_add_one_port returned %d\n",result); | ||
719 | return result; | ||
720 | } | ||
721 | dev_port_map[i].base_addr=dev_info->base_addr; | ||
722 | dev_port_map[i].port=port; | ||
723 | printk("uart00: added device at %x as ttyUA%d\n",dev_port_map[i].base_addr,i); | ||
724 | return 0; | ||
725 | |||
726 | } | ||
727 | |||
728 | int uart00_remove_devices(void) | ||
729 | { | ||
730 | int i,result; | ||
731 | |||
732 | |||
733 | result=0; | ||
734 | for(i=1;i<UART_NR;i++){ | ||
735 | if(dev_port_map[i].base_addr){ | ||
736 | result=uart_remove_one_port(&uart00_reg, dev_port_map[i].port); | ||
737 | if(result) | ||
738 | return result; | ||
739 | |||
740 | /* port removed sucessfully, so now tidy up */ | ||
741 | kfree(dev_port_map[i].port); | ||
742 | dev_port_map[i].base_addr=0; | ||
743 | dev_port_map[i].port=NULL; | ||
744 | } | ||
745 | } | ||
746 | return 0; | ||
747 | |||
748 | } | ||
749 | |||
750 | struct pld_hotswap_ops uart00_pldhs_ops={ | ||
751 | .name = "uart00", | ||
752 | .add_device = uart00_add_device, | ||
753 | .remove_devices = uart00_remove_devices, | ||
754 | }; | ||
755 | |||
756 | #endif | ||
757 | |||
758 | static int __init uart00_init(void) | ||
759 | { | ||
760 | int result; | ||
761 | |||
762 | printk(KERN_INFO "Serial: UART00 driver $Revision: 1.35 $\n"); | ||
763 | |||
764 | printk(KERN_WARNING "serial_uart00:Using temporary major/minor pairs" | ||
765 | " - these WILL change in the future\n"); | ||
766 | |||
767 | result = uart_register_driver(&uart00_reg); | ||
768 | if (result) | ||
769 | return result; | ||
770 | #ifdef CONFIG_ARCH_CAMELOT | ||
771 | result = uart_add_one_port(&uart00_reg,&epxa10db_port); | ||
772 | #endif | ||
773 | if (result) | ||
774 | uart_unregister_driver(&uart00_reg); | ||
775 | |||
776 | #ifdef CONFIG_PLD_HOTSWAP | ||
777 | pldhs_register_driver(&uart00_pldhs_ops); | ||
778 | #endif | ||
779 | return result; | ||
780 | } | ||
781 | |||
782 | __initcall(uart00_init); | ||
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index 865d4dea65df..d61494d185cd 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for NEC VR4100 series Serial Interface Unit. | 2 | * Driver for NEC VR4100 series Serial Interface Unit. |
3 | * | 3 | * |
4 | * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> | 4 | * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> |
5 | * | 5 | * |
6 | * Based on drivers/serial/8250.c, by Russell King. | 6 | * Based on drivers/serial/8250.c, by Russell King. |
7 | * | 7 | * |
@@ -371,11 +371,6 @@ static inline void receive_chars(struct uart_port *port, uint8_t *status, | |||
371 | lsr = *status; | 371 | lsr = *status; |
372 | 372 | ||
373 | do { | 373 | do { |
374 | if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { | ||
375 | if (tty->low_latency) | ||
376 | tty_flip_buffer_push(tty); | ||
377 | } | ||
378 | |||
379 | ch = siu_read(port, UART_RX); | 374 | ch = siu_read(port, UART_RX); |
380 | port->icount.rx++; | 375 | port->icount.rx++; |
381 | flag = TTY_NORMAL; | 376 | flag = TTY_NORMAL; |