[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pcmcia card speed

Ulrich Müller wrote :
> Hi,
> > I can only talk from my experience with BlueZ and here everything
> > works find when setting the serial port's rate to 115200 because the
> > card itself will then deal with the rest, i.e. it really connects at
> > 921600 because the UART chip inside the card is modified this way.
> I have to disagree. Brainboxes' CF cards have a modified UART that runs
> at either 38400 or 921600 baud (according to their documentation), but
> their PCMCIA cards have a real 16950 UART and the CSR chip is preset to
> run at 115200 baud. So, "out of the box" BBs PCMCIA cards run at 115200
> baud.
> To use other baud rates, both the CSR chip and the UART must be set to
> other rates (in that order). It is possible to set the CSR chip's
> baudrate either with BB's Windows tools or OpenBTs vendor specific
> functions (the later doesn't work for me), but setting the UART to
> 921600 baud seems to be complicated, as it runs at 115200 baud when
> setting the divisor register to 1. If you look at the serial kernel
> driver (2.4.12), setting a baudrate higher than 460800 at a 16950 UART
> has no effect, as the driver has no support for the 16950's CPR
> register. The strange thing is that according to the 16950 specification
> the CPR register should be disabled after a chip reset, so the baud rate
> should be the maximum possible.
> Unfortunatly, Brainboxes was so far unable to provide help in this
> affair. I really doubt if anyone has ever got their PCMCIA cards working
> with "real" 921600 baud under Linux. What data rates do you get with the
> cards?
> br, Ulrich Mueller

	Yes, I agree 100% with you. I was reading the doc of the
16C950 yesterday and staring at the driver, and I came to the same

	In details :
	There is 2 speed setting, the CSR chip and the UART.
	The Windows tools knows how to set the CSR speed, but if you
look at the code of OpenBT, OpenBT also knows how to set the speed of
the CSR chip (see in hci_vendor.c).
	Changing the speed seems pretty simple : you just send the
appropriate command to the CSR chip.

	The UART is another matter.
        The 16C950 UART used in the Pcmcia card has 3 speed setting,
the regular clock divider (DLM:DLL), the over-sampling (TCR) and the
prescaler (CPR) (chapter 14, page 28).
        The final speed depend of those 3 registers and the clock
frequency (cristal frequency supplied to the chip). It's easy to know
the value of those 3 registers (they are set int he driver), however I
don't know what's the value of the clock frequency of the Pcmcia card.
        For a normal UART, the clock frequency is 1.84 MHz. However,
using such a clock the maximum bauds that can be acheived is 460800
bps (see table 17 at page 30).
        So, the only option to get 921600 bps out of the 16C950 UART
is to use a higher clock frequency. Unfortunately, a higher clock
frequency require that the prescaler is set properly to do the
expected rates.
	If you set the clock frequency to 7.3728 MHz, which is 4 times
the standard frequency, you need to set the prescaler to 4 if you want
to do the standard UART rate (so, you would set CPR to 0x20). If you
want to do the higher rate, you set the prescaler to 1 (CPR = 0x08).
	From the documentation, it seems that you are not supposed to
use prescaler lower than 1. In theory, CPR = 0x04 would allow to reach
921600 with TCR=0x4 and div=1, but I suspect the serial pulse would
not be stable and acurate enough (it's already oversampled 4 times
because of TCR).

	I'm going to make a patch to the serial driver to support CPR
properly. The problem is that there is no way to know what is the
clock frequency of the board (I've sent an e-mail to BrainBox, no
answer so far), so I'll do a hack (I'll use MCR[7] as a best guess +
adding an ioctl to set the proper prescaler value).

	Have fun...