在openwrt中已经支持 RT5350 的SPI I2C等驱动。

1 只需要在内核模块选上即可:

make menuconfig

-> Kernel modules
  -> SPI Support
  -> I2C support

根据自己的需求选中模块。

2 修改配置文件

vi target/linux/ramips/dts/rt5350.dtsi

               i2c@900 {
                        compatible = "link,rt5350-i2c", "ralink,rt2880-i2c";
                        reg = <0x900 0x100>;

                        resets = <&rstctrl 16>;
                        reset-names = "i2c";

                        #address-cells = <1>;
                        #size-cells = <0>;

                        pinctrl-names = "default";
                        pinctrl-0 = <&i2c_pins>;

                        status = "disabled";
                };

                spi@b00 {
                        compatible = "ralink,rt5350-spi";
                        reg = <0xb00 0x100>;

                        resets = <&rstctrl 18>;
                        reset-names = "spi";

                        #address-cells = <1>;
                        #size-cells = <1>;

                        pinctrl-names = "default";
                        pinctrl-0 = <&spi_pins &spi_cs1>;

                        status = "disabled";
                };

我们可以看到。配置文件默认是不启用 SPI I2C 的。我们需要把 status = “disabled”; 改为 status = “okay”;

对于 I2C 。我们还要修改这个文件:
vi target/linux/ramips/dts/MPRA2.dts

      pinctrl {
                state_default: pinctrl0 {
                        gpio {
                                ralink,group = "i2c", "jtag", "rgmii", "mdio", "uartf";
                                ralink,function = "gpio";
                        };
                };
        };

可以看到。”i2c”,”jtag”, “rgmii”, “mdio”, “uartf” 等默认都复用为 gpio 口、要启用 I2C,需要去掉 i2c。同样,我们还需要启用 uartf。所有,修改为:

      pinctrl {
                state_default: pinctrl0 {
                        gpio {
                                ralink,group =  "jtag", "rgmii", "mdio";
                                ralink,function = "gpio";
                        };
                };
        };

make V=s

Logo

更多推荐