WhyCan Forum

本站无需注册,无需积分,无需回复可下载所有资料,如果真的喜欢小站,请您注册之后请至少回复一个帖子激活Id,谢谢支持! 站长QQ: 516333132 (挖坑网/填坑网) admin@whycan.cn

您尚未登录。

#1 2019-05-09 11:48:56

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 6,937

H5的spi控制器驱动, 可以通过 gpio 控制 spi 片选 (转载)

离线

#2 2019-05-09 11:50:52

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 6,937

Re: H5的spi控制器驱动, 可以通过 gpio 控制 spi 片选 (转载)

在设备树的文件arch/arm64/boot/dts/allwinner/sunxi-h3-h5.dtsi里,厂家已写好两个spi控制器相关的设备节点:

    spi0_pins: spi0 {
        pins = "PC0", "PC1", "PC2", "PC3";
        function = "spi0";
    };

    spi1_pins: spi1 {
        pins = "PA15", "PA16", "PA14", "PA13";
        function = "spi1";
    };


spi0: spi@01c68000 {
    compatible = "allwinner,sun8i-h3-spi";
    reg = <0x01c68000 0x1000>;
    interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
    clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>;
    clock-names = "ahb", "mod";
    dmas = <&dma 23>, <&dma 23>;
    dma-names = "rx", "tx";
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins>;
    resets = <&ccu RST_BUS_SPI0>;
    status = "disabled";
    #address-cells = <1>;
    #size-cells = <0>;
};

spi1: spi@01c69000 {
    compatible = "allwinner,sun8i-h3-spi";
    reg = <0x01c69000 0x1000>;
    interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
    clocks = <&ccu CLK_BUS_SPI1>, <&ccu CLK_SPI1>;
    clock-names = "ahb", "mod";
    dmas = <&dma 24>, <&dma 24>;
    dma-names = "rx", "tx";
    pinctrl-names = "default";
    pinctrl-0 = <&spi1_pins>;
    resets = <&ccu RST_BUS_SPI1>;
    status = "disabled";
    #address-cells = <1>;
    #size-cells = <0>;
};



在板级主要的设备树文件arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts:

&pio {
...
    spi0_cs_pins: spi0_cs_pins {
        pins = "PC3", "PA6";
        function = "gpio_out";
    };
};

&spi0 {
    /* needed to avoid dtc warning */
    #address-cells = <1>;
    #size-cells = <0>;

    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
    cs-gpios = <&pio 2 3 GPIO_ACTIVE_HIGH>, <&pio 0 6 GPIO_ACTIVE_HIGH>;
...

离线

#3 2019-05-09 11:51:52

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 6,937

Re: H5的spi控制器驱动, 可以通过 gpio 控制 spi 片选 (转载)

也就说,理论上V3s也 可以通过配置设备树, 使用 gpio 完成片选, 实现 SPI 复用。

未测试
未测试
未测试

离线

#4 2019-07-09 17:34:38

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 6,937

Re: H5的spi控制器驱动, 可以通过 gpio 控制 spi 片选 (转载)

手动 up,路过有闲钱有闲心的大神可以测试一下

离线

#5 2019-07-12 13:45:35

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 6,937

Re: H5的spi控制器驱动, 可以通过 gpio 控制 spi 片选 (转载)

QQ20190712134352.jpg

QQ20190712134356.png


感谢QQ群的 @龙涎香 网友, ta 在 2019/07/09 18:27:40

验证过了,是可以的,多路复用.

离线

页脚