pin controller
pin controller 是用来设置引脚上下拉、三态、驱动强度、复用功能的,作为一个设备树节点,如 testgrp
iomuxc: pinctrl@20e0000 { compatible = "fsl,imx6ul-iomuxc"; reg = <0x020e0000 0x4000>; }; &iomuxc { pinctrl_test: testgrp { fsl,pins = < MX6UL_PAD_GPIO1_IO00__GPIO1_IO00 config /*config 是具体设置值*/ >; };
pinctrl作为一个设备节点,必然一个驱动程序以之对应,在linux kernel中搜索 "fsl,imx6ul-iomuxc" 即可
参考文档:
Documentation\devicetree\bindings\pinctrl\fsl,imx-pinctrl.txt
Documentation\devicetree\bindings\pinctrl\fsl,imx6ul-pinctrl.txt
gpio controller
gpio1: gpio@73f84000 { compatible = "fsl,imx35-gpio"; reg = <0x73f84000 0x4000>; interrupts = <50 51>; gpio-controller; #gpio-cells = <2>; interrupt-controller; #interrupt-cells = <2>; };
gipo作为一个设备节点,必然有一个驱动程序以之对应,在linux kernel 中搜索 "fsl,imx35-gpio" 即可
#gpio-cells = <2>:引用 gpio controller 的语句称为 gpio-specifier,比如 "led-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>",#gpio-cells是用来指示 gpio-specifier 带几个参数的,此处 2 对应的参数是 3 和 GPIO_ACTIVE_LOW。
参考文档:
Documentation\devicetree\bindings\gpio\gpio.txt
Documentation\devicetree\bindings\gpio\fsl-imx-gpio.yaml
client device
如果某个设备节点需要设置 pin,此设备节点称为 client device。
client device 设置 pin 的方法为引用 pin controller
gpioled { #address-cells = <1>; #size-cells = <1>; compatible = "atkalpha-gpioled"; pinctrl-0 = <&pinctrl_led>; led-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>; status = "okay"; };
参考文档:
Documentation\devicetree\bindings\pinctrl\pinctrl-bindings.txt
以上的节点属性,只有 led-gpio 是自定义的,在 gpioled 的驱动程序中,我们就可以指定节点属性 led-gpio,从而获得此 gpio 的编号,最后控制此 gpio 的电平。
标签:cells,fsl,pinctrl,controller,GPIO,gpio,bindings,子系统 From: https://www.cnblogs.com/god-of-death/p/17114144.html