The MultiMediaCard (MMC)/Secure Digital (SD)/Secure Digital Input Output (SDIO) host driver implements a standard Linux driver interface to the SD/MMC host controller (SDMMC). The host driver is part of the Linux kernel MMC framework.

The STMicroelectronics STM32MP13 CPU has three SDMMC controllers.

On the ConnectCore MP13 system-on-module:

  • All three SDMMC interfaces are available at the LGA pads, multiplexed with other functionality.

  • SDMMC1 is available (4 data bits) at the castellated pads, multiplexed with other functionality.

  • SDMMC2 connects internally to the Murata LBEE5PK2AE-564 wireless chip using four data lines (on wireless variants).

On the ConnectCore MP13 Development Kit:

  • SDMMC1 is connected to the microSD card holder (using four data lines).

Kernel configuration

You can manage the SDMMC driver support through the following kernel configuration option:

  • STMicroelectronics STM32 SDMMC host controller (CONFIG_MMC_STM32_SDMMC)

This option is enabled as built-in on the default ConnectCore MP13 kernel configuration file.

Kernel driver

The driver for the SDMMC is located at:

File Description

drivers/mmc/host/mmci_stm32_sdmmc.c

SDMMC driver

Device tree bindings and customization

The SDMMC device tree binding is documented at Documentation/devicetree/bindings/mmc/arm,pl18x.yaml.

Common MMC device tree bindings are documented at Documentation/devicetree/bindings/mmc/mmc-controller.yaml.

The common STM32MP13 CPU device tree defines all the SDMMC ports. The platform device tree must:

  • Enable the required SDMMC port, by setting the status property to "okay".

  • Select the bus-width depending on the number of data lines to use.

  • Select optional properties (broken-cd, non-removable…​), depending on the interface (see binding documentation).

  • Configure the pinctrl of the pads to use for the interface.

ConnectCore MP13 device tree
/* SDMMC2 (Wireless) */
&sdmmc2 {
	arm,primecell-periphid = <0x10153180>;
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc2_b4_pins_a>;
	pinctrl-1 = <&sdmmc2_b4_od_pins_a>;
	pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;
	non-removable;
	no-1-8-v;
	st,neg-edge;
	bus-width = <4>;
	vmmc-supply = <&reg_rf_wl_en>;
	status = "disabled";
};

If you are using the non-wireless variant, you may use sdmmc2 interface on your carrier board.

User space usage

The MMC block driver handles the file system read/write calls and uses the low-level MMC host controller interface driver to send the commands to the SDMMC controller.

The MMC device driver exposes the device through the file system at /dev/mmcblkX where X is a number, starting at zero, that indicates the device index.

If the block device is partitioned, the partitions will appear as /dev/mcblkXpY where Y is a number, starting at one, that indicates the partition index.

By default, formatted partitions are auto-mounted upon detection if they are block devices. You can also mount a partition’s file system using the mount command with the partition node, the file system type, and the mount point:

# mkdir -p /media/mmcblk1p1 && mount -t vfat /dev/mmcblk1p1 /media/mmcblk1p1

Detect microSD card

The microSD card holder on the ConnectCore MP13 Development Kit does not have a card detection line. However, the Linux driver supports card detection by polling for the presence of a card.

If the device is not partitioned, you can use fdisk to create one partition of type .vfat and then give it format with mkfs, for example:

# echo -e 'o\nn\np\n1\n\n\nt\nb\nw\n' | fdisk /dev/mmcblk0 > /dev/null
# mkfs.vfat /dev/mmcblk0p1

If the device is partitioned but you still want to re-partition or re-format it, you must first unmount all the mounted partitions.