[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4857ace4d241d3a0de4fe7247312ff07c930b11e.camel@pengutronix.de>
Date: Wed, 05 Nov 2025 17:04:54 +0100
From: Philipp Zabel <p.zabel@...gutronix.de>
To: Tommaso Merciai <tommaso.merciai.xr@...renesas.com>,
tomm.merciai@...il.com
Cc: linux-renesas-soc@...r.kernel.org, biju.das.jz@...renesas.com, Vinod
Koul <vkoul@...nel.org>, Kishon Vijay Abraham I <kishon@...nel.org>, Rob
Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor
Dooley <conor+dt@...nel.org>, Fabrizio Castro
<fabrizio.castro.jz@...esas.com>, Lad Prabhakar
<prabhakar.mahadev-lad.rj@...renesas.com>, Peter Rosin <peda@...ntia.se>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>, Geert Uytterhoeven
<geert+renesas@...der.be>, Magnus Damm <magnus.damm@...il.com>, Arnd
Bergmann <arnd@...db.de>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-phy@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 06/21] reset: rzv2h-usb2phy: Add support for VBUS mux
controller registration
On Mi, 2025-11-05 at 16:39 +0100, Tommaso Merciai wrote:
> 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@...renesas.com>
> ---
> v1->v2:
> - New patch
>
> drivers/reset/Kconfig | 1 +
> drivers/reset/reset-rzv2h-usb2phy.c | 65 +++++++++++++++++++++++++++++
> 2 files changed, 66 insertions(+)
>
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index e1ae624661f3..f54e216ca7f6 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -255,6 +255,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..6074aa8cc13a 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,62 @@ static int rzv2h_usb2phy_reset_of_xlate(struct reset_controller_dev *rcdev,
> return 0;
> }
>
> +static void rzv2h_usb2phy_reset_adev_unregister(void *data)
> +{
> + struct auxiliary_device *adev = data;
> +
> + auxiliary_device_delete(adev);
> + auxiliary_device_uninit(adev);
> +}
> +
> +static void rzv2h_usb2phy_reset_adev_release(struct device *dev)
> +{
> + struct auxiliary_device *adev = to_auxiliary_dev(dev);
> +
> + 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 ret;
> +
> + rdev = devm_kzalloc(dev, sizeof(*rdev), GFP_KERNEL);
> + if (!rdev)
> + return -ENOMEM;
> +
> + rdev->base = base;
> +
> + adev = &rdev->adev;
> + adev->name = mux_name;
> + adev->dev.parent = dev->parent;
> + adev->dev.release = rzv2h_usb2phy_reset_adev_release;
> + adev->dev.of_node = dev->of_node;
> + ret = ida_alloc(&auxiliary_ids, GFP_KERNEL);
> + if (ret < 0)
> + return ret;
> + adev->id = ret;
> +
> + ret = auxiliary_device_init(adev);
> + if (ret)
> + goto cleanup_ida;
> +
> + ret = auxiliary_device_add(adev);
> + if (ret) {
> + auxiliary_device_uninit(adev);
> + goto cleanup_ida;
> + }
> +
> + return devm_add_action_or_reset(dev, rzv2h_usb2phy_reset_adev_unregister, adev);
Can't you use __devm_auxiliary_device_create()?
regards
Philipp
Powered by blists - more mailing lists