Devicetree
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Changhuang Liang <changhuang.liang@starfivetech.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Emil Renner Berthing <kernel@esmil.dk>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Walker Chen <walker.chen@starfivetech.com>,
	Hal Feng <hal.feng@starfivetech.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org
Subject: Re: [RESEND v2 3/6] soc: starfive: Modify ioremap to regmap
Date: Wed, 19 Apr 2023 18:29:12 +0100	[thread overview]
Message-ID: <20230419-headdress-surcharge-8017d6db444b@spud> (raw)
In-Reply-To: <20230419035646.43702-4-changhuang.liang@starfivetech.com>

[-- Attachment #1: Type: text/plain, Size: 5550 bytes --]

On Tue, Apr 18, 2023 at 08:56:43PM -0700, Changhuang Liang wrote:
> Modify ioremap to regmap which can be compatible with the syscon
> interface, such as:
> struct regmap *syscon_node_to_regmap(struct device_node *np)
> Convenient introduction of syscon operation.

What's missing here is an explanation of *why* you are making this
compatible with the syscon interface. Provided everything else is fine,
I can fix this when applying the series.

Thanks,
Conor.

> 
> Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
> ---
>  drivers/soc/starfive/jh71xx_pmu.c | 43 +++++++++++++++++--------------
>  1 file changed, 23 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/soc/starfive/jh71xx_pmu.c b/drivers/soc/starfive/jh71xx_pmu.c
> index 7d5f50d71c0d..306218c83691 100644
> --- a/drivers/soc/starfive/jh71xx_pmu.c
> +++ b/drivers/soc/starfive/jh71xx_pmu.c
> @@ -6,13 +6,13 @@
>   */
>  
>  #include <linux/interrupt.h>
> -#include <linux/io.h>
> -#include <linux/iopoll.h>
> +#include <linux/mfd/syscon.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_domain.h>
> +#include <linux/regmap.h>
>  #include <dt-bindings/power/starfive,jh7110-pmu.h>
>  
>  /* register offset */
> @@ -59,7 +59,7 @@ struct jh71xx_pmu_match_data {
>  struct jh71xx_pmu {
>  	struct device *dev;
>  	const struct jh71xx_pmu_match_data *match_data;
> -	void __iomem *base;
> +	struct regmap *base;
>  	struct generic_pm_domain **genpd;
>  	struct genpd_onecell_data genpd_data;
>  	int irq;
> @@ -75,11 +75,14 @@ struct jh71xx_pmu_dev {
>  static int jh71xx_pmu_get_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool *is_on)
>  {
>  	struct jh71xx_pmu *pmu = pmd->pmu;
> +	unsigned int val;
>  
>  	if (!mask)
>  		return -EINVAL;
>  
> -	*is_on = readl(pmu->base + JH71XX_PMU_CURR_POWER_MODE) & mask;
> +	regmap_read(pmu->base, JH71XX_PMU_CURR_POWER_MODE, &val);
> +
> +	*is_on = val & mask;
>  
>  	return 0;
>  }
> @@ -130,7 +133,7 @@ static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on)
>  		encourage_hi = JH71XX_PMU_SW_ENCOURAGE_DIS_HI;
>  	}
>  
> -	writel(mask, pmu->base + mode);
> +	regmap_write(pmu->base, mode, mask);
>  
>  	/*
>  	 * 2.Write SW encourage command sequence to the Software Encourage Reg (offset 0x44)
> @@ -140,21 +143,21 @@ static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on)
>  	 *   Then write the lower bits of the command sequence, followed by the upper
>  	 *   bits. The sequence differs between powering on & off a domain.
>  	 */
> -	writel(JH71XX_PMU_SW_ENCOURAGE_ON, pmu->base + JH71XX_PMU_SW_ENCOURAGE);
> -	writel(encourage_lo, pmu->base + JH71XX_PMU_SW_ENCOURAGE);
> -	writel(encourage_hi, pmu->base + JH71XX_PMU_SW_ENCOURAGE);
> +	regmap_write(pmu->base, JH71XX_PMU_SW_ENCOURAGE, JH71XX_PMU_SW_ENCOURAGE_ON);
> +	regmap_write(pmu->base, JH71XX_PMU_SW_ENCOURAGE, encourage_lo);
> +	regmap_write(pmu->base, JH71XX_PMU_SW_ENCOURAGE, encourage_hi);
>  
>  	spin_unlock_irqrestore(&pmu->lock, flags);
>  
>  	/* Wait for the power domain bit to be enabled / disabled */
>  	if (on) {
> -		ret = readl_poll_timeout_atomic(pmu->base + JH71XX_PMU_CURR_POWER_MODE,
> -						val, val & mask,
> -						1, JH71XX_PMU_TIMEOUT_US);
> +		ret = regmap_read_poll_timeout_atomic(pmu->base, JH71XX_PMU_CURR_POWER_MODE,
> +						      val, val & mask,
> +						      1, JH71XX_PMU_TIMEOUT_US);
>  	} else {
> -		ret = readl_poll_timeout_atomic(pmu->base + JH71XX_PMU_CURR_POWER_MODE,
> -						val, !(val & mask),
> -						1, JH71XX_PMU_TIMEOUT_US);
> +		ret = regmap_read_poll_timeout_atomic(pmu->base, JH71XX_PMU_CURR_POWER_MODE,
> +						      val, !(val & mask),
> +						      1, JH71XX_PMU_TIMEOUT_US);
>  	}
>  
>  	if (ret) {
> @@ -190,14 +193,14 @@ static void jh71xx_pmu_int_enable(struct jh71xx_pmu *pmu, u32 mask, bool enable)
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&pmu->lock, flags);
> -	val = readl(pmu->base + JH71XX_PMU_TIMER_INT_MASK);
> +	regmap_read(pmu->base, JH71XX_PMU_TIMER_INT_MASK, &val);
>  
>  	if (enable)
>  		val &= ~mask;
>  	else
>  		val |= mask;
>  
> -	writel(val, pmu->base + JH71XX_PMU_TIMER_INT_MASK);
> +	regmap_write(pmu->base, JH71XX_PMU_TIMER_INT_MASK, val);
>  	spin_unlock_irqrestore(&pmu->lock, flags);
>  }
>  
> @@ -206,7 +209,7 @@ static irqreturn_t jh71xx_pmu_interrupt(int irq, void *data)
>  	struct jh71xx_pmu *pmu = data;
>  	u32 val;
>  
> -	val = readl(pmu->base + JH71XX_PMU_INT_STATUS);
> +	regmap_read(pmu->base, JH71XX_PMU_INT_STATUS, &val);
>  
>  	if (val & JH71XX_PMU_INT_SEQ_DONE)
>  		dev_dbg(pmu->dev, "sequence done.\n");
> @@ -220,8 +223,8 @@ static irqreturn_t jh71xx_pmu_interrupt(int irq, void *data)
>  		dev_err(pmu->dev, "p-channel fail event.\n");
>  
>  	/* clear interrupts */
> -	writel(val, pmu->base + JH71XX_PMU_INT_STATUS);
> -	writel(val, pmu->base + JH71XX_PMU_EVENT_STATUS);
> +	regmap_write(pmu->base, JH71XX_PMU_INT_STATUS, val);
> +	regmap_write(pmu->base, JH71XX_PMU_EVENT_STATUS, val);
>  
>  	return IRQ_HANDLED;
>  }
> @@ -271,7 +274,7 @@ static int jh71xx_pmu_probe(struct platform_device *pdev)
>  	if (!pmu)
>  		return -ENOMEM;
>  
> -	pmu->base = devm_platform_ioremap_resource(pdev, 0);
> +	pmu->base = device_node_to_regmap(np);
>  	if (IS_ERR(pmu->base))
>  		return PTR_ERR(pmu->base);
>  
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2023-04-19 17:29 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19  3:56 [RESEND v2 0/6] Add JH7110 AON PMU support Changhuang Liang
2023-04-19  3:56 ` [RESEND v2 1/6] dt-bindings: power: " Changhuang Liang
2023-04-19 18:29   ` Conor Dooley
2023-04-20  7:00     ` Changhuang Liang
2023-04-24 16:52       ` Conor Dooley
2023-04-25  3:41         ` Changhuang Liang
2023-04-25  6:59           ` Conor Dooley
2023-04-25  7:57             ` Changhuang Liang
2023-04-25  8:19               ` Krzysztof Kozlowski
2023-04-25  9:18                 ` Changhuang Liang
2023-04-25  9:35                   ` Conor Dooley
2023-04-25 12:26                     ` Changhuang Liang
2023-04-25 16:56                       ` Conor Dooley
2023-04-26  2:11                         ` Changhuang Liang
2023-05-04  1:34                         ` Changhuang Liang
2023-05-04  6:13                           ` Krzysztof Kozlowski
2023-05-04  6:53                             ` Changhuang Liang
2023-05-04  7:04                               ` Krzysztof Kozlowski
2023-05-04  7:20                                 ` Changhuang Liang
2023-05-04  7:26                                   ` Krzysztof Kozlowski
2023-05-04  8:43                                     ` Changhuang Liang
2023-05-04  9:36                                       ` Krzysztof Kozlowski
2023-05-04  9:48                                         ` Changhuang Liang
2023-05-04  9:57                                           ` Conor Dooley
2023-05-05  1:29                                             ` Changhuang Liang
2023-05-05 12:38                                               ` Conor Dooley
2023-05-06  1:45                                                 ` Changhuang Liang
2023-05-06  6:31                                                   ` Krzysztof Kozlowski
2023-05-06  7:00                                                     ` Changhuang Liang
2023-05-06 10:17                                                   ` Conor Dooley
2023-05-06 12:26                                                     ` Changhuang Liang
2023-05-06 12:29                                                       ` Conor Dooley
2023-05-07  4:00                                                         ` Changhuang Liang
2023-04-19 19:46   ` Krzysztof Kozlowski
2023-04-20  7:40     ` Changhuang Liang
2023-04-19  3:56 ` [RESEND v2 2/6] soc: starfive: Replace SOC_STARFIVE with ARCH_STARFIVE Changhuang Liang
2023-04-19  3:56 ` [RESEND v2 3/6] soc: starfive: Modify ioremap to regmap Changhuang Liang
2023-04-19 17:29   ` Conor Dooley [this message]
2023-04-20  6:03     ` Changhuang Liang
2023-04-19  3:56 ` [RESEND v2 4/6] soc: starfive: Extract JH7110 pmu private operations Changhuang Liang
2023-04-19 17:47   ` Conor Dooley
2023-04-21  3:27     ` Changhuang Liang
2023-04-21  6:57       ` Conor Dooley
2023-04-21  7:47         ` Changhuang Liang
2023-04-19  3:56 ` [RESEND v2 5/6] soc: starfive: Add JH7110 AON PMU support Changhuang Liang
2023-05-06 13:58   ` Shengyu Qu
2023-05-06 14:05     ` Conor Dooley
2023-05-06 14:07       ` Shengyu Qu
2023-05-06 14:12         ` Conor Dooley
2023-04-19  3:56 ` [RESEND v2 6/6] riscv: dts: starfive: jh7110: Add AON PMU node Changhuang Liang
2023-04-19  6:23 ` [RESEND v2 0/6] Add JH7110 AON PMU support Conor Dooley
2023-04-19  6:57   ` Changhuang Liang

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=20230419-headdress-surcharge-8017d6db444b@spud \
    --to=conor@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=changhuang.liang@starfivetech.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hal.feng@starfivetech.com \
    --cc=kernel@esmil.dk \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=walker.chen@starfivetech.com \
    /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