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 STM32MP25 CPU has three SDMMC controllers.

On the ConnectCore MP25 system-on-module:

  • SDMMC3 is available (4 data bits) at the outer LGA ring pads, multiplexed with other functionality.

  • SDMMC1 connects internally to the Murata LBEE5HY2GY wireless chip using four data lines (on wireless variants).

On the ConnectCore MP25 Development Kit:

  • SDMMC3 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 MP25 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 STM32MP25 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 MP25 device tree
/* Wireless */
&sdmmc1 {
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc1_b4_pins_a>;
	pinctrl-1 = <&sdmmc1_b4_od_pins_a>;
	pinctrl-2 = <&sdmmc1_b4_sleep_pins_a>;
	non-removable;
	st,neg-edge;
	bus-width = <4>;
	vmmc-supply = <&reg_rf_wl_en>;
	vqmmc-supply = <&scmi_vddio1>;
	cap-sdio-irq;
	status = "disabled";

	#address-cells = <1>;
	#size-cells = <0>;
	brcmf: bcrmf@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};.

If you are using the non-wireless variant, you may use sdmmc1 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/mmcblkXpY 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 /run/media/mmcblk1p1
# mount -t vfat /dev/mmcblk1p1 /run/media/mmcblk1p1

Device node mapping

On the ConnectCore MP25 Development Kit device tree, the uSDHC interfaces are set up to be mapped by Linux as follows:

  • The eMMC (connected to SDMMC2) is mapped to /dev/mmcblk0.

  • The microSD card (connected to SDMMC3) is mapped to /dev/mmcblk1.

microSD card detection

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

Formatted partitions are auto-mounted upon card insertion.

If the microSD 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/mmcblk1 > /dev/null
# mkfs.vfat /dev/mmcblk1p1

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