SDMMC device tree configuration

来自百问网嵌入式Linux wiki

Article purpose

本文介绍了将SDMMC internal peripheral分配给 Linux® OS. 时如何配置。 在这种情况下,它由 MMC framework控制。 使用device tree 机制执行配置,该机制提供STM32 SDMMC Linux驱动程序和MMC框架使用的SDMMC外设的硬件描述。

如果外围设备已分配给另一个执行上下文,请参阅 How to assign an internal peripheral to a runtime context 文章,以获取有关外围设备分配和配置的准则。

DT bindings documentation

SDMMC设备树绑定包括:

  • 通用MMC设备树绑定 [1].
  • SDMMC MMC/SD/SDIO接口绑定 [2].

DT configuration

该硬件描述是STM32微处理器设备树文件(扩展名为.dtsi)和板子设备树文件(扩展名为.dts)的组合。 有关设备树文件分割的说明,请参见Device tree

STM32CubeMX可用于生成板卡设备树。 有关更多详细信息,请参考How to configure the DT using STM32CubeMX

DT configuration (STM32 level)

SDMMC外设节点位于``stm32mp157c.dtsi[3]文件。

   sdmmc1: sdmmc@58005000 {                                  Comments
       compatible = "arm,pl18x", "arm,primecell";
       arm,primecell-periphid = <0x00253180>;
       reg = <0x58005000 0x1000>,                            --> The controller register location 
             <0x58006000 0x1000>;                            --> The delay block register location
       interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;        --> The interrupt number used
       interrupt-names = "cmd_irq";
       clocks = <&rcc SDMMC1_K>;
       clock-names = apb_pclk
       resets = <&rcc SDMMC1_R>;                      
       status = "disabled";
   };
Warning.png 该设备树部分与STM32微处理器有关。 它应该保持原样,而不要由最终用户修改。

DT configuration (board level)

The SDMMC peripheral may connect to one SD card, one e•MMC™ device or one SDIO card.

   &sdmmc1{                                                  Comments     
       pinctrl-names = "default", "opendrain", "sleep";      --> For pinctrl configuration, please refer to Pinctrl device tree configuration
       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;                                          --> Generate data and command on sdmmc clock falling edge
       st,sig-dir;                                           --> Allow to select direction polarity of an external transceiver
       st,use-ckin;                                          --> Use sdmmc_ckin pin from an external transceiver to sample the receive data
       bus-width = <4>;                                      --> Number of data lines, can be 1, 4 or 8
       vmmc-supply = <&vdd_sd>;                              --> Supply node for card's power
       vqmmc-supply = <&sd_switch>;                          --> Supply node for IO line power
       status = "okay";                                      --> Enable the node
   };

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.

DT configuration examples

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

   &sdmmc2{                                                  Comments     
       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;                                        --> Non-removable slot, assume always present
       no-sd;                                                --> Avoid to send SD command during initialization
       no-sdio;                                              --> Avoid to send SDIO command during initialization
       st,neg-edge;                                           
       bus-width = <8>;                                    
       vmmc-supply = <&v3v3>;                      
       vqmmc-supply = <&vdd>;
       mmc-ddr-3_3v;                                         --> Host supports e•MMC™ DDR 3.3V                         
       status = "okay";                                     
   };

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

   &sdmmc1{                                                  Comments     
       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;                                            --> use polling mode for card detection
       st,neg-edge;
       st,sig-dir;
       st,use-ckin;                                    
       bus-width = <4>;
       sd-uhs-sdr12;                                         --> sd modes supported [1]
       sd-uhs-sdr25;
       sd-uhs-sdr50;
       sd-uhs-ddr50;
       sd-uhs-sdr104;
       vmmc-supply = <&vdd_sd>;                      
       vqmmc-supply = <&sd_switch>;                          
       status = "okay";                                     
   };

How to configure the DT using STM32CubeMX

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.

References

Please refer to the following links for additional information:

<securetransclude src="ProtectedTemplate:PublicationRequestId" params="9408 | 2018-10-26 | BrunoB"></securetransclude> <securetransclude src="ProtectedTemplate:ArticleBasedOnModel" params="Peripheral or framework device tree configuration model"></securetransclude>