“SDMMC device tree configuration”的版本间的差异
Zhouyuebiao(讨论 | 贡献) |
|||
(未显示2个用户的8个中间版本) | |||
第1行: | 第1行: | ||
− | + | == Article purpose == | |
+ | 本文介绍了将[[SDMMC internal peripheral|'''SDMMC''' internal peripheral]]分配给 Linux<sup>®</sup> OS. 时如何配置。 在这种情况下,它由 [[MMC overview|MMC framework]]控制。 | ||
+ | 使用[[Device tree|device tree]] 机制执行配置,该机制提供STM32 SDMMC Linux驱动程序和MMC框架使用的SDMMC外设的硬件描述。 | ||
+ | 如果外围设备已分配给另一个执行上下文,请参阅 [[How to assign an internal peripheral to a runtime context]] 文章,以获取有关外围设备分配和配置的准则。 | ||
− | [[ | + | == DT bindings documentation == |
− | + | SDMMC设备树绑定包括: | |
− | + | ||
+ | * 通用MMC设备树绑定 <ref name="mmc.txt">{{CodeSource | Linux kernel | Documentation/devicetree/bindings/mmc/mmc.txt}}</ref>. | ||
+ | |||
+ | * SDMMC MMC/SD/SDIO接口绑定 <ref> {{CodeSource | Linux kernel | Documentation/devicetree/bindings/mmc/mmci.txt}} </ref>. | ||
+ | |||
+ | == DT configuration == | ||
+ | 该硬件描述是'''STM32微处理器'''设备树文件(扩展名为.dtsi)和'''板子'''设备树文件(扩展名为.dts)的组合。 有关设备树文件分割的说明,请参见[[Device tree]]。 | ||
+ | |||
+ | '''STM32CubeMX'''可用于生成板卡设备树。 有关更多详细信息,请参考[[#How_to_configure_the_DT_using_STM32CubeMX|How to configure the DT using STM32CubeMX]]。 | ||
+ | |||
+ | === DT configuration (STM32 level) === | ||
+ | SDMMC外设节点位于``stm32mp157c.dtsi''<ref>{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi}}</ref>文件。 | ||
+ | |||
+ | sdmmc1: sdmmc@58005000 { {{highlight|Comments}} | ||
+ | compatible = "arm,pl18x", "arm,primecell"; | ||
+ | arm,primecell-periphid = <0x00253180>; | ||
+ | reg = <0x58005000 0x1000>, {{highlight|--> The controller register location}} | ||
+ | <0x58006000 0x1000>; {{highlight|--> The delay block register location}} | ||
+ | interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; {{highlight|--> The interrupt number used}} | ||
+ | interrupt-names = "cmd_irq"; | ||
+ | clocks = <&rcc SDMMC1_K>; | ||
+ | clock-names = apb_pclk | ||
+ | resets = <&rcc SDMMC1_R>; | ||
+ | status = "disabled"; | ||
+ | }; | ||
+ | |||
+ | {{Warning|该设备树部分与STM32微处理器有关。 它应该保持原样,而不要由最终用户修改。}} | ||
+ | |||
+ | === DT configuration (board level) === | ||
+ | SDMMC外围设备可以连接到一张SD卡,一张“ e”•MMC™设备或一张SDIO卡。 | ||
+ | |||
+ | &sdmmc1{ {{highlight|Comments}} | ||
+ | pinctrl-names = "default", "opendrain", "sleep"; {{highlight|--> 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; {{highlight|--> Generate data and command on sdmmc clock falling edge}} | ||
+ | st,sig-dir; {{highlight|--> Allow to select direction polarity of an external transceiver}} | ||
+ | st,use-ckin; {{highlight|--> Use sdmmc_ckin pin from an external transceiver to sample the receive data}} | ||
+ | bus-width = <4>; {{highlight|--> Number of data lines, can be 1, 4 or 8}} | ||
+ | vmmc-supply = <&vdd_sd>; {{highlight|--> Supply node for card's power}} | ||
+ | vqmmc-supply = <&sd_switch>; {{highlight|--> Supply node for IO line power}} | ||
+ | status = "okay"; {{highlight|--> Enable the node}} | ||
+ | }; | ||
+ | |||
+ | 连接外部收发器时,必须使用以下可选属性: | ||
+ | * st,sig-dir:此属性允许选择外部收发器方向信号的极性。 设置此属性后,方向信号为高电平时,电压收发器IO将作为输出驱动。 如果不设置此属性,则当方向信号为低电平时,电压收发器IO将作为输出驱动。 | ||
+ | * st,use-ckin:通过设置此属性,来自外部收发器的sdmmc_ckin引脚用于采样接收数据。 | ||
+ | |||
+ | === DT configuration examples === | ||
+ | 下面的示例显示了当一个‘’e‘’·mmc内核连接到8条数据线时如何配置sdmmc。<ref name="ED1">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c-ed1.dts}}</ref>. | ||
+ | |||
+ | &sdmmc2{ {{highlight|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; {{highlight|--> Non-removable slot, assume always present}} | ||
+ | no-sd; {{highlight|--> Avoid to send SD command during initialization}} | ||
+ | no-sdio; {{highlight|--> Avoid to send SDIO command during initialization}} | ||
+ | st,neg-edge; | ||
+ | bus-width = <8>; | ||
+ | vmmc-supply = <&v3v3>; | ||
+ | vqmmc-supply = <&vdd>; | ||
+ | mmc-ddr-3_3v; {{highlight|--> Host supports ''e''•MMC™ DDR 3.3V}} | ||
+ | status = "okay"; | ||
+ | }; | ||
+ | |||
+ | 下例显示了如何使用外部收发器将SDMMC配置为SD卡(4条数据线) <ref name="ED1"/>. | ||
+ | |||
+ | &sdmmc1{ {{highlight|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; {{highlight|--> use polling mode for card detection}} | ||
+ | st,neg-edge; | ||
+ | st,sig-dir; | ||
+ | st,use-ckin; | ||
+ | bus-width = <4>; | ||
+ | sd-uhs-sdr12; {{highlight|--> sd modes supported <ref name="mmc.txt"/>}} | ||
+ | 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]]工具可用于配置STM32MPU设备并获取相应的[[Device_tree#STM32|platform configuration device tree]] 文件。<br /> | ||
+ | STM32CubeMX可能不支持以上 [[#DT bindings documentation|DT bindings documentation]] 段中描述的所有属性。 如果是这样,该工具会在生成的设备树中插入“''用户部分”''。 然后可以编辑这些部分以添加一些属性,并将它们一代一代地保留下来。 有关更多信息,请参见[[STM32CubeMX]] 用户手册。 | ||
+ | |||
+ | ==References== | ||
+ | 有关更多信息,请参阅以下链接: | ||
+ | <references /> |
2020年11月10日 (二) 11:09的最新版本
目录
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 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"; };
该设备树部分与STM32微处理器有关。 它应该保持原样,而不要由最终用户修改。 |
DT configuration (board level)
SDMMC外围设备可以连接到一张SD卡,一张“ e”•MMC™设备或一张SDIO卡。
&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 };
连接外部收发器时,必须使用以下可选属性:
- st,sig-dir:此属性允许选择外部收发器方向信号的极性。 设置此属性后,方向信号为高电平时,电压收发器IO将作为输出驱动。 如果不设置此属性,则当方向信号为低电平时,电压收发器IO将作为输出驱动。
- st,use-ckin:通过设置此属性,来自外部收发器的sdmmc_ckin引脚用于采样接收数据。
DT configuration examples
下面的示例显示了当一个‘’e‘’·mmc内核连接到8条数据线时如何配置sdmmc。[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"; };
下例显示了如何使用外部收发器将SDMMC配置为SD卡(4条数据线) [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工具可用于配置STM32MPU设备并获取相应的platform configuration device tree 文件。
STM32CubeMX可能不支持以上 DT bindings documentation 段中描述的所有属性。 如果是这样,该工具会在生成的设备树中插入“用户部分”。 然后可以编辑这些部分以添加一些属性,并将它们一代一代地保留下来。 有关更多信息,请参见STM32CubeMX 用户手册。
References
有关更多信息,请参阅以下链接:
- ↑ 1.01.1 Documentation/devicetree/bindings/mmc/mmc.txt| |}} Documentation/devicetree/bindings/mmc/mmc.txt
- ↑ Documentation/devicetree/bindings/mmc/mmci.txt| |}} Documentation/devicetree/bindings/mmc/mmci.txt
- ↑ arch/arm/boot/dts/stm32mp157c.dtsi| |}} arch/arm/boot/dts/stm32mp157c.dtsi
- ↑ 4.04.1 arch/arm/boot/dts/stm32mp157c-ed1.dts| |}} arch/arm/boot/dts/stm32mp157c-ed1.dts