Trouble specifying dts gpio-leds with GPIO expander chip

Grant Likely grant.likely at
Tue Dec 22 09:32:17 EST 2009

On Mon, Dec 21, 2009 at 12:40 PM, Bill Gatliff <bgat at> wrote:
> Guys:
> I'm trying to come up with the right stuff for my dts file to assign a
> Linux "heartbeat" trigger to an I2C GPIO expansion device (MAX7314).
> I'm running on a platform that is very similar to the lite5200b, with
> linux-2.6.32.  I'm a bit new to the device tree concept, having come
> most recently from an ARM world, so please be gentle...  :)
> I have this so far:
>        soc5200 at f0000000 {
>            #address-cells = <1>;
>            #size-cells = <1>;
>            compatible = "fsl,mpc5200b-immr","simple-bus";
>            ranges = <0 0xf0000000 0x0000c000>;
>            reg = <0xf0000000 0x00000100>;
>            bus-frequency = <0>;        // from bootloader
>            system-frequency = <0>;        // from bootloader
>    ...
>            i2c at 3d40 {
>                #address-cells = <1>;
>                #size-cells = <0>;
>                compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
>                reg = <0x3d40 0x40>;
>                interrupts = <2 16 0>;
>                lext20: max7314 at 20 {
>                       #gpio-cells = <2>;
>                       compatible = "maxim,max7314","phillips,pca953x";
>                       reg = <0x20>;
>                       linux,phandle = <0x20>;

Drop the linux,phandle.  The phandle property is generated
automatically by the device tree compiler.  This could mess things up.

As Anton says, the 7314 driver doesn't register the GPIO in a way that
the of_gpio layer understands, so cannot translate.  What the of_gpio
infrastructure *should* be doing is to fetch the device tree node out
of the struct device and use that path to translate device tree GPIO
references to Linux GPIO numbers.  ie.
dev_archdata_get_node(gc->dev->archdata).  Then as long as the device
tree node pointer is set in the struct device (which it always should
be), then OF translations for GPIO numbers should work without driver

In other words; given a device tree node pointer; loop over all the
registered GPIO devices and look for a matching node pointer in the
struct device.  When a matching one is found; do the translation.
However, on further thought, this may require an additional hook added
to the gpio_chip registration to override the translation function if

Anton, what are you thinking about to simplify OF GPIO registrations?

Bill, in the mean time you could do as Anton suggests and modify the
GPIO driver to have an of_gpio_chip allocation.


Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

More information about the Linuxppc-dev mailing list