public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathias Adam <a2@adamis.de>
To: bluez-users@lists.sourceforge.net
Subject: Re: [Bluez-users] Once again: Socket CF card and Kernel 2.6
Date: Sat, 5 Mar 2005 15:18:58 +0100	[thread overview]
Message-ID: <20050305141858.GA21208@adamis.de> (raw)
In-Reply-To: <1110021859.8058.111.camel@pegasus>

[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]

Hi Marcel,

On 05.03.05 12:24:19, Marcel Holtmann wrote:
> > I just got it working by doing a little change in the serial driver 
> > (8250.c). I tested it with 2.6.11 but I think it could work for any 2.6 
> > kernel.
> 
> please provide a patch for your change.

So - after some cleaning - here it is. A short description:

The BlueZ driver requests a baud rate
of 230400 which is uartclk/8 (serial_cs sets uartclk=1843200). However
serial8250_set_termios() refuses to program a baud rate larger than
uartclk/16 which should be ok for most UARTs. I looked into the 2.4
driver and found some code that changes the internal prescaler to values
between 1:16 and 1:4 to support baud rates up to uartclk/4 respectively
(this is done for 16C950 UARTs only). The datasheet of oxford's oxcf950
chip confirms this feature.

Apply the patch to the file drivers/serial/8250.c

Please let me know if there are problems or if it does work.

> > One thing I discovered while debugging this: the hci_uart driver 
> > seems to initialize the actual UART with only 230400 baud. Is this 
> > really the case or are those UARTs clocked at nonstandard (higher) 
> > frequencies so that this setting does result in a higher real baud rate?
> 
> The hci_uart is only a line discipline. Every initialization and baud
> rate settings are done with hciattach.

ok so it's hciattach that sets the baudrate - but that wasn't the point
(or I misunderstood your answer?): I wonder if the bluetooth module is
really accessed at only 230400 baud (that's the rate which is given to
the 8250 driver) which seems a little bit slow thinking of bluetooths
>700kbaud maximum rate...


Regards

Mathias


-- 
Der Jammer der Menschen ist, daß die Narren so sicher sind und die
Klugen so voller Zweifel. (Bertrand Russel)

[-- Attachment #2: patch-serial-16c950 --]
[-- Type: text/plain, Size: 1535 bytes --]

--- 8250.c_2.6.11-org	2005-03-02 08:37:47.000000000 +0100
+++ 8250.c	2005-03-05 15:01:34.000000000 +0100
@@ -1604,7 +1604,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:
@@ -1636,9 +1636,29 @@
 	/*
 	 * 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);
 
+	/* 
+	 * 16C950 supports additional prescaler ratios between 1:16 and 1:4
+	 * thus increasing max baud rate to uartclk/4. The following was taken
+	 * from kernel 2.4 by Mathias Adam <a2@adamis.de> to make the Socket
+	 * Bluetooth CF Card work under 2.6.11.
+	 * (Patch might have other side effects so be careful!)
+	 */
+	if (up->port.type == PORT_16C950) {
+		unsigned int baud_base = port->uartclk/16;
+		if (baud <= port->uartclk/16)
+			serial_icr_write(up, UART_TCR, 0);
+		else if (baud <= port->uartclk/8) {
+			serial_icr_write(up, UART_TCR, 0x8);
+		} else if (baud <= port->uartclk/4) {
+			serial_icr_write(up, UART_TCR, 0x4);
+		} else
+			serial_icr_write(up, UART_TCR, 0);
+	}
+	
 	/*
 	 * Work around a bug in the Oxford Semiconductor 952 rev B
 	 * chip which causes it to seriously miscalculate baud rates

  reply	other threads:[~2005-03-05 14:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-26  3:19 [Bluez-users] Once again: Socket CF card and Kernel 2.6 Mathias Adam
2005-02-28  8:13 ` Marcel Holtmann
2005-02-28 22:02   ` a2
2005-03-01  8:29     ` Marcel Holtmann
2005-03-05  5:37       ` Mathias Adam
2005-03-05  9:17         ` Erwin Authried
2005-03-05 14:42           ` Mathias Adam
2005-03-05 11:24         ` Marcel Holtmann
2005-03-05 14:18           ` Mathias Adam [this message]
2005-03-05 14:35             ` Mathias Adam
2005-03-05 18:17             ` Marcel Holtmann
2005-03-05 19:25               ` Mathias Adam
2005-03-05 19:55                 ` Marcel Holtmann
2005-03-06 19:37                   ` Mathias Adam

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=20050305141858.GA21208@adamis.de \
    --to=a2@adamis.de \
    --cc=bluez-users@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox