Thread (5 messages) 5 messages, 3 authors, 2026-09-02

Re: [PATCH v4 2/2] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY

From: Marek Vasut <hidden>
Date: 2026-09-02 14:01:27
Also in: linux-devicetree, linux-phy, lkml

On 9/2/26 9:52 AM, Fabrice Gasnier wrote:

[...]
quoted
+static int stm32_usb2phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	u32 mask = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		   SYSCFG_USB2PHY2CR_VBUSVALID |
+		   SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+	u32 val = 0;
+	int ret;
+
+	if (mode == PHY_MODE_USB_HOST) {
+		if (submode != USB_ROLE_NONE)
+			val = SYSCFG_USB2PHY2CR_VBUSVALID;
+	} else if (mode == PHY_MODE_USB_DEVICE) {
+		val = SYSCFG_USB2PHY2CR_USB2PHY2CMN |
+		      SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+		if (submode != USB_ROLE_NONE)
+			val |= SYSCFG_USB2PHY2CR_VBUSVLDEXT;
+		mask |= SYSCFG_USB2PHY2CR_VBUSVLDEXTSEL;
+	} else {
+		return -EINVAL;
+	}
+
+	ret = regmap_update_bits(phy_dev->regmap, phy_dev->cr_offset, mask, val);
+	if (ret)
+		return ret;
+
+	phy_dev->mode = mode;
Hello Marek,

The 'mode' is used typically when exiting low power mode. Should keep
track of the submode too here. See next comment.
quoted
+
+	return 0;
+}
+
+static int stm32_usb2phy1_init(struct phy *phy)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
+	ret = stm32_usb2phy_enable(phy_dev);
+	if (ret)
+		return ret;
+
+	phy_dev->is_init = true;
+
+	return 0;
+}
+
+static int stm32_usb2phy2_init(struct phy *phy)
+{
+	struct stm32_usb2phy *phy_dev = phy_get_drvdata(phy);
+	int ret;
+
+	ret = stm32_usb2phy_enable(phy_dev);
+	if (ret)
+		return ret;
+
+	if (phy_dev->mode != PHY_MODE_INVALID) {
+		ret = stm32_usb2phy_set_mode(phy, phy_dev->mode, USB_ROLE_NONE);
This part restores the mode, when existing from low power: Controller
driver (dwc3) calls phy_init/power_on. The submode should be restored
too here, instead of USB_ROLE_NONE.
Will do in V5, thanks !
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help