USBPHYC device tree configuration

来自百问网嵌入式Linux wiki
Wiki讨论 | 贡献2020年11月11日 (三) 09:28的版本 →‎DT configuration

Article purpose

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

使用 device tree机制执行配置。

“USBPHYC Linux驱动程序”[1] 它将相关信息注册在 PHY framework中。

DT bindings documentation

“ USBPHYC设备树绑定”[2] 描述了所有必需和可选功能。

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

DT configuration

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

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

DT configuration (STM32 level)

USBPHYC节点在stm32mp157c.dtsi[3]中声明。

  • 根节点 usbphyc描述了USBPHYC硬件模块的参数,例如寄存器,时钟,复位和电源。
  • 子节点,例如 usbphyc_port0usbphyc_port1描述了两个高速PHY端口:“端口#1”和“端口#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 该设备树部分与STM32微处理器有关。它必须保持原样,而不能由最终用户修改。

DT configuration (board level)

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

' usbphyc' 根节点必须填写:

  • 通过设置status =“ okay”。来启用USBPHYC模块。
  • 通过设置vdd3v3-supply = <&your_regulator>来配置USBPHYC 3V3稳压器Regulator overview</ref>。
Info.png USB HS PHY端口需要在VDD3V3_USBHS引脚上提供外部3V3电源。

可以调整每个端口的“子节点”:

  • 可选:创建一个usb_phy_tuning节点,该节点可以在DT根文件夹('/')中采用可选参数
  • 可选:在 usbphyc_port0和/或 usbphyc_port1节点中添加st,phy-tuning = <&usb_phy_tuning>以使用此调整。
Info.png 可能有必要调整phy设置以补偿寄生效应,这可能是由于USB连接器/插座,布线,ESD保护组件引起的。

``USBPHYC设备树绑定中提供了可选的调整参数列表[2].


DT configuration example

以下示例显示了如何在板文件中启用和配置USBPHYC端口

&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[4]:

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>