aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2008-02-07 03:15:14 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:24 -0500
commitff11d0780376a3821d790a6ceb8b297d976b14fe (patch)
tree89f035c09efdb91c1e3e899a40bd200115c22fb4
parent789c7048bfaa4901860b4c86606c2651fc2298f4 (diff)
dz: clean up and improve the setup of termios settings
A set of changes to the way termios settings are propagated to the serial port hardware. The DZ11 only supports a selection of fixed baud settings, so some requests may not be fulfilled. Keep the old setting in such a case and failing that resort to 9600bps. Also add a missing update of the transmit timeout. And remove the explicit encoding of the line selected from writes to the Line Parameters Register as it has been preencoded by the ->set_termios() call already. Finally, remove a duplicate macro for the Receiver Enable bit. Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/serial/dz.c103
-rw-r--r--drivers/serial/dz.h4
2 files changed, 56 insertions, 51 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 */
diff --git a/drivers/serial/dz.h b/drivers/serial/dz.h
index 1e836c3411d4..faf169ed27b3 100644
--- a/drivers/serial/dz.h
+++ b/drivers/serial/dz.h
@@ -109,8 +109,8 @@
109#define DZ_B7200 0x0D00 109#define DZ_B7200 0x0D00
110#define DZ_B9600 0x0E00 110#define DZ_B9600 0x0E00
111 111
112#define DZ_CREAD 0x1000 /* Enable receiver */ 112#define DZ_RXENAB 0x1000 /* Receiver Enable */
113#define DZ_RXENAB 0x1000 /* enable receive char */ 113
114/* 114/*
115 * Addresses for the DZ registers 115 * Addresses for the DZ registers
116 */ 116 */