Skip to content

Commit 942a7a6

Browse files
claudiubezneavinodkoul
authored andcommitted
phy: renesas: rcar-gen3-usb2: Add suspend/resume support
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> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patch.msgid.link/20251119120418.686224-3-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 79d9db7 commit 942a7a6

1 file changed

Lines changed: 42 additions & 15 deletions

File tree

drivers/phy/renesas/phy-rcar-gen3-usb2.c

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ struct rcar_gen3_chan {
132132
struct device *dev; /* platform_device's device */
133133
const struct rcar_gen3_phy_drv_data *phy_data;
134134
struct extcon_dev *extcon;
135+
struct reset_control *rstc;
135136
struct rcar_gen3_phy rphys[NUM_OF_PHYS];
136137
struct regulator *vbus;
137138
struct work_struct work;
@@ -778,38 +779,24 @@ static void rcar_gen3_reset_assert(void *data)
778779
static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
779780
{
780781
struct device *dev = channel->dev;
781-
struct reset_control *rstc;
782782
int ret;
783783
u32 val;
784784

785785
if (!channel->phy_data->init_bus)
786786
return 0;
787787

788-
rstc = devm_reset_control_array_get_shared(dev);
789-
if (IS_ERR(rstc))
790-
return PTR_ERR(rstc);
791-
792788
ret = pm_runtime_resume_and_get(dev);
793789
if (ret)
794790
return ret;
795791

796-
ret = reset_control_deassert(rstc);
797-
if (ret)
798-
goto rpm_put;
799-
800-
ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, rstc);
801-
if (ret)
802-
goto rpm_put;
803-
804792
val = readl(channel->base + USB2_AHB_BUS_CTR);
805793
val &= ~USB2_AHB_BUS_CTR_MBL_MASK;
806794
val |= USB2_AHB_BUS_CTR_MBL_INCR4;
807795
writel(val, channel->base + USB2_AHB_BUS_CTR);
808796

809-
rpm_put:
810797
pm_runtime_put(dev);
811798

812-
return ret;
799+
return 0;
813800
}
814801

815802
static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
@@ -849,6 +836,18 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
849836
}
850837
}
851838

839+
channel->rstc = devm_reset_control_array_get_optional_shared(dev);
840+
if (IS_ERR(channel->rstc))
841+
return PTR_ERR(channel->rstc);
842+
843+
ret = reset_control_deassert(channel->rstc);
844+
if (ret)
845+
return ret;
846+
847+
ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, channel->rstc);
848+
if (ret)
849+
return ret;
850+
852851
/*
853852
* devm_phy_create() will call pm_runtime_enable(&phy->dev);
854853
* And then, phy-core will manage runtime pm for this device.
@@ -937,10 +936,38 @@ static void rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
937936
pm_runtime_disable(&pdev->dev);
938937
};
939938

939+
static int rcar_gen3_phy_usb2_suspend(struct device *dev)
940+
{
941+
struct rcar_gen3_chan *channel = dev_get_drvdata(dev);
942+
943+
return reset_control_assert(channel->rstc);
944+
}
945+
946+
static int rcar_gen3_phy_usb2_resume(struct device *dev)
947+
{
948+
struct rcar_gen3_chan *channel = dev_get_drvdata(dev);
949+
int ret;
950+
951+
ret = reset_control_deassert(channel->rstc);
952+
if (ret)
953+
return ret;
954+
955+
ret = rcar_gen3_phy_usb2_init_bus(channel);
956+
if (ret)
957+
reset_control_assert(channel->rstc);
958+
959+
return ret;
960+
}
961+
962+
static DEFINE_SIMPLE_DEV_PM_OPS(rcar_gen3_phy_usb2_pm_ops,
963+
rcar_gen3_phy_usb2_suspend,
964+
rcar_gen3_phy_usb2_resume);
965+
940966
static struct platform_driver rcar_gen3_phy_usb2_driver = {
941967
.driver = {
942968
.name = "phy_rcar_gen3_usb2",
943969
.of_match_table = rcar_gen3_phy_usb2_match_table,
970+
.pm = pm_ptr(&rcar_gen3_phy_usb2_pm_ops),
944971
},
945972
.probe = rcar_gen3_phy_usb2_probe,
946973
.remove = rcar_gen3_phy_usb2_remove,

0 commit comments

Comments
 (0)