Hello gaobo,
See below steps, please!
---------------------------------------
1. Remove these pins related to ECSPI2
pinctrl_pcie1: pcie1grp {
fsl,pins = <
MX8MQ_IOMUXC_I2C4_SDA_PCIE2_CLKREQ_B 0x76 /* open drain, pull up */
MX8MQ_IOMUXC_ECSPI2_SCLK_GPIO5_IO10 0x16
MX8MQ_IOMUXC_ECSPI2_MISO_GPIO5_IO12 0x16
>;
};
By default, on i.mx8mq-evk, above 2 pins are multiplexed as GPIO, both for PCIe port, so you should remove them, and then assign other 2 GPIOs for PCIe port if you also want to use PCIe.
2. Referring to eCSPI code in imx8mn-evk.dts, add ecspi of i.MX8MQ to your board dts.
Below is from imx8mn-evk.dts
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
>;
};
Change related pins to those of i.MX8MQ's, please! then add code to your dts for i.MX8MQ.
3. Adding eCPSI node like below.
Below is from imx8mn-evk.dts:
&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";
/* code below is determined by what device is connected to eCSPI, change it to yours */
spidev0: spi@0 {
reg = <0>;
compatible = "rohm,dh2228fv";
spi-max-frequency = <500000>;
};
};
-------------------------------------------------------
OK, above 3 steps are enough for using ecspi.
Hope these steps are helpful for you!
Have a nice day!
B.R,
Weidong