* [PATCH] phy: renesas: rcar-gen3-usb2: Add suspend/resume support
@ 2025-11-06 14:41 Claudiu
2025-11-18 13:54 ` Neil Armstrong
0 siblings, 1 reply; 5+ messages in thread
From: Claudiu @ 2025-11-06 14:41 UTC (permalink / raw)
To: yoshihiro.shimoda.uh, vkoul, kishon, geert+renesas, magnus.damm,
p.zabel
Cc: claudiu.beznea, linux-renesas-soc, linux-phy, linux-kernel,
Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The Renesas RZ/G3S supports a power saving mode where power to most of the
SoC components is turned off. The USB PHY is among these components.
Because of this the settings applied in driver probe need to be executed
also on resume path. On suspend path only reset signal need to be asserted.
Add suspend/resume support.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
This patch is built on top of patches 1/7, 2/7 at [1]
[1] https://lore.kernel.org/all/20251023135810.1688415-2-claudiu.beznea.uj@bp.renesas.com
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 66 +++++++++++++++++-------
1 file changed, 47 insertions(+), 19 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index a38ead7c8055..3c063e4dea41 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -132,6 +132,7 @@ struct rcar_gen3_chan {
struct device *dev; /* platform_device's device */
const struct rcar_gen3_phy_drv_data *phy_data;
struct extcon_dev *extcon;
+ struct reset_control *rstc;
struct rcar_gen3_phy rphys[NUM_OF_PHYS];
struct regulator *vbus;
struct work_struct work;
@@ -778,35 +779,24 @@ static void rcar_gen3_reset_assert(void *data)
static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
{
struct device *dev = channel->dev;
- struct reset_control *rstc;
int ret;
u32 val;
- rstc = devm_reset_control_array_get_shared(dev);
- if (IS_ERR(rstc))
- return PTR_ERR(rstc);
+ if (!channel->phy_data->init_bus)
+ return 0;
ret = pm_runtime_resume_and_get(dev);
if (ret)
return ret;
- ret = reset_control_deassert(rstc);
- if (ret)
- goto rpm_put;
-
- ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, rstc);
- if (ret)
- goto rpm_put;
-
val = readl(channel->base + USB2_AHB_BUS_CTR);
val &= ~USB2_AHB_BUS_CTR_MBL_MASK;
val |= USB2_AHB_BUS_CTR_MBL_INCR4;
writel(val, channel->base + USB2_AHB_BUS_CTR);
-rpm_put:
pm_runtime_put(dev);
- return ret;
+ return 0;
}
static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
@@ -846,6 +836,18 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
}
}
+ channel->rstc = devm_reset_control_array_get_optional_shared(dev);
+ if (IS_ERR(channel->rstc))
+ return PTR_ERR(channel->rstc);
+
+ ret = reset_control_deassert(channel->rstc);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, channel->rstc);
+ if (ret)
+ return ret;
+
/*
* devm_phy_create() will call pm_runtime_enable(&phy->dev);
* And then, phy-core will manage runtime pm for this device.
@@ -861,11 +863,9 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, channel);
channel->dev = dev;
- if (channel->phy_data->init_bus) {
- ret = rcar_gen3_phy_usb2_init_bus(channel);
- if (ret)
- goto error;
- }
+ ret = rcar_gen3_phy_usb2_init_bus(channel);
+ if (ret)
+ goto error;
spin_lock_init(&channel->lock);
for (i = 0; i < NUM_OF_PHYS; i++) {
@@ -936,10 +936,38 @@ static void rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
};
+static int rcar_gen3_phy_usb2_suspend(struct device *dev)
+{
+ struct rcar_gen3_chan *channel = dev_get_drvdata(dev);
+
+ return reset_control_assert(channel->rstc);
+}
+
+static int rcar_gen3_phy_usb2_resume(struct device *dev)
+{
+ struct rcar_gen3_chan *channel = dev_get_drvdata(dev);
+ int ret;
+
+ ret = reset_control_deassert(channel->rstc);
+ if (ret)
+ return ret;
+
+ ret = rcar_gen3_phy_usb2_init_bus(channel);
+ if (ret)
+ reset_control_assert(channel->rstc);
+
+ return ret;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(rcar_gen3_phy_usb2_pm_ops,
+ rcar_gen3_phy_usb2_suspend,
+ rcar_gen3_phy_usb2_resume);
+
static struct platform_driver rcar_gen3_phy_usb2_driver = {
.driver = {
.name = "phy_rcar_gen3_usb2",
.of_match_table = rcar_gen3_phy_usb2_match_table,
+ .pm = pm_ptr(&rcar_gen3_phy_usb2_pm_ops),
},
.probe = rcar_gen3_phy_usb2_probe,
.remove = rcar_gen3_phy_usb2_remove,
--
2.43.0
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] phy: renesas: rcar-gen3-usb2: Add suspend/resume support
2025-11-06 14:41 [PATCH] phy: renesas: rcar-gen3-usb2: Add suspend/resume support Claudiu
@ 2025-11-18 13:54 ` Neil Armstrong
2025-11-18 14:13 ` Claudiu Beznea
0 siblings, 1 reply; 5+ messages in thread
From: Neil Armstrong @ 2025-11-18 13:54 UTC (permalink / raw)
To: Claudiu, yoshihiro.shimoda.uh, vkoul, kishon, geert+renesas,
magnus.damm, p.zabel
Cc: linux-renesas-soc, linux-phy, linux-kernel, Claudiu Beznea
On 11/6/25 15:41, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> The Renesas RZ/G3S supports a power saving mode where power to most of the
> SoC components is turned off. The USB PHY is among these components.
> Because of this the settings applied in driver probe need to be executed
> also on resume path. On suspend path only reset signal need to be asserted.
> Add suspend/resume support.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
>
> This patch is built on top of patches 1/7, 2/7 at [1]
>
> [1] https://lore.kernel.org/all/20251023135810.1688415-2-claudiu.beznea.uj@bp.renesas.com
>
> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 66 +++++++++++++++++-------
> 1 file changed, 47 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index a38ead7c8055..3c063e4dea41 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -132,6 +132,7 @@ struct rcar_gen3_chan {
> struct device *dev; /* platform_device's device */
> const struct rcar_gen3_phy_drv_data *phy_data;
> struct extcon_dev *extcon;
> + struct reset_control *rstc;
> struct rcar_gen3_phy rphys[NUM_OF_PHYS];
> struct regulator *vbus;
> struct work_struct work;
> @@ -778,35 +779,24 @@ static void rcar_gen3_reset_assert(void *data)
> static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
> {
> struct device *dev = channel->dev;
> - struct reset_control *rstc;
> int ret;
> u32 val;
>
> - rstc = devm_reset_control_array_get_shared(dev);
> - if (IS_ERR(rstc))
> - return PTR_ERR(rstc);
> + if (!channel->phy_data->init_bus)
> + return 0;
>
> ret = pm_runtime_resume_and_get(dev);
> if (ret)
> return ret;
>
> - ret = reset_control_deassert(rstc);
> - if (ret)
> - goto rpm_put;
> -
> - ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, rstc);
> - if (ret)
> - goto rpm_put;
> -
> val = readl(channel->base + USB2_AHB_BUS_CTR);
> val &= ~USB2_AHB_BUS_CTR_MBL_MASK;
> val |= USB2_AHB_BUS_CTR_MBL_INCR4;
> writel(val, channel->base + USB2_AHB_BUS_CTR);
>
> -rpm_put:
> pm_runtime_put(dev);
>
> - return ret;
> + return 0;
> }
>
> static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> @@ -846,6 +836,18 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> }
> }
>
> + channel->rstc = devm_reset_control_array_get_optional_shared(dev);
> + if (IS_ERR(channel->rstc))
> + return PTR_ERR(channel->rstc);
> +
> + ret = reset_control_deassert(channel->rstc);
> + if (ret)
> + return ret;
> +
> + ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, channel->rstc);
> + if (ret)
> + return ret;
> +
> /*
> * devm_phy_create() will call pm_runtime_enable(&phy->dev);
> * And then, phy-core will manage runtime pm for this device.
> @@ -861,11 +863,9 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, channel);
> channel->dev = dev;
>
> - if (channel->phy_data->init_bus) {
> - ret = rcar_gen3_phy_usb2_init_bus(channel);
> - if (ret)
> - goto error;
> - }
I don't see why you changed the logic of calling rcar_gen3_phy_usb2_init_bus(),
moving the reset setup and handling should be enough, no ?
Neil
> + ret = rcar_gen3_phy_usb2_init_bus(channel);
> + if (ret)
> + goto error;
>
> spin_lock_init(&channel->lock);
> for (i = 0; i < NUM_OF_PHYS; i++) {
> @@ -936,10 +936,38 @@ static void rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
> pm_runtime_disable(&pdev->dev);
> };
>
> +static int rcar_gen3_phy_usb2_suspend(struct device *dev)
> +{
> + struct rcar_gen3_chan *channel = dev_get_drvdata(dev);
> +
> + return reset_control_assert(channel->rstc);
> +}
> +
> +static int rcar_gen3_phy_usb2_resume(struct device *dev)
> +{
> + struct rcar_gen3_chan *channel = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = reset_control_deassert(channel->rstc);
> + if (ret)
> + return ret;
> +
> + ret = rcar_gen3_phy_usb2_init_bus(channel);
> + if (ret)
> + reset_control_assert(channel->rstc);
> +
> + return ret;
> +}
> +
> +static DEFINE_SIMPLE_DEV_PM_OPS(rcar_gen3_phy_usb2_pm_ops,
> + rcar_gen3_phy_usb2_suspend,
> + rcar_gen3_phy_usb2_resume);
> +
> static struct platform_driver rcar_gen3_phy_usb2_driver = {
> .driver = {
> .name = "phy_rcar_gen3_usb2",
> .of_match_table = rcar_gen3_phy_usb2_match_table,
> + .pm = pm_ptr(&rcar_gen3_phy_usb2_pm_ops),
> },
> .probe = rcar_gen3_phy_usb2_probe,
> .remove = rcar_gen3_phy_usb2_remove,
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] phy: renesas: rcar-gen3-usb2: Add suspend/resume support
2025-11-18 13:54 ` Neil Armstrong
@ 2025-11-18 14:13 ` Claudiu Beznea
2025-11-18 14:13 ` Claudiu Beznea
2025-11-18 15:03 ` Neil Armstrong
0 siblings, 2 replies; 5+ messages in thread
From: Claudiu Beznea @ 2025-11-18 14:13 UTC (permalink / raw)
To: Neil Armstrong, yoshihiro.shimoda.uh, vkoul, kishon,
geert+renesas, magnus.damm, p.zabel
Cc: linux-renesas-soc, linux-phy, linux-kernel, Claudiu Beznea
Hi, Neil,
On 11/18/25 15:54, Neil Armstrong wrote:
> On 11/6/25 15:41, Claudiu wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> The Renesas RZ/G3S supports a power saving mode where power to most of the
>> SoC components is turned off. The USB PHY is among these components.
>> Because of this the settings applied in driver probe need to be executed
>> also on resume path. On suspend path only reset signal need to be asserted.
>> Add suspend/resume support.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>> ---
>>
>> This patch is built on top of patches 1/7, 2/7 at [1]
>>
>> [1] https://lore.kernel.org/all/20251023135810.1688415-2-
>> claudiu.beznea.uj@bp.renesas.com
>>
>> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 66 +++++++++++++++++-------
>> 1 file changed, 47 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/
>> renesas/phy-rcar-gen3-usb2.c
>> index a38ead7c8055..3c063e4dea41 100644
>> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>> @@ -132,6 +132,7 @@ struct rcar_gen3_chan {
>> struct device *dev; /* platform_device's device */
>> const struct rcar_gen3_phy_drv_data *phy_data;
>> struct extcon_dev *extcon;
>> + struct reset_control *rstc;
>> struct rcar_gen3_phy rphys[NUM_OF_PHYS];
>> struct regulator *vbus;
>> struct work_struct work;
>> @@ -778,35 +779,24 @@ static void rcar_gen3_reset_assert(void *data)
>> static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
>> {
>> struct device *dev = channel->dev;
>> - struct reset_control *rstc;
>> int ret;
>> u32 val;
>> - rstc = devm_reset_control_array_get_shared(dev);
>> - if (IS_ERR(rstc))
>> - return PTR_ERR(rstc);
>> + if (!channel->phy_data->init_bus)
>> + return 0;
>> ret = pm_runtime_resume_and_get(dev);
>> if (ret)
>> return ret;
>> - ret = reset_control_deassert(rstc);
>> - if (ret)
>> - goto rpm_put;
>> -
>> - ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, rstc);
>> - if (ret)
>> - goto rpm_put;
>> -
>> val = readl(channel->base + USB2_AHB_BUS_CTR);
>> val &= ~USB2_AHB_BUS_CTR_MBL_MASK;
>> val |= USB2_AHB_BUS_CTR_MBL_INCR4;
>> writel(val, channel->base + USB2_AHB_BUS_CTR);
>> -rpm_put:
>> pm_runtime_put(dev);
>> - return ret;
>> + return 0;
>> }
>> static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>> @@ -846,6 +836,18 @@ static int rcar_gen3_phy_usb2_probe(struct
>> platform_device *pdev)
>> }
>> }
>> + channel->rstc = devm_reset_control_array_get_optional_shared(dev);
>> + if (IS_ERR(channel->rstc))
>> + return PTR_ERR(channel->rstc);
>> +
>> + ret = reset_control_deassert(channel->rstc);
>> + if (ret)
>> + return ret;
>> +
>> + ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, channel-
>> >rstc);
>> + if (ret)
>> + return ret;
>> +
>> /*
>> * devm_phy_create() will call pm_runtime_enable(&phy->dev);
>> * And then, phy-core will manage runtime pm for this device.
>> @@ -861,11 +863,9 @@ static int rcar_gen3_phy_usb2_probe(struct
>> platform_device *pdev)
>> platform_set_drvdata(pdev, channel);
>> channel->dev = dev;
>> - if (channel->phy_data->init_bus) {
>> - ret = rcar_gen3_phy_usb2_init_bus(channel);
>> - if (ret)
>> - goto error;
>> - }
>
> I don't see why you changed the logic of calling
> rcar_gen3_phy_usb2_init_bus(),
> moving the reset setup and handling should be enough, no ?
>
Sorry, I missed to mention it. I did it like this just to avoid this pattern:
if (channel->phy_data->init_bus) {
ret = rcar_gen3_phy_usb2_init_bus(channel);
if (ret)
return ret;
}
in both probe and resume path. The channel->phy_data->init_bus check is not
embedded in rcar_gen3_phy_usb2_init_bus(). Please let me know if you want
me to revert it.
Thank you,
Claudiu
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] phy: renesas: rcar-gen3-usb2: Add suspend/resume support
2025-11-18 14:13 ` Claudiu Beznea
@ 2025-11-18 14:13 ` Claudiu Beznea
2025-11-18 15:03 ` Neil Armstrong
1 sibling, 0 replies; 5+ messages in thread
From: Claudiu Beznea @ 2025-11-18 14:13 UTC (permalink / raw)
To: Neil Armstrong, yoshihiro.shimoda.uh, vkoul, kishon,
geert+renesas, magnus.damm, p.zabel
Cc: linux-renesas-soc, linux-phy, linux-kernel, Claudiu Beznea
On 11/18/25 16:13, Claudiu Beznea wrote:
> Hi, Neil,
>
> On 11/18/25 15:54, Neil Armstrong wrote:
>> On 11/6/25 15:41, Claudiu wrote:
>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>
>>> The Renesas RZ/G3S supports a power saving mode where power to most of the
>>> SoC components is turned off. The USB PHY is among these components.
>>> Because of this the settings applied in driver probe need to be executed
>>> also on resume path. On suspend path only reset signal need to be asserted.
>>> Add suspend/resume support.
>>>
>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>> ---
>>>
>>> This patch is built on top of patches 1/7, 2/7 at [1]
>>>
>>> [1] https://lore.kernel.org/all/20251023135810.1688415-2-
>>> claudiu.beznea.uj@bp.renesas.com
>>>
>>> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 66 +++++++++++++++++-------
>>> 1 file changed, 47 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/
>>> renesas/phy-rcar-gen3-usb2.c
>>> index a38ead7c8055..3c063e4dea41 100644
>>> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> @@ -132,6 +132,7 @@ struct rcar_gen3_chan {
>>> struct device *dev; /* platform_device's device */
>>> const struct rcar_gen3_phy_drv_data *phy_data;
>>> struct extcon_dev *extcon;
>>> + struct reset_control *rstc;
>>> struct rcar_gen3_phy rphys[NUM_OF_PHYS];
>>> struct regulator *vbus;
>>> struct work_struct work;
>>> @@ -778,35 +779,24 @@ static void rcar_gen3_reset_assert(void *data)
>>> static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
>>> {
>>> struct device *dev = channel->dev;
>>> - struct reset_control *rstc;
>>> int ret;
>>> u32 val;
>>> - rstc = devm_reset_control_array_get_shared(dev);
>>> - if (IS_ERR(rstc))
>>> - return PTR_ERR(rstc);
>>> + if (!channel->phy_data->init_bus)
>>> + return 0;
>>> ret = pm_runtime_resume_and_get(dev);
>>> if (ret)
>>> return ret;
>>> - ret = reset_control_deassert(rstc);
>>> - if (ret)
>>> - goto rpm_put;
>>> -
>>> - ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, rstc);
>>> - if (ret)
>>> - goto rpm_put;
>>> -
>>> val = readl(channel->base + USB2_AHB_BUS_CTR);
>>> val &= ~USB2_AHB_BUS_CTR_MBL_MASK;
>>> val |= USB2_AHB_BUS_CTR_MBL_INCR4;
>>> writel(val, channel->base + USB2_AHB_BUS_CTR);
>>> -rpm_put:
>>> pm_runtime_put(dev);
>>> - return ret;
>>> + return 0;
>>> }
>>> static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>>> @@ -846,6 +836,18 @@ static int rcar_gen3_phy_usb2_probe(struct
>>> platform_device *pdev)
>>> }
>>> }
>>> + channel->rstc = devm_reset_control_array_get_optional_shared(dev);
>>> + if (IS_ERR(channel->rstc))
>>> + return PTR_ERR(channel->rstc);
>>> +
>>> + ret = reset_control_deassert(channel->rstc);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, channel-
>>>> rstc);
>>> + if (ret)
>>> + return ret;
>>> +
>>> /*
>>> * devm_phy_create() will call pm_runtime_enable(&phy->dev);
>>> * And then, phy-core will manage runtime pm for this device.
>>> @@ -861,11 +863,9 @@ static int rcar_gen3_phy_usb2_probe(struct
>>> platform_device *pdev)
>>> platform_set_drvdata(pdev, channel);
>>> channel->dev = dev;
>>> - if (channel->phy_data->init_bus) {
>>> - ret = rcar_gen3_phy_usb2_init_bus(channel);
>>> - if (ret)
>>> - goto error;
>>> - }
>>
>> I don't see why you changed the logic of calling
>> rcar_gen3_phy_usb2_init_bus(),
>> moving the reset setup and handling should be enough, no ?
>>
> Sorry, I missed to mention it. I did it like this just to avoid this pattern:
>
> if (channel->phy_data->init_bus) {
> ret = rcar_gen3_phy_usb2_init_bus(channel);
> if (ret)
> return ret;
> }
>
> in both probe and resume path. The channel->phy_data->init_bus check is not
s/not/now
> embedded in rcar_gen3_phy_usb2_init_bus(). Please let me know if you want
> me to revert it.
>
> Thank you,
> Claudiu
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] phy: renesas: rcar-gen3-usb2: Add suspend/resume support
2025-11-18 14:13 ` Claudiu Beznea
2025-11-18 14:13 ` Claudiu Beznea
@ 2025-11-18 15:03 ` Neil Armstrong
1 sibling, 0 replies; 5+ messages in thread
From: Neil Armstrong @ 2025-11-18 15:03 UTC (permalink / raw)
To: Claudiu Beznea, yoshihiro.shimoda.uh, vkoul, kishon,
geert+renesas, magnus.damm, p.zabel
Cc: linux-renesas-soc, linux-phy, linux-kernel, Claudiu Beznea
On 11/18/25 15:13, Claudiu Beznea wrote:
> Hi, Neil,
>
> On 11/18/25 15:54, Neil Armstrong wrote:
>> On 11/6/25 15:41, Claudiu wrote:
>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>
>>> The Renesas RZ/G3S supports a power saving mode where power to most of the
>>> SoC components is turned off. The USB PHY is among these components.
>>> Because of this the settings applied in driver probe need to be executed
>>> also on resume path. On suspend path only reset signal need to be asserted.
>>> Add suspend/resume support.
>>>
>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>> ---
>>>
>>> This patch is built on top of patches 1/7, 2/7 at [1]
>>>
>>> [1] https://lore.kernel.org/all/20251023135810.1688415-2-
>>> claudiu.beznea.uj@bp.renesas.com
>>>
>>> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 66 +++++++++++++++++-------
>>> 1 file changed, 47 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/
>>> renesas/phy-rcar-gen3-usb2.c
>>> index a38ead7c8055..3c063e4dea41 100644
>>> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
>>> @@ -132,6 +132,7 @@ struct rcar_gen3_chan {
>>> struct device *dev; /* platform_device's device */
>>> const struct rcar_gen3_phy_drv_data *phy_data;
>>> struct extcon_dev *extcon;
>>> + struct reset_control *rstc;
>>> struct rcar_gen3_phy rphys[NUM_OF_PHYS];
>>> struct regulator *vbus;
>>> struct work_struct work;
>>> @@ -778,35 +779,24 @@ static void rcar_gen3_reset_assert(void *data)
>>> static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
>>> {
>>> struct device *dev = channel->dev;
>>> - struct reset_control *rstc;
>>> int ret;
>>> u32 val;
>>> - rstc = devm_reset_control_array_get_shared(dev);
>>> - if (IS_ERR(rstc))
>>> - return PTR_ERR(rstc);
>>> + if (!channel->phy_data->init_bus)
>>> + return 0;
>>> ret = pm_runtime_resume_and_get(dev);
>>> if (ret)
>>> return ret;
>>> - ret = reset_control_deassert(rstc);
>>> - if (ret)
>>> - goto rpm_put;
>>> -
>>> - ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, rstc);
>>> - if (ret)
>>> - goto rpm_put;
>>> -
>>> val = readl(channel->base + USB2_AHB_BUS_CTR);
>>> val &= ~USB2_AHB_BUS_CTR_MBL_MASK;
>>> val |= USB2_AHB_BUS_CTR_MBL_INCR4;
>>> writel(val, channel->base + USB2_AHB_BUS_CTR);
>>> -rpm_put:
>>> pm_runtime_put(dev);
>>> - return ret;
>>> + return 0;
>>> }
>>> static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
>>> @@ -846,6 +836,18 @@ static int rcar_gen3_phy_usb2_probe(struct
>>> platform_device *pdev)
>>> }
>>> }
>>> + channel->rstc = devm_reset_control_array_get_optional_shared(dev);
>>> + if (IS_ERR(channel->rstc))
>>> + return PTR_ERR(channel->rstc);
>>> +
>>> + ret = reset_control_deassert(channel->rstc);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, channel-
>>>> rstc);
>>> + if (ret)
>>> + return ret;
>>> +
>>> /*
>>> * devm_phy_create() will call pm_runtime_enable(&phy->dev);
>>> * And then, phy-core will manage runtime pm for this device.
>>> @@ -861,11 +863,9 @@ static int rcar_gen3_phy_usb2_probe(struct
>>> platform_device *pdev)
>>> platform_set_drvdata(pdev, channel);
>>> channel->dev = dev;
>>> - if (channel->phy_data->init_bus) {
>>> - ret = rcar_gen3_phy_usb2_init_bus(channel);
>>> - if (ret)
>>> - goto error;
>>> - }
>>
>> I don't see why you changed the logic of calling
>> rcar_gen3_phy_usb2_init_bus(),
>> moving the reset setup and handling should be enough, no ?
>>
> Sorry, I missed to mention it. I did it like this just to avoid this pattern:
>
> if (channel->phy_data->init_bus) {
> ret = rcar_gen3_phy_usb2_init_bus(channel);
> if (ret)
> return ret;
> }
>
> in both probe and resume path. The channel->phy_data->init_bus check is not
> embedded in rcar_gen3_phy_usb2_init_bus(). Please let me know if you want
> me to revert it.
It's an unrelated change, so I think it should be moved to a separate cleanup patch.
Thanks,
Neil
>
> Thank you,
> Claudiu
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-18 15:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 14:41 [PATCH] phy: renesas: rcar-gen3-usb2: Add suspend/resume support Claudiu
2025-11-18 13:54 ` Neil Armstrong
2025-11-18 14:13 ` Claudiu Beznea
2025-11-18 14:13 ` Claudiu Beznea
2025-11-18 15:03 ` Neil Armstrong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox