[PATCH v4 2/2] phy: stm32: Add support for ST STM32MP25 USB2-FEMTO PHY
Marek Vasut
marex at nabladev.com
Wed Sep 2 06:45:05 PDT 2026
On 9/2/26 9:52 AM, Fabrice Gasnier wrote:
[...]
>> +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.
>
>> +
>> + 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 !
More information about the linux-phy
mailing list