Skip to content

Commit f62fcdf

Browse files
Tommaso MerciaipH5
authored andcommitted
reset: rzv2h-usb2phy: Add support for VBUS mux controller registration
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 the rzv2h-usb-vbenctl auxiliary driver during probe. This enables proper management of USB2.0 VBUS source selection on platforms using the RZ/V2H SoC. Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
1 parent 890628c commit f62fcdf

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

drivers/reset/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ config RESET_RZG2L_USBPHY_CTRL
257257
config RESET_RZV2H_USB2PHY
258258
tristate "Renesas RZ/V2H(P) (and similar SoCs) USB2PHY Reset driver"
259259
depends on ARCH_RENESAS || COMPILE_TEST
260+
select AUXILIARY_BUS
260261
select REGMAP_MMIO
261262
help
262263
Support for USB2PHY Port reset Control found on the RZ/V2H(P) SoC

drivers/reset/reset-rzv2h-usb2phy.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
* Copyright (C) 2025 Renesas Electronics Corporation
66
*/
77

8+
#include <linux/auxiliary_bus.h>
89
#include <linux/delay.h>
10+
#include <linux/idr.h>
911
#include <linux/io.h>
1012
#include <linux/module.h>
1113
#include <linux/of.h>
@@ -15,6 +17,8 @@
1517
#include <linux/reset.h>
1618
#include <linux/reset-controller.h>
1719

20+
static DEFINE_IDA(auxiliary_ids);
21+
1822
struct rzv2h_usb2phy_reset_of_data {
1923
const struct reg_sequence *init_seq;
2024
unsigned int init_nseq;
@@ -84,6 +88,33 @@ static int rzv2h_usb2phy_reset_of_xlate(struct reset_controller_dev *rcdev,
8488
return 0;
8589
}
8690

91+
static void rzv2h_usb2phy_reset_ida_free(void *data)
92+
{
93+
struct auxiliary_device *adev = data;
94+
95+
ida_free(&auxiliary_ids, adev->id);
96+
}
97+
98+
static int rzv2h_usb2phy_reset_mux_register(struct device *dev,
99+
const char *mux_name)
100+
{
101+
struct auxiliary_device *adev;
102+
int id;
103+
104+
id = ida_alloc(&auxiliary_ids, GFP_KERNEL);
105+
if (id < 0)
106+
return id;
107+
108+
adev = __devm_auxiliary_device_create(dev, dev->driver->name,
109+
mux_name, NULL, id);
110+
if (!adev) {
111+
ida_free(&auxiliary_ids, id);
112+
return -ENOMEM;
113+
}
114+
115+
return devm_add_action_or_reset(dev, rzv2h_usb2phy_reset_ida_free, adev);
116+
}
117+
87118
static const struct regmap_config rzv2h_usb2phy_reset_regconf = {
88119
.reg_bits = 32,
89120
.val_bits = 32,
@@ -153,6 +184,10 @@ static int rzv2h_usb2phy_reset_probe(struct platform_device *pdev)
153184
if (error)
154185
return dev_err_probe(dev, error, "could not register reset controller\n");
155186

187+
error = rzv2h_usb2phy_reset_mux_register(dev, "vbenctl");
188+
if (error)
189+
return dev_err_probe(dev, error, "could not register aux mux\n");
190+
156191
return 0;
157192
}
158193

0 commit comments

Comments
 (0)