From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Tyser Date: Mon, 06 Dec 2010 19:34:05 -0600 Subject: [U-Boot] [PATCH] gpio: add driver for PCA9539 16-bit I2C gpio expander In-Reply-To: References: <1291680833.20072.725.camel@petert> Message-ID: <1291685645.20072.736.camel@petert> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > > 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. - 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. - 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); Best, Peter