Skip to main content
Associate
July 22, 2025
Solved

stm32mp255 USB-C VBUS GPIO device tree configuration

  • July 22, 2025
  • 1 reply
  • 811 views
I am trying to configure a USB-C connector on a peripheral device to detect VBUS via GPIO (PH9). I have tried several iterations using the following device tree documentation.
The only way I have been able to get USB traffic to occur is by using the role-switch-default-mode attribute, but that comes with the warning about VBUS:
Forcing default mode bypasses the vbus detection, which is normally required to raise the pull-up resistor on D+ data line. This makes it non compliant with USB specifications. Recommended method to implement peripheral only role, is to use GPIO to detect Vbus,
 
And I suspect this warning is the reason why USB traffic doesn't come back after coming back out of suspend/low-power mode.
Example snippet of a configuration I've tried is as follows:
/ {
	usb_c_connector {
		compatible = "usb-c-connector";
		label = "USB-C Connector";
		type = "usb-c";
		vbus-gpios = <&gpioh 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
		vbus-supply = <&scmi_vdd3v3_usb>;

		port {
			dwc3_ep: endpoint {
				remote-endpoint = <&typec_ep>;
			};
		};
	};
};
&usb3dr {
	status = "okay";

	dwc3:usb@48300000{
		maximum-speed = "high-speed";
		usb-role-switch;

		port {
			typec_ep: endpoint {
				remote-endpoint = <&dwc3_ep>;
			};
		};
 };
};
 
Is there an example using the DWC3 driver with a `typec` connector and/or VBUS via GPIO?
Best answer by erich664
/ {
 usb-b-connector {
 compatible = "gpio-usb-b-connector", "usb-b-connector";
 label = "USB-C";
 type = "mini";
 vbus-gpios = <&gpioh 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;

 port {
 con_usb3dr_ep: endpoint {
 remote-endpoint = <&usb3dr_ep>;
 };
 };
 };
};
&usb3dr {
 status = "okay";

 /* USER CODE BEGIN usb3dr */
 dwc3:usb@48300000{
 maximum-speed = "high-speed";
 usb-role-switch;
 port {
 usb3dr_ep: endpoint {
 remote-endpoint = <&con_usb3dr_ep>;
 };
 };
 };
 /* USER CODE END usb3dr */
};

I was able to end up getting this working with the following device tree configuration:

 

1 reply

erich664AuthorBest answer
Associate
September 3, 2025
/ {
 usb-b-connector {
 compatible = "gpio-usb-b-connector", "usb-b-connector";
 label = "USB-C";
 type = "mini";
 vbus-gpios = <&gpioh 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;

 port {
 con_usb3dr_ep: endpoint {
 remote-endpoint = <&usb3dr_ep>;
 };
 };
 };
};
&usb3dr {
 status = "okay";

 /* USER CODE BEGIN usb3dr */
 dwc3:usb@48300000{
 maximum-speed = "high-speed";
 usb-role-switch;
 port {
 usb3dr_ep: endpoint {
 remote-endpoint = <&con_usb3dr_ep>;
 };
 };
 };
 /* USER CODE END usb3dr */
};

I was able to end up getting this working with the following device tree configuration: