转自:https://bbs.alpha-star.org/%E8%B ... -%E8%AE%BE%E7%BD%AE
在编写设备驱动中,我们经常会遇到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子系统,代码架构后续再更新,先解决下上面看到的疑惑呀。 - <p style="line-height: 18px;">gpio27: gpio@fff10000 {</p><p style="line-height: 18px;">compatible = "arm,pl061", "arm,primecell", "arm,primecell27";</p><p style="line-height: 18px;">reg = <0 0xfff10000 0 0x1000>;</p><p style="line-height: 18px;">interrupts = <0 111 0x4>;</p><p style="line-height: 18px;">gpio-controller;</p><p style="line-height: 18px;">#gpio-cells = <2>;</p><p style="line-height: 18px;">/* GPIO216 */</p><p style="line-height: 18px;">gpio-ranges = <&pmx4 0 36 6>;</p><p style="line-height: 18px;">interrupt-controller;</p><p style="line-height: 18px;">#interrupt-cells = <2>;</p><p style="line-height: 18px;">clocks = <&sctrl HI3660_PCLK_AO_GPIO5>;</p><p style="line-height: 18px;">clock-names = "apb_pclk";</p><p style="line-height: 18px;">status = "ok";</p><p style="line-height: 18px;">};</p>
复制代码218在上述gpio27这个分组里面,看来gpiochip288 对应gpio@fff10000 控制器。在我验证后,得出结论,给出如下对应表格: |