Hi ,
I am currently working on the i.MX8QM MEK with Yocto kernel version 5.15.52. I am attempting to establish communication with an external SD card through the SPI interface. The SD card is connected via a micro-SD card (SPI) adapter to the SPI ports available on the Microbus headers (J29) on the baseboard.
To utilize the mmc-spi driver instead of spidev, I have modified the lpspi2 device node in the imx8qm-mek.dts file as follows:
&lpspi2 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpspi2 &pinctrl_lpspi2_cs>;
cs-gpios = <&lsio_gpio3 10 GPIO_ACTIVE_LOW>;
status = "okay";
mmc-slot@0 {
compatible = "fsl,mpc8323rdb-mmc-slot", "mmc-spi-slot";
reg = <0>;
voltage-ranges = <3300 3300>;
spi-max-frequency = <30000000>;
};
};
The issue I am facing is that the obtained OCR (Operating Condition Register) value is 0x00, which appears to be invalid. Consequently, the initialization of the SD card fails, and it does not proceed to the block driver stage (i.e., no block device is formed).
Has anyone encountered a similar issue? I would greatly appreciate any insights or solutions to resolve this problem.
Thanks and Regards ,
Sujith Sajeev
Hello @sujith_sajeev
Could you please share the pinctrl of your device tree?
Also, could you please confirm that the SD works with spidev?
Best regards,
--... ...--
Salas.
Hi @Manuel_Salas
Can you please provide your suggestions on this matter ?
Also , I tried to communicate with the SD using the sd-spi-communication library (using spidev driver). It was also unsuccessful since the initialization of SD card failed. It was seen that an undersized response was received for CMD0 during initialization (0x00 was received instead of 0x01). The github link of sd-spi-communication library is https://github.com/wpenson/sd-spi-communications-library.git
Please provide your suggestions on this matter. Your insight on this matter would be really helpful
Thanks and Regards
Sujith Sajeev
Hello @sujith_sajeev
I hope you are doing well.
I have not a i.MX8QM to test by my side, but I tested with other i.MX with the same environment as you and I could integrate the mmc-spi driver without any issue.
Could you please share the logs related to the mmc spi driver on linux?
Also, about of sd-spi-communication library, I am not sure if it is totally compatible with an SD, because some commands differs a little from commands that you can find on reference manual.
Best regards,
Salas.
Hi @Manuel_Salas ,
Thank you for your response.
I have successfully integrated the mmc_spi driver into my Yocto build (kernel version 5.15.52) without encountering any errors. I have also modified the lpspi2 node in the imx8qm-mek.dts file to use the mmc_spi driver instead of the spidev driver. This modification was made to facilitate communication with an SD card using a SPI interface SD card adapter module connected to the SPI ports (pins 3-8) on the J29 Mikrobus headers of the Baseboard. The edited lpspi2 node is as follows:
&lpspi2 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpspi2 &pinctrl_lpspi2_cs>;
cs-gpios = <&lsio_gpio3 10 GPIO_ACTIVE_LOW>;
status = "okay";
mmc-slot@0 {
compatible = "fsl,mpc8323rdb-mmc-slot", "mmc-spi-slot";
reg = <0>;
voltage-ranges = <3300 3300>;
spi-max-frequency = <30000000>;
};
};
The driver initialization appears to be successful, as evidenced by the following output:
root@imx8qmmek:/sys/bus/spi/devices/spi0.0# cat modalias
spi:mpc8323rdb-mmc-slot
root@imx8qmmek:/sys/bus/spi/devices/spi0.0# cat uevent
DRIVER=mmc_spi
OF_NAME=mmc-slot
OF_FULLNAME=/bus@5a000000/spi@5a020000/mmc-slot@0
OF_COMPATIBLE_0=fsl,mpc8323rdb-mmc-slot
OF_COMPATIBLE_1=mmc-spi-slot
OF_COMPATIBLE_N=2
MODALIAS=spi:mpc8323rdb-mmc-slot
However, the block device for the SD card is not created, which prevents me from communicating with the SD card. Given that the driver is operational but the block device is not being created, I am seeking your advice on potential resolutions for this issue.
For additional context, here is the output from mmc3:
root@imx8qmmek:/sys/kernel/debug/mmc3# cat ios
clock: 0 Hz
vdd: 0 (invalid)
bus mode: 2 (push-pull)
chip select: 1 (active high)
power mode: 0 (off)
bus width: 0 (1 bits)
timing spec: 0 (legacy)
signal voltage: 0 (3.30 V)
driver type: 0 (driver type B)
Your insights on this matter would be greatly appreciated.
Thank you and regards,
Sujith Sajeev