From: Peter Tyser <ptyser@xes-inc.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] gpio: add driver for PCA9539 16-bit I2C gpio expander
Date: Mon, 06 Dec 2010 22:31:18 -0600 [thread overview]
Message-ID: <4CFDB896.5000401@xes-inc.com> (raw)
In-Reply-To: <AANLkTimP6RXAhsLmNkHfygFUgaHz-0mPcVom+OhO9T3K@mail.gmail.com>
Chris Packham wrote:
> On Tue, Dec 7, 2010 at 2:34 PM, Peter Tyser <ptyser@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.
>
I believe the only mainline users of the pca953x driver are my company's
boards. I'm more than happy to test any modifications to the driver and
to tweak our boards as needed, so I'd recommend choosing whichever
approach is the cleanest in the long run.
Best,
Peter
prev parent reply other threads:[~2010-12-07 4:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-06 21:48 [U-Boot] [PATCH] gpio: add driver for PCA9539 16-bit I2C gpio expander Chris Packham
2010-12-07 0:13 ` Peter Tyser
2010-12-07 1:12 ` Chris Packham
2010-12-07 1:34 ` Peter Tyser
2010-12-07 1:50 ` Chris Packham
2010-12-07 4:31 ` Peter Tyser [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=4CFDB896.5000401@xes-inc.com \
--to=ptyser@xes-inc.com \
--cc=u-boot@lists.denx.de \
/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