I was looking to modify my GPIO driver for raspberry pi using device tree support. First there were 2 files:
- I read the device tree file in /arc/arm/boot/dts/bcm2835.dts
and for gpio following section was present:
gpio: gpio {
compatible = "brcm,bcm2835-gpio"; reg = <0x7e200000 0xb4>; /* * The GPIO IP block is designed for 3 banks of GPIOs. * Each bank has a GPIO interrupt for itself. * There is an overall "any bank" interrupt. * In order, these are GIC interrupts 17, 18, 19, 20. * Since the BCM2835 only has 2 banks, the 2nd bank * interrupt output appears to be mirrored onto the * 3rd bank's interrupt signal. * So, a bank0 interrupt shows up on 17, 20, and * a bank1 interrupt shows up on 18, 19, 20! */ interrupts = <2 17>, <2 18>, <2 19>, <2 20>; gpio-controller; #gpio-cells = <2>; interrupt-controller; #interrupt-cells = <2>; };
From the references on the internet The reg = 0x7e200000 is understood but What is 0xb4.
- I read the device tree file in /arch/arm/boot/dts/bcm2835-rpi-b.dts
and for gpio following section was present:
/ {
compatible = "raspberrypi,model-b", "brcm,bcm2835";
model = "Raspberry Pi Model B";
memory {
reg = <0 0x10000000>;
};
leds {
compatible = "gpio-leds";
act {
label = "ACT";
gpios = <&gpio 16 1>;
default-state = "keep";
linux,default-trigger = "heartbeat";
};
};
};
&gpio {
pinctrl-names = "default";
pinctrl-0 = <&alt0 &alt3>;
alt0: alt0 {
brcm,pins = <0 1 2 3 4 5 6 7 8 9 10 11 14 15 40 45>;
brcm,function = <4>; /* alt0 */
};
alt3: alt3 {
brcm,pins = <48 49 50 51 52 53>;
brcm,function = <7>; /* alt3 */
};
};
So, Which one of the dts files should I use, and how to read and interpret those key value pairs, for eg: what is pinctrl. and how does this approach affect on my code.
I know I am asking a lot of stuff here, but this is new and looks interesting and I want to modify my driver using this approach. Please help.
PS: I have made a driver using the standard udev support. So dynamic device node creation is managed. I am not using platform model.