在编写设备驱动中,我们经常会遇到GPIO操作,在hikey960 中会有什么不同呢?
我在check spi 控制器代码时有关注SPI_CS信号的获取以及操作,如下代码:
SPI_CS信号是从dts 中 cs_gpios获取的,如下代码:
spi4: spi@fdf06000 {
compatible = "arm,pl022", "arm,primecell";
reg = <0x0 0xfdf06000 0x0 0x1000>;
#address-cells = <1>;
#size-cells = <0>;
interrupts = <0 313 4>;
clocks = <&crg_ctrl HI3660_CLK_GATE_SPI4>;
clock-names = "apb_pclk";
pinctrl-names = "default";
pinctrl-0 = <&spi4_pmx_func &spi4_cfg_func>;
num-cs = <1>;
cs-gpios = <&gpio27 2 0>; /*cs : 218*/
//status = "disabled";
status = "ok";
};
cs_gpios 对应的gpio 编号为218。然而,我们从dts上面获取的cs_gpio = 290,很诡异呀。
所以就催生了我研究hikey960 gpio子系统,代码架构后续再更新,先解决下上面看到的疑惑呀。
gpio27: gpio@fff10000 {
compatible = "arm,pl061", "arm,primecell", "arm,primecell27";
reg = <0 0xfff10000 0 0x1000>;
interrupts = <0 111 0x4>;
gpio-controller;
#gpio-cells = <2>;
/* GPIO216 */
gpio-ranges = <&pmx4 0 36 6>;
interrupt-controller;
#interrupt-cells = <2>;
clocks = <&sctrl HI3660_PCLK_AO_GPIO5>;
clock-names = "apb_pclk";
status = "ok";
};
218在上述gpio27这个分组里面,看来gpiochip288 对应gpio@fff10000 控制器。在我验证后,得出结论,给出如下对应表格:
Working