[U-Boot] [PATCH] gpio: add driver for PCA9539 16-bit I2C gpio expander
Chris Packham
judge.packham at gmail.com
Tue Dec 7 02:50:18 CET 2010
On Tue, Dec 7, 2010 at 2:34 PM, Peter Tyser <ptyser at xes-inc.com> wrote:
> <snip>
>
>> > You could do the same thing to the U-Boot pca953x driver.
>> > Eg at the top you could add:
>> > #ifdef CONFIG_PCA953X_16BIT
>> > #define NGPIO = 16
>> > #else
>> > #define NGPIO = 8
>> > #endif
>>
>> I have a small problem with this due to the fact that we have some
>> designs here that use a pca9534 and a pca9539. Having a compile-time
>> conditional like this means you can only support one or the other.
>> Linux can handle this because it's actually got a structure that
>> contains the 8 vs 16 whereas u-boot only has the address an no other
>> information. Any suggestions on handling this would be welcome.
>
> Some ideas:
> - Do a series of byte reads and determine the number of GPIOs based on
> mirroring of registers, or reads failing if they are past the "end" of
> the device. eg reading register 4 on a 8-bit device might fail, or wrap
> around and return the same data as register 0.
Hmm, I can see problems ahead for that approach.
> - Make CONFIG_PCA953X_16BIT an array that lists which I2C address
> support 16 bits, then use it to determine which devices are 8 vs 16 bits
> dynamically.
I think this is probably the best option. It shouldn't be that hard to
implement.
> - Convert the driver to be more intelligent. eg add an interface like
> pca953x_add_dev(u8 addr, u8 bits) which each board calls to add a device
> to a list of devices maintained by the pca953x driver. Eg in my board
> code I'd do:
> pca953x_add_dev(0x18, 8);
> pca953x_add_dev(0x1c, 8);
> pca953x_add_dev(0x1e, 8);
> pca953x_add_dev(0x1f, 8);
I like the idea but I was hoping not to affect other boards, but if
people are on-board and able to test I could look into this option.
Another approach I though about was having a global variable which
would default to 8 but could be modified via an appropriate setter
prior to making calls to pca953x_set_xyz.
More information about the U-Boot
mailing list