Using gpio from device tree on platform devices.

Daniel. danielhilst at gmail.com
Thu Aug 20 16:53:27 EDT 2015


Hi all,

I'm trying to migrate a driver from board files to device tree. I've
added the gpios to device tree. My device is loaded automatically,
this is nice, but I'm facing problems while getting gpio from device
tree using of_get_property().


Here is the device tree node:
        powerfailure {
                compatible = "powerfailure";
                poff_pfail  = <&gpio5 12 GPIO_ACTIVE_LOW>;
                irq_pfail   = <&gpio5 17 GPIO_ACTIVE_LOW>;
        };


Here is my driver: http://pastebin.com/4DsRaXMS

A simple description of it. There is a circuit that triggers the
irq_pfail at failure of power supply. The irq handler then start a
clean shutdown. At the end of shutdown pf_power_off to cut the energy
from the device. The logic works fine, but I'm having problems on
pf_probe function. I got this dump:
http://pastebin.com/paTBWwcE

So I think I'm doing something wrong with of_get_property returned
value. I'm using the kernel 3.14.28 from freescale (iMX6 quad core
cpu).

What is the right way to get gpio values from device tree? Is that
of_get_property() lines right?

Thanks in advance,
Cheers

-- dhs


-- 
"Do or do not. There is no try"
  Yoda Master



More information about the Kernelnewbies mailing list