通过使用 Linux GPIO 子系统操作 8 位移位寄存器来控制 SPI 输入

问题描述 投票:0回答:0

我正在研究 74hc595 设备,它是我基于 iMX8MP 的定制板上的一个 8 位移位寄存器。实际上有 16 个移位寄存器是菊花链式的。在输入中,我有

MOSI
的 spi。有一个支持此设备的内核驱动程序
drivers/gpio/gpio-74x164.c
。我设法创建了一个设备树节点:

&ecspi2 {
#address-cells = <1>;                                                                      
#size-cells = <0>;
fsl,spi-num-chipselects = <2>;                                                             
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;
cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW &gpio2 0 GPIO_ACTIVE_LOW>;                           
status = "okay";

  first_dummy_node@0{

  };

    74hc595@1 {
        compatible = "fairchild,74hc595";
        gpio-controller;
        #gpio-cells = <2>;
        reg = <1>;
        registers-number = <16>;
        enable-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
        spi-max-frequency = <100000>;
    };
};

我的驱动程序被探测到,在我的

/sys/devices/platform/soc@0/30800000.bus/30830000.spi/spi_master/spi0/spi0.1/gpio/gpiochip368
目录下,我有一个名为
ngpio
的文件,用于“number gpio”,其中包含值
128
,这看起来很公平(8 位 * 16)。

现在我想知道是否可以直接设置 GPIO 的值。例如

echo 1 > gpio368
并输入正确的
MOSI
信号?

linux-kernel linux-device-driver embedded-linux gpio spi
© www.soinside.com 2019 - 2024. All rights reserved.