第十五章 I2C的配置

SSD20X提供2组硬件的I2C,根据 SSD201 HW Checklist V6.xlsx[GPIOList] 一表,我们可以看出I2C0和I2C1可以复用哪些引脚:

总结得出下表数据:

首先配置DTS的i2c节点:

 vi arch/arm/boot/dts/infinity2m-ssc011a-s01a-display.dtsi
        i2c0@0{
            compatible = "sstar,i2c";
            reg = <0x1F223000 0x200>,<0x1F203c00 0x200>,<0x1F207000 0x200>;
                #address-cells = <1>;
                #size-cells = <0>;
            clocks = <&CLK_miic0>;
            i2c-group = <0>;
            /*
             * padmux: 1 -> PAD_HDMITX_SCL, PAD_HDMITX_SDA
             *         2 -> PAD_TTL1, PAD_TTL2
             *         3 -> PAD_TTL14, PAD_TTL15
             *         4 -> PAD_GPIO6, PAD_GPIO7
            */
            i2c-padmux = <4>;
           /*
              *  speed: 0 -> HWI2C_HIGH(high speed: 400 KHz)
              *         1 -> HWI2C_NORMAL(normal speed: 300 KHz)
              *         2 -> HWI2C_SLOW(slow speed: 200 KHz)
              *         3 -> HWI2C_VSLOW(very slow: 100 KHz)
              *         4 -> HWI2C_USLOW(ultra slow: 50 KHz)
              *         5 -> HWI2C_UVSLOW(ultra-very slow: 25 KHz)
              */
            i2c-speed = <3>;
            i2c-en-dma = <0>;  // 0: disable; 1: enable;
            status = "ok";
        };

需要关注使用的是哪一组GPIO,并赋值i2c-padmux。然后设置该组GPIO的复用mode:

vi infinity2m-ssc011a-s01a-padmux-display.dtsi
    <PAD_GPIO6          PINMUX_FOR_I2C0_MODE_4      MDRV_PUSE_I2C0_SCL >,
    <PAD_GPIO7          PINMUX_FOR_I2C0_MODE_4      MDRV_PUSE_I2C0_SDA >,

开启 i2c 配置

make menuconfig 

Device Drivers —>
[*] SStar SoC platform drivers —>

同步一下config配置

cp config arch/arm/configs/infinity2m_spinand_ssc011a_s01a_minigui_defconfig

重新编译,再升级。
系统起来后,可以看到/dev/i2c-0,说明驱动加载成功。

文档更新时间: 2022-08-01 10:29   作者:Aeeditor