Configuring eCSPI2 as SPI Slave on i.MX8MP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuring eCSPI2 as SPI Slave on i.MX8MP

Jump to solution
425 Views
yaen
Contributor I

Dear NXP,

I'm working on a project that requires the use of the eCSPI2 interface on the IMX8MPLUS processor in SPI slave mode

I've been able to successfully configure and test the eCSPI2 in SPI master mode using spidev_test but I'm facing some challenges getting it to work in SPI slave mode

When I try to communicate with the eCSPI2 in slave mode from another IMX8MPLUS acting as the SPI master, I'm not able to receive any data on the slave side

Could you please provide a working example or guidance on how to correctly configure the eCSPI2 to operate in SPI slave mode?

I'd also appreciate if you could share any tips on how to properly read the RX buffer of the eCSPI2 slave interface.

DT snippet:

&ecspi2 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;
cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>;
status = "okay";
fsl,spi-only-use-cs1-sel;
spi-slave;
spidev1: slave@0 {
reg = <0>;
compatible = "rohm,dh2228fv";
spi-max-frequency = <500000>;
status = "okay";
};
};

pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK 0x82
MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI 0x82
MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO 0x82
MX8MP_IOMUXC_ECSPI2_SS0__ECSPI2_SS0 0x82
>;
};

pinctrl_ecspi2_cs: ecspi2cs {
fsl,pins = <
MX8MP_IOMUXC_ECSPI2_SS0__GPIO5_IO13 0x40000
>;
};

Any assistance you can provide would be greatly appreciated. Please let me know if you need any additional information from me.

Thank you,

Yaakov

0 Kudos
1 Solution
414 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @yaen!

I think the correct configuration for that is the next:

 

 

&ecspi2 {


    #address-cells = <1>;


    #size-cells = <0>;


    pinctrl-names = "default", "sleep";


    pinctrl-0 = <&pinctrl_ecspi2>;


    pinctrl-1 = <&pinctrl_ecspi2>;


    spi-slave;




    spidev1: slave@0 {


        reg = <0>;


        compatible = "rohm,dh2228fv";


        spi-max-frequency = <500000>;


        status = "okay";


    };


};




pinctrl_ecspi2: ecspi2grp {


    fsl,pins = <


        MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK 0x82


        MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI 0x82


        MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO 0x82


        MX8MP_IOMUXC_ECSPI2_SS0__ECSPI2_SS0 0x82


    >;


};

 

If you have more inquiries about the usage of the epi in slave mode you can refer to our next application note:

https://www.nxp.com/docs/en/application-note/AN13633.pdf

 

Best Regards!

Chavira

 

View solution in original post

0 Kudos
3 Replies
415 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @yaen!

I think the correct configuration for that is the next:

 

 

&ecspi2 {


    #address-cells = <1>;


    #size-cells = <0>;


    pinctrl-names = "default", "sleep";


    pinctrl-0 = <&pinctrl_ecspi2>;


    pinctrl-1 = <&pinctrl_ecspi2>;


    spi-slave;




    spidev1: slave@0 {


        reg = <0>;


        compatible = "rohm,dh2228fv";


        spi-max-frequency = <500000>;


        status = "okay";


    };


};




pinctrl_ecspi2: ecspi2grp {


    fsl,pins = <


        MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK 0x82


        MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI 0x82


        MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO 0x82


        MX8MP_IOMUXC_ECSPI2_SS0__ECSPI2_SS0 0x82


    >;


};

 

If you have more inquiries about the usage of the epi in slave mode you can refer to our next application note:

https://www.nxp.com/docs/en/application-note/AN13633.pdf

 

Best Regards!

Chavira

 

0 Kudos
354 Views
yaen
Contributor I

Thanks @Chavira 

This is a very useful document.

Do you have one for iMX93 (lpspi)?

0 Kudos
320 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @yaen!

I haven't found any documentation for iMX93 of how to do that like iMX8, but we have a device tree configuring the SPI bus in slave mode.

https://github.com/nxp-imx/linux-imx/blob/lf-6.1.y/arch/arm64/boot/dts/freescale/imx93-11x11-evk-lps...

Sorry for the mistake!

Best Regards!
Chavira

0 Kudos