“OTG device tree configuration”的版本间的差异

来自百问网嵌入式Linux wiki
 
(未显示同一用户的6个中间版本)
第1行: 第1行:
  
 
== Article purpose ==
 
== Article purpose ==
This article explains how to configure the [[OTG internal peripheral|'''OTG''' internal peripheral]] when it is assigned to the Linux<sup>&reg;</sup> OS. In that case, it is controlled by the [[USB overview|USB framework]].
+
本文介绍了在将[[OTG internal peripheral|'''OTG''' internal peripheral]] 分配给Linux<sup>&reg;</sup> OS时如何进行配置。 在这种情况下,它由 [[USB overview|USB framework]]控制。
  
The configuration is performed using the [[Device tree|device tree]] mechanism.
+
使用 [[Device tree|device tree]] 机制执行配置。
  
It is used by ''OTG Linux driver''<ref>{{CodeSource | Linux kernel | drivers/usb/dwc2/}}, DesignWare HS OTG Controller driver</ref> which registers the relevant information in the [[USB overview|USB framework]].
+
它由“ OTG Linux驱动程序”<ref>{{CodeSource | Linux kernel | drivers/usb/dwc2/}}, DesignWare HS OTG Controller driver</ref> 用于在[[USB overview|USB framework]]中注册相关信息。
  
 
== DT bindings documentation ==
 
== DT bindings documentation ==
The ''Platform DesignWare HS OTG USB 2.0 controller device tree bindings''<ref name="dwc2_bindings>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/usb/dwc2.txt}}, Platform DesignWare HS OTG USB 2.0 controller device tree bindings</ref> document represents the [[OTG internal peripheral|OTG]] (DRD) controller.
+
"Platform DesignWare HS OTG USB 2.0控制器设备树绑定"<ref name="dwc2_bindings>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/usb/dwc2.txt}},Platform DesignWare HS OTG USB 2.0控制器设备树绑定</ref> document represents the [[OTG internal peripheral|OTG]](DRD)控制器。
  
The ''Generic USB device tree bindings''<ref name="generic_bindings">{{CodeSource | Linux kernel | Documentation/devicetree/bindings/usb/generic.txt}}, Generic USB device tree bindings</ref> document represents generic USB properties, proposed by [[USB overview|USB framework]] such as maximum speed, dr_mode...
+
“通用USB设备树绑定” <ref name="generic_bindings">{{CodeSource | Linux kernel | Documentation/devicetree/bindings/usb/generic.txt}}, Generic USB device tree bindings</ref> 文档表示通用USB属性,由[[USB overview|USB framework]] 提出,例如最大速度,dr_mode ...
  
 
== DT configuration ==
 
== DT configuration ==
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.
+
该硬件描述是“''STM32微处理器”''设备树文件(扩展名为.dtsi)和“''板子”设备树文件(扩展名为.dts)的组合。 有关设备树文件分割的说明,请参见 [[Device tree]]
 
