From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Store the SoC-specific driver data pointer (struct rcar_gen3_phy_drv_data)
directly in struct rcar_gen3_chan instead of copying individual flags
into separate fields. Update all references to use channel->drvdata->flags,
removing the redundant soc_no_adp_ctrl and utmi_ctrl members from the
channel structure.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 47beb94cd424..cfa9667c7680 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -122,6 +122,7 @@ struct rcar_gen3_phy {
struct rcar_gen3_chan {
void __iomem *base;
struct device *dev; /* platform_device's device */
+ const struct rcar_gen3_phy_drv_data *drvdata;
struct extcon_dev *extcon;
struct rcar_gen3_phy rphys[NUM_OF_PHYS];
struct regulator *vbus;
@@ -133,8 +134,6 @@ struct rcar_gen3_chan {
bool extcon_host;
bool is_otg_channel;
bool uses_otg_pins;
- bool soc_no_adp_ctrl;
- bool utmi_ctrl;
};
struct rcar_gen3_phy_drv_data {
@@ -204,7 +203,7 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
u32 val;
dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus);
- if (ch->soc_no_adp_ctrl) {
+ if (ch->drvdata->no_adp_ctrl) {
if (ch->vbus)
regulator_hardware_enable(ch->vbus, vbus);
@@ -290,7 +289,7 @@ static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
if (!ch->uses_otg_pins)
return (ch->dr_mode == USB_DR_MODE_HOST) ? false : true;
- if (ch->soc_no_adp_ctrl)
+ if (ch->drvdata->no_adp_ctrl)
return !!(readl(ch->base + USB2_LINECTRL1) & USB2_LINECTRL1_USB2_IDMON);
return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
@@ -421,7 +420,7 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch)
USB2_LINECTRL1_DMRPD_EN | USB2_LINECTRL1_DM_RPD;
writel(val, usb2_base + USB2_LINECTRL1);
- if (!ch->soc_no_adp_ctrl) {
+ if (!ch->drvdata->no_adp_ctrl) {
val = readl(usb2_base + USB2_VBCTRL);
val &= ~USB2_VBCTRL_OCCLREN;
writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL);
@@ -487,7 +486,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
if (rphy->int_enable_bits)
rcar_gen3_init_otg(channel);
- if (channel->utmi_ctrl) {
+ if (channel->drvdata->utmi_ctrl) {
val = readl(usb2_base + USB2_REGEN_CG_CTRL) | USB2_REGEN_CG_CTRL_UPHY_WEN;
writel(val, usb2_base + USB2_REGEN_CG_CTRL);
@@ -778,6 +777,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
ret = -EINVAL;
goto error;
}
+ channel->drvdata = phy_data;
platform_set_drvdata(pdev, channel);
channel->dev = dev;
@@ -788,12 +788,9 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
goto error;
}
- channel->soc_no_adp_ctrl = phy_data->no_adp_ctrl;
if (phy_data->no_adp_ctrl)
channel->obint_enable_bits = USB2_OBINT_IDCHG_EN;
- channel->utmi_ctrl = phy_data->utmi_ctrl;
-
spin_lock_init(&channel->lock);
for (i = 0; i < NUM_OF_PHYS; i++) {
channel->rphys[i].phy = devm_phy_create(dev, NULL,
@@ -808,7 +805,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
}
- if (channel->soc_no_adp_ctrl && channel->is_otg_channel)
+ if (channel->drvdata->no_adp_ctrl && channel->is_otg_channel)
channel->vbus = devm_regulator_get_exclusive(dev, "vbus");
else
channel->vbus = devm_regulator_get_optional(dev, "vbus");
--
2.50.1
On 05/08/2025 14:25, Prabhakar wrote: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Store the SoC-specific driver data pointer (struct rcar_gen3_phy_drv_data) > directly in struct rcar_gen3_chan instead of copying individual flags > into separate fields. Update all references to use channel->drvdata->flags, > removing the redundant soc_no_adp_ctrl and utmi_ctrl members from the > channel structure. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > --- > drivers/phy/renesas/phy-rcar-gen3-usb2.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) > > diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c > index 47beb94cd424..cfa9667c7680 100644 > --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c > +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c > @@ -122,6 +122,7 @@ struct rcar_gen3_phy { > struct rcar_gen3_chan { > void __iomem *base; > struct device *dev; /* platform_device's device */ > + const struct rcar_gen3_phy_drv_data *drvdata; Why not phy_data ? > struct extcon_dev *extcon; > struct rcar_gen3_phy rphys[NUM_OF_PHYS]; > struct regulator *vbus; > @@ -133,8 +134,6 @@ struct rcar_gen3_chan { > bool extcon_host; > bool is_otg_channel; > bool uses_otg_pins; > - bool soc_no_adp_ctrl; > - bool utmi_ctrl; > }; > > struct rcar_gen3_phy_drv_data { > @@ -204,7 +203,7 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus) > u32 val; > > dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus); > - if (ch->soc_no_adp_ctrl) { > + if (ch->drvdata->no_adp_ctrl) { > if (ch->vbus) > regulator_hardware_enable(ch->vbus, vbus); > > @@ -290,7 +289,7 @@ static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) > if (!ch->uses_otg_pins) > return (ch->dr_mode == USB_DR_MODE_HOST) ? false : true; > > - if (ch->soc_no_adp_ctrl) > + if (ch->drvdata->no_adp_ctrl) > return !!(readl(ch->base + USB2_LINECTRL1) & USB2_LINECTRL1_USB2_IDMON); > > return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); > @@ -421,7 +420,7 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch) > USB2_LINECTRL1_DMRPD_EN | USB2_LINECTRL1_DM_RPD; > writel(val, usb2_base + USB2_LINECTRL1); > > - if (!ch->soc_no_adp_ctrl) { > + if (!ch->drvdata->no_adp_ctrl) { > val = readl(usb2_base + USB2_VBCTRL); > val &= ~USB2_VBCTRL_OCCLREN; > writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL); > @@ -487,7 +486,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p) > if (rphy->int_enable_bits) > rcar_gen3_init_otg(channel); > > - if (channel->utmi_ctrl) { > + if (channel->drvdata->utmi_ctrl) { > val = readl(usb2_base + USB2_REGEN_CG_CTRL) | USB2_REGEN_CG_CTRL_UPHY_WEN; > writel(val, usb2_base + USB2_REGEN_CG_CTRL); > > @@ -778,6 +777,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) > ret = -EINVAL; > goto error; > } > + channel->drvdata = phy_data; Replace the whole block with: channel->drvdata = device_get_match_data(dev); if (!channel->drvdata) { ret = -EINVAL; goto error; } and drop the local phy_data. > > platform_set_drvdata(pdev, channel); > channel->dev = dev; > @@ -788,12 +788,9 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) > goto error; > } > > - channel->soc_no_adp_ctrl = phy_data->no_adp_ctrl; > if (phy_data->no_adp_ctrl) > channel->obint_enable_bits = USB2_OBINT_IDCHG_EN; > > - channel->utmi_ctrl = phy_data->utmi_ctrl; > - > spin_lock_init(&channel->lock); > for (i = 0; i < NUM_OF_PHYS; i++) { > channel->rphys[i].phy = devm_phy_create(dev, NULL, > @@ -808,7 +805,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) > phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]); > } > Thanks, Neil > - if (channel->soc_no_adp_ctrl && channel->is_otg_channel) > + if (channel->drvdata->no_adp_ctrl && channel->is_otg_channel) > channel->vbus = devm_regulator_get_exclusive(dev, "vbus"); > else > channel->vbus = devm_regulator_get_optional(dev, "vbus");
Hi Neil, Thank you for the review. On Wed, Aug 6, 2025 at 3:06 PM Neil Armstrong <neil.armstrong@linaro.org> wrote: > > On 05/08/2025 14:25, Prabhakar wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > Store the SoC-specific driver data pointer (struct rcar_gen3_phy_drv_data) > > directly in struct rcar_gen3_chan instead of copying individual flags > > into separate fields. Update all references to use channel->drvdata->flags, > > removing the redundant soc_no_adp_ctrl and utmi_ctrl members from the > > channel structure. > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > --- > > drivers/phy/renesas/phy-rcar-gen3-usb2.c | 17 +++++++---------- > > 1 file changed, 7 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c > > index 47beb94cd424..cfa9667c7680 100644 > > --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c > > +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c > > @@ -122,6 +122,7 @@ struct rcar_gen3_phy { > > struct rcar_gen3_chan { > > void __iomem *base; > > struct device *dev; /* platform_device's device */ > > + const struct rcar_gen3_phy_drv_data *drvdata; > > Why not phy_data ? > Agreed, I will rename it. > > struct extcon_dev *extcon; > > struct rcar_gen3_phy rphys[NUM_OF_PHYS]; > > struct regulator *vbus; > > @@ -133,8 +134,6 @@ struct rcar_gen3_chan { > > bool extcon_host; > > bool is_otg_channel; > > bool uses_otg_pins; > > - bool soc_no_adp_ctrl; > > - bool utmi_ctrl; > > }; > > > > struct rcar_gen3_phy_drv_data { > > @@ -204,7 +203,7 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus) > > u32 val; > > > > dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus); > > - if (ch->soc_no_adp_ctrl) { > > + if (ch->drvdata->no_adp_ctrl) { > > if (ch->vbus) > > regulator_hardware_enable(ch->vbus, vbus); > > > > @@ -290,7 +289,7 @@ static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) > > if (!ch->uses_otg_pins) > > return (ch->dr_mode == USB_DR_MODE_HOST) ? false : true; > > > > - if (ch->soc_no_adp_ctrl) > > + if (ch->drvdata->no_adp_ctrl) > > return !!(readl(ch->base + USB2_LINECTRL1) & USB2_LINECTRL1_USB2_IDMON); > > > > return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); > > @@ -421,7 +420,7 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch) > > USB2_LINECTRL1_DMRPD_EN | USB2_LINECTRL1_DM_RPD; > > writel(val, usb2_base + USB2_LINECTRL1); > > > > - if (!ch->soc_no_adp_ctrl) { > > + if (!ch->drvdata->no_adp_ctrl) { > > val = readl(usb2_base + USB2_VBCTRL); > > val &= ~USB2_VBCTRL_OCCLREN; > > writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL); > > @@ -487,7 +486,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p) > > if (rphy->int_enable_bits) > > rcar_gen3_init_otg(channel); > > > > - if (channel->utmi_ctrl) { > > + if (channel->drvdata->utmi_ctrl) { > > val = readl(usb2_base + USB2_REGEN_CG_CTRL) | USB2_REGEN_CG_CTRL_UPHY_WEN; > > writel(val, usb2_base + USB2_REGEN_CG_CTRL); > > > > @@ -778,6 +777,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) > > ret = -EINVAL; > > goto error; > > } > > + channel->drvdata = phy_data; > > Replace the whole block with: > > channel->drvdata = device_get_match_data(dev); > if (!channel->drvdata) { > ret = -EINVAL; > goto error; > } > > and drop the local phy_data. > Ok. Cheers, Prabhakar
© 2016 - 2025 Red Hat, Inc.