[PATCH 04/11] reset: rzg2l-usbphy-ctrl: Introduce info struct for match data

From: Biju

Date: Fri Jun 12 2026 - 10:34:56 EST


From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>

Replace the integer flag RZG2L_USBPHY_CTRL_PWRRDY with a structured
rzg2l_usbphy_ctrl_info type to hold per-compatible configuration data.

The new struct carries the regulator driver name and a pwr_rdy flag,
allowing the probe function to conditionally call
rzg2l_usbphy_ctrl_pwrrdy_init() based on the matched device data rather
than casting match data to an integer.

This restructuring makes it easier to extend per-variant configuration
in a follow-up patch to support the RZ/G3L SoC, which has 2 VBUS
regulators.

Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
---
drivers/reset/reset-rzg2l-usbphy-ctrl.c | 38 +++++++++++++++----------
1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index fd75d9601a3b..1c4c8aae0e80 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -41,6 +41,11 @@ struct rzg2l_usbphy_ctrl_priv {
spinlock_t lock;
};

+struct rzg2l_usbphy_ctrl_info {
+ const char *regulator_driver_name;
+ bool pwrrdy;
+};
+
#define rcdev_to_priv(x) container_of(x, struct rzg2l_usbphy_ctrl_priv, rcdev)

static int rzg2l_usbphy_ctrl_assert(struct reset_controller_dev *rcdev,
@@ -106,14 +111,18 @@ static void rzg2l_usbphy_ctrl_init(struct rzg2l_usbphy_ctrl_priv *priv)
spin_unlock_irqrestore(&priv->lock, flags);
}

-#define RZG2L_USBPHY_CTRL_PWRRDY 1
+static const struct rzg2l_usbphy_ctrl_info rzg2l_info = {
+ .regulator_driver_name = "rzg2l-usb-vbus-regulator",
+};
+
+static const struct rzg2l_usbphy_ctrl_info rzg3s_info = {
+ .regulator_driver_name = "rzg2l-usb-vbus-regulator",
+ .pwrrdy = true,
+};

static const struct of_device_id rzg2l_usbphy_ctrl_match_table[] = {
- { .compatible = "renesas,rzg2l-usbphy-ctrl" },
- {
- .compatible = "renesas,r9a08g045-usbphy-ctrl",
- .data = (void *)RZG2L_USBPHY_CTRL_PWRRDY
- },
+ { .compatible = "renesas,rzg2l-usbphy-ctrl", .data = &rzg2l_info },
+ { .compatible = "renesas,r9a08g045-usbphy-ctrl", .data = &rzg3s_info },
{ /* Sentinel */ }
};
MODULE_DEVICE_TABLE(of, rzg2l_usbphy_ctrl_match_table);
@@ -153,14 +162,9 @@ static int rzg2l_usbphy_ctrl_pwrrdy_init(struct device *dev,
{
struct reg_field field;
struct regmap *regmap;
- const int *data;
u32 args[2];
int ret;

- data = device_get_match_data(dev);
- if ((uintptr_t)data != RZG2L_USBPHY_CTRL_PWRRDY)
- return 0;
-
regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
"renesas,sysc-pwrrdy",
ARRAY_SIZE(args), args);
@@ -188,6 +192,7 @@ static int rzg2l_usbphy_ctrl_pwrrdy_init(struct device *dev,

static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
{
+ const struct rzg2l_usbphy_ctrl_info *info;
struct device *dev = &pdev->dev;
struct rzg2l_usbphy_ctrl_priv *priv;
struct platform_device *vdev;
@@ -206,9 +211,12 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
if (IS_ERR(regmap))
return PTR_ERR(regmap);

- error = rzg2l_usbphy_ctrl_pwrrdy_init(dev, priv);
- if (error)
- return error;
+ info = device_get_match_data(dev);
+ if (info->pwrrdy) {
+ error = rzg2l_usbphy_ctrl_pwrrdy_init(dev, priv);
+ if (error)
+ return error;
+ }

priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(priv->rstc))
@@ -241,7 +249,7 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
if (error)
goto err_pm_runtime_put;

- vdev = platform_device_alloc("rzg2l-usb-vbus-regulator", pdev->id);
+ vdev = platform_device_alloc(info->regulator_driver_name, pdev->id);
if (!vdev) {
error = -ENOMEM;
goto err_pm_runtime_put;
--
2.43.0