aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/sh-sci.c
diff options
context:
space:
mode:
authorTakashi Yoshii <takashi.yoshii.zj@renesas.com>2012-11-15 20:52:49 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-15 21:02:37 -0500
commit9d482cc353bd0391730730b26e4c2938dc90e477 (patch)
tree41e37908c1d0eca6e9a19ecbb39c49a6585cb42b /drivers/tty/serial/sh-sci.c
parent4ffc3cdb642823ebee84538addac7cde1174e314 (diff)
serial: sh-sci: support lower baud rate
Support prescaler 1/16 and 1/64, in addition to current 1 and 1/4. Supporting below 2400bps was dropped long time ago in mainline. Since then, setting lower rate has been resulting in erroneous register value, without indicating any errors through API. This patch adds more prescaler to support lower rates again. This still doesn't check range, but we won't hit the case because even 50bps at 48MHz clock is now supported. Signed-off-by: Takashi Yoshii <takashi.yoshii.zj@renesas.com> Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/sh-sci.c')
-rw-r--r--drivers/tty/serial/sh-sci.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 6c1fddb0e20a..a54c47d0fd63 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1815,7 +1815,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1815{ 1815{
1816 struct sci_port *s = to_sci_port(port); 1816 struct sci_port *s = to_sci_port(port);
1817 struct plat_sci_reg *reg; 1817 struct plat_sci_reg *reg;
1818 unsigned int baud, smr_val, max_baud; 1818 unsigned int baud, smr_val, max_baud, cks;
1819 int t = -1; 1819 int t = -1;
1820 1820
1821 /* 1821 /*
@@ -1849,21 +1849,18 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1849 1849
1850 uart_update_timeout(port, termios->c_cflag, baud); 1850 uart_update_timeout(port, termios->c_cflag, baud);
1851 1851
1852 serial_port_out(port, SCSMR, smr_val); 1852 for (cks = 0; t >= 256 && cks <= 3; cks++)
1853 t >>= 2;
1853 1854
1854 dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t, 1855 dev_dbg(port->dev, "%s: SMR %x, cks %x, t %x, SCSCR %x\n",
1855 s->cfg->scscr); 1856 __func__, smr_val, cks, t, s->cfg->scscr);
1856 1857
1857 if (t >= 0) { 1858 if (t >= 0) {
1858 if (t >= 256) { 1859 serial_port_out(port, SCSMR, (smr_val & ~3) | cks);
1859 serial_port_out(port, SCSMR, (serial_port_in(port, SCSMR) & ~3) | 1);
1860 t >>= 2;
1861 } else
1862 serial_port_out(port, SCSMR, serial_port_in(port, SCSMR) & ~3);
1863
1864 serial_port_out(port, SCBRR, t); 1860 serial_port_out(port, SCBRR, t);
1865 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ 1861 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
1866 } 1862 } else
1863 serial_port_out(port, SCSMR, smr_val);
1867 1864
1868 sci_init_pins(port, termios->c_cflag); 1865 sci_init_pins(port, termios->c_cflag);
1869 1866