Kernel support for SD Card over SPI on iMX7?

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

Kernel support for SD Card over SPI on iMX7?

跳至解决方案
3,183 次查看
adriansapio
Contributor II

I'm trying to add an SD card over SPI (ecspi2) on the iMX7 Solo. I would use an SDIO port but its not an option on my hardware (custom board). I'm using Yocto and Linux 4.1.

I have added the following to my .dts, but I don't see any new block device show up in lsblk or any new partition in /proc/partitions, or any prints related to this show up in /var/log/messages.

&ecspi2 {
   status = "okay";
   sdcard: mmc-slot@0 {
      #address-cells = <1>;
      #size-cells = <1>;
      compatible = "mmc-spi-slot";
      reg = <0>;
      spi-max-frequency = <5000000>;
      voltage-ranges = <3200 3400>;
      disable-wp;
      disable-cd;
   };
};

pinctrl_ecspi2: ecspi2grp {
   fsl,pins = <
      MX7D_PAD_ECSPI2_MISO__ECSPI2_MISO 0x00000014
      MX7D_PAD_ECSPI2_MOSI__ECSPI2_MOSI 0x00000014
      MX7D_PAD_ECSPI2_SCLK__ECSPI2_SCLK 0x00000014
      MX7D_PAD_ECSPI2_SS0__ECSPI2_SS0 0x00000014
   >;
};

My theory now is that the MMC_SPI kernel driver (which has "mmc-spi-slot" as the compatible string) is not being compiled into my kernel. I have found other posts where people used this driver for this purpose (sd card over spi on iMX6 was the closest case I could find) :


https://github.com/torvalds/linux/blob/master/drivers/mmc/host/mmc_spi.c

TargetMachine$ cat /lib/modules/$(uname -r)/modules.builtin | grep mmc
kernel/drivers/mmc/card/mmc_block.ko
kernel/drivers/mmc/core/mmc_core.ko
kernel/drivers/mmc/host/sdhci.ko
kernel/drivers/mmc/host/sdhci-pltfm.ko
kernel/drivers/mmc/host/sdhci-esdhc-imx.ko

TargetMachine$ cat /lib/modules/$(uname -r)/modules.builtin | grep spi
kernel/drivers/base/regmap/regmap-spi.ko
kernel/drivers/mfd/mc13xxx-spi.ko
kernel/drivers/mtd/spi-nor/spi-nor.ko
kernel/drivers/mtd/spi-nor/fsl-quadspi.ko
kernel/drivers/spi/spi-bitbang.ko
kernel/drivers/spi/spi-gpio.ko
kernel/drivers/spi/spi-imx.ko


I searched around the kernel menuconfig UI for relevant kernel components to add. I already had the following config entries set:

HostMachine$ cat .config | grep MMC

# Supported MMC/SDIO adapters
CONFIG_MMC=y
# CONFIG_MMC_DEBUG is not set
# CONFIG_MMC_CLKGATE is not set
# MMC/SD/SDIO Card Drivers
CONFIG_MMC_BLOCK=y
CONFIG_MMC_BLOCK_MINORS=8
CONFIG_MMC_BLOCK_BOUNCE=y
# CONFIG_MMC_TEST is not set
# MMC/SD/SDIO Host Controller Drivers
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_IO_ACCESSORS=y
CONFIG_MMC_SDHCI_PLTFM=y
# CONFIG_MMC_SDHCI_OF_ARASAN is not set
CONFIG_MMC_SDHCI_ESDHC_IMX=y
# CONFIG_MMC_SDHCI_F_SDH30 is not set
# CONFIG_MMC_MXC is not set
# CONFIG_MMC_DW is not set
# CONFIG_MMC_VUB300 is not set
# CONFIG_MMC_USHC is not set
# CONFIG_MMC_USDHI6ROL0 is not set

When I search for "MMC" in the menuconfig UI, I see an additional entry that is not in my .config file:

Symbol: MMC_SPI [=n]
Type : tristate
Prompt: MMC/SD/SDIO over SPI
Location:
-> Device Drivers
(1) -> MMC/SD/SDIO card support (MMC [=y])
Depends on: MMC [=y] && SPI_MASTER [=y] && !HIGHMEM [=y] && HAS_DMA [=y]
Defined at drivers/mmc/host/Kconfig:472
Selects: CRC7 [=m] && CRC_ITU_T [=m]

However, I dont see any way in the menu to enable the MMC_SPI symbol, or to get CONFIG_MMC_SPI to showup in my .config file. 

https://github.com/torvalds/linux/blob/master/drivers/mmc/host/Kconfig 

Can you help me get past this point? Do you agree that I need to get the mmc_spi driver compiled in? If so, how can I get it to compile in? What else might be the problem and how do I troubleshoot ? 

标签 (1)
0 项奖励
1 解答
2,244 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Adrian

I am afraid SD Card over SPI is not supported with i.MX7.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
6 回复数
2,245 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Adrian

I am afraid SD Card over SPI is not supported with i.MX7.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
2,244 次查看
sidebranch
Contributor II

You say SD Card SPI mode (*) is not possible on i.MX7.

Do you mean the uSDHC does not support this, or the ECSPI module does not support this?

As the SD card SPI mode requires just a normal SPI host, the ECSPI should be able to handle it?

So, indeed, like Stefano asked: please explain.

Regards,

Leon.

(*) SD card SPI mode: How to Use MMC/SDC 

0 项奖励
2,244 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Leon

pastedImage_1.jpg

I believe ECSPI should be able to handle it, one can look at AN2689 document

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

Best regards
igor

0 项奖励
2,244 次查看
s_querin
Contributor I

Hello Igor,
 please could you explain me why the i.MX7 does not support the SD Card over SPI?

Best regards

Stefano

0 项奖励
2,244 次查看
adriansapio
Contributor II

Thanks for the replies, Jas and Igor.

Looks like we'll have to find a different way forward on this design. 

Take care,

Adrian

0 项奖励
2,244 次查看
mtx512
Contributor V

The option doesn't appear because imx_v7_defconfig negates the dependency ie:

1. CONFIG_HIGHMEM=y

2. CONFIG_HAS_DMA is not set

You would need to re-enable and see what happens. 

0 项奖励