Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Lad Prabhakar and committed by
Vinod Koul
f75806d2 ab9c8aeb

+11 -16
+11 -16
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 122 122 struct rcar_gen3_chan { 123 123 void __iomem *base; 124 124 struct device *dev; /* platform_device's device */ 125 + const struct rcar_gen3_phy_drv_data *phy_data; 125 126 struct extcon_dev *extcon; 126 127 struct rcar_gen3_phy rphys[NUM_OF_PHYS]; 127 128 struct regulator *vbus; ··· 134 133 bool extcon_host; 135 134 bool is_otg_channel; 136 135 bool uses_otg_pins; 137 - bool soc_no_adp_ctrl; 138 - bool utmi_ctrl; 139 136 }; 140 137 141 138 struct rcar_gen3_phy_drv_data { ··· 203 204 u32 val; 204 205 205 206 dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus); 206 - if (ch->soc_no_adp_ctrl) { 207 + if (ch->phy_data->no_adp_ctrl) { 207 208 if (ch->vbus) 208 209 regulator_hardware_enable(ch->vbus, vbus); 209 210 ··· 289 290 if (!ch->uses_otg_pins) 290 291 return (ch->dr_mode == USB_DR_MODE_HOST) ? false : true; 291 292 292 - if (ch->soc_no_adp_ctrl) 293 + if (ch->phy_data->no_adp_ctrl) 293 294 return !!(readl(ch->base + USB2_LINECTRL1) & USB2_LINECTRL1_USB2_IDMON); 294 295 295 296 return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); ··· 420 421 USB2_LINECTRL1_DMRPD_EN | USB2_LINECTRL1_DM_RPD; 421 422 writel(val, usb2_base + USB2_LINECTRL1); 422 423 423 - if (!ch->soc_no_adp_ctrl) { 424 + if (!ch->phy_data->no_adp_ctrl) { 424 425 val = readl(usb2_base + USB2_VBCTRL); 425 426 val &= ~USB2_VBCTRL_OCCLREN; 426 427 writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL); ··· 486 487 if (rphy->int_enable_bits) 487 488 rcar_gen3_init_otg(channel); 488 489 489 - if (channel->utmi_ctrl) { 490 + if (channel->phy_data->utmi_ctrl) { 490 491 val = readl(usb2_base + USB2_REGEN_CG_CTRL) | USB2_REGEN_CG_CTRL_UPHY_WEN; 491 492 writel(val, usb2_base + USB2_REGEN_CG_CTRL); 492 493 ··· 729 730 730 731 static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) 731 732 { 732 - const struct rcar_gen3_phy_drv_data *phy_data; 733 733 struct device *dev = &pdev->dev; 734 734 struct rcar_gen3_chan *channel; 735 735 struct phy_provider *provider; ··· 771 773 */ 772 774 pm_runtime_enable(dev); 773 775 774 - phy_data = of_device_get_match_data(dev); 775 - if (!phy_data) { 776 + channel->phy_data = of_device_get_match_data(dev); 777 + if (!channel->phy_data) { 776 778 ret = -EINVAL; 777 779 goto error; 778 780 } ··· 780 782 platform_set_drvdata(pdev, channel); 781 783 channel->dev = dev; 782 784 783 - if (phy_data->init_bus) { 785 + if (channel->phy_data->init_bus) { 784 786 ret = rcar_gen3_phy_usb2_init_bus(channel); 785 787 if (ret) 786 788 goto error; 787 789 } 788 790 789 - channel->soc_no_adp_ctrl = phy_data->no_adp_ctrl; 790 - if (phy_data->no_adp_ctrl) 791 + if (channel->phy_data->no_adp_ctrl) 791 792 channel->obint_enable_bits = USB2_OBINT_IDCHG_EN; 792 - 793 - channel->utmi_ctrl = phy_data->utmi_ctrl; 794 793 795 794 spin_lock_init(&channel->lock); 796 795 for (i = 0; i < NUM_OF_PHYS; i++) { 797 796 channel->rphys[i].phy = devm_phy_create(dev, NULL, 798 - phy_data->phy_usb2_ops); 797 + channel->phy_data->phy_usb2_ops); 799 798 if (IS_ERR(channel->rphys[i].phy)) { 800 799 dev_err(dev, "Failed to create USB2 PHY\n"); 801 800 ret = PTR_ERR(channel->rphys[i].phy); ··· 803 808 phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]); 804 809 } 805 810 806 - if (channel->soc_no_adp_ctrl && channel->is_otg_channel) 811 + if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) 807 812 channel->vbus = devm_regulator_get_exclusive(dev, "vbus"); 808 813 else 809 814 channel->vbus = devm_regulator_get_optional(dev, "vbus");