mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>,
	 tomm.merciai@gmail.com, peda@axentia.se
Cc: linux-renesas-soc@vger.kernel.org, biju.das.jz@bp.renesas.com,
	Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	 Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	Greg Kroah-Hartman	 <gregkh@linuxfoundation.org>,
	Josua Mayer <josua@solid-run.com>,
	Ulf Hansson	 <ulf.hansson@linaro.org>,
	devicetree@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 5/6] reset: rzv2h-usb2phy: Convert to regmap API
Date: Tue, 31 Mar 2026 18:36:45 +0200	[thread overview]
Message-ID: <283a6336658045be8906ee219620c994e85c7fb8.camel@pengutronix.de> (raw)
In-Reply-To: <0259040014396ea03d58a87c2ce2a3f9eff2b0b6.1774601289.git.tommaso.merciai.xr@bp.renesas.com>

On Fr, 2026-03-27 at 19:08 +0100, Tommaso Merciai wrote:
> Replace raw MMIO accesses (void __iomem *, readl/writel) with
> regmap_read/regmap_write via devm_regmap_init_mmio(). Regmap
> provides its own internal locking, so the manual spinlock and
> scoped_guard() wrappers are no longer needed.
> 
> Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> ---
> v8->v9:
>  - New patch
> 
>  drivers/reset/Kconfig               |  1 +
>  drivers/reset/reset-rzv2h-usb2phy.c | 42 ++++++++++++++++-------------
>  2 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index 5165006be693..c539ca88518f 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -257,6 +257,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 REGMAP_MMIO
>  	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..4014eff0f017 100644
> --- a/drivers/reset/reset-rzv2h-usb2phy.c
> +++ b/drivers/reset/reset-rzv2h-usb2phy.c
> @@ -5,13 +5,13 @@
>   * Copyright (C) 2025 Renesas Electronics Corporation
>   */
>  
> -#include <linux/cleanup.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/regmap.h>
>  #include <linux/reset.h>
>  #include <linux/reset-controller.h>
>  
> @@ -37,10 +37,9 @@ struct rzv2h_usb2phy_reset_of_data {
>  
>  struct rzv2h_usb2phy_reset_priv {
>  	const struct rzv2h_usb2phy_reset_of_data *data;
> -	void __iomem *base;
> +	struct regmap *regmap;
>  	struct device *dev;
>  	struct reset_controller_dev rcdev;
> -	spinlock_t lock; /* protects register accesses */
>  };
>  
>  static inline struct rzv2h_usb2phy_reset_priv
> @@ -55,10 +54,8 @@ static int rzv2h_usbphy_reset_assert(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;
>  
> -	scoped_guard(spinlock, &priv->lock) {
> -		writel(data->reset2_acquire_val, priv->base + data->reset2_reg);
> -		writel(data->reset_assert_val, priv->base + data->reset_reg);
> -	}
> +	regmap_write(priv->regmap, data->reset2_reg, data->reset2_acquire_val);
> +	regmap_write(priv->regmap, data->reset_reg, data->reset_assert_val);

What is the spinlock protecting? acquire/assert registers being set
together, without another acquire/assert or deassert/release register
access pair interleaving?
In that case you still need the lock. Or use regmap_multi_reg_write().
You could even directly store the sequences as struct reg_sequence in
rzv2h_usb2phy_reset_of_data.

>  	usleep_range(11, 20);
>  
> @@ -71,11 +68,9 @@ 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;
>  
> -	scoped_guard(spinlock, &priv->lock) {
> -		writel(data->reset_deassert_val, priv->base + data->reset_reg);
> -		writel(data->reset2_release_val, priv->base + data->reset2_reg);
> -		writel(data->reset_release_val, priv->base + data->reset_reg);
> -	}
> +	regmap_write(priv->regmap, data->reset_reg, data->reset_deassert_val);
> +	regmap_write(priv->regmap, data->reset2_reg, data->reset2_release_val);
> +	regmap_write(priv->regmap, data->reset_reg, data->reset_release_val);

Same as above.

[...]

> @@ -149,7 +153,7 @@ static int rzv2h_usb2phy_reset_probe(struct platform_device *pdev)
>  		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);
> +		regmap_write(priv->regmap, data->init_vals[i].reg, data->init_vals[i].val);

Not required for locking, but this could use regmap_multi_reg_write()
as well.

regards
Philipp

  reply	other threads:[~2026-03-31 16:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-27 18:08 [PATCH v9 0/6] Add USB2.0 VBUS mux driver and extend rzv2h-usb2phy reset for RZ/G3E support Tommaso Merciai
2026-03-27 18:08 ` [PATCH v9 1/6] mux: Add driver for Renesas RZ/V2H USB VBENCTL VBUS_SEL mux Tommaso Merciai
2026-03-27 18:08 ` [PATCH v9 2/6] dt-bindings: reset: renesas,rzv2h-usb2phy: Add '#mux-state-cells' property Tommaso Merciai
2026-03-27 18:08 ` [PATCH v9 3/6] dt-bindings: reset: renesas,rzv2h-usb2phy: Document RZ/G3E USB2PHY reset Tommaso Merciai
2026-03-27 18:08 ` [PATCH v9 4/6] reset: rzv2h-usb2phy: Keep PHY clock enabled for entire device lifetime Tommaso Merciai
2026-03-27 18:08 ` [PATCH v9 5/6] reset: rzv2h-usb2phy: Convert to regmap API Tommaso Merciai
2026-03-31 16:36   ` Philipp Zabel [this message]
2026-04-01  8:04     ` Tommaso Merciai
2026-04-01  8:23       ` Philipp Zabel
2026-04-01  9:10         ` Tommaso Merciai
2026-04-01  9:25           ` Philipp Zabel
2026-04-01 10:25             ` Tommaso Merciai
2026-03-27 18:08 ` [PATCH v9 6/6] reset: rzv2h-usb2phy: Add support for VBUS mux controller registration Tommaso Merciai
2026-03-31 16:16 ` [PATCH v9 0/6] Add USB2.0 VBUS mux driver and extend rzv2h-usb2phy reset for RZ/G3E support Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=283a6336658045be8906ee219620c994e85c7fb8.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=josua@solid-run.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=peda@axentia.se \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh@kernel.org \
    --cc=tomm.merciai@gmail.com \
    --cc=tommaso.merciai.xr@bp.renesas.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®