How to enable ECSPI2 on iMX8MN-EVK

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

How to enable ECSPI2 on iMX8MN-EVK

How to enable ECSPI2 on iMX8MN-EVK

Sometimes we need to use an SPI bus to communicate with sensors or another device.


Unfortunately, by default on iMX8MN-EVK, we have the ECSPI2 disabled on our BSP.

 

We can use that peripheral on Linux enabling it in the device tree.

 

To enable the ECSPI2 on the device tree we have to add the next on imx8mn-evk.dtsi:

 

 

  status = "okay";

 };

 

+&ecspi2 {

+ #address-cells = <1>;

+ #size-cells = <0>;

+ fsl,spi-num-chipselects = <1>;

+ pinctrl-names = "default";

+ pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;

+ cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>;

+ status = "okay";

+

+ spidev0: spi@0 {

+ reg = <0>;

+ compatible = "rohm,dh2228fv";

+ spi-max-frequency = <500000>;

+ };

+};

+

 &fec1 {

  pinctrl-names = "default";

  pinctrl-0 = <&pinctrl_fec1>;

 

On iomux node:

 

 

+ pinctrl_ecspi2: ecspi2grp {

+ fsl,pins = <

+ MX8MN_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0x82

+ MX8MN_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI 0x82

+ MX8MN_IOMUXC_ECSPI2_MISO_ECSPI2_MISO 0x82

+ >;

+ };

+

+ pinctrl_ecspi2_cs: ecspi2cs {

+ fsl,pins = <

+ MX8MN_IOMUXC_ECSPI2_SS0_GPIO5_IO13 0x40000

+ >;

+ };

+

  pinctrl_ir_recv: ir-recv {

    fsl,pins = <

      MX8MN_IOMUXC_GPIO1_IO13_GPIO1_IO13 0x4f

 

 after modifying and compiling the device tree you can see the device active like this:

 

Chavira_0-1708970246353.png

 

Connection:

Chavira_1-1708970679367.png

 

Test:

spidev_test -D /dev/spidev1.0 -v
Chavira_0-1708978109966.png

 

 

 

You can use the devsheell of yocto to make the changes:

 

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/How-to-use-Devshell-to-compile-device-tr...

Attachments
%3CLINGO-SUB%20id%3D%22lingo-sub-1815850%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHow%20to%20enable%20ECSPI2%20on%20iMX8MN-EVK%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1815850%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ESometimes%20we%20need%20to%20use%20an%20SPI%20bus%20to%20communicate%20with%20sensors%20or%20another%20device.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%3CBR%20%2F%3EUnfortunately%2C%20by%20default%20on%20iMX8MN-EVK%2C%20we%20have%20the%20ECSPI2%20disabled%20on%20our%20BSP.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EWe%20can%20use%20that%20peripheral%20on%20Linux%20enabling%20it%20in%20the%20device%20tree.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ETo%20enable%20the%20ECSPI2%20on%20the%20device%20tree%20we%20have%20to%20add%20the%20next%20on%20imx8mn-evk.dtsi%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20status%20%3D%20%22okay%22%3B%0A%0A%20%7D%3B%0A%0A%20%0A%0A%2B%26amp%3Becspi2%20%7B%0A%0A%2B%20%23address-cells%20%3D%20%26lt%3B1%26gt%3B%3B%0A%0A%2B%20%23size-cells%20%3D%20%26lt%3B0%26gt%3B%3B%0A%0A%2B%20fsl%2Cspi-num-chipselects%20%3D%20%26lt%3B1%26gt%3B%3B%0A%0A%2B%20pinctrl-names%20%3D%20%22default%22%3B%0A%0A%2B%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinctrl_ecspi2%20%26amp%3Bpinctrl_ecspi2_cs%26gt%3B%3B%0A%0A%2B%20cs-gpios%20%3D%20%26lt%3B%26amp%3Bgpio5%2013%20GPIO_ACTIVE_LOW%26gt%3B%3B%0A%0A%2B%20status%20%3D%20%22okay%22%3B%0A%0A%2B%0A%0A%2B%20spidev0%3A%20spi%400%20%7B%0A%0A%2B%20reg%20%3D%20%26lt%3B0%26gt%3B%3B%0A%0A%2B%20compatible%20%3D%20%22rohm%2Cdh2228fv%22%3B%0A%0A%2B%20spi-max-frequency%20%3D%20%26lt%3B500000%26gt%3B%3B%0A%0A%2B%20%7D%3B%0A%0A%2B%7D%3B%0A%0A%2B%0A%0A%20%26amp%3Bfec1%20%7B%0A%0A%20%20pinctrl-names%20%3D%20%22default%22%3B%0A%0A%20%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinctrl_fec1%26gt%3B%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EOn%20iomux%20node%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%0A%0A%2B%20pinctrl_ecspi2%3A%20ecspi2grp%20%7B%0A%0A%2B%20fsl%2Cpins%20%3D%20%26lt%3B%0A%0A%2B%20MX8MN_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK%200x82%0A%0A%2B%20MX8MN_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI%200x82%0A%0A%2B%20MX8MN_IOMUXC_ECSPI2_MISO_ECSPI2_MISO%200x82%0A%0A%2B%20%26gt%3B%3B%0A%0A%2B%20%7D%3B%0A%0A%2B%0A%0A%2B%20pinctrl_ecspi2_cs%3A%20ecspi2cs%20%7B%0A%0A%2B%20fsl%2Cpins%20%3D%20%26lt%3B%0A%0A%2B%20MX8MN_IOMUXC_ECSPI2_SS0_GPIO5_IO13%200x40000%0A%0A%2B%20%26gt%3B%3B%0A%0A%2B%20%7D%3B%0A%0A%2B%0A%0A%20%20pinctrl_ir_recv%3A%20ir-recv%20%7B%0A%0A%20%20%20%20fsl%2Cpins%20%3D%20%26lt%3B%0A%0A%20%20%20%20%20%20MX8MN_IOMUXC_GPIO1_IO13_GPIO1_IO13%200x4f%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3Bafter%20modifying%20and%20compiling%20the%20device%20tree%20you%20can%20see%20the%20device%20active%20like%20this%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Chavira_0-1708970246353.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Chavira_0-1708970246353.png%22%20style%3D%22width%3A%20351px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F265115i63F5AEA6D39DFF20%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Chavira_0-1708970246353.png%22%20alt%3D%22Chavira_0-1708970246353.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3EConnection%3A%3C%2FP%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Chavira_1-1708970679367.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Chavira_1-1708970679367.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F265119i4110FB54D498C01F%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Chavira_1-1708970679367.png%22%20alt%3D%22Chavira_1-1708970679367.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3ETest%3A%3C%2FP%3E%0A%3CPRE%3Espidev_test%20-D%20%2Fdev%2Fspidev1.0%20-v%3C%2FPRE%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Chavira_0-1708978109966.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Chavira_0-1708978109966.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F265140i14456151A08CBAD7%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Chavira_0-1708978109966.png%22%20alt%3D%22Chavira_0-1708978109966.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%0A%3CBR%20%2F%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EYou%20can%20use%20the%20devsheell%20of%20yocto%20to%20make%20the%20changes%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%22%3E%3CA%20class%3D%22editor-rtfLink%22%20style%3D%22color%3A%20%230e101a%3B%20background%3A%20transparent%3B%20margin-top%3A%200pt%3B%20margin-bottom%3A%200pt%3B%20%3B%20color%3A%20%234a6ee0%3B%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FHow-to-use-Devshell-to-compile-device-tree-files%2Fta-p%2F1727428%22%20target%3D%22_blank%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FHow-to-use-Devshell-to-compile-device-tree-files%2Fta-p%2F1727428%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1815850%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
No ratings
Version history
Last update:
‎02-27-2024 11:27 AM
Updated by: