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

来自百问网嵌入式Linux wiki
第1行: 第1行:
{{DISPLAYTITLE:USBPHYC设备树配置}}
+
== Article purpose ==
 +
This article explains how to configure the [[USBPHYC internal peripheral|'''USBPHYC''' internal peripheral]] when it is assigned to the Linux<sup>&reg;</sup> OS. In that case, it is controlled by the [[PHY_overview|PHY framework]].
  
[[Category:Linux_Operating_System]]
+
The configuration is performed using the [[Device tree|device tree]] mechanism.
[[Category:High_speed_interface]]
+
 
[[Category:USB]]
+
It is used by the ''USBPHYC Linux driver''<ref>{{CodeSource | Linux kernel | drivers/phy/st/phy-stm32-usbphyc.c}}, STM32 USB PHY Controller driver</ref> which registers the relevant information in [[PHY_overview|PHY framework]].
 +
 
 +
== DT bindings documentation ==
 +
''USBPHYC device tree bindings''<ref name="phy-stm32-usbphyc.txt">{{CodeSource | Linux kernel | Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.txt}}, USBPHYC device tree bindings</ref> describe all the required and optional functions.
 +
 
 +
USBPHYC
 +
      |_ PLL
 +
      |
 +
      |_ PHY port#1 _________________ HOST controller
 +
      |                    _                |
 +
      |                  / 1|________________|
 +
      |_ PHY port#2 ----|  |________________
 +
      |                  \_0|                |
 +
      |_ UTMI switch_______|          OTG controller
 +
 
 +
== 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.
 +
 
 +
'''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) ===
 +
The USBPHYC node is declared in stm32mp157c.dtsi<ref name="stm32mp157c_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp157c.dtsi}}, STM32MP157C device tree file</ref>.
 +
 
 +
* root node e.g. '''usbphyc''' describes the USBPHYC hardware block parameters such as registers, clocks, resets and supplies.
 +
* child nodes e.g. '''usbphyc_port0''' and '''usbphyc_port1''' describe the two high speed PHY ports: ''port#1'' and ''port#2''.
 +
usbphyc: usbphyc@address {
 +
compatible = "st,stm32mp1-usbphyc";
 +
...                                        {{highlight|/* usbphyc resources: registers, clocks, resets and supplies */}}
 +
usbphyc_port0: usb-phy@0 {
 +
...                                {{highlight|/* usbphyc HS PHY port#1 */}}
 +
};
 +
usbphyc_port1: usb-phy@1 {
 +
...                                {{highlight|/* usbphyc HS PHY port#2 */}}
 +
};
 +
};
 +
{{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}}
 +
 
 +
=== DT configuration (board level) ===
 +
Follow the sequences described in the below chapters to configure and enable the USBPHYC on your board.
 +
 
 +
The ''''usbphyc'''' '''root node''' must be filled in:
 +
* Enable the USBPHYC block by setting '''status = "okay".'''
 +
* Configure the USBPHYC 3V3 regulator<ref name="Regulator overview">[[Regulator overview]]</ref> by setting '''vdd3v3-supply = <&your_regulator>'''.
 +
{{Info| USB HS PHY ports require an external 3V3 power supply to be provided at VDD3V3_USBHS pin.}}
 +
 
 +
The '''child nodes''' for each port may be tuned:
 +
* Optional: create a '''usb_phy_tuning''' node that can take optional parameters in DT root folder ('/')
 +
* Optional: add ''''st,phy-tuning = <&usb_phy_tuning>'''' in ''''usbphyc_port0'''' and/or ''''usbphyc_port1'''' node to use this tuning.
 +
{{Info| It may be necessary to adjust the phy settings to compensate parasitics, which can be due to USB connector/receptacle, routing, ESD protection component.
 +
Optional tuning parameter list is available in ''USBPHYC device tree bindings''<ref name="phy-stm32-usbphyc.txt"/>.}}
 +
{{ReviewsComments|FGA W902: Later add reference link to the application note that explains how to tune these parameters (once published)}}
 +
 
 +
=== DT configuration example ===
 +
The example below shows how to enable and configure USBPHYC ports in the board file
 +
&usbphyc {
 +
vdd3v3-supply = <&vdd_usb>;                {{highlight|/* references the 3V3 voltage regulator on the user board */}}
 +
status = "okay";                            {{highlight|/* enable USB HS PHY controller */}}
 +
};
 +
 +
&usbphyc_port0 {
 +
st,phy-tuning = <&usb_phy_tuning>;          {{highlight|/* Optional USB HS PHY port#1 tuning */}}
 +
};
 +
 +
&usbphyc_port1 {
 +
st,phy-tuning = <&usb_phy_tuning>;          {{highlight|/* Optional USB HS PHY port#2 tuning */}}
 +
};
 +
 
 +
/ {                                                {{highlight|/* Optional USB HS PHY tuning example, to be added in DT root node, e.g. '/' */}}
 +
usb_phy_tuning: usb-phy-tuning {
 +
st,current-boost = <2>;
 +
st,no-lfs-fb-cap;
 +
st,hs-dc-level = <2>;
 +
st,hs-rftime-reduction;
 +
st,hs-current-trim = <5>;
 +
st,hs-impedance-trim = <0>;
 +
st,squelch-level = <1>;
 +
st,no-hs-ftime-ctrl;
 +
st,hs-tx-staggering;
 +
};
 +
};
 +
{{Info| Static configuration of the UTMI switch to assign the '''port#2''' to either [[USBH_internal_peripheral|USBH]] or [[OTG_internal_peripheral|OTG]] is done by the '''PHY user node'''<ref>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/phy/phy-bindings.txt}},PHY generic bindings</ref>:
 +
* Please refer to [[USBH_device_tree_configuration]]
 +
* Please refer to [[OTG_device_tree_configuration]]
 +
'''usbphyc_port1''' user must configure an additional specifier for UTMI switch: '''0 to select OTG''', '''1 to select USBH'''
 +
}}
 +
Abstract of the example to configure port#2, to be assigned to the USBH:
 +
&usbh_ehci {
 +
phys = <&usbphyc_port0>, <&usbphyc_port1 {{highlight|'''1'''}}>; {{highlight|/* '''1''': UTMI switch selects the USBH */}}
 +
phy-names = "usb", "usb";
 +
...
 +
}
 +
Abstract of the example to configure port#2, to be assigned to the OTG:
 +
&usbotg_hs {
 +
phys = <&usbphyc_port1 {{highlight|'''0'''}}>;                  {{highlight|/* '''0''': UTMI switch selects the OTG */}}
 +
phy-names = "usb2-phy";
 +
...
 +
}
 +
 
 +
==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 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.
 +
 
 +
==References==
 +
Please refer to the following links for additional information:
 +
 
 +
<references />
 +
 
 +
<noinclude>
 +
[[Category:Device tree configuration]]
 +
[[Category:USB]]
 +
{{PublicationRequestId | 10329 | 2019-01-15 | AlainF}}
 +
{{ArticleBasedOnModel | Peripheral or framework device tree configuration model}}
 +
</noinclude>

2020年5月6日 (三) 22:20的版本

Article purpose

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

The configuration is performed using the device tree mechanism.

It is used by the USBPHYC Linux driver[1] which registers the relevant information in PHY framework.

DT bindings documentation

USBPHYC device tree bindings[2] describe all the required and optional functions.

USBPHYC
      |_ PLL
      |
      |_ PHY port#1 _________________ HOST controller
      |                    _                 |
      |                  / 1|________________|
      |_ PHY port#2 ----|   |________________
      |                  \_0|                |
      |_ UTMI switch_______|          OTG controller

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.

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

DT configuration (STM32 level)

The USBPHYC node is declared in stm32mp157c.dtsi[3].

  • root node e.g. usbphyc describes the USBPHYC hardware block parameters such as registers, clocks, resets and supplies.
  • child nodes e.g. usbphyc_port0 and usbphyc_port1 describe the two high speed PHY ports: port#1 and port#2.
usbphyc: usbphyc@address {
	compatible = "st,stm32mp1-usbphyc";
	...                                         /* usbphyc resources: registers, clocks, resets and supplies */
	usbphyc_port0: usb-phy@0 {
		...                                 /* usbphyc HS PHY port#1 */
	};
	usbphyc_port1: usb-phy@1 {
		...                                 /* usbphyc HS PHY port#2 */
	};
};
Warning.png This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.

DT configuration (board level)

Follow the sequences described in the below chapters to configure and enable the USBPHYC on your board.

The 'usbphyc' root node must be filled in:

  • Enable the USBPHYC block by setting status = "okay".
  • Configure the USBPHYC 3V3 regulator[4] by setting vdd3v3-supply = <&your_regulator>.
Info.png USB HS PHY ports require an external 3V3 power supply to be provided at VDD3V3_USBHS pin.

The child nodes for each port may be tuned:

  • Optional: create a usb_phy_tuning node that can take optional parameters in DT root folder ('/')
  • Optional: add 'st,phy-tuning = <&usb_phy_tuning>' in 'usbphyc_port0' and/or 'usbphyc_port1' node to use this tuning.
Info.png It may be necessary to adjust the phy settings to compensate parasitics, which can be due to USB connector/receptacle, routing, ESD protection component.

Optional tuning parameter list is available in USBPHYC device tree bindings[2].

<securetransclude src="ProtectedTemplate:ReviewsComments" params="FGA W902: Later add reference link to the application note that explains how to tune these parameters (once published)"></securetransclude>{{#set:Has reviews comments=true}}

DT configuration example

The example below shows how to enable and configure USBPHYC ports in the board file

&usbphyc {
	vdd3v3-supply = <&vdd_usb>;                 /* references the 3V3 voltage regulator on the user board */
	status = "okay";                            /* enable USB HS PHY controller */
};

&usbphyc_port0 {
	st,phy-tuning = <&usb_phy_tuning>;          /* Optional USB HS PHY port#1 tuning */
};

&usbphyc_port1 {
	st,phy-tuning = <&usb_phy_tuning>;          /* Optional USB HS PHY port#2 tuning */
};
/ {                                                 /* Optional USB HS PHY tuning example, to be added in DT root node, e.g. '/' */
	usb_phy_tuning: usb-phy-tuning {
		st,current-boost = <2>;
		st,no-lfs-fb-cap;
		st,hs-dc-level = <2>;
		st,hs-rftime-reduction;
		st,hs-current-trim = <5>;
		st,hs-impedance-trim = <0>;
		st,squelch-level = <1>;
		st,no-hs-ftime-ctrl;
		st,hs-tx-staggering;
	};
};
Info.png Static configuration of the UTMI switch to assign the port#2 to either USBH or OTG is done by the PHY user node[5]:

usbphyc_port1 user must configure an additional specifier for UTMI switch: 0 to select OTG, 1 to select USBH

Abstract of the example to configure port#2, to be assigned to the USBH:

&usbh_ehci {
	phys = <&usbphyc_port0>, <&usbphyc_port1 1>; /* 1: UTMI switch selects the USBH */
	phy-names = "usb", "usb";
	...
}

Abstract of the example to configure port#2, to be assigned to the OTG:

&usbotg_hs {
	phys = <&usbphyc_port1 0>;                  /* 0: UTMI switch selects the OTG */
	phy-names = "usb2-phy";
	...
}

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="10329 | 2019-01-15 | AlainF"></securetransclude> <securetransclude src="ProtectedTemplate:ArticleBasedOnModel" params="Peripheral or framework device tree configuration model"></securetransclude>