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