Jesse Keating 7a32965
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
Jesse Keating 7a32965
index 2209620..659c1bb 100644
ae3db82
--- a/drivers/tty/serial/8250/8250.c
ae3db82
+++ b/drivers/tty/serial/8250/8250.c
Jesse Keating 7a32965
@@ -7,6 +7,9 @@
Jesse Keating 7a32965
  *
Jesse Keating 7a32965
  *  Copyright (C) 2001 Russell King.
Jesse Keating 7a32965
  *
Jesse Keating 7a32965
+ *  2005/09/16: Enabled higher baud rates for 16C95x.
Jesse Keating 7a32965
+ *		(Mathias Adam <a2@adamis.de>)
Jesse Keating 7a32965
+ *
Jesse Keating 7a32965
  * This program is free software; you can redistribute it and/or modify
Jesse Keating 7a32965
  * it under the terms of the GNU General Public License as published by
Jesse Keating 7a32965
  * the Free Software Foundation; either version 2 of the License, or
Jesse Keating 7a32965
@@ -2227,6 +2230,14 @@ static unsigned int serial8250_get_divisor(struct uart_port *port, unsigned int
Jesse Keating 7a32965
 	else if ((port->flags & UPF_MAGIC_MULTIPLIER) &&
Jesse Keating 7a32965
 		 baud == (port->uartclk/8))
Jesse Keating 7a32965
 		quot = 0x8002;
Jesse Keating 7a32965
+	/*
Jesse Keating 7a32965
+	 * For 16C950s UART_TCR is used in combination with divisor==1
Jesse Keating 7a32965
+	 * to achieve baud rates up to baud_base*4.
Jesse Keating 7a32965
+	 */
Jesse Keating 7a32965
+	else if ((port->type == PORT_16C950) &&
Jesse Keating 7a32965
+		 baud > (port->uartclk/16))
Jesse Keating 7a32965
+		quot = 1;
Jesse Keating 7a32965
+
Jesse Keating 7a32965
 	else
Jesse Keating 7a32965
 		quot = uart_get_divisor(port, baud);
Jesse Keating 7a32965
 
Jesse Keating 7a32965
@@ -2240,7 +2251,7 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
fc85362
		container_of(port, struct uart_8250_port, port);
Jesse Keating 7a32965
 	unsigned char cval, fcr = 0;
Jesse Keating 7a32965
 	unsigned long flags;
Jesse Keating 7a32965
-	unsigned int baud, quot;
Jesse Keating 7a32965
+	unsigned int baud, quot, max_baud;
fc85362
	int fifo_bug = 0;
Jesse Keating 7a32965
 
Jesse Keating 7a32965
 	switch (termios->c_cflag & CSIZE) {
Jesse Keating 7a32965
@@ -2272,9 +2283,10 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
Jesse Keating 7a32965
 	/*
Jesse Keating 7a32965
 	 * Ask the core to calculate the divisor for us.
Jesse Keating 7a32965
 	 */
Jesse Keating 7a32965
+	max_baud = (up->port.type == PORT_16C950 ? port->uartclk/4 : port->uartclk/16);
Jesse Keating 7a32965
 	baud = uart_get_baud_rate(port, termios, old,
Jesse Keating 7a32965
 				  port->uartclk / 16 / 0xffff,
Jesse Keating 7a32965
-				  port->uartclk / 16);
Jesse Keating 7a32965
+				  max_baud);
Jesse Keating 7a32965
 	quot = serial8250_get_divisor(port, baud);
Jesse Keating 7a32965
 
Jesse Keating 7a32965
 	/*
Jesse Keating 7a32965
@@ -2311,6 +2323,19 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
Jesse Keating 7a32965
 	spin_lock_irqsave(&up->port.lock, flags);
Jesse Keating 7a32965
 
Jesse Keating 7a32965
 	/*
Jesse Keating 7a32965
+	 * 16C950 supports additional prescaler ratios between 1:16 and 1:4
Jesse Keating 7a32965
+	 * thus increasing max baud rate to uartclk/4.
Jesse Keating 7a32965
+	 */
Jesse Keating 7a32965
+	if (up->port.type == PORT_16C950) {
Jesse Keating 7a32965
+		if (baud == port->uartclk/4)
Jesse Keating 7a32965
+			serial_icr_write(up, UART_TCR, 0x4);
Jesse Keating 7a32965
+		else if (baud == port->uartclk/8)
Jesse Keating 7a32965
+			serial_icr_write(up, UART_TCR, 0x8);
Jesse Keating 7a32965
+		else
Jesse Keating 7a32965
+			serial_icr_write(up, UART_TCR, 0);
Jesse Keating 7a32965
+	}
Jesse Keating 7a32965
+
Jesse Keating 7a32965
+	/*
Jesse Keating 7a32965
 	 * Update the per-port timeout.
Jesse Keating 7a32965
 	 */
Jesse Keating 7a32965
 	uart_update_timeout(port, termios->c_cflag, baud);