AnsweredAssumed Answered

IMXRT1050 SPI and Linux Device Tree

Question asked by Bill Elliot on Aug 9, 2019
Latest reply on Aug 13, 2019 by Bill Elliot

Hello,

I am new to the device tree aspect of linux (4.5.0).  We are using an imxrt1050 on a board similar to the IMXRT105X_NXPEVK and trying to add an external RTC via SPI.  My Kinetis experience suggests that there are clock gating registers that need to be set, pin mux modes, chip select identification, etc. that needs to be done. 

- What are the proper device tree entries that need to be added for this part to complete the device tree? 

- What goes in the clock section to get the LPSPI_CLK_ROOT going? Or does the spi-fsl-lpspi driver take care of that?

- What goes in the SOC section (iomuxc? gpio? lpspi?)?

- What about pinctrl for the iomuxc?  How are the chip selects handled versus the SDI, SDO and SCK pins?

- What else am I missing?

 

Here are snippets of the DT as I have it so far:

 

/ {
   model = "NXP IMXRT1050 board";
   compatible = "nxp,imxrt1050-evk", "nxp,imxrt105x";

   (other stuff)

   soc {
      aips0: aips-bus@40000000 {
         compatible = "fsl,aips-bus", "simple-bus";
         #address-cells = <1>;
         size-cells = <1>;
         ranges;

 

     (some gpiox stuff I don't fully understand)

     (other stuff)

 

      lpspi3: lpspi@4039c000 {
         compatible = "fsl,imx7ulp-spi";
         reg = <0x4039c000 0x4000>;
         interrupts = <34>;
         clocks = <&ipg_clk>;
         clock-names = "ipg";
      };

   };

};

 

#define MXRT105X_PAD_CFG_SPI_CS    0xA0B0
#define MXRT105X_PAD_CFG_SPI      0xB0    

 

&iomuxc {

   (other stuff)

   pinctrl_lpspi3_cs: lpspi3_cs_grp {
      fsl,pins = <
         MXRT105X_PAD_AD_B1_12_LPSPI3_PCS0 MXRT105X_PAD_CFG_SPI_CS
      >;
   };

   pinctrl_lpspi3: lpspi3grp {
      fsl,pins = <
         MXRT105X_PAD_AD_B1_13_LPSPI3_SDI MXRT105X_PAD_CFG_SPI
         MXRT105X_PAD_AD_B1_14_LPSPI3_SDO MXRT105X_PAD_CFG_SPI
         MXRT105X_PAD_AD_B1_15_LPSPI3_SCK MXRT105X_PAD_CFG_SPI
      >;
   };

};

 

&lpspi3 {
        fsl,spi-num-chipselects = <1>;
         pinctrl-names = "default";
         pinctrl-0 = <&pinctrl_lpspi3 &pinctrl_lpspi3_cs>;
         status = "okay";
         #address-cells = <1>;
         #size-cells = <0>;
   mcp795: rtc@0 {
      compatible = "maxim,mcp795";
      spi-max-frequency = <500000>;
      #address-cells = <1>;
      #size-cells = <0>;
      reg = <0>;
   };
};

 

The SPI master is found and loaded.  The RTC driver is also found and loaded but the RTC does not yet respond to the SPI requests.  By faking the data returned by the RTC driver, from a system point of view, everything looks correct.  /dev/rtc0 exists it just doesn't talk.  I am in the process of trying to get scope probes on some of the lines to see if they are wiggling but I expect there is more to be done in the device tree than I presently understand.  Any help would be appreciated and hopefully answers here will help many more people climbing the learning curve of the imxrt1050 and linux device trees.

Outcomes