From: Mathias Adam <a2@adamis.de>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 8250.c: Fix to make 16C950 UARTs work
Date: Fri, 16 Sep 2005 14:11:16 +0200 [thread overview]
Message-ID: <20050916121116.GA6195@adamis.de> (raw)
In-Reply-To: <20050909111835.D17575@flint.arm.linux.org.uk>
I've reworked the patch a little. Now it should enable both the 230400 and
the 460800 baud rates on any serial port which is using a 16C95x UART.
However as my 16C950 device is part of a Bluetooth dongle I couldn't
test the 460800 baud rate myself (I am able to set this rate with stty
though).
Please, could someone who owns such a UART try this out?
Any other comments?
Regards
Mathias
--- linux-2.6.13-org/drivers/serial/8250.c 2005-08-29 01:41:01.000000000 +0200
+++ linux-2.6.13/drivers/serial/8250.c 2005-09-16 12:18:14.000000000 +0200
@@ -7,6 +7,9 @@
*
* Copyright (C) 2001 Russell King.
*
+ * 2005/09/16: Enabled higher baud rates for 16C95x.
+ * (Mathias Adam <a2@adamis.de>)
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -1652,6 +1655,14 @@
else if ((port->flags & UPF_MAGIC_MULTIPLIER) &&
baud == (port->uartclk/8))
quot = 0x8002;
+ /*
+ * For 16C950s UART_TCR is used in combination with divisor==1
+ * to achieve baud rates up to baud_base*4.
+ */
+ else if ((port->type == PORT_16C950) &&
+ baud > (port->uartclk/16))
+ quot = 1;
+
else
quot = uart_get_divisor(port, baud);
@@ -1665,7 +1676,7 @@
struct uart_8250_port *up = (struct uart_8250_port *)port;
unsigned char cval, fcr = 0;
unsigned long flags;
- unsigned int baud, quot;
+ unsigned int baud, quot, max_baud;
switch (termios->c_cflag & CSIZE) {
case CS5:
@@ -1697,7 +1708,8 @@
/*
* Ask the core to calculate the divisor for us.
*/
- baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
+ max_baud = (up->port.type == PORT_16C950 ? port->uartclk/4 : port->uartclk/16);
+ baud = uart_get_baud_rate(port, termios, old, 0, max_baud);
quot = serial8250_get_divisor(port, baud);
/*
@@ -1733,6 +1745,19 @@
*/
spin_lock_irqsave(&up->port.lock, flags);
+ /*
+ * 16C950 supports additional prescaler ratios between 1:16 and 1:4
+ * thus increasing max baud rate to uartclk/4.
+ */
+ if (up->port.type == PORT_16C950) {
+ if (baud == port->uartclk/4)
+ serial_icr_write(up, UART_TCR, 0x4);
+ else if (baud == port->uartclk/8)
+ serial_icr_write(up, UART_TCR, 0x8);
+ else
+ serial_icr_write(up, UART_TCR, 0);
+ }
+
/*
* Update the per-port timeout.
*/
prev parent reply other threads:[~2005-09-16 12:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-09 1:31 [PATCH] 8250.c: Fix to make 16C950 UARTs work Mathias Adam
2005-09-09 1:58 ` Stefan Smietanowski
2005-09-09 2:49 ` Mathias Adam
2005-09-09 10:18 ` Russell King
2005-09-09 14:42 ` Mathias Adam
2005-09-16 12:11 ` Mathias Adam [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050916121116.GA6195@adamis.de \
--to=a2@adamis.de \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+lkml@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.