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 18:13:53 -0600 [thread overview]
Message-ID: <1291680833.20072.725.camel@petert> (raw)
In-Reply-To: <AANLkTikUpzYoU-WQ7BXi8OxXnR-rDD+RL2BgM16qU9oc@mail.gmail.com>
Hi Chris,
On Tue, 2010-12-07 at 10:48 +1300, Chris Packham wrote:
> This adds support for the PCA9539 family of gpio devices which have 16
> output pins. The devices are similar to chips that use the pca953x driver
> except the register map is expanded (in a non-backwards compatible manner)
> to allow for the extra 8 pins.
>
> This driver has one gotcha that you can only set the top or bottom 8 bits
> at a time. For example to set the 16 pins to be outputs you need to make
> the function calls
>
> pca9539_set_dir(PCA9539_ADDR, 0xff00, 0x0000);
> pca9539_set_dir(PCA9539_ADDR, 0x00ff, 0x0000);
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> Hi,
>
> I have a couple of questions related to my patch. Firstly is anyone
> interested in
> support for these gpio devices? Secondly is my gotcha acceptable or should I
> put some effort into making it handle a 16-bit argument in 1 hit?
>
> I toyed with the idea of making this part of the pca953x driver. I
> didn't because
> the register layout is different so I'd still need to define PCA9539 specific
> functions and macros (although pca953x_reg_write could be re-used). I also
> figured that some people may want to define only CONFIG_PCA9539 (that is
> the case for me at the moment but the overhead of CONFIG_PCA953X wouldn't
> push the size of my image over any boundary).
I think it'd be nice to add support for 16-bit pca953x devices. I don't
personally use them, but others might in the future, or they may choose
to use them since they are well supported in U-Boot and Linux. If you
already use the pca9539, getting it in mainline U-Boot will be nice for
you in the long run either way.
I think it'd be worth attempting to combine your changes in the existing
pca953x driver though. They are similar enough that it should be doable
without too much headache, and it'll be more maintainable to have a
unified driver.
Linux combines the 2 for what its worth (see drivers/gpio/pca953x.c).
It uses the number of GPIO pins to conditionally support 8 or 16-bit
expanders. 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
You could also change the read/write parameters to be uint16's instead
of the current uint8's to support 16-bits of GPIO. I think with those 2
changes, plus some additional conditionals you could combine the 2
drivers without too much effort.
Best,
Peter
next prev parent reply other threads:[~2010-12-07 0:13 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 [this message]
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
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=1291680833.20072.725.camel@petert \
--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