Atlas 200I PRO SPI接口代码适配示例
收藏回复举报
Atlas 200I PRO SPI接口代码适配示例
发表于2026-03-17 11:40:24
0 查看

一.确认可用的外设

cid:link_0

cke_20048.png

参见驱动开发指南中的SPI外设调测章节:cid:link_1

在后文增加全量可用的SPI控制器, 主要增加了SPI0到SPI3的设备树控制器配置。 

二.hi1910p-server-asic-spi.dtsi

    1.适配的源码

    alg_clk: alg_clk {

        compatible = "fixed-clock";

        #clock-cells = <0>;

        clock-frequency = <200000000>;

    };

    spi_0: spi@8B080000{

        compatible = "hisi-spi";

        reg = <0x0 0x8B080000 0 0x10000>;

        interrupts = <0 108 4>;

        clocks = <&alg_clk>;

        clock-names = "spi_clk";

        num-cs = <1>;

        id = <0>;

        status = "ok";

        pinctrl-names = "default";

        pinctrl-0 = <&iomg006_pmx_func &iomg007_pmx_func &iomg008_pmx_func &iomg009_pmx_func>;

    };

    spi_1: spi@8B090000{

        compatible = "hisi-spi";

        reg = <0x0 0x8B090000 0 0x10000>;

        interrupts = <0 109 4>;

        clocks = <&alg_clk>;

        clock-names = "spi_clk";

        num-cs = <1>;

        id = <1>;

        status = "ok";

        pinctrl-names = "default";

        pinctrl-0 = <&iomg010_pmx_func &iomg011_pmx_func &iomg012_pmx_func &iomg013_pmx_func>;

    };

    spi_2: spi@A4480000{

        compatible = "hisi-spi";

        reg = <0x0 0xA4480000 0 0x10000>;

        interrupts = <0 121 4>;

        clocks = <&alg_clk>;

        clock-names = "spi_clk";

        num-cs = <4>;

        id = <2>;

        status = "ok";

        pinctrl-names = "default";

        pinctrl-0 = <&gpio0_pmx_func &gpio1_pmx_func &gpio2_pmx_func

        &gpio3_pmx_func &gpio4_pmx_func &gpio5_pmx_func &gpio6_pmx_func>;

    };

    spi_3: spi@A4490000{

        compatible = "hisi-spi";

        reg = <0x0 0xA4490000 0 0x10000>;

        interrupts = <0 122 4>;

        clocks = <&alg_clk>;

        clock-names = "spi_clk";

        num-cs = <3>;

        id = <3>;

        status = "ok";

        pinctrl-names = "default";

        pinctrl-0 = <&strob10_pmx_func &strob11_pmx_func &strob12_pmx_func

        &strob13_pmx_func &strob14_pmx_func &strob15_pmx_func>;

        cs@0 {

            compatible = "rohm,dh2228fv";

            reg = <0>; /* cs片选id */

            spi-max-frequency = <25000000>;

        };

    };

    spi_5: spi@A44A0000{

        compatible = "spi_slave_mcu";

        reg = <0x0 0xA44A0000 0 0x10000>;

        interrupts = <0 124 4>;

        clocks = <&alg_clk>;

        clock-names = "spi_clk";

        num-cs = <1>;

        id = <5>;

        status = "ok";

        pinctrl-names = "default";

        pinctrl-0 = <&iomg045_pmx_func &iomg046_pmx_func &iomg047_pmx_func

                     &iomg048_pmx_func>;

    };

    spi_6: spi@A44B0000{

        compatible = "hisi-spi";

        reg = <0x0 0xA44B0000 0 0x10000>;

        interrupts = <0 125 4>;

        clocks = <&alg_clk>;

        clock-names = "spi_clk";

        num-cs = <1>;

        id = <6>;

        status = "ok";

        pinctrl-names = "default";

        pinctrl-0 = <&iomg049_pmx_func &iomg050_pmx_func &iomg051_pmx_func

                     &iomg052_pmx_func>;

        spi6_0: spi_smbus@0 {

            compatible = "spi_mcu";

            reg = <0>;

            spi-max-frequency = <1000000>;

            mode = <0>;

        };

    };

    2.适配说明

cke_32235.png

如上图所示,以SPI3进行主要参数说明。

   1>复用

“pinctrl-0”是复用这些这些管脚的地方。用户配置时可参照驱动开发指南SPI的寄存器描述章节,确认其中引用的节点是否被复用成了SPI模式。

此处以SPI3中的“strob10_pmx_func”为例,其引用的地方为:

cke_46627.png

与开发指南中的寄存器描述章节说明一致:

cke_62614.png

    2>配置片选与从机

其中的片选引脚数量“num-cs”,用户可根据实际情况设置。

“cs@0”则是用户需要自己配置的设备,用户可参照SPI3下挂的设备格式、或网上通用配置进行适配。

我要发帖子