Skip to content

Commit f75806d

Browse files
prabhakarladvinodkoul
authored andcommitted
phy: renesas: rcar-gen3-usb2: store drvdata pointer in channel
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 channel members. Obtain the drvdata with of_device_get_match_data() in probe and assign it to channel->phy_data. Update all call sites to reference `channel->phy_data->*` for SoC-specific behaviour (for example no_adp_ctrl and utmi_ctrl). Remove the redundant soc_no_adp_ctrl and utmi_ctrl fields from struct rcar_gen3_chan. This simplifies the probe path, reduces duplication, and makes it easier to extend the driver with additional platform-specific fields in the future. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Link: https://lore.kernel.org/r/20250808215209.3692744-3-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent ab9c8ae commit f75806d

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ struct rcar_gen3_phy {
122122
struct rcar_gen3_chan {
123123
void __iomem *base;
124124
struct device *dev; /* platform_device's device */
125+
const struct rcar_gen3_phy_drv_data *phy_data;
125126
struct extcon_dev *extcon;
126127
struct rcar_gen3_phy rphys[NUM_OF_PHYS];
127128
struct regulator *vbus;
@@ -133,8 +134,6 @@ struct rcar_gen3_chan {
133134
bool extcon_host;
134135
bool is_otg_channel;
135136
bool uses_otg_pins;
136-
bool soc_no_adp_ctrl;
137-
bool utmi_ctrl;
138137
};
139138

140139
struct rcar_gen3_phy_drv_data {
@@ -204,7 +203,7 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
204203
u32 val;
205204

206205
dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus);
207-
if (ch->soc_no_adp_ctrl) {
206+
if (ch->phy_data->no_adp_ctrl) {
208207
if (ch->vbus)
209208
regulator_hardware_enable(ch->vbus, vbus);
210209

@@ -290,7 +289,7 @@ static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
290289
if (!ch->uses_otg_pins)
291290
return (ch->dr_mode == USB_DR_MODE_HOST) ? false : true;
292291

293-
if (ch->soc_no_adp_ctrl)
292+
if (ch->phy_data->no_adp_ctrl)
294293
return !!(readl(ch->base + USB2_LINECTRL1) & USB2_LINECTRL1_USB2_IDMON);
295294

296295
return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
@@ -421,7 +420,7 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch)
421420
USB2_LINECTRL1_DMRPD_EN | USB2_LINECTRL1_DM_RPD;
422421
writel(val, usb2_base + USB2_LINECTRL1);
423422

424-
if (!ch->soc_no_adp_ctrl) {
423+
if (!ch->phy_data->no_adp_ctrl) {
425424
val = readl(usb2_base + USB2_VBCTRL);
426425
val &= ~USB2_VBCTRL_OCCLREN;
427426
writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL);
@@ -487,7 +486,7 @@ static int rcar_gen3_phy_usb2_init(struct phy *p)
487486
if (rphy->int_enable_bits)
488487
rcar_gen3_init_otg(channel);
489488

490-
if (channel->utmi_ctrl) {
489+
if (channel->phy_data->utmi_ctrl) {
491490
val = readl(usb2_base + USB2_REGEN_CG_CTRL) | USB2_REGEN_CG_CTRL_UPHY_WEN;
492491
writel(val, usb2_base + USB2_REGEN_CG_CTRL);
493492

@@ -730,7 +729,6 @@ static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
730729

731730
static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
732731
{
733-
const struct rcar_gen3_phy_drv_data *phy_data;
734732
struct device *dev = &pdev->dev;
735733
struct rcar_gen3_chan *channel;
736734
struct phy_provider *provider;
@@ -773,31 +771,28 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
773771
*/
774772
pm_runtime_enable(dev);
775773

776-
phy_data = of_device_get_match_data(dev);
777-
if (!phy_data) {
774+
channel->phy_data = of_device_get_match_data(dev);
775+
if (!channel->phy_data) {
778776
ret = -EINVAL;
779777
goto error;
780778
}
781779

782780
platform_set_drvdata(pdev, channel);
783781
channel->dev = dev;
784782

785-
if (phy_data->init_bus) {
783+
if (channel->phy_data->init_bus) {
786784
ret = rcar_gen3_phy_usb2_init_bus(channel);
787785
if (ret)
788786
goto error;
789787
}
790788

791-
channel->soc_no_adp_ctrl = phy_data->no_adp_ctrl;
792-
if (phy_data->no_adp_ctrl)
789+
if (channel->phy_data->no_adp_ctrl)
793790
channel->obint_enable_bits = USB2_OBINT_IDCHG_EN;
794791

795-
channel->utmi_ctrl = phy_data->utmi_ctrl;
796-
797792
spin_lock_init(&channel->lock);
798793
for (i = 0; i < NUM_OF_PHYS; i++) {
799794
channel->rphys[i].phy = devm_phy_create(dev, NULL,
800-
phy_data->phy_usb2_ops);
795+
channel->phy_data->phy_usb2_ops);
801796
if (IS_ERR(channel->rphys[i].phy)) {
802797
dev_err(dev, "Failed to create USB2 PHY\n");
803798
ret = PTR_ERR(channel->rphys[i].phy);
@@ -808,7 +803,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
808803
phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
809804
}
810805

811-
if (channel->soc_no_adp_ctrl && channel->is_otg_channel)
806+
if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel)
812807
channel->vbus = devm_regulator_get_exclusive(dev, "vbus");
813808
else
814809
channel->vbus = devm_regulator_get_optional(dev, "vbus");

0 commit comments

Comments
 (0)