第十四章 SPI的配置

从数据手册中可以了解到,SSD20X有2个SPI接口,一个已经用于SPIFlash,因此供开发者使用的只有一个SPI接口。

如果需要开启SPI接口,则需要将DTS中的status改为ok:

# vi  arch/arm/boot/dts/infinity2m.dtsi
spinandflash {
            compatible = "ms-spinand";
            clocks =<&CLK_bdma>;
            status = "ok";
        };

        spi: spi {
            compatible = "sstar_spi";
            io_phy_addr = <0x1f000000>;
            banks = <0x1110>,<0x1111>,<0x1038>,<0x101E>,<0x100B>;
            clocks = <&CLK_mspi0>;
            interrupts = <GIC_SPI INT_IRQ_MSPI_0 IRQ_TYPE_LEVEL_HIGH>;
            /*
             * padmux:
             * mode=1: PAD_PM_SD_CDZ,PAD_SD_D1,PAD_SD_D0,PAD_SD_CLK,PAD_SD_CMD
             * mode=2: PAD_TTL16,PAD_TTL17,PAD_TTL18,PAD_TTL19
             * mode=3: PAD_GPIO4,PAD_GPIO5,PAD_GPIO6,PAD_GPIO7
             * mode=4: PAD_FUART_RX,PAD_FUART_TX,PAD_FUART_CTS,PAD_FUART_RTS
             * mode=5: PAD_GPIO8,PAD_GPIO9,PAD_GPIO10,PAD_GPIO11
             * mode=6: PAD_GPIO0,PAD_GPIO1,PAD_GPIO2,PAD_GPIO3
             */
            dma = <1>;
            spi0_mode = <2>;
            status = "ok";
                spidev: spidev0 {
                compatible = "rohm,dh2228fv";
                reg = <0>;
                status = "ok";
               };
        };

接着将对应的引脚配置为SPI_MODE:

# vi  arch/arm/boot/dts/infinity2m-ssc011a-s01a-padmux-display.dtsi
<PAD_GPIO8              PINMUX_FOR_SPI0_MODE_5   MDRV_PUSE_SPI0_CZ>,
<PAD_GPIO9              PINMUX_FOR_SPI0_MODE_5   MDRV_PUSE_SPI0_CK >,
<PAD_GPIO10             PINMUX_FOR_SPI0_MODE_5   MDRV_PUSE_SPI0_DI >,
<PAD_GPIO11             PINMUX_FOR_SPI0_MODE_5   MDRV_PUSE_SPI0_DO >,

这里由于默认已经设置为SPI_MODE,因此只需要保证不被配置为其他功能即可。最后加载MSPI驱动:

# cd kernel && ARCH=arm make menuconfig

文档更新时间: 2022-04-13 17:22   作者:Aeeditor