* [PATCH v4 00/22] Add USB2.0 support for RZ/G3E
@ 2025-11-21 15:11 Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints Tommaso Merciai
` (21 more replies)
0 siblings, 22 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Dear All,
This patch series adds USB2.0 support for the Renesas R9A09G047 SoC and
enables it on the RZ/G3E SMARK II board. RZ/G3E has USB2.0 IP that is
identical to the one's found into the RZ/V2H SoC (R9A09G057).
Thanks & Regards,
Tommaso
v3->v4:
- Rebased on top of next-20251121
- Added patch 01/22 to remove nodename pattern from mux-controller schema.
- Switch back to v2 implementation for mux controller in patches
5/22, 15/22, 16/22, 21/22.
- Improved commit bodies for patches 5/22, 15/22, 16/22, 21/22.
- Removed mux_chip->dev.of_node not needed in patch 06/22.
- Collected CDooley tag in patch 09/22.
- Added missing select MULTIPLEXER into Kconfig in patch 11/22.
v2->v3:
- Rebased on top of next-20251110 + [1] + [2]
- Add missing Cc: stable@vger.kernel.org in patch 03/21
- Patch 03/21: Added missing Cc: stable@vger.kernel.org.
Improved commit body describing the removal of rzv2h_usbphy_assert_helper()
from rzv2h_usb2phy_reset_probe().
- Patch 04/21: Manipulate mux-controller as an internal node.
Improved commit body.
- Patch 05/21: The main driver is using now __devm_auxiliary_device_create()
then update the aux driver accordingly.
- Patch 06/21: Use __devm_auxiliary_device_create() to create the aux device.
- Patch 08/21: Improved commit body and mux-states description.
- Patch 14/21: Manipulate the mux controller as an internal node,
and update commit body accordingly.
- Patch 15/21: Manipulate the mux controller as an internal node,
and update commit body accordingly.
- Patch 20/21: Manipulate the mux controller as an internal node.
v1->v2:
- Rebased on top of next-20251103 + [1] + [2]
- Reworked series to use mux-state for controlling VBUS_SEL
as suggested by PZabel added also mux bindings documentation
on phy and rst side.
- Collected Conor Dooley tags
- Dropped unnecessary rzv2h_usbphy_assert_helper() function from
rzv2h_usb2phy_reset_probe()
Tommaso Merciai (22):
dt-bindings: mux: Remove nodename pattern constraints
phy: renesas: rcar-gen3-usb2: Use devm_pm_runtime_enable()
phy: renesas: rcar-gen3-usb2: Factor out VBUS control logic
reset: rzv2h-usb2phy: Keep PHY clock enabled for entire device
lifetime
dt-bindings: reset: renesas,rzv2h-usb2phy: Add '#mux-state-cells'
property
mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux
reset: rzv2h-usb2phy: Add support for VBUS mux controller registration
dt-bindings: phy: renesas,usb2-phy: Document USB VBUS regulator
dt-bindings: phy: renesas,usb2-phy: Document mux-states property
phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control
phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management
dt-bindings: usb: renesas,usbhs: Add RZ/G3E SoC support
dt-bindings: phy: renesas,usb2-phy: Document RZ/G3E SoC
dt-bindings: reset: Document RZ/G3E USB2PHY reset
arm64: dts: renesas: r9a09g057: Add USB2.0 VBUS_SEL mux-controller
support
arm64: dts: renesas: r9a09g056: Add USB2.0 VBUS_SEL mux-controller
support
arm64: dts: renesas: r9a09g056: Add USB2.0 PHY VBUS internal regulator
node
arm64: dts: renesas: r9a09g056n48-rzv2n-evk: Enable USB2 PHY0 VBUS
support
arm64: dts: renesas: r9a09g057: Add USB2.0 PHY VBUS internal regulator
node
arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable USB2 PHY0 VBUS
support
arm64: dts: renesas: r9a09g047: Add USB2.0 support
arm64: dts: renesas: r9a09g047e57-smarc: Enable USB2.0 support
.../bindings/mux/mux-controller.yaml | 6 -
.../bindings/phy/renesas,usb2-phy.yaml | 15 +-
.../reset/renesas,rzv2h-usb2phy-reset.yaml | 9 +-
.../bindings/usb/renesas,usbhs.yaml | 1 +
arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 125 +++++++++
.../boot/dts/renesas/r9a09g047e57-smarc.dts | 49 ++++
arch/arm64/boot/dts/renesas/r9a09g056.dtsi | 7 +
.../dts/renesas/r9a09g056n48-rzv2n-evk.dts | 5 +
arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 9 +
.../dts/renesas/r9a09g057h44-rzv2h-evk.dts | 5 +
.../boot/dts/renesas/renesas-smarc2.dtsi | 23 ++
drivers/mux/Kconfig | 10 +
drivers/mux/Makefile | 2 +
drivers/mux/rzv2h-usb-vbus.c | 97 +++++++
drivers/phy/renesas/Kconfig | 1 +
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 263 ++++++++++++++----
drivers/reset/Kconfig | 1 +
drivers/reset/reset-rzv2h-usb2phy.c | 108 ++++---
include/linux/reset/reset_rzv2h_usb2phy.h | 11 +
19 files changed, 644 insertions(+), 103 deletions(-)
create mode 100644 drivers/mux/rzv2h-usb-vbus.c
create mode 100644 include/linux/reset/reset_rzv2h_usb2phy.h
--
2.43.0
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 18:24 ` Conor Dooley
2025-11-21 15:11 ` [PATCH v4 02/22] phy: renesas: rcar-gen3-usb2: Use devm_pm_runtime_enable() Tommaso Merciai
` (20 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
The nodename pattern in created an unnecessary restriction that forced
all mux nodes to be named with the 'mux-controller' prefix.
This prevented valid use cases where mux functionality is part of other
hardware blocks that should use more specific naming conventions.
Remove the $nodename pattern constraints from both the 'select' keyword
and the properties section of the mux-controller schema.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- New patch.
Documentation/devicetree/bindings/mux/mux-controller.yaml | 6 ------
1 file changed, 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/mux/mux-controller.yaml b/Documentation/devicetree/bindings/mux/mux-controller.yaml
index 78340bbe4df6..6defb9da10f7 100644
--- a/Documentation/devicetree/bindings/mux/mux-controller.yaml
+++ b/Documentation/devicetree/bindings/mux/mux-controller.yaml
@@ -63,18 +63,12 @@ description: |
select:
anyOf:
- - properties:
- $nodename:
- pattern: '^mux-controller'
- required:
- '#mux-control-cells'
- required:
- '#mux-state-cells'
properties:
- $nodename:
- pattern: '^mux-controller(@.*|-([0-9]|[1-9][0-9]+))?$'
-
'#mux-control-cells':
enum: [ 0, 1 ]
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 02/22] phy: renesas: rcar-gen3-usb2: Use devm_pm_runtime_enable()
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 03/22] phy: renesas: rcar-gen3-usb2: Factor out VBUS control logic Tommaso Merciai
` (19 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Replace pm_runtime_enable() with devm_pm_runtime_enable() to ensure proper
cleanup if the probe fails. This change enhances driver reliability by
avoiding resource leaks, as the devm-managed version automatically handles
disabling at probe failure or device removal.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 53 ++++++++++--------------
1 file changed, 21 insertions(+), 32 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 582de10d5beb..41e0c818ae34 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -852,30 +852,29 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
* devm_phy_create() will call pm_runtime_enable(&phy->dev);
* And then, phy-core will manage runtime pm for this device.
*/
- pm_runtime_enable(dev);
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable pm_runtime\n");
channel->phy_data = of_device_get_match_data(dev);
- if (!channel->phy_data) {
- ret = -EINVAL;
- goto error;
- }
+ if (!channel->phy_data)
+ return -EINVAL;
platform_set_drvdata(pdev, channel);
channel->dev = dev;
ret = rcar_gen3_phy_usb2_init_bus(channel);
if (ret)
- goto error;
+ return ret;
spin_lock_init(&channel->lock);
for (i = 0; i < NUM_OF_PHYS; i++) {
channel->rphys[i].phy = devm_phy_create(dev, NULL,
channel->phy_data->phy_usb2_ops);
- if (IS_ERR(channel->rphys[i].phy)) {
- dev_err(dev, "Failed to create USB2 PHY\n");
- ret = PTR_ERR(channel->rphys[i].phy);
- goto error;
- }
+ if (IS_ERR(channel->rphys[i].phy))
+ return dev_err_probe(dev, PTR_ERR(channel->rphys[i].phy),
+ "Failed to create USB2 PHY\n");
+
channel->rphys[i].ch = channel;
channel->rphys[i].int_enable_bits = rcar_gen3_int_enable[i];
phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
@@ -886,44 +885,36 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
else
channel->vbus = devm_regulator_get_optional(dev, "vbus");
if (IS_ERR(channel->vbus)) {
- if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) {
- ret = PTR_ERR(channel->vbus);
- goto error;
- }
+ if (PTR_ERR(channel->vbus) == -EPROBE_DEFER)
+ return PTR_ERR(channel->vbus);
+
channel->vbus = NULL;
}
irq = platform_get_irq_optional(pdev, 0);
if (irq < 0 && irq != -ENXIO) {
- ret = irq;
- goto error;
+ return irq;
} else if (irq > 0) {
INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
ret = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
IRQF_SHARED, dev_name(dev), channel);
- if (ret < 0) {
- dev_err(dev, "Failed to request irq (%d)\n", irq);
- goto error;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret,
+ "Failed to request irq (%d)\n",
+ irq);
}
provider = devm_of_phy_provider_register(dev, rcar_gen3_phy_usb2_xlate);
if (IS_ERR(provider)) {
- dev_err(dev, "Failed to register PHY provider\n");
- ret = PTR_ERR(provider);
- goto error;
+ return dev_err_probe(dev, PTR_ERR(provider),
+ "Failed to register PHY provider\n");
} else if (channel->is_otg_channel) {
ret = device_create_file(dev, &dev_attr_role);
if (ret < 0)
- goto error;
+ return ret;
}
return 0;
-
-error:
- pm_runtime_disable(dev);
-
- return ret;
}
static void rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
@@ -932,8 +923,6 @@ static void rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
if (channel->is_otg_channel)
device_remove_file(&pdev->dev, &dev_attr_role);
-
- pm_runtime_disable(&pdev->dev);
}
static int rcar_gen3_phy_usb2_suspend(struct device *dev)
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 03/22] phy: renesas: rcar-gen3-usb2: Factor out VBUS control logic
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 02/22] phy: renesas: rcar-gen3-usb2: Use devm_pm_runtime_enable() Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 04/22] reset: rzv2h-usb2phy: Keep PHY clock enabled for entire device lifetime Tommaso Merciai
` (18 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Refactor the VBUS control logic into a new helper function to improve
code clarity and reduce duplication. This makes it easier to handle
different VBUS control register cases and aids future maintenance.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 34 +++++++++++++++---------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 41e0c818ae34..94a4521d7187 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -204,28 +204,38 @@ static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm)
writel(val, usb2_base + USB2_LINECTRL1);
}
-static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
+static void rcar_gen3_phy_usb2_set_vbus(struct rcar_gen3_chan *ch,
+ u32 vbus_ctrl_reg,
+ u32 vbus_ctrl_val,
+ bool enable)
{
void __iomem *usb2_base = ch->base;
- u32 vbus_ctrl_reg = USB2_ADPCTRL;
- u32 vbus_ctrl_val = USB2_ADPCTRL_DRVVBUS;
u32 val;
+ val = readl(usb2_base + vbus_ctrl_reg);
+ if (enable)
+ val |= vbus_ctrl_val;
+ else
+ val &= ~vbus_ctrl_val;
+ writel(val, usb2_base + vbus_ctrl_reg);
+
+ dev_vdbg(ch->dev, "%s: reg=0x%08x, val=%08x, enable=%d\n",
+ __func__, vbus_ctrl_reg, val, enable);
+}
+
+static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
+{
if (ch->phy_data->no_adp_ctrl || ch->phy_data->vblvl_ctrl) {
if (ch->vbus)
regulator_hardware_enable(ch->vbus, vbus);
- vbus_ctrl_reg = USB2_VBCTRL;
- vbus_ctrl_val = USB2_VBCTRL_VBOUT;
+ rcar_gen3_phy_usb2_set_vbus(ch, USB2_VBCTRL,
+ USB2_VBCTRL_VBOUT, vbus);
+ return;
}
- val = readl(usb2_base + vbus_ctrl_reg);
- if (vbus)
- val |= vbus_ctrl_val;
- else
- val &= ~vbus_ctrl_val;
- dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus);
- writel(val, usb2_base + vbus_ctrl_reg);
+ rcar_gen3_phy_usb2_set_vbus(ch, USB2_ADPCTRL,
+ USB2_ADPCTRL_DRVVBUS, vbus);
}
static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable)
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 04/22] reset: rzv2h-usb2phy: Keep PHY clock enabled for entire device lifetime
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (2 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 03/22] phy: renesas: rcar-gen3-usb2: Factor out VBUS control logic Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 05/22] dt-bindings: reset: renesas,rzv2h-usb2phy: Add '#mux-state-cells' property Tommaso Merciai
` (17 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy, stable
The driver was disabling the USB2 PHY clock immediately after register
initialization in probe() and after each reset operation. This left the
PHY unclocked even though it must remain active for USB functionality.
The behavior appeared to work only when another driver
(e.g., USB controller) had already enabled the clock, making operation
unreliable and hardware-dependent. In configurations where this driver
is the sole clock user, USB functionality would fail.
Fix this by:
- Enabling the clock once in probe() via pm_runtime_resume_and_get()
- Removing all pm_runtime_put() calls from assert/deassert/status
- Registering a devm cleanup action to release the clock at removal
- Removed rzv2h_usbphy_assert_helper() and its call in
rzv2h_usb2phy_reset_probe()
This ensures the PHY clock remains enabled for the entire device lifetime,
preventing instability and aligning with hardware requirements.
Cc: stable@vger.kernel.org
Fixes: e3911d7f865b ("reset: Add USB2PHY port reset driver for Renesas RZ/V2H(P)")
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes.
v2->v3:
- Added missing Cc: stable@vger.kernel.org
- Improved commit body describing the removal of rzv2h_usbphy_assert_helper()
from rzv2h_usb2phy_reset_probe().
v1->v2:
- Improve commit body and commit msg
- Added Fixes tag
- Dropped unnecessary rzv2h_usbphy_assert_helper() function
drivers/reset/reset-rzv2h-usb2phy.c | 64 ++++++++---------------------
1 file changed, 18 insertions(+), 46 deletions(-)
diff --git a/drivers/reset/reset-rzv2h-usb2phy.c b/drivers/reset/reset-rzv2h-usb2phy.c
index ae643575b067..5bdd39274612 100644
--- a/drivers/reset/reset-rzv2h-usb2phy.c
+++ b/drivers/reset/reset-rzv2h-usb2phy.c
@@ -49,9 +49,10 @@ static inline struct rzv2h_usb2phy_reset_priv
return container_of(rcdev, struct rzv2h_usb2phy_reset_priv, rcdev);
}
-/* This function must be called only after pm_runtime_resume_and_get() has been called */
-static void rzv2h_usbphy_assert_helper(struct rzv2h_usb2phy_reset_priv *priv)
+static int rzv2h_usbphy_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
{
+ struct rzv2h_usb2phy_reset_priv *priv = rzv2h_usbphy_rcdev_to_priv(rcdev);
const struct rzv2h_usb2phy_reset_of_data *data = priv->data;
scoped_guard(spinlock, &priv->lock) {
@@ -60,24 +61,6 @@ static void rzv2h_usbphy_assert_helper(struct rzv2h_usb2phy_reset_priv *priv)
}
usleep_range(11, 20);
-}
-
-static int rzv2h_usbphy_reset_assert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- struct rzv2h_usb2phy_reset_priv *priv = rzv2h_usbphy_rcdev_to_priv(rcdev);
- struct device *dev = priv->dev;
- int ret;
-
- ret = pm_runtime_resume_and_get(dev);
- if (ret) {
- dev_err(dev, "pm_runtime_resume_and_get failed\n");
- return ret;
- }
-
- rzv2h_usbphy_assert_helper(priv);
-
- pm_runtime_put(dev);
return 0;
}
@@ -87,14 +70,6 @@ static int rzv2h_usbphy_reset_deassert(struct reset_controller_dev *rcdev,
{
struct rzv2h_usb2phy_reset_priv *priv = rzv2h_usbphy_rcdev_to_priv(rcdev);
const struct rzv2h_usb2phy_reset_of_data *data = priv->data;
- struct device *dev = priv->dev;
- int ret;
-
- ret = pm_runtime_resume_and_get(dev);
- if (ret) {
- dev_err(dev, "pm_runtime_resume_and_get failed\n");
- return ret;
- }
scoped_guard(spinlock, &priv->lock) {
writel(data->reset_deassert_val, priv->base + data->reset_reg);
@@ -102,8 +77,6 @@ static int rzv2h_usbphy_reset_deassert(struct reset_controller_dev *rcdev,
writel(data->reset_release_val, priv->base + data->reset_reg);
}
- pm_runtime_put(dev);
-
return 0;
}
@@ -111,20 +84,10 @@ static int rzv2h_usbphy_reset_status(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct rzv2h_usb2phy_reset_priv *priv = rzv2h_usbphy_rcdev_to_priv(rcdev);
- struct device *dev = priv->dev;
- int ret;
u32 reg;
- ret = pm_runtime_resume_and_get(dev);
- if (ret) {
- dev_err(dev, "pm_runtime_resume_and_get failed\n");
- return ret;
- }
-
reg = readl(priv->base + priv->data->reset_reg);
- pm_runtime_put(dev);
-
return (reg & priv->data->reset_status_bits) == priv->data->reset_status_bits;
}
@@ -141,6 +104,11 @@ static int rzv2h_usb2phy_reset_of_xlate(struct reset_controller_dev *rcdev,
return 0;
}
+static void rzv2h_usb2phy_reset_pm_runtime_put(void *data)
+{
+ pm_runtime_put(data);
+}
+
static int rzv2h_usb2phy_reset_probe(struct platform_device *pdev)
{
const struct rzv2h_usb2phy_reset_of_data *data;
@@ -175,14 +143,14 @@ static int rzv2h_usb2phy_reset_probe(struct platform_device *pdev)
if (error)
return dev_err_probe(dev, error, "pm_runtime_resume_and_get failed\n");
+ error = devm_add_action_or_reset(dev, rzv2h_usb2phy_reset_pm_runtime_put,
+ dev);
+ if (error)
+ return dev_err_probe(dev, error, "unable to register cleanup action\n");
+
for (unsigned int i = 0; i < data->init_val_count; i++)
writel(data->init_vals[i].val, priv->base + data->init_vals[i].reg);
- /* keep usb2phy in asserted state */
- rzv2h_usbphy_assert_helper(priv);
-
- pm_runtime_put(dev);
-
priv->rcdev.ops = &rzv2h_usbphy_reset_ops;
priv->rcdev.of_reset_n_cells = 0;
priv->rcdev.nr_resets = 1;
@@ -190,7 +158,11 @@ static int rzv2h_usb2phy_reset_probe(struct platform_device *pdev)
priv->rcdev.of_node = dev->of_node;
priv->rcdev.dev = dev;
- return devm_reset_controller_register(dev, &priv->rcdev);
+ error = devm_reset_controller_register(dev, &priv->rcdev);
+ if (error)
+ return dev_err_probe(dev, error, "could not register reset controller\n");
+
+ return 0;
}
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 05/22] dt-bindings: reset: renesas,rzv2h-usb2phy: Add '#mux-state-cells' property
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (3 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 04/22] reset: rzv2h-usb2phy: Keep PHY clock enabled for entire device lifetime Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux Tommaso Merciai
` (16 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Add the '#mux-state-cells' property to support describing the USB VBUS_SEL
multiplexer as a mux-controller in the Renesas RZ/V2H(P) USB2PHY binding.
The mux-controller cannot be integrated into the parent USB2PHY node
because the VBUS source selector is part of a separate hardware block,
not the USB2PHY block itself.
This is required to properly configure USB PHY power selection on
RZ/V2H(P) and RZ/G3E SoCs.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- Switch back to v2 implementation.
- Improve commit body.
v2->v3:
- Manipulate mux-controller as an internal node.
- Improved commit body.
v1->v2:
- New patch
.../bindings/reset/renesas,rzv2h-usb2phy-reset.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml b/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml
index c1b800a10b53..7ed0980b9ee1 100644
--- a/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml
+++ b/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml
@@ -37,6 +37,9 @@ properties:
'#reset-cells':
const: 0
+ '#mux-state-cells':
+ const: 1
+
required:
- compatible
- reg
@@ -44,6 +47,7 @@ required:
- resets
- power-domains
- '#reset-cells'
+ - '#mux-state-cells'
additionalProperties: false
@@ -58,4 +62,5 @@ examples:
resets = <&cpg 0xaf>;
power-domains = <&cpg>;
#reset-cells = <0>;
+ #mux-state-cells = <1>;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (4 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 05/22] dt-bindings: reset: renesas,rzv2h-usb2phy: Add '#mux-state-cells' property Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-27 2:28 ` Jian Hui Lee
2025-11-21 15:11 ` [PATCH v4 07/22] reset: rzv2h-usb2phy: Add support for VBUS mux controller registration Tommaso Merciai
` (15 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
As per the RZ/V2H(P) HW manual, VBUSEN can be controlled by the VBUS_SEL
bit of the VBENCTL Control Register. This register is mapped in the
reset framework. The reset driver expose this register as mux-controller
and instantiates this driver. The consumer will use the mux API to
control the VBUS_SEL bit.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- Removed mux_chip->dev.of_node not needed.
v2->v3:
- Added mux_chip->dev.of_node = dev->of_node->child as the mux-controller
is an internal node.
- Fixed auxiliary_device_id name.
- Get rdev using from platform_data.
- Drop struct auxiliary_device adev from reset_rzv2h_usb2phy_adev
as it is needed.
- Drop to_reset_rzv2h_usb2phy_adev() as it is not needed.
v1->v2:
- New patch
drivers/mux/Kconfig | 10 +++
drivers/mux/Makefile | 2 +
drivers/mux/rzv2h-usb-vbus.c | 97 +++++++++++++++++++++++
include/linux/reset/reset_rzv2h_usb2phy.h | 11 +++
4 files changed, 120 insertions(+)
create mode 100644 drivers/mux/rzv2h-usb-vbus.c
create mode 100644 include/linux/reset/reset_rzv2h_usb2phy.h
diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
index c68132e38138..604f625544ed 100644
--- a/drivers/mux/Kconfig
+++ b/drivers/mux/Kconfig
@@ -59,4 +59,14 @@ config MUX_MMIO
To compile the driver as a module, choose M here: the module will
be called mux-mmio.
+config MUX_RZV2H_VBENCTL
+ tristate "Renesas RZ/V2H USB VBUS mux driver"
+ depends on RESET_RZV2H_USB2PHY || COMPILE_TEST
+ depends on OF
+ select REGMAP_MMIO
+ select AUXILIARY_BUS
+ default RESET_RZV2H_USB2PHY
+ help
+ Support for VBUS mux implemented on Renesas RZ/V2H SoCs.
+
endmenu
diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
index 6e9fa47daf56..9421660399af 100644
--- a/drivers/mux/Makefile
+++ b/drivers/mux/Makefile
@@ -8,9 +8,11 @@ mux-adg792a-objs := adg792a.o
mux-adgs1408-objs := adgs1408.o
mux-gpio-objs := gpio.o
mux-mmio-objs := mmio.o
+mux-rzv2h-usb-vbus-objs := rzv2h-usb-vbus.o
obj-$(CONFIG_MULTIPLEXER) += mux-core.o
obj-$(CONFIG_MUX_ADG792A) += mux-adg792a.o
obj-$(CONFIG_MUX_ADGS1408) += mux-adgs1408.o
obj-$(CONFIG_MUX_GPIO) += mux-gpio.o
obj-$(CONFIG_MUX_MMIO) += mux-mmio.o
+obj-$(CONFIG_MUX_RZV2H_VBENCTL) += mux-rzv2h-usb-vbus.o
diff --git a/drivers/mux/rzv2h-usb-vbus.c b/drivers/mux/rzv2h-usb-vbus.c
new file mode 100644
index 000000000000..9513bc8f35ff
--- /dev/null
+++ b/drivers/mux/rzv2h-usb-vbus.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas RZ/V2H(P) USB2 VBUS_SEL mux driver
+ *
+ * Copyright (C) 2025 Renesas Electronics Corp.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bitops.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/mux/driver.h>
+#include <linux/of.h>
+#include <linux/property.h>
+#include <linux/regmap.h>
+#include <linux/reset/reset_rzv2h_usb2phy.h>
+
+#define RZV2H_VBENCTL 0xf0c
+
+struct mux_rzv2h_usb_vbus_priv {
+ struct regmap_field *field;
+};
+
+static int mux_rzv2h_usb_vbus_set(struct mux_control *mux, int state)
+{
+ struct mux_rzv2h_usb_vbus_priv *priv = mux_chip_priv(mux->chip);
+
+ return regmap_field_write(priv->field, state);
+}
+
+static const struct mux_control_ops mux_rzv2h_usb_vbus_ops = {
+ .set = mux_rzv2h_usb_vbus_set,
+};
+
+static const struct regmap_config rzv2h_usb_vbus_regconf = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+ .max_register = RZV2H_VBENCTL,
+};
+
+static int mux_rzv2h_usb_vbus_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ struct reset_rzv2h_usb2phy_adev *rdev = adev->dev.platform_data;
+ struct mux_rzv2h_usb_vbus_priv *priv;
+ struct device *dev = &adev->dev;
+ struct mux_chip *mux_chip;
+ struct regmap *regmap;
+ struct reg_field reg_field = {
+ .reg = RZV2H_VBENCTL,
+ .lsb = 0,
+ .msb = 0,
+ };
+ int ret;
+
+ regmap = devm_regmap_init_mmio(dev, rdev->base, &rzv2h_usb_vbus_regconf);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
+
+ mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*priv));
+ if (IS_ERR(mux_chip))
+ return PTR_ERR(mux_chip);
+
+ priv = mux_chip_priv(mux_chip);
+
+ priv->field = devm_regmap_field_alloc(dev, regmap, reg_field);
+ if (IS_ERR(priv->field))
+ return PTR_ERR(priv->field);
+
+ mux_chip->ops = &mux_rzv2h_usb_vbus_ops;
+ mux_chip->mux[0].states = 2;
+ mux_chip->mux[0].idle_state = MUX_IDLE_AS_IS;
+
+ ret = devm_mux_chip_register(dev, mux_chip);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to register mux chip\n");
+
+ return 0;
+}
+
+static const struct auxiliary_device_id mux_rzv2h_usb_vbus_ids[] = {
+ { .name = "rzv2h_usb2phy_reset.vbus-sel-mux" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(auxiliary, mux_rzv2h_usb_vbus_ids);
+
+static struct auxiliary_driver mux_rzv2h_usb_vbus_driver = {
+ .name = "vbus-sel-mux",
+ .probe = mux_rzv2h_usb_vbus_probe,
+ .id_table = mux_rzv2h_usb_vbus_ids,
+};
+module_auxiliary_driver(mux_rzv2h_usb_vbus_driver);
+
+MODULE_DESCRIPTION("RZ/V2H USB VBUS_SEL mux driver");
+MODULE_AUTHOR("Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/reset/reset_rzv2h_usb2phy.h b/include/linux/reset/reset_rzv2h_usb2phy.h
new file mode 100644
index 000000000000..06247080a66c
--- /dev/null
+++ b/include/linux/reset/reset_rzv2h_usb2phy.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _RESET_RZV2H_USB2PHY_H
+#define _RESET_RZV2H_USB2PHY_H
+
+#include <linux/auxiliary_bus.h>
+
+struct reset_rzv2h_usb2phy_adev {
+ void __iomem *base;
+};
+
+#endif
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 07/22] reset: rzv2h-usb2phy: Add support for VBUS mux controller registration
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (5 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 08/22] dt-bindings: phy: renesas,usb2-phy: Document USB VBUS regulator Tommaso Merciai
` (14 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
The RZ/V2H USB2 PHY requires control of the VBUS selection line
(VBENCTL) through a mux controller described in the device tree as
"mux-controller". This change adds support for registering
vbus-sel-mux auxiliary driver during probe.
This enables proper management of USB2.0 VBUS source selection on
platforms using the RZ/V2H SoC.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes.
v2->v3:
- Use __devm_auxiliary_device_create() to create the auxiliary device.
v1->v2:
- New patch
drivers/reset/Kconfig | 1 +
drivers/reset/reset-rzv2h-usb2phy.c | 44 +++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index a771e2be53cb..acab9a028291 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -256,6 +256,7 @@ config RESET_RZG2L_USBPHY_CTRL
config RESET_RZV2H_USB2PHY
tristate "Renesas RZ/V2H(P) (and similar SoCs) USB2PHY Reset driver"
depends on ARCH_RENESAS || COMPILE_TEST
+ select AUXILIARY_BUS
help
Support for USB2PHY Port reset Control found on the RZ/V2H(P) SoC
(and similar SoCs).
diff --git a/drivers/reset/reset-rzv2h-usb2phy.c b/drivers/reset/reset-rzv2h-usb2phy.c
index 5bdd39274612..873191f30448 100644
--- a/drivers/reset/reset-rzv2h-usb2phy.c
+++ b/drivers/reset/reset-rzv2h-usb2phy.c
@@ -5,8 +5,10 @@
* Copyright (C) 2025 Renesas Electronics Corporation
*/
+#include <linux/auxiliary_bus.h>
#include <linux/cleanup.h>
#include <linux/delay.h>
+#include <linux/idr.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -14,6 +16,9 @@
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <linux/reset-controller.h>
+#include <linux/reset/reset_rzv2h_usb2phy.h>
+
+static DEFINE_IDA(auxiliary_ids);
struct rzv2h_usb2phy_regval {
u16 reg;
@@ -104,6 +109,41 @@ static int rzv2h_usb2phy_reset_of_xlate(struct reset_controller_dev *rcdev,
return 0;
}
+static void rzv2h_usb2phy_reset_ida_free(void *data)
+{
+ struct auxiliary_device *adev = data;
+
+ ida_free(&auxiliary_ids, adev->id);
+}
+
+static int rzv2h_usb2phy_reset_mux_register(struct device *dev,
+ void __iomem *base,
+ const char *mux_name)
+{
+ struct reset_rzv2h_usb2phy_adev *rdev;
+ struct auxiliary_device *adev;
+ int id;
+
+ rdev = devm_kzalloc(dev, sizeof(*rdev), GFP_KERNEL);
+ if (!rdev)
+ return -ENOMEM;
+
+ rdev->base = base;
+
+ id = ida_alloc(&auxiliary_ids, GFP_KERNEL);
+ if (id < 0)
+ return id;
+
+ adev = __devm_auxiliary_device_create(dev, dev->driver->name,
+ mux_name, rdev, id);
+ if (!adev) {
+ ida_free(&auxiliary_ids, id);
+ return -ENOMEM;
+ }
+
+ return devm_add_action_or_reset(dev, rzv2h_usb2phy_reset_ida_free, adev);
+}
+
static void rzv2h_usb2phy_reset_pm_runtime_put(void *data)
{
pm_runtime_put(data);
@@ -162,6 +202,10 @@ static int rzv2h_usb2phy_reset_probe(struct platform_device *pdev)
if (error)
return dev_err_probe(dev, error, "could not register reset controller\n");
+ error = rzv2h_usb2phy_reset_mux_register(dev, priv->base, "vbus-sel-mux");
+ if (error)
+ return dev_err_probe(dev, error, "could not register aux mux\n");
+
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 08/22] dt-bindings: phy: renesas,usb2-phy: Document USB VBUS regulator
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (6 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 07/22] reset: rzv2h-usb2phy: Add support for VBUS mux controller registration Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 09/22] dt-bindings: phy: renesas,usb2-phy: Document mux-states property Tommaso Merciai
` (13 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy, Conor Dooley
Document the 'vbus-regulator' child node in the Renesas USB2 PHY binding
to describe the internal USB VBUS regulator.
Require this regulator node on OTG channels to accurately represent
hardware dependencies in the device tree.
Documenting this regulator allows device trees to model the VBUS power
requirements of these SoCs properly.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- Collected CDooley tag
Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
index 2bbec8702a1e..2cd0efa75f81 100644
--- a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
@@ -89,6 +89,12 @@ properties:
Phandle to a regulator that provides power to the VBUS. This regulator
will be managed during the PHY power on/off sequence.
+ vbus-regulator:
+ $ref: /schemas/regulator/regulator.yaml#
+ description: USB VBUS internal regulator
+ type: object
+ unevaluatedProperties: false
+
renesas,no-otg-pins:
$ref: /schemas/types.yaml#/definitions/flag
description: |
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 09/22] dt-bindings: phy: renesas,usb2-phy: Document mux-states property
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (7 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 08/22] dt-bindings: phy: renesas,usb2-phy: Document USB VBUS regulator Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 10/22] phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control Tommaso Merciai
` (12 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy, Conor Dooley
Some Renesas SoCs, such as RZ/G3E, provide a USB2.0 OTG PHY with
configurable VBUS control through a multiplexed hardware register.
This register allows selecting the VBUS source via a mux control
line exposed by the PHY.
To represent this hardware configuration, support the standard
`mux-states` property in the Renesas USB2 PHY binding.
This allows the DeviceTree to model the VBUS source selection as
a mux, consistent with generic binding conventions.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- Collected CDooley tag.
v2->v3:
- Improved commit body.
- Improved mux-states description.
v1->v2:
- New patch
Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
index 2cd0efa75f81..448da30757f2 100644
--- a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
@@ -102,6 +102,11 @@ properties:
dr_mode: true
+ mux-states:
+ description:
+ phandle to a mux controller node that select the source for USB VBUS.
+ maxItems: 1
+
if:
properties:
compatible:
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 10/22] phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (8 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 09/22] dt-bindings: phy: renesas,usb2-phy: Document mux-states property Tommaso Merciai
@ 2025-11-21 15:11 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management Tommaso Merciai
` (11 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:11 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Enable OTG VBUS control on R-Car Gen3 USB2 PHY by registering a regulator
driver that manages the VBOUT line. This change allows the controller to
handle VBUS output for OTG ports using the regulator framework when the
platform requires hardware-based VBUS control.
Without this, some platforms cannot properly manage VBUS power on OTG-
capable ports, leading to potential USB functionality issues.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 142 ++++++++++++++++++++++-
1 file changed, 137 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 94a4521d7187..d2c03a846b58 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -22,6 +22,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
+#include <linux/regulator/driver.h>
#include <linux/reset.h>
#include <linux/string.h>
#include <linux/usb/of.h>
@@ -141,6 +142,7 @@ struct rcar_gen3_chan {
bool extcon_host;
bool is_otg_channel;
bool uses_otg_pins;
+ bool otg_internal_reg;
};
struct rcar_gen3_phy_drv_data {
@@ -225,6 +227,11 @@ static void rcar_gen3_phy_usb2_set_vbus(struct rcar_gen3_chan *ch,
static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
{
+ if (ch->otg_internal_reg) {
+ regulator_hardware_enable(ch->vbus, vbus);
+ return;
+ }
+
if (ch->phy_data->no_adp_ctrl || ch->phy_data->vblvl_ctrl) {
if (ch->vbus)
regulator_hardware_enable(ch->vbus, vbus);
@@ -593,7 +600,7 @@ static int rcar_gen3_phy_usb2_power_on(struct phy *p)
u32 val;
int ret = 0;
- if (channel->vbus) {
+ if (channel->vbus && !channel->otg_internal_reg) {
ret = regulator_enable(channel->vbus);
if (ret)
return ret;
@@ -634,7 +641,7 @@ static int rcar_gen3_phy_usb2_power_off(struct phy *p)
}
}
- if (channel->vbus)
+ if (channel->vbus && !channel->otg_internal_reg)
ret = regulator_disable(channel->vbus);
return ret;
@@ -809,6 +816,128 @@ static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
return 0;
}
+static int rcar_gen3_phy_usb2_regulator_endisable(struct regulator_dev *rdev,
+ bool enable)
+{
+ struct rcar_gen3_chan *channel = rdev_get_drvdata(rdev);
+ struct device *dev = channel->dev;
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0) {
+ dev_warn(dev, "pm_runtime_get failed: %i\n", ret);
+ return ret;
+ }
+
+ rcar_gen3_phy_usb2_set_vbus(channel, USB2_VBCTRL,
+ USB2_VBCTRL_VBOUT, enable);
+ pm_runtime_put_noidle(dev);
+
+ return ret;
+}
+
+static int rcar_gen3_phy_usb2_regulator_enable(struct regulator_dev *rdev)
+{
+ return rcar_gen3_phy_usb2_regulator_endisable(rdev, true);
+}
+
+static int rcar_gen3_phy_usb2_regulator_disable(struct regulator_dev *rdev)
+{
+ return rcar_gen3_phy_usb2_regulator_endisable(rdev, false);
+}
+
+static int rcar_gen3_phy_usb2_regulator_is_enabled(struct regulator_dev *rdev)
+{
+ struct rcar_gen3_chan *channel = rdev_get_drvdata(rdev);
+ void __iomem *usb2_base = channel->base;
+ struct device *dev = channel->dev;
+ u32 vbus_ctrl_reg = USB2_VBCTRL;
+ u32 val;
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0) {
+ dev_warn(dev, "pm_runtime_get failed: %i\n", ret);
+ return ret;
+ }
+
+ val = readl(usb2_base + vbus_ctrl_reg);
+
+ pm_runtime_put_noidle(dev);
+ dev_dbg(channel->dev, "%s: %08x\n", __func__, val);
+
+ return (val & USB2_VBCTRL_VBOUT) ? 1 : 0;
+}
+
+static const struct regulator_ops rcar_gen3_phy_usb2_regulator_ops = {
+ .enable = rcar_gen3_phy_usb2_regulator_enable,
+ .disable = rcar_gen3_phy_usb2_regulator_disable,
+ .is_enabled = rcar_gen3_phy_usb2_regulator_is_enabled,
+};
+
+static const struct regulator_desc rcar_gen3_phy_usb2_regulator = {
+ .name = "otg-vbus-regulator",
+ .of_match = of_match_ptr("vbus-regulator"),
+ .ops = &rcar_gen3_phy_usb2_regulator_ops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ .fixed_uV = 5000000,
+ .n_voltages = 1,
+};
+
+static void rcar_gen3_phy_usb2_vbus_disable_action(void *data)
+{
+ struct regulator *vbus = data;
+
+ regulator_disable(vbus);
+}
+
+static int rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(struct rcar_gen3_chan *channel,
+ bool enable)
+{
+ struct device *dev = channel->dev;
+ int ret;
+
+ channel->vbus = devm_regulator_get_exclusive(dev, "vbus");
+ if (IS_ERR(channel->vbus))
+ return PTR_ERR(channel->vbus);
+
+ if (!enable)
+ return 0;
+
+ ret = regulator_enable(channel->vbus);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, rcar_gen3_phy_usb2_vbus_disable_action,
+ channel->vbus);
+}
+
+static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *channel)
+{
+ struct device *dev = channel->dev;
+ struct regulator_config rcfg = { .dev = dev, };
+ struct regulator_dev *rdev;
+ bool enable = false;
+
+ rcfg.of_node = of_get_available_child_by_name(dev->of_node,
+ "vbus-regulator");
+ if (rcfg.of_node) {
+ rcfg.driver_data = channel;
+ rdev = devm_regulator_register(dev, &rcar_gen3_phy_usb2_regulator,
+ &rcfg);
+ of_node_put(rcfg.of_node);
+ if (IS_ERR(rdev))
+ return dev_err_probe(dev, PTR_ERR(rdev),
+ "Failed to create vbus-regulator\n");
+
+ channel->otg_internal_reg = true;
+ enable = true;
+ }
+
+ return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable);
+}
+
static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -890,10 +1019,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
}
- if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel)
- channel->vbus = devm_regulator_get_exclusive(dev, "vbus");
- else
+ if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) {
+ ret = rcar_gen3_phy_usb2_vbus_regulator_register(channel);
+ if (ret)
+ return ret;
+ } else {
channel->vbus = devm_regulator_get_optional(dev, "vbus");
+ }
if (IS_ERR(channel->vbus)) {
if (PTR_ERR(channel->vbus) == -EPROBE_DEFER)
return PTR_ERR(channel->vbus);
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (9 preceding siblings ...)
2025-11-21 15:11 ` [PATCH v4 10/22] phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-25 14:10 ` Geert Uytterhoeven
2025-11-21 15:12 ` [PATCH v4 12/22] dt-bindings: usb: renesas,usbhs: Add RZ/G3E SoC support Tommaso Merciai
` (10 subsequent siblings)
21 siblings, 1 reply; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Add support for selecting the phyrst mux-state using the Linux mux
subsystem in the R-Car Gen3 USB2 PHY driver. This ensures correct hardware
initialization and integration with systems utilizing the mux-state device
tree property.
A temporary wrapper for optional muxes is introduced until native support
is available in the multiplexer subsystem.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- Added missing select MULTIPLEXER into Kconfig.
v2->v3:
- No changes
v1->v2:
- New patch
drivers/phy/renesas/Kconfig | 1 +
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 34 ++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
index 16211072098e..d217c630b2fd 100644
--- a/drivers/phy/renesas/Kconfig
+++ b/drivers/phy/renesas/Kconfig
@@ -30,6 +30,7 @@ config PHY_RCAR_GEN3_USB2
depends on EXTCON || !EXTCON # if EXTCON=m, this cannot be built-in
depends on USB_SUPPORT
select GENERIC_PHY
+ select MULTIPLEXER
select USB_COMMON
help
Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs.
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index d2c03a846b58..9a1ea15b9869 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -17,6 +17,7 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/mux/consumer.h>
#include <linux/of.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
@@ -938,11 +939,27 @@ static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *cha
return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable);
}
+/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
+static inline struct mux_state *
+devm_mux_state_get_optional(struct device *dev, const char *mux_name)
+{
+ if (!of_property_present(dev->of_node, "mux-states"))
+ return NULL;
+
+ return devm_mux_state_get(dev, mux_name);
+}
+
+static void rcar_gen3_phy_mux_state_deselect(void *data)
+{
+ mux_state_deselect(data);
+}
+
static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct rcar_gen3_chan *channel;
struct phy_provider *provider;
+ struct mux_state *mux_state;
int ret = 0, i, irq;
if (!dev->of_node) {
@@ -1019,6 +1036,23 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
}
+ mux_state = devm_mux_state_get_optional(dev, NULL);
+ if (IS_ERR(mux_state)) {
+ if (PTR_ERR(mux_state) == -EPROBE_DEFER)
+ return PTR_ERR(mux_state);
+ mux_state = NULL;
+ } else {
+ ret = mux_state_select(mux_state);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to select USB mux\n");
+
+ ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
+ mux_state);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to register USB mux state deselect\n");
+ }
+
if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) {
ret = rcar_gen3_phy_usb2_vbus_regulator_register(channel);
if (ret)
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 12/22] dt-bindings: usb: renesas,usbhs: Add RZ/G3E SoC support
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (10 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 13/22] dt-bindings: phy: renesas,usb2-phy: Document RZ/G3E SoC Tommaso Merciai
` (9 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy, Conor Dooley
Document the Renesas USBHS controller found on the Renesas RZ/G3E SoC.
The USBHS block on RZ/G3E is functionally identical to the one found
on the RZ/G2L family, so no driver changes are needed. The existing
"renesas,rzg2l-usbhs" fallback compatible will continue to be used for
handling this IP.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- Collected CDooley tag
Documentation/devicetree/bindings/usb/renesas,usbhs.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
index 0b8b90dd1951..dc74e70f1b92 100644
--- a/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
+++ b/Documentation/devicetree/bindings/usb/renesas,usbhs.yaml
@@ -27,6 +27,7 @@ properties:
- renesas,usbhs-r9a07g044 # RZ/G2{L,LC}
- renesas,usbhs-r9a07g054 # RZ/V2L
- renesas,usbhs-r9a08g045 # RZ/G3S
+ - renesas,usbhs-r9a09g047 # RZ/G3E
- renesas,usbhs-r9a09g056 # RZ/V2N
- renesas,usbhs-r9a09g057 # RZ/V2H(P)
- const: renesas,rzg2l-usbhs
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 13/22] dt-bindings: phy: renesas,usb2-phy: Document RZ/G3E SoC
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (11 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 12/22] dt-bindings: usb: renesas,usbhs: Add RZ/G3E SoC support Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 14/22] dt-bindings: reset: Document RZ/G3E USB2PHY reset Tommaso Merciai
` (8 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy, Conor Dooley
Document USB2.0 phy bindings for RZ/G3E ("R9A09G047") SoC.
The RZ/G3E USB2.0 phy is functionally identical to the one found
on the RZ/V2H(P), so no driver changes are needed. The existing
"renesas,usb2-phy-r9a09g057" will be used as a fallback compatible for
this IP.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- Collected CDooley tag
Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
index 448da30757f2..9740e5b335f9 100644
--- a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml
@@ -41,7 +41,9 @@ properties:
- const: renesas,rzg2l-usb2-phy
- items:
- - const: renesas,usb2-phy-r9a09g056 # RZ/V2N
+ - enum:
+ - renesas,usb2-phy-r9a09g047 # RZ/G3E
+ - renesas,usb2-phy-r9a09g056 # RZ/V2N
- const: renesas,usb2-phy-r9a09g057
- const: renesas,usb2-phy-r9a09g077 # RZ/T2H
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 14/22] dt-bindings: reset: Document RZ/G3E USB2PHY reset
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (12 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 13/22] dt-bindings: phy: renesas,usb2-phy: Document RZ/G3E SoC Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 15/22] arm64: dts: renesas: r9a09g057: Add USB2.0 VBUS_SEL mux-controller support Tommaso Merciai
` (7 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy, Conor Dooley
Document USB2PHY reset controller bindings for RZ/G3E ("R9A09G047") SoC.
The RZ/G3E USB2PHY reset controller is functionally identical to the one
found on the RZ/V2H(P), so no driver changes are needed. The existing
"renesas,r9a09g057-usb2phy-reset" will be used as a fallback compatible
for this IP.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- Collected CDooley tag
.../bindings/reset/renesas,rzv2h-usb2phy-reset.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml b/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml
index 7ed0980b9ee1..66650ef8f772 100644
--- a/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml
+++ b/Documentation/devicetree/bindings/reset/renesas,rzv2h-usb2phy-reset.yaml
@@ -17,7 +17,9 @@ properties:
compatible:
oneOf:
- items:
- - const: renesas,r9a09g056-usb2phy-reset # RZ/V2N
+ - enum:
+ - renesas,r9a09g047-usb2phy-reset # RZ/G3E
+ - renesas,r9a09g056-usb2phy-reset # RZ/V2N
- const: renesas,r9a09g057-usb2phy-reset
- const: renesas,r9a09g057-usb2phy-reset # RZ/V2H(P)
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 15/22] arm64: dts: renesas: r9a09g057: Add USB2.0 VBUS_SEL mux-controller support
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (13 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 14/22] dt-bindings: reset: Document RZ/G3E USB2PHY reset Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 16/22] arm64: dts: renesas: r9a09g056: " Tommaso Merciai
` (6 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Enable control of USB2.0 VBUSEN via the VBUS_SEL bit in the VBENCTL
register. According to the RZ/V2H(P) SoC hardware manual, OTG channels
require VBUS_SEL set, while HOST-only channels require it cleared.
Add `#mux-state-cell` to the usb20phyrst and usb21phyrst reset
nodes to expose them as mux controllers.
Set the required mux-states in usb2_phy0 (OTG: state 1) and usb2_phy1
(HOST: state 0) nodes.
This enables proper VBUSEN management for OTG and HOST-only USB2.0
channels.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- Switch back to v2 implementation.
- Improve commit body.
v2->v3:
- Manipulate the mux controller as an internal node, and update
commit body accordingly.
v1->v2:
- New patch
arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g057.dtsi b/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
index 4df32d7e9998..b4bbcde33099 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
@@ -1034,6 +1034,7 @@ usb2_phy0: usb-phy@15800200 {
resets = <&usb20phyrst>;
#phy-cells = <1>;
power-domains = <&cpg>;
+ mux-states = <&usb20phyrst 1>;
status = "disabled";
};
@@ -1047,6 +1048,7 @@ usb2_phy1: usb-phy@15810200 {
resets = <&usb21phyrst>;
#phy-cells = <1>;
power-domains = <&cpg>;
+ mux-states = <&usb21phyrst 0>;
status = "disabled";
};
@@ -1074,6 +1076,7 @@ usb20phyrst: usb20phy-reset@15830000 {
resets = <&cpg 0xaf>;
power-domains = <&cpg>;
#reset-cells = <0>;
+ #mux-state-cells = <1>;
status = "disabled";
};
@@ -1084,6 +1087,7 @@ usb21phyrst: usb21phy-reset@15840000 {
resets = <&cpg 0xaf>;
power-domains = <&cpg>;
#reset-cells = <0>;
+ #mux-state-cells = <1>;
status = "disabled";
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 16/22] arm64: dts: renesas: r9a09g056: Add USB2.0 VBUS_SEL mux-controller support
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (14 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 15/22] arm64: dts: renesas: r9a09g057: Add USB2.0 VBUS_SEL mux-controller support Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 17/22] arm64: dts: renesas: r9a09g056: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
` (5 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Enable control of USB2.0 VBUSEN via the VBUS_SEL bit in the VBENCTL
register. According to the RZ/V2N SoC hardware manual, OTG channel
require VBUS_SEL set.
Add `#mux-state-cells` to the usb20phyrst reset node to expose
them as mux controllers.
Set the required mux-states in usb2_phy0 (OTG: state 1) node.
This enables proper VBUSEN management for OTG channel.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- Switch back to v2 implementation.
- Improve commit body.
v2->v3:
- No changes
v1->v2:
- No changes
arch/arm64/boot/dts/renesas/r9a09g056.dtsi | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g056.dtsi b/arch/arm64/boot/dts/renesas/r9a09g056.dtsi
index 8781c2fa7313..fd2b72caeceb 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g056.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g056.dtsi
@@ -663,6 +663,7 @@ usb2_phy0: usb-phy@15800200 {
resets = <&usb20phyrst>;
#phy-cells = <1>;
power-domains = <&cpg>;
+ mux-states = <&usb20phyrst 1>;
status = "disabled";
};
@@ -691,6 +692,7 @@ usb20phyrst: usb20phy-reset@15830000 {
resets = <&cpg 0xaf>;
power-domains = <&cpg>;
#reset-cells = <0>;
+ #mux-state-cells = <1>;
status = "disabled";
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 17/22] arm64: dts: renesas: r9a09g056: Add USB2.0 PHY VBUS internal regulator node
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (15 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 16/22] arm64: dts: renesas: r9a09g056: " Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 18/22] arm64: dts: renesas: r9a09g056n48-rzv2n-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
` (4 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
USB2.0 PHY of the RZ/V2N SoC can drive VBUS line via the VBOUT bit of
the VBCTRL register.
Add VBUS regulator nodes (usb2_phy0_vbus_otg) under the usb2_phy0
node to describe this hw functionality.
This enables proper management of VBUS for USB2.0 OTG devices and ensures
compliance with hardware requirements.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
arch/arm64/boot/dts/renesas/r9a09g056.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g056.dtsi b/arch/arm64/boot/dts/renesas/r9a09g056.dtsi
index fd2b72caeceb..c22721de7c23 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g056.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g056.dtsi
@@ -665,6 +665,11 @@ usb2_phy0: usb-phy@15800200 {
power-domains = <&cpg>;
mux-states = <&usb20phyrst 1>;
status = "disabled";
+
+ usb2_phy0_vbus_otg: vbus-regulator {
+ regulator-name = "USB2PHY0-VBUS-OTG";
+ status = "disabled";
+ };
};
hsusb: usb@15820000 {
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 18/22] arm64: dts: renesas: r9a09g056n48-rzv2n-evk: Enable USB2 PHY0 VBUS support
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (16 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 17/22] arm64: dts: renesas: r9a09g056: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 19/22] arm64: dts: renesas: r9a09g057: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
` (3 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Enable the vbus-supply and status properties for USB2 PHY0 and its
VBUS OTG regulator in the r9a09g056n48-rzv2n-evk device tree.
Enabling them ensures proper VBUS handling and reliable USB OTG
operation on the channel.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
arch/arm64/boot/dts/renesas/r9a09g056n48-rzv2n-evk.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g056n48-rzv2n-evk.dts b/arch/arm64/boot/dts/renesas/r9a09g056n48-rzv2n-evk.dts
index 066e66b5d51a..54ed7cb2d73b 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g056n48-rzv2n-evk.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g056n48-rzv2n-evk.dts
@@ -389,6 +389,11 @@ &usb2_phy0 {
pinctrl-0 = <&usb20_pins>;
pinctrl-names = "default";
+ vbus-supply = <&usb2_phy0_vbus_otg>;
+ status = "okay";
+};
+
+&usb2_phy0_vbus_otg {
status = "okay";
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 19/22] arm64: dts: renesas: r9a09g057: Add USB2.0 PHY VBUS internal regulator node
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (17 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 18/22] arm64: dts: renesas: r9a09g056n48-rzv2n-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 20/22] arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
` (2 subsequent siblings)
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
USB2.0 PHY of the RZ/V2H(P) SoC can drive VBUS line via the VBOUT bit of
the VBCTRL register.
Add VBUS regulator nodes (usb2_phy0_vbus_otg) under the usb2_phy0
nodes to describe this hw functionality.
This enables proper management of VBUS for USB2.0 OTG devices and ensures
compliance with hardware requirements.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g057.dtsi b/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
index b4bbcde33099..9dc0fcaad86f 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
@@ -1036,6 +1036,11 @@ usb2_phy0: usb-phy@15800200 {
power-domains = <&cpg>;
mux-states = <&usb20phyrst 1>;
status = "disabled";
+
+ usb2_phy0_vbus_otg: vbus-regulator {
+ regulator-name = "USB2PHY0-VBUS-OTG";
+ status = "disabled";
+ };
};
usb2_phy1: usb-phy@15810200 {
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 20/22] arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable USB2 PHY0 VBUS support
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (18 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 19/22] arm64: dts: renesas: r9a09g057: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 21/22] arm64: dts: renesas: r9a09g047: Add USB2.0 support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 22/22] arm64: dts: renesas: r9a09g047e57-smarc: Enable " Tommaso Merciai
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Enable the vbus-supply and status properties for USB2 PHY0 and its
VBUS OTG regulator in the r9a09g057h44-rzv2h-evk device tree.
Enabling them ensures proper VBUS handling and reliable USB OTG
operation on the channel.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts b/arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts
index 445fce156f73..eeeb5a0be6b6 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g057h44-rzv2h-evk.dts
@@ -440,6 +440,11 @@ &usb2_phy0 {
pinctrl-0 = <&usb20_pins>;
pinctrl-names = "default";
+ vbus-supply = <&usb2_phy0_vbus_otg>;
+ status = "okay";
+};
+
+&usb2_phy0_vbus_otg {
status = "okay";
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 21/22] arm64: dts: renesas: r9a09g047: Add USB2.0 support
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (19 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 20/22] arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 22/22] arm64: dts: renesas: r9a09g047e57-smarc: Enable " Tommaso Merciai
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
The Renesas RZ/G3E ("R9A09G047") SoC supports 1x channel with OTG/DRD
and 1x channel with host interface.
Add the ECHI, OHCI, USB2.0 PHY and reset control nodes for USB2.0 channels
in R9A09G047 SoC DTSI.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- Switch back to v2 implementation for mux controller.
v2->v3:
- Manipulate the mux controller as an internal node.
v1->v2:
- No changes
arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 125 +++++++++++++++++++++
1 file changed, 125 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g047.dtsi b/arch/arm64/boot/dts/renesas/r9a09g047.dtsi
index 7a469de3bb62..90435e5673fb 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g047.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g047.dtsi
@@ -853,6 +853,131 @@ gic: interrupt-controller@14900000 {
interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>;
};
+ ohci0: usb@15800000 {
+ compatible = "generic-ohci";
+ reg = <0 0x15800000 0 0x100>;
+ interrupts = <GIC_SPI 742 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xb3>, <&cpg CPG_MOD 0xb6>;
+ resets = <&usb20phyrst>, <&cpg 0xac>;
+ phys = <&usb2_phy0 1>;
+ phy-names = "usb";
+ power-domains = <&cpg>;
+ status = "disabled";
+ };
+
+ ohci1: usb@15810000 {
+ compatible = "generic-ohci";
+ reg = <0 0x15810000 0 0x100>;
+ interrupts = <GIC_SPI 747 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xb4>, <&cpg CPG_MOD 0xb7>;
+ resets = <&usb21phyrst>, <&cpg 0xad>;
+ phys = <&usb2_phy1 1>;
+ phy-names = "usb";
+ power-domains = <&cpg>;
+ status = "disabled";
+ };
+
+ ehci0: usb@15800100 {
+ compatible = "generic-ehci";
+ reg = <0 0x15800100 0 0x100>;
+ interrupts = <GIC_SPI 743 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xb3>, <&cpg CPG_MOD 0xb6>;
+ resets = <&usb20phyrst>, <&cpg 0xac>;
+ phys = <&usb2_phy0 2>;
+ phy-names = "usb";
+ companion = <&ohci0>;
+ power-domains = <&cpg>;
+ status = "disabled";
+ };
+
+ ehci1: usb@15810100 {
+ compatible = "generic-ehci";
+ reg = <0 0x15810100 0 0x100>;
+ interrupts = <GIC_SPI 748 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xb4>, <&cpg CPG_MOD 0xb7>;
+ resets = <&usb21phyrst>, <&cpg 0xad>;
+ phys = <&usb2_phy1 2>;
+ phy-names = "usb";
+ companion = <&ohci1>;
+ power-domains = <&cpg>;
+ status = "disabled";
+ };
+
+ usb2_phy0: usb-phy@15800200 {
+ compatible = "renesas,usb2-phy-r9a09g047",
+ "renesas,usb2-phy-r9a09g057";
+ reg = <0 0x15800200 0 0x700>;
+ interrupts = <GIC_SPI 745 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xb3>,
+ <&cpg CPG_CORE R9A09G047_USB2_0_CLK_CORE0>;
+ clock-names = "fck", "usb_x1";
+ resets = <&usb20phyrst>;
+ #phy-cells = <1>;
+ power-domains = <&cpg>;
+ mux-states = <&usb20phyrst 1>;
+ status = "disabled";
+
+ usb2_phy0_vbus_otg: vbus-regulator {
+ regulator-name = "USB2PHY0-VBUS-OTG";
+ status = "disabled";
+ };
+ };
+
+ usb2_phy1: usb-phy@15810200 {
+ compatible = "renesas,usb2-phy-r9a09g047",
+ "renesas,usb2-phy-r9a09g057";
+ reg = <0 0x15810200 0 0x700>;
+ interrupts = <GIC_SPI 750 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xb4>,
+ <&cpg CPG_CORE R9A09G047_USB2_0_CLK_CORE1>;
+ clock-names = "fck", "usb_x1";
+ resets = <&usb21phyrst>;
+ #phy-cells = <1>;
+ power-domains = <&cpg>;
+ mux-states = <&usb21phyrst 0>;
+ status = "disabled";
+ };
+
+ hsusb: usb@15820000 {
+ compatible = "renesas,usbhs-r9a09g047",
+ "renesas,rzg2l-usbhs";
+ reg = <0 0x15820000 0 0x10000>;
+ interrupts = <GIC_SPI 751 IRQ_TYPE_EDGE_RISING>,
+ <GIC_SPI 752 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 753 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 754 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xb3>, <&cpg CPG_MOD 0xb5>;
+ resets = <&usb20phyrst>, <&cpg 0xae>;
+ phys = <&usb2_phy0 3>;
+ phy-names = "usb";
+ power-domains = <&cpg>;
+ status = "disabled";
+ };
+
+ usb20phyrst: reset-controller@15830000 {
+ compatible = "renesas,r9a09g047-usb2phy-reset",
+ "renesas,r9a09g057-usb2phy-reset";
+ reg = <0 0x15830000 0 0x10000>;
+ clocks = <&cpg CPG_MOD 0xb6>;
+ resets = <&cpg 0xaf>;
+ power-domains = <&cpg>;
+ #reset-cells = <0>;
+ #mux-state-cells = <1>;
+ status = "disabled";
+ };
+
+ usb21phyrst: reset-controller@15840000 {
+ compatible = "renesas,r9a09g047-usb2phy-reset",
+ "renesas,r9a09g057-usb2phy-reset";
+ reg = <0 0x15840000 0 0x10000>;
+ clocks = <&cpg CPG_MOD 0xb7>;
+ resets = <&cpg 0xaf>;
+ power-domains = <&cpg>;
+ #reset-cells = <0>;
+ #mux-state-cells = <1>;
+ status = "disabled";
+ };
+
sdhi0: mmc@15c00000 {
compatible = "renesas,sdhi-r9a09g047", "renesas,sdhi-r9a09g057";
reg = <0x0 0x15c00000 0 0x10000>;
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v4 22/22] arm64: dts: renesas: r9a09g047e57-smarc: Enable USB2.0 support
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
` (20 preceding siblings ...)
2025-11-21 15:12 ` [PATCH v4 21/22] arm64: dts: renesas: r9a09g047: Add USB2.0 support Tommaso Merciai
@ 2025-11-21 15:12 ` Tommaso Merciai
21 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-21 15:12 UTC (permalink / raw)
To: tomm.merciai
Cc: linux-renesas-soc, biju.das.jz, Tommaso Merciai, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Enable USB2.0 support on the RZ/G3E EVK board, USB1B_1A_HOST and
USB5_4_HOST connectors support only host operation and USB0_OTG
supports host/peripheral operation.
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v3->v4:
- No changes
v2->v3:
- No changes
v1->v2:
- No changes
.../boot/dts/renesas/r9a09g047e57-smarc.dts | 49 +++++++++++++++++++
.../boot/dts/renesas/renesas-smarc2.dtsi | 23 +++++++++
2 files changed, 72 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
index 08e814c03fa8..ca19e8628c80 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
@@ -164,6 +164,28 @@ sd1-data {
<RZG3E_PORT_PINMUX(G, 5, 1)>; /* SD1DAT3 */
};
};
+
+ usb20_pins: usb20 {
+ ovc {
+ pinmux = <RZG3E_PORT_PINMUX(0, 0, 12)>; /* OVC */
+ bias-pull-up;
+ };
+
+ vbus {
+ pinmux = <RZG3E_PORT_PINMUX(0, 1, 12)>; /* VBUS */
+ };
+ };
+
+ usb21_pins: usb21 {
+ ovc {
+ pinmux = <RZG3E_PORT_PINMUX(G, 6, 12)>; /* OVC */
+ bias-pull-up;
+ };
+
+ vbus {
+ pinmux = <RZG3E_PORT_PINMUX(K, 3, 12)>; /* VBUS */
+ };
+ };
};
&scif0 {
@@ -179,3 +201,30 @@ &sdhi1 {
vmmc-supply = <®_3p3v>;
vqmmc-supply = <&vqmmc_sd1_pvdd>;
};
+
+&usb20phyrst {
+ status = "okay";
+};
+
+&usb21phyrst {
+ status = "okay";
+};
+
+&usb2_phy0 {
+ pinctrl-0 = <&usb20_pins>;
+ pinctrl-names = "default";
+
+ vbus-supply = <&usb2_phy0_vbus_otg>;
+ status = "okay";
+};
+
+&usb2_phy0_vbus_otg {
+ status = "okay";
+};
+
+&usb2_phy1 {
+ pinctrl-0 = <&usb21_pins>;
+ pinctrl-names = "default";
+
+ status = "okay";
+};
diff --git a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
index 58561da3007a..2daf437abb82 100644
--- a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
+++ b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
@@ -90,11 +90,34 @@ &canfd {
status = "okay";
};
+&ehci0 {
+ dr_mode = "otg";
+ status = "okay";
+};
+
+&ehci1 {
+ status = "okay";
+};
+
+&hsusb {
+ dr_mode = "otg";
+ status = "okay";
+};
+
&i2c0 {
status = "okay";
clock-frequency = <400000>;
};
+&ohci0 {
+ dr_mode = "otg";
+ status = "okay";
+};
+
+&ohci1 {
+ status = "okay";
+};
+
&scif0 {
status = "okay";
};
--
2.43.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints
2025-11-21 15:11 ` [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints Tommaso Merciai
@ 2025-11-21 18:24 ` Conor Dooley
2025-11-24 8:57 ` Tommaso Merciai
0 siblings, 1 reply; 30+ messages in thread
From: Conor Dooley @ 2025-11-21 18:24 UTC (permalink / raw)
To: Tommaso Merciai
Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
[-- Attachment #1: Type: text/plain, Size: 2056 bytes --]
On Fri, Nov 21, 2025 at 04:11:50PM +0100, Tommaso Merciai wrote:
> The nodename pattern in created an unnecessary restriction that forced
> all mux nodes to be named with the 'mux-controller' prefix.
> This prevented valid use cases where mux functionality is part of other
> hardware blocks that should use more specific naming conventions.
>
> Remove the $nodename pattern constraints from both the 'select' keyword
> and the properties section of the mux-controller schema.
>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Funnily enough, there's another patch that I saw today that hit this
same thing:
https://lore.kernel.org/all/176373269741.263545.10849918874919174841.robh@kernel.org/
> ---
> v3->v4:
> - New patch.
>
> Documentation/devicetree/bindings/mux/mux-controller.yaml | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/mux/mux-controller.yaml b/Documentation/devicetree/bindings/mux/mux-controller.yaml
> index 78340bbe4df6..6defb9da10f7 100644
> --- a/Documentation/devicetree/bindings/mux/mux-controller.yaml
> +++ b/Documentation/devicetree/bindings/mux/mux-controller.yaml
> @@ -63,18 +63,12 @@ description: |
>
> select:
> anyOf:
> - - properties:
> - $nodename:
> - pattern: '^mux-controller'
> - required:
> - '#mux-control-cells'
> - required:
> - '#mux-state-cells'
>
> properties:
> - $nodename:
> - pattern: '^mux-controller(@.*|-([0-9]|[1-9][0-9]+))?$'
I need to apologise, I told you to delete the wrong thing in my DM
earlier. Only deleting this part was actually required, deleting the
select portion doesn't really do anything for your problem.
What you've done is probably fine though, since anything actually acting
as a mux-controller will have the cells properties.
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
> -
> '#mux-control-cells':
> enum: [ 0, 1 ]
>
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints
2025-11-21 18:24 ` Conor Dooley
@ 2025-11-24 8:57 ` Tommaso Merciai
0 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-24 8:57 UTC (permalink / raw)
To: Conor Dooley
Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Geert Uytterhoeven, Magnus Damm,
Sebastian Reichel, Andi Shyti, Jonathan Cameron,
Uwe Kleine-König, Arnd Bergmann, Greg Kroah-Hartman,
devicetree, linux-kernel, linux-phy
Hi Conor,
Thank you for your review!
On Fri, Nov 21, 2025 at 06:24:03PM +0000, Conor Dooley wrote:
> On Fri, Nov 21, 2025 at 04:11:50PM +0100, Tommaso Merciai wrote:
> > The nodename pattern in created an unnecessary restriction that forced
> > all mux nodes to be named with the 'mux-controller' prefix.
> > This prevented valid use cases where mux functionality is part of other
> > hardware blocks that should use more specific naming conventions.
> >
> > Remove the $nodename pattern constraints from both the 'select' keyword
> > and the properties section of the mux-controller schema.
> >
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
>
> Funnily enough, there's another patch that I saw today that hit this
> same thing:
> https://lore.kernel.org/all/176373269741.263545.10849918874919174841.robh@kernel.org/
:)
>
> > ---
> > v3->v4:
> > - New patch.
> >
> > Documentation/devicetree/bindings/mux/mux-controller.yaml | 6 ------
> > 1 file changed, 6 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/mux/mux-controller.yaml b/Documentation/devicetree/bindings/mux/mux-controller.yaml
> > index 78340bbe4df6..6defb9da10f7 100644
> > --- a/Documentation/devicetree/bindings/mux/mux-controller.yaml
> > +++ b/Documentation/devicetree/bindings/mux/mux-controller.yaml
> > @@ -63,18 +63,12 @@ description: |
> >
> > select:
> > anyOf:
> > - - properties:
> > - $nodename:
> > - pattern: '^mux-controller'
> > - required:
> > - '#mux-control-cells'
> > - required:
> > - '#mux-state-cells'
> >
>
> > properties:
> > - $nodename:
> > - pattern: '^mux-controller(@.*|-([0-9]|[1-9][0-9]+))?$'
>
> I need to apologise, I told you to delete the wrong thing in my DM
> earlier. Only deleting this part was actually required, deleting the
> select portion doesn't really do anything for your problem.
> What you've done is probably fine though, since anything actually acting
> as a mux-controller will have the cells properties.
No worries! :)
Thank you for your review/hint!
>
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> pw-bot: not-applicable
>
> > -
> > '#mux-control-cells':
> > enum: [ 0, 1 ]
> >
> > --
> > 2.43.0
> >
Thanks & Regards,
Tommaso
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management
2025-11-21 15:12 ` [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management Tommaso Merciai
@ 2025-11-25 14:10 ` Geert Uytterhoeven
2025-11-25 15:57 ` Tommaso Merciai
0 siblings, 1 reply; 30+ messages in thread
From: Geert Uytterhoeven @ 2025-11-25 14:10 UTC (permalink / raw)
To: Tommaso Merciai
Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Magnus Damm, Sebastian Reichel,
Andi Shyti, Jonathan Cameron, Uwe Kleine-König,
Arnd Bergmann, Greg Kroah-Hartman, devicetree, linux-kernel,
linux-phy
Hi Tommaso,
On Fri, 21 Nov 2025 at 16:14, Tommaso Merciai
<tommaso.merciai.xr@bp.renesas.com> wrote:
> Add support for selecting the phyrst mux-state using the Linux mux
> subsystem in the R-Car Gen3 USB2 PHY driver. This ensures correct hardware
> initialization and integration with systems utilizing the mux-state device
> tree property.
>
> A temporary wrapper for optional muxes is introduced until native support
> is available in the multiplexer subsystem.
>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Thanks for your patch!
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -938,11 +939,27 @@ static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *cha
> return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable);
> }
>
> +/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
> +static inline struct mux_state *
> +devm_mux_state_get_optional(struct device *dev, const char *mux_name)
> +{
> + if (!of_property_present(dev->of_node, "mux-states"))
> + return NULL;
> +
> + return devm_mux_state_get(dev, mux_name);
> +}
> +
> +static void rcar_gen3_phy_mux_state_deselect(void *data)
> +{
> + mux_state_deselect(data);
> +}
> +
> static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct rcar_gen3_chan *channel;
> struct phy_provider *provider;
> + struct mux_state *mux_state;
> int ret = 0, i, irq;
>
> if (!dev->of_node) {
> @@ -1019,6 +1036,23 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
> }
>
> + mux_state = devm_mux_state_get_optional(dev, NULL);
> + if (IS_ERR(mux_state)) {
> + if (PTR_ERR(mux_state) == -EPROBE_DEFER)
> + return PTR_ERR(mux_state);
> + mux_state = NULL;
No need to set mux_state to NULL, as mux_state is not used below.
However, shouldn't you propagate all errors up?
If the mux is not present, mux_state should already be NULL,
i.e. IS_ERR(mux_state) would be false.
> + } else {
> + ret = mux_state_select(mux_state);
This causes a crash on R-Car Gen3 and RZ/Five, as mux_state_select()
doesn't handle NULL pointers gracefully yet.
Adding a check like
- } else {
+ } else if (mux_state) {
fixes the issue.
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to select USB mux\n");
> +
> + ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
> + mux_state);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "Failed to register USB mux state deselect\n");
> + }
> +
> if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) {
> ret = rcar_gen3_phy_usb2_vbus_regulator_register(channel);
> if (ret)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management
2025-11-25 14:10 ` Geert Uytterhoeven
@ 2025-11-25 15:57 ` Tommaso Merciai
2025-11-26 7:43 ` Geert Uytterhoeven
0 siblings, 1 reply; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-25 15:57 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Magnus Damm, Sebastian Reichel,
Andi Shyti, Jonathan Cameron, Uwe Kleine-König,
Arnd Bergmann, Greg Kroah-Hartman, devicetree, linux-kernel,
linux-phy
Hi Geert,
Thanks for your review!
On Tue, Nov 25, 2025 at 03:10:22PM +0100, Geert Uytterhoeven wrote:
> Hi Tommaso,
>
> On Fri, 21 Nov 2025 at 16:14, Tommaso Merciai
> <tommaso.merciai.xr@bp.renesas.com> wrote:
> > Add support for selecting the phyrst mux-state using the Linux mux
> > subsystem in the R-Car Gen3 USB2 PHY driver. This ensures correct hardware
> > initialization and integration with systems utilizing the mux-state device
> > tree property.
> >
> > A temporary wrapper for optional muxes is introduced until native support
> > is available in the multiplexer subsystem.
> >
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
>
> Thanks for your patch!
>
> > --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > @@ -938,11 +939,27 @@ static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *cha
> > return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable);
> > }
> >
> > +/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
> > +static inline struct mux_state *
> > +devm_mux_state_get_optional(struct device *dev, const char *mux_name)
> > +{
> > + if (!of_property_present(dev->of_node, "mux-states"))
> > + return NULL;
> > +
> > + return devm_mux_state_get(dev, mux_name);
> > +}
> > +
> > +static void rcar_gen3_phy_mux_state_deselect(void *data)
> > +{
> > + mux_state_deselect(data);
> > +}
> > +
> > static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > struct rcar_gen3_chan *channel;
> > struct phy_provider *provider;
> > + struct mux_state *mux_state;
> > int ret = 0, i, irq;
> >
> > if (!dev->of_node) {
> > @@ -1019,6 +1036,23 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> > phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
> > }
> >
> > + mux_state = devm_mux_state_get_optional(dev, NULL);
> > + if (IS_ERR(mux_state)) {
> > + if (PTR_ERR(mux_state) == -EPROBE_DEFER)
> > + return PTR_ERR(mux_state);
> > + mux_state = NULL;
>
> No need to set mux_state to NULL, as mux_state is not used below.
>
> However, shouldn't you propagate all errors up?
> If the mux is not present, mux_state should already be NULL,
> i.e. IS_ERR(mux_state) would be false.
>
> > + } else {
> > + ret = mux_state_select(mux_state);
>
> This causes a crash on R-Car Gen3 and RZ/Five, as mux_state_select()
> doesn't handle NULL pointers gracefully yet.
>
> Adding a check like
>
> - } else {
> + } else if (mux_state) {
>
> fixes the issue.
Thank you for checking this!
Ack :)
I will switch to:
mux_state = devm_mux_state_get_optional(dev, NULL);
if (IS_ERR(mux_state)) {
return PTR_ERR(mux_state);
} else if (mux_state) {
ret = mux_state_select(mux_state);
if (ret)
return dev_err_probe(dev, ret, "Failed to select USB mux\n");
ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
mux_state);
if (ret)
return dev_err_probe(dev, ret,
"Failed to register USB mux state deselect\n");
}
In v5.
Kind Regards,
Tommaso
>
> > + if (ret)
> > + return dev_err_probe(dev, ret, "Failed to select USB mux\n");
> > +
> > + ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
> > + mux_state);
> > + if (ret)
> > + return dev_err_probe(dev, ret,
> > + "Failed to register USB mux state deselect\n");
> > + }
> > +
> > if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) {
> > ret = rcar_gen3_phy_usb2_vbus_regulator_register(channel);
> > if (ret)
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management
2025-11-25 15:57 ` Tommaso Merciai
@ 2025-11-26 7:43 ` Geert Uytterhoeven
0 siblings, 0 replies; 30+ messages in thread
From: Geert Uytterhoeven @ 2025-11-26 7:43 UTC (permalink / raw)
To: Tommaso Merciai
Cc: tomm.merciai, linux-renesas-soc, biju.das.jz, Peter Rosin,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vinod Koul,
Kishon Vijay Abraham I, Fabrizio Castro, Lad Prabhakar,
Philipp Zabel, Yoshihiro Shimoda, Magnus Damm, Sebastian Reichel,
Andi Shyti, Jonathan Cameron, Uwe Kleine-König,
Arnd Bergmann, Greg Kroah-Hartman, devicetree, linux-kernel,
linux-phy
Hi Tommaso,
On Tue, 25 Nov 2025 at 16:57, Tommaso Merciai
<tommaso.merciai.xr@bp.renesas.com> wrote:
> On Tue, Nov 25, 2025 at 03:10:22PM +0100, Geert Uytterhoeven wrote:
> > On Fri, 21 Nov 2025 at 16:14, Tommaso Merciai
> > <tommaso.merciai.xr@bp.renesas.com> wrote:
> > > Add support for selecting the phyrst mux-state using the Linux mux
> > > subsystem in the R-Car Gen3 USB2 PHY driver. This ensures correct hardware
> > > initialization and integration with systems utilizing the mux-state device
> > > tree property.
> > >
> > > A temporary wrapper for optional muxes is introduced until native support
> > > is available in the multiplexer subsystem.
> > >
> > > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > > --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > > +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> > > @@ -938,11 +939,27 @@ static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *cha
> > > return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable);
> > > }
> > >
> > > +/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
> > > +static inline struct mux_state *
> > > +devm_mux_state_get_optional(struct device *dev, const char *mux_name)
> > > +{
> > > + if (!of_property_present(dev->of_node, "mux-states"))
> > > + return NULL;
> > > +
> > > + return devm_mux_state_get(dev, mux_name);
> > > +}
> > > +
> > > +static void rcar_gen3_phy_mux_state_deselect(void *data)
> > > +{
> > > + mux_state_deselect(data);
> > > +}
> > > +
> > > static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> > > {
> > > struct device *dev = &pdev->dev;
> > > struct rcar_gen3_chan *channel;
> > > struct phy_provider *provider;
> > > + struct mux_state *mux_state;
> > > int ret = 0, i, irq;
> > >
> > > if (!dev->of_node) {
> > > @@ -1019,6 +1036,23 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
> > > phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
> > > }
> > >
> > > + mux_state = devm_mux_state_get_optional(dev, NULL);
> > > + if (IS_ERR(mux_state)) {
> > > + if (PTR_ERR(mux_state) == -EPROBE_DEFER)
> > > + return PTR_ERR(mux_state);
> > > + mux_state = NULL;
> >
> > No need to set mux_state to NULL, as mux_state is not used below.
> >
> > However, shouldn't you propagate all errors up?
> > If the mux is not present, mux_state should already be NULL,
> > i.e. IS_ERR(mux_state) would be false.
> >
> > > + } else {
> > > + ret = mux_state_select(mux_state);
> >
> > This causes a crash on R-Car Gen3 and RZ/Five, as mux_state_select()
> > doesn't handle NULL pointers gracefully yet.
> >
> > Adding a check like
> >
> > - } else {
> > + } else if (mux_state) {
> >
> > fixes the issue.
>
> Thank you for checking this!
>
> Ack :)
> I will switch to:
>
> mux_state = devm_mux_state_get_optional(dev, NULL);
> if (IS_ERR(mux_state)) {
> return PTR_ERR(mux_state);
> } else if (mux_state) {
Please no else after return.
> ret = mux_state_select(mux_state);
> if (ret)
> return dev_err_probe(dev, ret, "Failed to select USB mux\n");
>
> ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
> mux_state);
> if (ret)
> return dev_err_probe(dev, ret,
> "Failed to register USB mux state deselect\n");
> }
>
> In v5.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux
2025-11-21 15:11 ` [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux Tommaso Merciai
@ 2025-11-27 2:28 ` Jian Hui Lee
2025-11-27 9:07 ` Tommaso Merciai
0 siblings, 1 reply; 30+ messages in thread
From: Jian Hui Lee @ 2025-11-27 2:28 UTC (permalink / raw)
To: tommaso.merciai.xr
Cc: andi.shyti, arnd, biju.das.jz, conor+dt, devicetree,
fabrizio.castro.jz, geert+renesas, gregkh, jonathan.cameron,
kishon, krzk+dt, linux-kernel, linux-phy, linux-renesas-soc,
magnus.damm, p.zabel, peda, prabhakar.mahadev-lad.rj, robh,
sebastian.reichel, tomm.merciai, ukleinek, vkoul,
yoshihiro.shimoda.uh
On Fri, Nov 21, 2025 at 04:11:55PM +0100, Tommaso Merciai wrote:
> As per the RZ/V2H(P) HW manual, VBUSEN can be controlled by the VBUS_SEL
> bit of the VBENCTL Control Register. This register is mapped in the
> reset framework. The reset driver expose this register as mux-controller
> and instantiates this driver. The consumer will use the mux API to
> control the VBUS_SEL bit.
>
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> ---
> v3->v4:
> - Removed mux_chip->dev.of_node not needed.
>
> v2->v3:
> - Added mux_chip->dev.of_node = dev->of_node->child as the mux-controller
> is an internal node.
> - Fixed auxiliary_device_id name.
> - Get rdev using from platform_data.
> - Drop struct auxiliary_device adev from reset_rzv2h_usb2phy_adev
> as it is needed.
> - Drop to_reset_rzv2h_usb2phy_adev() as it is not needed.
>
> v1->v2:
> - New patch
>
> drivers/mux/Kconfig | 10 +++
> drivers/mux/Makefile | 2 +
> drivers/mux/rzv2h-usb-vbus.c | 97 +++++++++++++++++++++++
> include/linux/reset/reset_rzv2h_usb2phy.h | 11 +++
> 4 files changed, 120 insertions(+)
> create mode 100644 drivers/mux/rzv2h-usb-vbus.c
> create mode 100644 include/linux/reset/reset_rzv2h_usb2phy.h
>
> diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
> index c68132e38138..604f625544ed 100644
> --- a/drivers/mux/Kconfig
> +++ b/drivers/mux/Kconfig
> @@ -59,4 +59,14 @@ config MUX_MMIO
> To compile the driver as a module, choose M here: the module will
> be called mux-mmio.
>
> +config MUX_RZV2H_VBENCTL
> + tristate "Renesas RZ/V2H USB VBUS mux driver"
> + depends on RESET_RZV2H_USB2PHY || COMPILE_TEST
> + depends on OF
> + select REGMAP_MMIO
> + select AUXILIARY_BUS
> + default RESET_RZV2H_USB2PHY
> + help
> + Support for VBUS mux implemented on Renesas RZ/V2H SoCs.
> +
> endmenu
> diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
> index 6e9fa47daf56..9421660399af 100644
> --- a/drivers/mux/Makefile
> +++ b/drivers/mux/Makefile
> @@ -8,9 +8,11 @@ mux-adg792a-objs := adg792a.o
> mux-adgs1408-objs := adgs1408.o
> mux-gpio-objs := gpio.o
> mux-mmio-objs := mmio.o
> +mux-rzv2h-usb-vbus-objs := rzv2h-usb-vbus.o
>
> obj-$(CONFIG_MULTIPLEXER) += mux-core.o
> obj-$(CONFIG_MUX_ADG792A) += mux-adg792a.o
> obj-$(CONFIG_MUX_ADGS1408) += mux-adgs1408.o
> obj-$(CONFIG_MUX_GPIO) += mux-gpio.o
> obj-$(CONFIG_MUX_MMIO) += mux-mmio.o
> +obj-$(CONFIG_MUX_RZV2H_VBENCTL) += mux-rzv2h-usb-vbus.o
> diff --git a/drivers/mux/rzv2h-usb-vbus.c b/drivers/mux/rzv2h-usb-vbus.c
> new file mode 100644
> index 000000000000..9513bc8f35ff
> --- /dev/null
> +++ b/drivers/mux/rzv2h-usb-vbus.c
> @@ -0,0 +1,97 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Renesas RZ/V2H(P) USB2 VBUS_SEL mux driver
> + *
> + * Copyright (C) 2025 Renesas Electronics Corp.
> + */
> +
> +#include <linux/auxiliary_bus.h>
> +#include <linux/bitops.h>
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/mux/driver.h>
> +#include <linux/of.h>
> +#include <linux/property.h>
> +#include <linux/regmap.h>
> +#include <linux/reset/reset_rzv2h_usb2phy.h>
> +
> +#define RZV2H_VBENCTL 0xf0c
> +
> +struct mux_rzv2h_usb_vbus_priv {
> + struct regmap_field *field;
> +};
> +
> +static int mux_rzv2h_usb_vbus_set(struct mux_control *mux, int state)
> +{
> + struct mux_rzv2h_usb_vbus_priv *priv = mux_chip_priv(mux->chip);
> +
> + return regmap_field_write(priv->field, state);
> +}
> +
> +static const struct mux_control_ops mux_rzv2h_usb_vbus_ops = {
> + .set = mux_rzv2h_usb_vbus_set,
> +};
> +
> +static const struct regmap_config rzv2h_usb_vbus_regconf = {
> + .reg_bits = 32,
> + .val_bits = 32,
> + .reg_stride = 4,
> + .max_register = RZV2H_VBENCTL,
> +};
> +
> +static int mux_rzv2h_usb_vbus_probe(struct auxiliary_device *adev,
> + const struct auxiliary_device_id *id)
> +{
> + struct reset_rzv2h_usb2phy_adev *rdev = adev->dev.platform_data;
> + struct mux_rzv2h_usb_vbus_priv *priv;
> + struct device *dev = &adev->dev;
> + struct mux_chip *mux_chip;
> + struct regmap *regmap;
> + struct reg_field reg_field = {
> + .reg = RZV2H_VBENCTL,
> + .lsb = 0,
> + .msb = 0,
> + };
> + int ret;
> +
> + regmap = devm_regmap_init_mmio(dev, rdev->base, &rzv2h_usb_vbus_regconf);
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*priv));
> + if (IS_ERR(mux_chip))
> + return PTR_ERR(mux_chip);
> +
> + priv = mux_chip_priv(mux_chip);
> +
> + priv->field = devm_regmap_field_alloc(dev, regmap, reg_field);
> + if (IS_ERR(priv->field))
> + return PTR_ERR(priv->field);
> +
> + mux_chip->ops = &mux_rzv2h_usb_vbus_ops;
> + mux_chip->mux[0].states = 2;
> + mux_chip->mux[0].idle_state = MUX_IDLE_AS_IS;
> +
> + ret = devm_mux_chip_register(dev, mux_chip);
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "Failed to register mux chip\n");
> +
> + return 0;
> +}
> +
> +static const struct auxiliary_device_id mux_rzv2h_usb_vbus_ids[] = {
> + { .name = "rzv2h_usb2phy_reset.vbus-sel-mux" },
hi Tommaso,
this string causes buffer overflow, could you help to check on it?
[ 15.349036] strlen: detected buffer overflow: 33 byte read of buffer size 32
[ 15.349083] WARNING: CPU: 0 PID: 518 at lib/string_helpers.c:1035 __fortify_report+0x64/0xc8
[ 15.349110] Modules linked in: mux_rzv2h_usb_vbus(+) rcar_canfd(+) mtd sm4_ce(-) can_dev rz_dmac(+) pwm_rzg2l_gpt binfmt_misc dm_multipath efi_pstore nfnetlink ip_tables x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor xor_neon raid6_pq raid1 raid0 linear rtc_isl1208 micrel phy_package mmc_block raa215300 rpmb_core dwmac_renesas_gbeth spi_rpc_if pcs_rzn1_miic stmmac_platform stmmac polyval_ce renesas_sdhi_internal_dmac renesas_usbhs ghash_ce panfrost udc_core pcs_xpcs renesas_sdhi_core reset_rzv2h_usb2phy gpu_sched tmio_mmc_core xhci_rcar_hcd ehci_platform sm4 phy_rzg3e_usb3 phy_rcar_gen3_usb2 rzv2m_usb3drd xhci_plat_hcd ohci_platform renesas_rpc_if i2c_riic gpio_regulator gpio_keys fixed aes_neon_bs aes_neon_blk aes_ce_blk aes_ce_cipher
[ 15.349359] CPU: 0 UID: 0 PID: 518 Comm: (udev-worker) Not tainted 6.18.0-5.5 #3 PREEMPT(voluntary)
[ 15.349371] Hardware name: Renesas SMARC EVK version 2 based on r9a09g047e57 (DT)
[ 15.349380] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 15.349390] pc : __fortify_report+0x64/0xc8
[ 15.349400] lr : __fortify_report+0x64/0xc8
[ 15.349408] sp : ffff8000854fb830
[ 15.349413] x29: ffff8000854fb830 x28: ffff80007c7a41d8 x27: ffff80007c7a4300
[ 15.349430] x26: ffff800083c4d780 x25: 0000000000000000 x24: ffff0000c5de9de8
[ 15.349446] x23: ffff800081d23b68 x22: ffff0000c004b200 x21: ffff0000ca6dd080
[ 15.349462] x20: 0000000000000020 x19: ffff80007c7a6140 x18: ffff800084b870a8
[ 15.349477] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
[ 15.349492] x14: 0000000000000000 x13: 323320657a697320 x12: 7265666675622066
[ 15.349507] x11: 0000000000000000 x10: 0000000000000000 x9 : ffff800080208f0c
[ 15.349522] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000
[ 15.349536] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
[ 15.349550] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
[ 15.349565] Call trace:
[ 15.349572] __fortify_report+0x64/0xc8 (P)
[ 15.349583] __fortify_panic+0x14/0x18
[ 15.349595] auxiliary_match_id+0xf8/0x110
[ 15.349608] auxiliary_match+0x28/0x60
[ 15.349617] __driver_attach+0x34/0x2a8
[ 15.349629] bus_for_each_dev+0x88/0x110
[ 15.349639] driver_attach+0x30/0x60
[ 15.349649] bus_add_driver+0x178/0x2d8
[ 15.349658] driver_register+0x74/0x178
[ 15.349668] __auxiliary_driver_register+0x7c/0x150
[ 15.349677] mux_rzv2h_usb_vbus_driver_init+0x34/0xfd0 [mux_rzv2h_usb_vbus]
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(auxiliary, mux_rzv2h_usb_vbus_ids);
> +
> +static struct auxiliary_driver mux_rzv2h_usb_vbus_driver = {
> + .name = "vbus-sel-mux",
> + .probe = mux_rzv2h_usb_vbus_probe,
> + .id_table = mux_rzv2h_usb_vbus_ids,
> +};
> +module_auxiliary_driver(mux_rzv2h_usb_vbus_driver);
> +
> +MODULE_DESCRIPTION("RZ/V2H USB VBUS_SEL mux driver");
> +MODULE_AUTHOR("Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/reset/reset_rzv2h_usb2phy.h b/include/linux/reset/reset_rzv2h_usb2phy.h
> new file mode 100644
> index 000000000000..06247080a66c
> --- /dev/null
> +++ b/include/linux/reset/reset_rzv2h_usb2phy.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _RESET_RZV2H_USB2PHY_H
> +#define _RESET_RZV2H_USB2PHY_H
> +
> +#include <linux/auxiliary_bus.h>
> +
> +struct reset_rzv2h_usb2phy_adev {
> + void __iomem *base;
> +};
> +
> +#endif
> --
> 2.43.0
>
>
> --
> linux-phy mailing list
> linux-phy@lists.infradead.org
> https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux
2025-11-27 2:28 ` Jian Hui Lee
@ 2025-11-27 9:07 ` Tommaso Merciai
0 siblings, 0 replies; 30+ messages in thread
From: Tommaso Merciai @ 2025-11-27 9:07 UTC (permalink / raw)
To: Jian Hui Lee
Cc: andi.shyti, arnd, biju.das.jz, conor+dt, devicetree,
fabrizio.castro.jz, geert+renesas, gregkh, jonathan.cameron,
kishon, krzk+dt, linux-kernel, linux-phy, linux-renesas-soc,
magnus.damm, p.zabel, peda, prabhakar.mahadev-lad.rj, robh,
sebastian.reichel, tomm.merciai, ukleinek, vkoul,
yoshihiro.shimoda.uh
Hi Jian,
Thanks for your comments!
On Thu, Nov 27, 2025 at 10:28:41AM +0800, Jian Hui Lee wrote:
> On Fri, Nov 21, 2025 at 04:11:55PM +0100, Tommaso Merciai wrote:
> > As per the RZ/V2H(P) HW manual, VBUSEN can be controlled by the VBUS_SEL
> > bit of the VBENCTL Control Register. This register is mapped in the
> > reset framework. The reset driver expose this register as mux-controller
> > and instantiates this driver. The consumer will use the mux API to
> > control the VBUS_SEL bit.
> >
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > ---
> > v3->v4:
> > - Removed mux_chip->dev.of_node not needed.
> >
> > v2->v3:
> > - Added mux_chip->dev.of_node = dev->of_node->child as the mux-controller
> > is an internal node.
> > - Fixed auxiliary_device_id name.
> > - Get rdev using from platform_data.
> > - Drop struct auxiliary_device adev from reset_rzv2h_usb2phy_adev
> > as it is needed.
> > - Drop to_reset_rzv2h_usb2phy_adev() as it is not needed.
> >
> > v1->v2:
> > - New patch
> >
> > drivers/mux/Kconfig | 10 +++
> > drivers/mux/Makefile | 2 +
> > drivers/mux/rzv2h-usb-vbus.c | 97 +++++++++++++++++++++++
> > include/linux/reset/reset_rzv2h_usb2phy.h | 11 +++
> > 4 files changed, 120 insertions(+)
> > create mode 100644 drivers/mux/rzv2h-usb-vbus.c
> > create mode 100644 include/linux/reset/reset_rzv2h_usb2phy.h
> >
> > diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
> > index c68132e38138..604f625544ed 100644
> > --- a/drivers/mux/Kconfig
> > +++ b/drivers/mux/Kconfig
> > @@ -59,4 +59,14 @@ config MUX_MMIO
> > To compile the driver as a module, choose M here: the module will
> > be called mux-mmio.
> >
> > +config MUX_RZV2H_VBENCTL
> > + tristate "Renesas RZ/V2H USB VBUS mux driver"
> > + depends on RESET_RZV2H_USB2PHY || COMPILE_TEST
> > + depends on OF
> > + select REGMAP_MMIO
> > + select AUXILIARY_BUS
> > + default RESET_RZV2H_USB2PHY
> > + help
> > + Support for VBUS mux implemented on Renesas RZ/V2H SoCs.
> > +
> > endmenu
> > diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
> > index 6e9fa47daf56..9421660399af 100644
> > --- a/drivers/mux/Makefile
> > +++ b/drivers/mux/Makefile
> > @@ -8,9 +8,11 @@ mux-adg792a-objs := adg792a.o
> > mux-adgs1408-objs := adgs1408.o
> > mux-gpio-objs := gpio.o
> > mux-mmio-objs := mmio.o
> > +mux-rzv2h-usb-vbus-objs := rzv2h-usb-vbus.o
> >
> > obj-$(CONFIG_MULTIPLEXER) += mux-core.o
> > obj-$(CONFIG_MUX_ADG792A) += mux-adg792a.o
> > obj-$(CONFIG_MUX_ADGS1408) += mux-adgs1408.o
> > obj-$(CONFIG_MUX_GPIO) += mux-gpio.o
> > obj-$(CONFIG_MUX_MMIO) += mux-mmio.o
> > +obj-$(CONFIG_MUX_RZV2H_VBENCTL) += mux-rzv2h-usb-vbus.o
> > diff --git a/drivers/mux/rzv2h-usb-vbus.c b/drivers/mux/rzv2h-usb-vbus.c
> > new file mode 100644
> > index 000000000000..9513bc8f35ff
> > --- /dev/null
> > +++ b/drivers/mux/rzv2h-usb-vbus.c
> > @@ -0,0 +1,97 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Renesas RZ/V2H(P) USB2 VBUS_SEL mux driver
> > + *
> > + * Copyright (C) 2025 Renesas Electronics Corp.
> > + */
> > +
> > +#include <linux/auxiliary_bus.h>
> > +#include <linux/bitops.h>
> > +#include <linux/err.h>
> > +#include <linux/module.h>
> > +#include <linux/mux/driver.h>
> > +#include <linux/of.h>
> > +#include <linux/property.h>
> > +#include <linux/regmap.h>
> > +#include <linux/reset/reset_rzv2h_usb2phy.h>
> > +
> > +#define RZV2H_VBENCTL 0xf0c
> > +
> > +struct mux_rzv2h_usb_vbus_priv {
> > + struct regmap_field *field;
> > +};
> > +
> > +static int mux_rzv2h_usb_vbus_set(struct mux_control *mux, int state)
> > +{
> > + struct mux_rzv2h_usb_vbus_priv *priv = mux_chip_priv(mux->chip);
> > +
> > + return regmap_field_write(priv->field, state);
> > +}
> > +
> > +static const struct mux_control_ops mux_rzv2h_usb_vbus_ops = {
> > + .set = mux_rzv2h_usb_vbus_set,
> > +};
> > +
> > +static const struct regmap_config rzv2h_usb_vbus_regconf = {
> > + .reg_bits = 32,
> > + .val_bits = 32,
> > + .reg_stride = 4,
> > + .max_register = RZV2H_VBENCTL,
> > +};
> > +
> > +static int mux_rzv2h_usb_vbus_probe(struct auxiliary_device *adev,
> > + const struct auxiliary_device_id *id)
> > +{
> > + struct reset_rzv2h_usb2phy_adev *rdev = adev->dev.platform_data;
> > + struct mux_rzv2h_usb_vbus_priv *priv;
> > + struct device *dev = &adev->dev;
> > + struct mux_chip *mux_chip;
> > + struct regmap *regmap;
> > + struct reg_field reg_field = {
> > + .reg = RZV2H_VBENCTL,
> > + .lsb = 0,
> > + .msb = 0,
> > + };
> > + int ret;
> > +
> > + regmap = devm_regmap_init_mmio(dev, rdev->base, &rzv2h_usb_vbus_regconf);
> > + if (IS_ERR(regmap))
> > + return PTR_ERR(regmap);
> > +
> > + mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*priv));
> > + if (IS_ERR(mux_chip))
> > + return PTR_ERR(mux_chip);
> > +
> > + priv = mux_chip_priv(mux_chip);
> > +
> > + priv->field = devm_regmap_field_alloc(dev, regmap, reg_field);
> > + if (IS_ERR(priv->field))
> > + return PTR_ERR(priv->field);
> > +
> > + mux_chip->ops = &mux_rzv2h_usb_vbus_ops;
> > + mux_chip->mux[0].states = 2;
> > + mux_chip->mux[0].idle_state = MUX_IDLE_AS_IS;
> > +
> > + ret = devm_mux_chip_register(dev, mux_chip);
> > + if (ret < 0)
> > + return dev_err_probe(dev, ret, "Failed to register mux chip\n");
> > +
> > + return 0;
> > +}
> > +
> > +static const struct auxiliary_device_id mux_rzv2h_usb_vbus_ids[] = {
> > + { .name = "rzv2h_usb2phy_reset.vbus-sel-mux" },
>
> hi Tommaso,
> this string causes buffer overflow, could you help to check on it?
I'll send v5 with:
{ .name = "rzv2h_usb2phy_reset.vbenctl" },
in v5.
Thank you!
Kind Regards,
Tommaso
>
> [ 15.349036] strlen: detected buffer overflow: 33 byte read of buffer size 32
> [ 15.349083] WARNING: CPU: 0 PID: 518 at lib/string_helpers.c:1035 __fortify_report+0x64/0xc8
> [ 15.349110] Modules linked in: mux_rzv2h_usb_vbus(+) rcar_canfd(+) mtd sm4_ce(-) can_dev rz_dmac(+) pwm_rzg2l_gpt binfmt_misc dm_multipath efi_pstore nfnetlink ip_tables x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor xor_neon raid6_pq raid1 raid0 linear rtc_isl1208 micrel phy_package mmc_block raa215300 rpmb_core dwmac_renesas_gbeth spi_rpc_if pcs_rzn1_miic stmmac_platform stmmac polyval_ce renesas_sdhi_internal_dmac renesas_usbhs ghash_ce panfrost udc_core pcs_xpcs renesas_sdhi_core reset_rzv2h_usb2phy gpu_sched tmio_mmc_core xhci_rcar_hcd ehci_platform sm4 phy_rzg3e_usb3 phy_rcar_gen3_usb2 rzv2m_usb3drd xhci_plat_hcd ohci_platform renesas_rpc_if i2c_riic gpio_regulator gpio_keys fixed aes_neon_bs aes_neon_blk aes_ce_blk aes_ce_cipher
> [ 15.349359] CPU: 0 UID: 0 PID: 518 Comm: (udev-worker) Not tainted 6.18.0-5.5 #3 PREEMPT(voluntary)
> [ 15.349371] Hardware name: Renesas SMARC EVK version 2 based on r9a09g047e57 (DT)
> [ 15.349380] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [ 15.349390] pc : __fortify_report+0x64/0xc8
> [ 15.349400] lr : __fortify_report+0x64/0xc8
> [ 15.349408] sp : ffff8000854fb830
> [ 15.349413] x29: ffff8000854fb830 x28: ffff80007c7a41d8 x27: ffff80007c7a4300
> [ 15.349430] x26: ffff800083c4d780 x25: 0000000000000000 x24: ffff0000c5de9de8
> [ 15.349446] x23: ffff800081d23b68 x22: ffff0000c004b200 x21: ffff0000ca6dd080
> [ 15.349462] x20: 0000000000000020 x19: ffff80007c7a6140 x18: ffff800084b870a8
> [ 15.349477] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
> [ 15.349492] x14: 0000000000000000 x13: 323320657a697320 x12: 7265666675622066
> [ 15.349507] x11: 0000000000000000 x10: 0000000000000000 x9 : ffff800080208f0c
> [ 15.349522] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000
> [ 15.349536] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
> [ 15.349550] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
> [ 15.349565] Call trace:
> [ 15.349572] __fortify_report+0x64/0xc8 (P)
> [ 15.349583] __fortify_panic+0x14/0x18
> [ 15.349595] auxiliary_match_id+0xf8/0x110
> [ 15.349608] auxiliary_match+0x28/0x60
> [ 15.349617] __driver_attach+0x34/0x2a8
> [ 15.349629] bus_for_each_dev+0x88/0x110
> [ 15.349639] driver_attach+0x30/0x60
> [ 15.349649] bus_add_driver+0x178/0x2d8
> [ 15.349658] driver_register+0x74/0x178
> [ 15.349668] __auxiliary_driver_register+0x7c/0x150
> [ 15.349677] mux_rzv2h_usb_vbus_driver_init+0x34/0xfd0 [mux_rzv2h_usb_vbus]
>
> > + { /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(auxiliary, mux_rzv2h_usb_vbus_ids);
> > +
> > +static struct auxiliary_driver mux_rzv2h_usb_vbus_driver = {
> > + .name = "vbus-sel-mux",
> > + .probe = mux_rzv2h_usb_vbus_probe,
> > + .id_table = mux_rzv2h_usb_vbus_ids,
> > +};
> > +module_auxiliary_driver(mux_rzv2h_usb_vbus_driver);
> > +
> > +MODULE_DESCRIPTION("RZ/V2H USB VBUS_SEL mux driver");
> > +MODULE_AUTHOR("Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>");
> > +MODULE_LICENSE("GPL");
> > diff --git a/include/linux/reset/reset_rzv2h_usb2phy.h b/include/linux/reset/reset_rzv2h_usb2phy.h
> > new file mode 100644
> > index 000000000000..06247080a66c
> > --- /dev/null
> > +++ b/include/linux/reset/reset_rzv2h_usb2phy.h
> > @@ -0,0 +1,11 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _RESET_RZV2H_USB2PHY_H
> > +#define _RESET_RZV2H_USB2PHY_H
> > +
> > +#include <linux/auxiliary_bus.h>
> > +
> > +struct reset_rzv2h_usb2phy_adev {
> > + void __iomem *base;
> > +};
> > +
> > +#endif
> > --
> > 2.43.0
> >
> >
> > --
> > linux-phy mailing list
> > linux-phy@lists.infradead.org
> > https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2025-11-27 9:07 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 15:11 [PATCH v4 00/22] Add USB2.0 support for RZ/G3E Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 01/22] dt-bindings: mux: Remove nodename pattern constraints Tommaso Merciai
2025-11-21 18:24 ` Conor Dooley
2025-11-24 8:57 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 02/22] phy: renesas: rcar-gen3-usb2: Use devm_pm_runtime_enable() Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 03/22] phy: renesas: rcar-gen3-usb2: Factor out VBUS control logic Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 04/22] reset: rzv2h-usb2phy: Keep PHY clock enabled for entire device lifetime Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 05/22] dt-bindings: reset: renesas,rzv2h-usb2phy: Add '#mux-state-cells' property Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL mux Tommaso Merciai
2025-11-27 2:28 ` Jian Hui Lee
2025-11-27 9:07 ` Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 07/22] reset: rzv2h-usb2phy: Add support for VBUS mux controller registration Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 08/22] dt-bindings: phy: renesas,usb2-phy: Document USB VBUS regulator Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 09/22] dt-bindings: phy: renesas,usb2-phy: Document mux-states property Tommaso Merciai
2025-11-21 15:11 ` [PATCH v4 10/22] phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 11/22] phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management Tommaso Merciai
2025-11-25 14:10 ` Geert Uytterhoeven
2025-11-25 15:57 ` Tommaso Merciai
2025-11-26 7:43 ` Geert Uytterhoeven
2025-11-21 15:12 ` [PATCH v4 12/22] dt-bindings: usb: renesas,usbhs: Add RZ/G3E SoC support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 13/22] dt-bindings: phy: renesas,usb2-phy: Document RZ/G3E SoC Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 14/22] dt-bindings: reset: Document RZ/G3E USB2PHY reset Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 15/22] arm64: dts: renesas: r9a09g057: Add USB2.0 VBUS_SEL mux-controller support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 16/22] arm64: dts: renesas: r9a09g056: " Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 17/22] arm64: dts: renesas: r9a09g056: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 18/22] arm64: dts: renesas: r9a09g056n48-rzv2n-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 19/22] arm64: dts: renesas: r9a09g057: Add USB2.0 PHY VBUS internal regulator node Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 20/22] arm64: dts: renesas: r9a09g057h44-rzv2h-evk: Enable USB2 PHY0 VBUS support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 21/22] arm64: dts: renesas: r9a09g047: Add USB2.0 support Tommaso Merciai
2025-11-21 15:12 ` [PATCH v4 22/22] arm64: dts: renesas: r9a09g047e57-smarc: Enable " Tommaso Merciai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).