Re: [ftdi_sio] FT232H support

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

 



Hi,

On Mon, 2011-07-11 at 17:06 +0300, Alex Stefan wrote:
> Basically, we have 2 issues that aren't really clear:
> 1) Is the FT232H placed in the correct branch when calculating the
> divisor?

Yes it actually is on the correct branch because the chip should support
baud rates up to 12 MBaud.

> 2) What't the explanation behind the algorithm which calculates the
> divisor in function "ftdi_2232h_baud_base_to_divisor()"  ?
> 

It's explained in section 4.4 of AN120. It's the same as the algorithm
for 232BM, but it uses a 12 Mhz reference clock instead of the 3 Mhz
reference clock the other functions are using.

Section 4.4 of AN120 also says:

"The instructions in section 4.3 are still applicable for the FT2232H
and the FT4232H up to 3MBaud. The calculations for sub integers still
apply.

To alias baud rates between 3MBaud and 12MBaud it is necessary to use
driver version 2.4.20 or later and the most significant bit (MSB) of the
divisor must be a 1. This will ensure the divisor is dividing a 12MHz
clock and not a 3MHz clock."

Now, one problem I see in ftdi_2232h_baud_base_to_divisor is that
another bit is set (not MSB):

divisor |= 0x00020000;

I think it should be:

divisor |= 0x80000000;

The AN120 examples for standard baud rates (such as: 38,41,00,80 =>
divisor = 312.5, rate = 38,400) also confirm that bit 31 needs to be
set, not bit 17 like in the current driver. So this looks like a bug...

However, setting it properly didn't help either. With a divisor value of
0x8000c068 calculated for 115200bps I still can't receive anything from
the other chip. I can only communicate with the other chip at 115200
when using the old algorithm with a divisor of 0x1a.

As a workaround (also valid from the documentation point of view), for
baud <= 3 MBaud we could use the 3 Mhz reference clock
(ftdi_232bm_baud_to_divisor) and for baud > 3 MBaud we
could use the 12Mhz reference clock (ftdi_2232h_baud_to_divisor).

In this scenario the code would look like this:

        case FT2232H: /* FT2232H chip */
        case FT4232H: /* FT4232H chip */
        case FT232H:  /* FT232H chip */
                if ((baud <= 12000000) && (baud > 3000000)) {
                        div_value = ftdi_2232h_baud_to_divisor(baud);
                } else if (baud <= 3000000) {
                        div_value = ftdi_232bm_baud_to_divisor(baud);
                } else {
                        dbg("%s - Baud rate too high!", __func__);
                        div_value = ftdi_232bm_baud_to_divisor(9600);
                        div_okay = 0;
                        baud = 9600;
                }
                break;

Does anyone have a 2232 or 4232 to test this? The chip connected to my
232H supports a maximum baud rate of 115200 so I can't really test at
higher rates.

> [1]
> http://www.ftdichip.com/Support/Documents/AppNotes/AN_120_Aliasing_VCP_Baud_Rates.pdf
> 

Thanks,
Ionut.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux