这是 dts 文件中的一个示例
led-s0-green {
label = "s0:green";
gpios = <&sgpio_out 2 1 GPIO_ACTIVE_LOW>;
default-state = "off";
};
led-s1-blue {
label = "s1:blue";
gpios = <&sgpio_out 3 0 GPIO_ACTIVE_LOW>;
default-state = "off";
};
led-s1-green {
label = "s1:green";
gpios = <&sgpio_out 3 1 GPIO_ACTIVE_LOW>;
default-state = "off";
};
谁能告诉我
<&sgpio_out 2 0 GPIO_ACTIVE_LOW>
中的2和0是什么意思?我找不到任何信息。谢谢你。
我搜遍了网站,没有相关文件。
谁能告诉我
中的2和0是什么意思?<&sgpio_out 2 0 GPIO_ACTIVE_LOW>
属性的数据格式应该记录在内核源代码中Documentation/devicetree/bindings/的绑定文档中。正如gpio/gpio.txt中所写:
The exact meaning of each specifier cell is controller specific, and must be documented
in the device tree binding for the device.
在本例中,“设备”是由标签
sgpio_out
标识的 GPIO 控制器,该标签在包含的文件 lan966x.dtsi: 中定义
sgpio: gpio@e2004190 {
compatible = "microchip,sparx5-sgpio";
...
sgpio_out: gpio@1 {
compatible = "microchip,sparx5-sgpio-bank";
reg = <1>;
gpio-controller;
#gpio-cells = <3>;
};
...
};
此设备的绑定文档(由其
compatible
属性标识)显然是 Documentation/devicetree/bindings/pinctrl/microchip,sparx5-sgpio.yaml,并且似乎包含您问题的答案:
Note that the SGIO pin is defined by *2* numbers,
a port number between 0 and 31,
and a **bit index**, 0 to 3.