Configuring eCSPI2 as SPI Slave on i.MX8MP

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Configuring eCSPI2 as SPI Slave on i.MX8MP

跳至解决方案
885 次查看
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 项奖励
回复
1 解答
874 次查看
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 项奖励
回复
3 回复数
875 次查看
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 项奖励
回复
814 次查看
yaen
Contributor I

Thanks @Chavira 

This is a very useful document.

Do you have one for iMX93 (lpspi)?

0 项奖励
回复
780 次查看
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 项奖励
回复