我正在寻找使用设备树支持修改树莓派的 GPIO 驱动程序。首先有2个文件:
- 我在 /arc/arm/boot/dts/bcm2835.dts 中读取了设备树文件
对于 gpio,存在以下部分:
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>; };
从互联网上的参考资料 reg = 0x7e200000 可以理解,但是 0xb4 是什么。
- 我在 /arch/arm/boot/dts/bcm2835-rpi-b.dts 中读取了设备树文件
对于 gpio,存在以下部分:
/ {
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 */
};
};
那么,我应该使用哪个 dts 文件,以及如何读取和解释这些键值对,例如:什么是 pinctrl。以及这种方法如何影响我的代码。
我知道我在这里问了很多东西,但这是新的并且看起来很有趣,我想使用这种方法修改我的驱动程序。请帮忙。
PS:我已经使用标准的udev支持制作了一个驱动程序。所以动态设备节点的创建是被管理的。我没有使用平台模型。