aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/dz.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/dz.c')
-rw-r--r--drivers/serial/dz.c103
1 files changed, 54 insertions, 49 deletions
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index ae3203b20134..765b700c019c 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -128,8 +128,8 @@ static void dz_stop_rx(struct uart_port *uport)
128{ 128{
129 struct dz_port *dport = (struct dz_port *)uport; 129 struct dz_port *dport = (struct dz_port *)uport;
130 130
131 dport->cflag &= ~DZ_CREAD; 131 dport->cflag &= ~DZ_RXENAB;
132 dz_out(dport, DZ_LPR, dport->cflag | dport->port.line); 132 dz_out(dport, DZ_LPR, dport->cflag);
133} 133}
134 134
135static void dz_enable_ms(struct uart_port *port) 135static void dz_enable_ms(struct uart_port *port)
@@ -464,12 +464,51 @@ static void dz_break_ctl(struct uart_port *uport, int break_state)
464 spin_unlock_irqrestore(&uport->lock, flags); 464 spin_unlock_irqrestore(&uport->lock, flags);
465} 465}
466 466
467static int dz_encode_baud_rate(unsigned int baud)
468{
469 switch (baud) {
470 case 50:
471 return DZ_B50;
472 case 75:
473 return DZ_B75;
474 case 110:
475 return DZ_B110;
476 case 134:
477 return DZ_B134;
478 case 150:
479 return DZ_B150;
480 case 300:
481 return DZ_B300;
482 case 600:
483 return DZ_B600;
484 case 1200:
485 return DZ_B1200;
486 case 1800:
487 return DZ_B1800;
488 case 2000:
489 return DZ_B2000;
490 case 2400:
491 return DZ_B2400;
492 case 3600:
493 return DZ_B3600;
494 case 4800:
495 return DZ_B4800;
496 case 7200:
497 return DZ_B7200;
498 case 9600:
499 return DZ_B9600;
500 default:
501 return -1;
502 }
503}
504
467static void dz_set_termios(struct uart_port *uport, struct ktermios *termios, 505static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
468 struct ktermios *old_termios) 506 struct ktermios *old_termios)
469{ 507{
470 struct dz_port *dport = (struct dz_port *)uport; 508 struct dz_port *dport = (struct dz_port *)uport;
471 unsigned long flags; 509 unsigned long flags;
472 unsigned int cflag, baud; 510 unsigned int cflag, baud;
511 int bflag;
473 512
474 cflag = dport->port.line; 513 cflag = dport->port.line;
475 514
@@ -496,60 +535,26 @@ static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
496 cflag |= DZ_PARODD; 535 cflag |= DZ_PARODD;
497 536
498 baud = uart_get_baud_rate(uport, termios, old_termios, 50, 9600); 537 baud = uart_get_baud_rate(uport, termios, old_termios, 50, 9600);
499 switch (baud) { 538 bflag = dz_encode_baud_rate(baud);
500 case 50: 539 if (bflag < 0) { /* Try to keep unchanged. */
501 cflag |= DZ_B50; 540 baud = uart_get_baud_rate(uport, old_termios, NULL, 50, 9600);
502 break; 541 bflag = dz_encode_baud_rate(baud);
503 case 75: 542 if (bflag < 0) { /* Resort to 9600. */
504 cflag |= DZ_B75; 543 baud = 9600;
505 break; 544 bflag = DZ_B9600;
506 case 110: 545 }
507 cflag |= DZ_B110; 546 tty_termios_encode_baud_rate(termios, baud, baud);
508 break;
509 case 134:
510 cflag |= DZ_B134;
511 break;
512 case 150:
513 cflag |= DZ_B150;
514 break;
515 case 300:
516 cflag |= DZ_B300;
517 break;
518 case 600:
519 cflag |= DZ_B600;
520 break;
521 case 1200:
522 cflag |= DZ_B1200;
523 break;
524 case 1800:
525 cflag |= DZ_B1800;
526 break;
527 case 2000:
528 cflag |= DZ_B2000;
529 break;
530 case 2400:
531 cflag |= DZ_B2400;
532 break;
533 case 3600:
534 cflag |= DZ_B3600;
535 break;
536 case 4800:
537 cflag |= DZ_B4800;
538 break;
539 case 7200:
540 cflag |= DZ_B7200;
541 break;
542 case 9600:
543 default:
544 cflag |= DZ_B9600;
545 } 547 }
548 cflag |= bflag;
546 549
547 if (termios->c_cflag & CREAD) 550 if (termios->c_cflag & CREAD)
548 cflag |= DZ_RXENAB; 551 cflag |= DZ_RXENAB;
549 552
550 spin_lock_irqsave(&dport->port.lock, flags); 553 spin_lock_irqsave(&dport->port.lock, flags);
551 554
552 dz_out(dport, DZ_LPR, cflag | dport->port.line); 555 uart_update_timeout(uport, termios->c_cflag, baud);
556
557 dz_out(dport, DZ_LPR, cflag);
553 dport->cflag = cflag; 558 dport->cflag = cflag;
554 559
555 /* setup accept flag */ 560 /* setup accept flag */