+
'''STM32CubeMX'''可用于生成板卡设备树。 有关更多详细信息,请参考 [[#How_to_configure_the_DT_using_STM32CubeMX|How to configure the DT using STM32CubeMX]]
'''STM32CubeMX''' can be used to generate the board device tree. Refer to [[#How_to_configure_the_DT_using_STM32CubeMX|How to configure the DT using STM32CubeMX]] for more details.
 
 
=== DT configuration (STM32 level) ===
 
=== DT configuration (STM32 level) ===
The '''usbotg_hs''' DT node is declared in stm32mp157c.dtsi<ref name="stm32mp157c_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi}}, STM32MP157C device tree file</ref>.
+
在stm32mp157c.dtsi <ref name="stm32mp157c_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi}}, STM32MP157C device tree file</ref>.
  
It is composed of a set of properties, used to describe the [[OTG_internal_peripheral#Features|OTG controller]]: registers address, clocks, resets, interrupts...
+
它由一组属性组成,用于描述[[OTG_internal_peripheral#Features|OTG controller]]:寄存器地址,时钟,复位,中断...
  
 
  '''usbotg_hs''': usb-otg@49000000 {
 
  '''usbotg_hs''': usb-otg@49000000 {
第32行: 第31行:
 
  status = "disabled";
 
  status = "disabled";
 
  };
 
  };
{{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}}
+
{{Warning|该设备树部分与STM32微处理器有关。 它必须保持原样,而不能由最终用户修改。}}
{{ReviewsComments|FGA W902: Later add some examples to fine tune various fifo size (g-rx-fifo-size, g-np-tx-fifo-size, g-tx-fifo-size) depending on the use case: host, gadget eth, gadget mass storage... Maybe part of a dedicated article}}
+
 
  
 
=== DT configuration (board level) ===
 
=== DT configuration (board level) ===
Follow the sequences described in the below chapters to configure and enable the OTG on your board.
+
请按照以下章节中描述的顺序在板上配置和启用OTG。
  
OTG supports two PHY interfaces that can be statically selected via DT:
+
OTG支持可通过DT静态选择的两个PHY接口:
* full-speed PHY, embedded with the [[OTG_internal_peripheral|OTG]] controller
+
* 内置有[[OTG_internal_peripheral|OTG]] 控制器的全速PHY
* high-speed [[USBPHYC_internal_peripheral|USBPHYC]] HS PHY that can be assigned to either the [[USBH_internal_peripheral|USBH]] or the [[OTG_internal_peripheral|OTG]] controller.
+
* 高速 [[USBPHYC_internal_peripheral|USBPHYC]] HS PHY,可以分配给 [[USBH_internal_peripheral|USBH]] 或者[[OTG_internal_peripheral|OTG]] 控制器。
When operating in "otg" or "host" mode, an external charge pump, e.g. 5V regulator must be specified.
+
在“ otg”或“主机”模式下运行时,需要使用外部电荷泵,例如 必须指定5V稳压器。
{{Info|Please refer to  [[Regulator overview]] for additional information on regulators configuration.}}
+
{{Info|有关调节器配置的更多信息,请参考[[Regulator overview]]}}
  
 
==== DT configuration using full-speed USB PHY ====
 
==== DT configuration using full-speed USB PHY ====
* Enable the OTG by setting '''status = "okay".'''
+
* 通过设置'''status =“ okay”。'''来启用OTG。
* Use embedded full-speed PHY by setting '''compatible = "st,stm32mp1-fsotg", "snps,dwc2"'''
+
* 通过设置'''compatible =“ st,stm32mp1-fsotg”,“ snps,dwc2”'''使用嵌入式全速PHY
* Configure full-speed PHY pins (OTG ID, DM, DP) as analog via [[Pinctrl overview|pinctrl]], through '''pinctrl-0''' and '''pinctrl-names'''.
+
* [[Pinctrl overview|pinctrl]],通过“''pinctrl-0””和“” pinctrl-names””,将全速PHY引脚(OTG ID,DM,DP)配置为模拟。
* Optionally set dual-role mode through '''dr_mode = "peripheral"''', '''"host"''' or '''"otg"''' (default to "otg" in case it is not set)
+
* (可选)通过'''dr_mode =“ peripheral”''''''主机“''''''otg”'''(如果未设置,默认为“ otg”)设置双角色模式 )
* Optionally set vbus voltage [[Regulator overview|regulator]] for otg and host modes, through '''vbus-supply = <&your_regulator>'''
+
* 可选地通过'''vbus-supply = <&your_regulator>'''为otg和主机模式设置vbus电压[[Regulator overview|regulator]]。
  
 
==== DT configuration using high-speed USB PHY ====
 
==== DT configuration using high-speed USB PHY ====
* Enable the OTG by setting '''status = "okay".'''
+
* 通过设置'''status =“ okay”。'''来启用OTG。
* Select USBPHYC port#2 by setting '''phys = <&usbphyc_port1 {{highlight|0}}>;''' and '''phy-names = "usb2-phy";'''
+
* 通过设置'''phys =<&usbphyc_port1 {{highlight|0}}>;'''''phy-names =usb2-phy”;'''选择USBPHYC端口#2
* Optionally configure OTG ID pin as analog via [[Pinctrl overview|pinctrl]], through '''pinctrl-0''' and '''pinctrl-names'''.
+
* (可选)通过[[Pinctrl overview|pinctrl]],通过'''pinctrl-0''''''pinctrl-names'''将OTG ID引脚配置为模拟引脚。
* Optionally set dual-role mode through '''dr_mode = "peripheral"''', '''"host"''' or '''"otg"''' (default to "otg" in case it is not set)
+
* (可选)通过'''dr_mode =“ peripheral”''''''主机“''''''otg”'''(如果未设置,默认为“ otg”)设置双角色模式 )
* Optionally set vbus voltage [[Regulator overview|regulator]] for otg and host modes, through '''vbus-supply = <&your_regulator>'''
+
* 可选地通过'''vbus-supply = <&your_regulator>'''为otg和主机模式设置vbus电压[[Regulator overview|regulator]].
{{Info|Please refer to [[USBPHYC device tree configuration]] for additional information on USBPHYC port#2 configuration}}
+
{{Info|有关USBPHYC端口2配置的更多信息,请参考[[USBPHYC device tree configuration]].}}
  
 
=== DT configuration examples ===
 
=== DT configuration examples ===
 
==== DT configuration example as full-speed OTG ====
 
==== DT configuration example as full-speed OTG ====
The example below shows how to configure full-speed OTG, with the ID pin to detect role (peripheral, host):
+
下面的示例显示了如何配置ID引脚以检测角色(外围设备,主机)的全速OTG:
* OTG ID and data (DM, DP) pins: use [[Pinctrl device tree configuration]] to configure PA10, PA11 and PA12 as analog input.
+
* OTG ID和数据(DM,DP)引脚:使用[[Pinctrl device tree configuration]] 将PA10,PA11和PA12配置为模拟输入。
* Use integrated ''full-speed USB PHY'' by setting '''compatible'''
+
* 通过设置“兼容”来使用集成的“全速USB PHY”
* Dual-role (dr_mode) is "otg" (e.g. the default as unspecified)
+
* 双角色(dr_mode)为“ otg”(例如,默认值未指定)
* Use vbus voltage regulator
+
* 使用vbus稳压器
 
  # part of pin-controller dt node
 
  # part of pin-controller dt node
 
  {{HighlightParam|usbotg_hs_pins_a}}: usbotg_hs-0 {
 
  {{HighlightParam|usbotg_hs_pins_a}}: usbotg_hs-0 {
第90行: 第89行:
  
 
==== DT configuration example as high speed OTG ====
 
==== DT configuration example as high speed OTG ====
The example below shows how to configure high-speed OTG, with the ID pin to detect role (peripheral, host):
+
下面的示例显示了如何使用ID引脚检测角色(外围设备,主机)来配置高速OTG:
* OTG ID pin: use [[Pinctrl device tree configuration]] to configure PA10 as analog input.
+
* OTG ID引脚:使用[[Pinctrl device tree configuration]] 将PA10配置为模拟输入
* Use ''USB HS PHY port#2'', with the UTMI switch that selects the OTG controller
+
* ''USB HS PHY端口#2''与UTMI开关一起使用以选择OTG控制器
* Dual-role mode (dr_mode) is "otg" (e.g. the default as unspecified)
+
* 双角色模式(dr_mode)为“ otg”(例如,默认值未指定)
* Use vbus voltage regulator
+
* 使用vbus稳压器
 
  # part of pin-controller dt node
 
  # part of pin-controller dt node
 
  {{HighlightParam|usbotg_hs_pins_a}}: usbotg_hs-0 {
 
  {{HighlightParam|usbotg_hs_pins_a}}: usbotg_hs-0 {
第114行: 第113行:
  
 
==How to configure the DT using STM32CubeMX==
 
==How to configure the DT using STM32CubeMX==
The [[STM32CubeMX]] tool can be used to configure the STM32MPU device and get the corresponding [[Device_tree#STM32|platform configuration device tree]] files.<br />
+
The [[STM32CubeMX]] 工具可用于配置STM32MPU设备并获取相应的[[Device_tree#STM32|platform configuration device tree]] 文件。<br />
The STM32CubeMX may not support all the properties described in the above [[#DT bindings documentation|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.
+
STM32CubeMX可能不支持以上[[#DT bindings documentation|DT bindings documentation]] 段中描述的所有属性。 如果是这样,该工具会在生成的设备树中插入“''用户部分”''。 然后可以编辑这些部分以添加一些属性,并将它们一代一代地保留下来。 有关更多信息,请参见[[STM32CubeMX]] 用户手册。
  
 
==References==
 
==References==
Please refer to the following links for additional information:
+
请参考以下链接以获取更多信息:
  
 
<references />
 
<references />
 
<noinclude>
 
{{ArticleBasedOnModel | Peripheral or framework device tree configuration model}}
 
{{PublicationRequestId | 10336 | 2019-01-16 | AlainF}}
 
[[Category:Device tree configuration]]
 
[[Category:USB|0]]
 
</noinclude>
 

2020年11月11日 (三) 10:57的最新版本

Article purpose

本文介绍了在将OTG internal peripheral 分配给Linux® OS时如何进行配置。 在这种情况下,它由 USB framework控制。

使用 device tree 机制执行配置。

它由“ OTG Linux驱动程序”[1] 用于在USB framework中注册相关信息。

DT bindings documentation

"Platform DesignWare HS OTG USB 2.0控制器设备树绑定"[2] document represents the OTG(DRD)控制器。

“通用USB设备树绑定” [3] 文档表示通用USB属性,由USB framework 提出,例如最大速度,dr_mode ...

DT configuration

该硬件描述是“STM32微处理器”设备树文件(扩展名为.dtsi)和“板子”设备树文件(扩展名为.dts)的组合。 有关设备树文件分割的说明,请参见 Device tree STM32CubeMX可用于生成板卡设备树。 有关更多详细信息,请参考 How to configure the DT using STM32CubeMX

DT configuration (STM32 level)

在stm32mp157c.dtsi [4].

它由一组属性组成,用于描述OTG controller:寄存器地址,时钟,复位,中断...

usbotg_hs: usb-otg@49000000 {
	compatible = "snps,dwc2";
	reg = <0x49000000 0x10000>;
	clocks = <&rcc USBO_K>;
	clock-names = "otg";
	resets = <&rcc USBO_R>;
	reset-names = "dwc2";
	interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
	dr_mode = "otg"; 	 	 	 	/* dr_mode[3] can be overwritten at board level to set a particular mode */
	status = "disabled";
};
Warning.png 该设备树部分与STM32微处理器有关。 它必须保持原样,而不能由最终用户修改。


DT configuration (board level)

请按照以下章节中描述的顺序在板上配置和启用OTG。

OTG支持可通过DT静态选择的两个PHY接口:

  • 内置有OTG 控制器的全速PHY
  • 高速 USBPHYC HS PHY,可以分配给 USBH 或者OTG 控制器。

在“ otg”或“主机”模式下运行时,需要使用外部电荷泵,例如 必须指定5V稳压器。

Info.png 有关调节器配置的更多信息,请参考Regulator overview

DT configuration using full-speed USB PHY

  • 通过设置status =“ okay”。来启用OTG。
  • 通过设置compatible =“ st,stm32mp1-fsotg”,“ snps,dwc2”使用嵌入式全速PHY
  • pinctrl,通过“pinctrl-0””和“” pinctrl-names””,将全速PHY引脚(OTG ID,DM,DP)配置为模拟。
  • (可选)通过dr_mode =“ peripheral”主机“otg”(如果未设置,默认为“ otg”)设置双角色模式 )
  • 可选地通过vbus-supply = <&your_regulator>为otg和主机模式设置vbus电压regulator

DT configuration using high-speed USB PHY

  • 通过设置status =“ okay”。来启用OTG。
  • 通过设置'phys =<&usbphyc_port1 0>;phy-names =“ usb2-phy”;选择USBPHYC端口#2
  • (可选)通过pinctrl,通过pinctrl-0pinctrl-names将OTG ID引脚配置为模拟引脚。
  • (可选)通过dr_mode =“ peripheral”主机“otg”(如果未设置,默认为“ otg”)设置双角色模式 )
  • 可选地通过vbus-supply = <&your_regulator>为otg和主机模式设置vbus电压regulator.
Info.png 有关USBPHYC端口2配置的更多信息,请参考USBPHYC device tree configuration.

DT configuration examples

DT configuration example as full-speed OTG

下面的示例显示了如何配置ID引脚以检测角色(外围设备,主机)的全速OTG:

  • OTG ID和数据(DM,DP)引脚:使用Pinctrl device tree configuration 将PA10,PA11和PA12配置为模拟输入。
  • 通过设置“兼容”来使用集成的“全速USB PHY”
  • 双角色(dr_mode)为“ otg”(例如,默认值未指定)
  • 使用vbus稳压器
# part of pin-controller dt node
usbotg_hs_pins_a: usbotg_hs-0 {
	pins {
		pinmux = <STM32_PINMUX('A', 10, ANALOG)>; /* OTG_ID */            /* configure 'PA10' as ANALOG */

	};
};

usbotg_fs_dp_dm_pins_a: usbotg-fs-dp-dm-0 {
	pins {
		pinmux = <STM32_PINMUX('A', 11, ANALOG)>, /* OTG_FS_DM */
			 <STM32_PINMUX('A', 12, ANALOG)>; /* OTG_FS_DP */
	};
};
&usbotg_hs {
	compatible = "st,stm32mp1-fsotg", "snps,dwc2";                            /* Use full-speed integrated PHY */
	pinctrl-names = "default";
	pinctrl-0 = <&usbotg_hs_pins_a &usbotg_fs_dp_dm_pins_a>;                  /* configure OTG ID and full-speed data pins */
	vbus-supply = <&vbus_otg>;                                                /* voltage regulator to supply Vbus */
	status = "okay";
};

DT configuration example as high speed OTG

下面的示例显示了如何使用ID引脚检测角色(外围设备,主机)来配置高速OTG:

  • OTG ID引脚:使用Pinctrl device tree configuration 将PA10配置为模拟输入
  • USB HS PHY端口#2与UTMI开关一起使用以选择OTG控制器
  • 双角色模式(dr_mode)为“ otg”(例如,默认值未指定)
  • 使用vbus稳压器
# part of pin-controller dt node
usbotg_hs_pins_a: usbotg_hs-0 {
	pins {
		pinmux = <STM32_PINMUX('A', 10, ANALOG)>; /* OTG_ID */            /* configure 'PA10' as ANALOG */

	};
};
&usbotg_hs {
	compatible = "st,stm32mp1-hsotg", "snps,dwc2";
	pinctrl-names = "default";
	pinctrl-0 = <&usbotg_hs_pins_a>;                                          /* configure OTG_ID pin */
	phys = <&usbphyc_port1 0>;                                                /* 0: UTMI switch selects the OTG controller */
	phy-names = "usb2-phy";
	vbus-supply = <&vbus_otg>;                                                /* voltage regulator to supply Vbus */
	status = "okay";                                                          /* enable OTG */
};

How to configure the DT using STM32CubeMX

The STM32CubeMX 工具可用于配置STM32MPU设备并获取相应的platform configuration device tree 文件。
STM32CubeMX可能不支持以上DT bindings documentation 段中描述的所有属性。 如果是这样,该工具会在生成的设备树中插入“用户部分”。 然后可以编辑这些部分以添加一些属性,并将它们一代一代地保留下来。 有关更多信息,请参见STM32CubeMX 用户手册。

References

请参考以下链接以获取更多信息: