Last edited 4 years ago

SDMMC device tree configuration

Template:ArticleBasedOnModel Template:ArticleMainWriter Template:ArticleApprovedVersion


1. Article purpose[edit source]

This article explains how to configure the SDMMC internal peripheral when it is assigned to the Linux® OS. In that case, it is controlled by the MMC framework.

The configuration is performed using the device tree mechanism that provides a hardware description of the SDMMC peripheral, used by the STM32 SDMMC Linux driver and by the MMC framework.

2. DT bindings documentation[edit source]

The SDMMC device tree bindings are composed of:

  • generic MMC device tree bindings [1].
  • SDMMC MMC/SD/SDIO interface bindings [2].

3. DT configuration[edit source]

This hardware description is a combination of the STM32 microprocessor device tree files (.dtsi extension) and board device tree files (.dts extension). See the Device tree for an explanation of the device tree file split.

STM32CubeMX can be used to generate the board device tree. Refer to How to configure the DT using STM32CubeMX for more details.

3.1. DT configuration (STM32 level)[edit source]

The SDMMC peripheral node is located in stm32mp157c.dtsi[3] file.

   sdmmc1: sdmmc@58005000 {                                  Template:Highlight
       compatible = "arm,pl18x", "arm,primecell";
       arm,primecell-periphid = <0x00253180>;
       reg = <0x58005000 0x1000>,                            Template:Highlight 
             <0x58006000 0x1000>;                            Template:Highlight
       interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;        Template:Highlight
       interrupt-names = "cmd_irq";
       clocks = <&rcc SDMMC1_K>;
       clock-names = apb_pclk
       resets = <&rcc SDMMC1_R>;                      
       status = "disabled";
   };

Template:Warning

3.2. DT configuration (board level)[edit source]

The SDMMC peripheral may connect to one SD card, one eMMC™ device or one SDIO card.

   &sdmmc1{                                                  Template:Highlight     
       pinctrl-names = "default", "opendrain", "sleep";      Template:Highlight
       pinctrl-0 = <&sdmmc1_b4_pins_a &sdmmc1_dir_pins_a>;
       pinctrl-1 = <&sdmmc1_b4_od_pins_a &sdmmc1_dir_pins_a>;
       pinctrl-2 = <&sdmmc1_b4_sleep_pins_a &sdmmc1_dir_sleep_pins_a>;
       st,neg-edge;                                          Template:Highlight
       st,sig-dir;                                           Template:Highlight
       st,use-ckin;                                          Template:Highlight
       bus-width = <4>;                                      Template:Highlight
       vmmc-supply = <&vdd_sd>;                              Template:Highlight
       vqmmc-supply = <&sd_switch>;                          Template:Highlight
       status = "okay";                                      Template:Highlight
   };

Below optional properties have to be used when an external transceiver is connected:

  • st,sig-dir: This property allows to select external transceiver direction signals polarity. When this property is set, the voltage transceiver IOs are driven as output when the direction signals are high. Without setting this property, the voltage transceiver IOs are driven as output when the direction signals are low.
  • st,use-ckin: By setting this property, the sdmmc_ckin pin from an external transceiver is used to sample the receive data.

3.3. DT configuration examples[edit source]

Below example shows how to configure the SDMMC when an eMMC™ is connected with 8 data lines [4].

   &sdmmc2{                                                  Template:Highlight     
       pinctrl-names = "default", "opendrain", "sleep";      
       pinctrl-0 = <&sdmmc2_b4_pins_a &sdmmc2_dir_pins_a>;
       pinctrl-1 = <&sdmmc2_b4_od_pins_a &sdmmc2_dir_pins_a>;
       pinctrl-2 = <&sdmmc2_b4_sleep_pins_a &sdmmc2_dir_sleep_pins_a>;             
       non-removable;                                        Template:Highlight
       no-sd;                                                Template:Highlight
       no-sdio;                                              Template:Highlight
       st,neg-edge;                                           
       bus-width = <8>;                                    
       vmmc-supply = <&v3v3>;                      
       vqmmc-supply = <&vdd>;
       mmc-ddr-3_3v;                                         Template:Highlight                         
       status = "okay";                                     
   };

Below example shows how to configure the SDMMC to SD card (4 data lines) with an external transceiver [4].

   &sdmmc1{                                                  Template:Highlight     
       pinctrl-names = "default", "opendrain", "sleep";    
       pinctrl-0 = <&sdmmc1_b4_pins_a &sdmmc1_dir_pins_a>;
       pinctrl-1 = <&sdmmc1_b4_od_pins_a &sdmmc1_dir_pins_a>;
       pinctrl-2 = <&sdmmc1_b4_sleep_pins_a &sdmmc1_dir_sleep_pins_a>;               
       broken-cd;                                            Template:Highlight
       st,neg-edge;
       st,sig-dir;
       st,use-ckin;                                    
       bus-width = <4>;
       sd-uhs-sdr12;                                         Template:Highlight
       sd-uhs-sdr25;
       sd-uhs-sdr50;
       sd-uhs-ddr50;
       sd-uhs-sdr104;
       vmmc-supply = <&vdd_sd>;                      
       vqmmc-supply = <&sd_switch>;                          
       status = "okay";                                     
   };

4. How to configure the DT using STM32CubeMX[edit source]

The STM32CubeMX tool can be used to configure the STM32MPU device and get the corresponding platform configuration device tree files.
The STM32CubeMX may not support all the properties described in the above DT bindings documentation paragraph. If so, the tool inserts user sections in the generated device tree. These sections can then be edited to add some properties and they are preserved from one generation to another. Refer to STM32CubeMX user manual for further information.

5. References[edit source]

Please refer to the following links for additional information: