updated on Tue Jan 10 08:08:34 UTC 2012
[aur-mirror.git] / linux-fedora / linux-2.6-serial-460800.patch
blob9aa392c9e9dd70da1ab8017a0284bd040344f458
1 diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
2 index 2209620..659c1bb 100644
3 --- a/drivers/tty/serial/8250.c
4 +++ b/drivers/tty/serial/8250.c
5 @@ -7,6 +7,9 @@
7 * Copyright (C) 2001 Russell King.
9 + * 2005/09/16: Enabled higher baud rates for 16C95x.
10 + * (Mathias Adam <a2@adamis.de>)
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 @@ -2227,6 +2230,14 @@ static unsigned int serial8250_get_divisor(struct uart_port *port, unsigned int
16 else if ((port->flags & UPF_MAGIC_MULTIPLIER) &&
17 baud == (port->uartclk/8))
18 quot = 0x8002;
19 + /*
20 + * For 16C950s UART_TCR is used in combination with divisor==1
21 + * to achieve baud rates up to baud_base*4.
22 + */
23 + else if ((port->type == PORT_16C950) &&
24 + baud > (port->uartclk/16))
25 + quot = 1;
27 else
28 quot = uart_get_divisor(port, baud);
30 @@ -2240,7 +2251,7 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
31 struct uart_8250_port *up = (struct uart_8250_port *)port;
32 unsigned char cval, fcr = 0;
33 unsigned long flags;
34 - unsigned int baud, quot;
35 + unsigned int baud, quot, max_baud;
37 switch (termios->c_cflag & CSIZE) {
38 case CS5:
39 @@ -2272,9 +2283,10 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
41 * Ask the core to calculate the divisor for us.
43 + max_baud = (up->port.type == PORT_16C950 ? port->uartclk/4 : port->uartclk/16);
44 baud = uart_get_baud_rate(port, termios, old,
45 port->uartclk / 16 / 0xffff,
46 - port->uartclk / 16);
47 + max_baud);
48 quot = serial8250_get_divisor(port, baud);
51 @@ -2311,6 +2323,19 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
52 spin_lock_irqsave(&up->port.lock, flags);
55 + * 16C950 supports additional prescaler ratios between 1:16 and 1:4
56 + * thus increasing max baud rate to uartclk/4.
57 + */
58 + if (up->port.type == PORT_16C950) {
59 + if (baud == port->uartclk/4)
60 + serial_icr_write(up, UART_TCR, 0x4);
61 + else if (baud == port->uartclk/8)
62 + serial_icr_write(up, UART_TCR, 0x8);
63 + else
64 + serial_icr_write(up, UART_TCR, 0);
65 + }
67 + /*
68 * Update the per-port timeout.
70 uart_update_timeout(port, termios->c_cflag, baud);