summaryrefslogtreecommitdiffstats
path: root/drivers/serial/mfd.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 19:59:04 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 19:59:04 -0700
commit73ecf3a6e3f0206bf56a0fefe3b3eda042fb7034 (patch)
tree866f0ebb2b148479e93b5ac955097b1cc94ceb4e /drivers/serial/mfd.c
parentb9da0571050c09863e59f94d0b8594a290d61b88 (diff)
parentcd3ecad19aea8debae9a48b53de2ec7a571f24e9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (49 commits) serial8250: ratelimit "too much work" error serial: bfin_sport_uart: speed up sport RX sample rate to be 3% faster serial: abstraction for 8250 legacy ports serial/imx: check that the buffer is non-empty before sending it out serial: mfd: add more baud rates support jsm: Remove the uart port on errors Alchemy: Add UART PM methods. 8250: allow platforms to override PM hook. altera_uart: Don't use plain integer as NULL pointer altera_uart: Fix missing prototype for registering an early console altera_uart: Fixup type usage of port flags altera_uart: Make it possible to use Altera UART and 8250 ports together altera_uart: Add support for different address strides altera_uart: Add support for getting mapbase and IRQ from resources altera_uart: Add support for polling mode (IRQ-less) serial: Factor out uart_poll_timeout() from 8250 driver serial: mark the 8250 driver as maintained serial: 8250: Don't delay after transmitter is ready. tty: MAINTAINERS: add drivers/serial/jsm/ as maintained driver vcs: invoke the vt update callback when /dev/vcs* is written to ...
Diffstat (limited to 'drivers/serial/mfd.c')
-rw-r--r--drivers/serial/mfd.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/drivers/serial/mfd.c b/drivers/serial/mfd.c
index dc0967fb9ea..5fc699e929d 100644
--- a/drivers/serial/mfd.c
+++ b/drivers/serial/mfd.c
@@ -172,6 +172,9 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf,
len += snprintf(buf + len, HSU_REGS_BUFSIZE - len,
"DIV: \t\t0x%08x\n", serial_in(up, UART_DIV));
+ if (len > HSU_REGS_BUFSIZE)
+ len = HSU_REGS_BUFSIZE;
+
ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
kfree(buf);
return ret;
@@ -219,6 +222,9 @@ static ssize_t dma_show_regs(struct file *file, char __user *user_buf,
len += snprintf(buf + len, HSU_REGS_BUFSIZE - len,
"D0TSR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3TSR));
+ if (len > HSU_REGS_BUFSIZE)
+ len = HSU_REGS_BUFSIZE;
+
ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
kfree(buf);
return ret;
@@ -925,39 +931,52 @@ serial_hsu_set_termios(struct uart_port *port, struct ktermios *termios,
cval |= UART_LCR_EPAR;
/*
+ * The base clk is 50Mhz, and the baud rate come from:
+ * baud = 50M * MUL / (DIV * PS * DLAB)
+ *
* For those basic low baud rate we can get the direct
- * scalar from 2746800, like 115200 = 2746800/24, for those
- * higher baud rate, we have to handle them case by case,
- * but DIV reg is never touched as its default value 0x3d09
+ * scalar from 2746800, like 115200 = 2746800/24. For those
+ * higher baud rate, we handle them case by case, mainly by
+ * adjusting the MUL/PS registers, and DIV register is kept
+ * as default value 0x3d09 to make things simple
*/
baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
- quot = uart_get_divisor(port, baud);
+ quot = 1;
switch (baud) {
case 3500000:
mul = 0x3345;
ps = 0xC;
- quot = 1;
+ break;
+ case 3000000:
+ mul = 0x2EE0;
break;
case 2500000:
mul = 0x2710;
- ps = 0x10;
- quot = 1;
break;
- case 18432000:
+ case 2000000:
+ mul = 0x1F40;
+ break;
+ case 1843200:
mul = 0x2400;
- ps = 0x10;
- quot = 1;
break;
case 1500000:
- mul = 0x1D4C;
- ps = 0xc;
- quot = 1;
+ mul = 0x1770;
+ break;
+ case 1000000:
+ mul = 0xFA0;
+ break;
+ case 500000:
+ mul = 0x7D0;
break;
default:
- ;
+ /* Use uart_get_divisor to get quot for other baud rates */
+ quot = 0;
}
+ if (!quot)
+ quot = uart_get_divisor(port, baud);
+
if ((up->port.uartclk / quot) < (2400 * 16))
fcr = UART_FCR_ENABLE_FIFO | UART_FCR_HSU_64_1B;
else if ((up->port.uartclk / quot) < (230400 * 16))