public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Ludovic Desroches <ludovic.desroches@atmel.com>,
	Josh Wu <josh.wu@atmel.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <mturquette@linaro.org>
Subject: Re: [PATCH v2 2/2] clk: at91: modify PMC peripheral clock to deal with newer register layout
Date: Wed, 17 Jun 2015 16:39:01 +0200	[thread overview]
Message-ID: <20150617163901.721cfdd0@bbrezillon> (raw)
In-Reply-To: <00aa7c245a7960d6101dad4b284a19cab766ee4a.1434544584.git.nicolas.ferre@atmel.com>

On Wed, 17 Jun 2015 14:40:39 +0200
Nicolas Ferre <nicolas.ferre@atmel.com> wrote:

> As some more information is added to the PCR register, we'd better use
> a copy of its content and modify just the peripheral-related bits.
> Implement a read-modify-write for the enable() and disable() callbacks.
> 
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
> v2: - modify header file beforehand so that we can use consistent field naming
> 
> 
>  drivers/clk/at91/clk-peripheral.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c
> index 61d0adda7088..1e7dcc57925a 100644
> --- a/drivers/clk/at91/clk-peripheral.c
> +++ b/drivers/clk/at91/clk-peripheral.c
> @@ -161,14 +161,18 @@ static int clk_sam9x5_peripheral_enable(struct clk_hw *hw)
>  {
>  	struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw);
>  	struct at91_pmc *pmc = periph->pmc;
> +	u32 tmp;
>  
>  	if (periph->id < PERIPHERAL_ID_MIN)
>  		return 0;
>  
> -	pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK) |
> -				     AT91_PMC_PCR_CMD |
> -				     AT91_PMC_PCR_DIV(periph->div) |
> -				     AT91_PMC_PCR_EN);
> +	pmc_lock(pmc);
> +	pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK));
> +	tmp = pmc_read(pmc, AT91_PMC_PCR) & ~AT91_PMC_PCR_DIV_MASK;
> +	pmc_write(pmc, AT91_PMC_PCR, tmp | AT91_PMC_PCR_DIV(periph->div)
> +					 | AT91_PMC_PCR_CMD
> +					 | AT91_PMC_PCR_EN);
> +	pmc_unlock(pmc);
>  	return 0;
>  }
>  
> @@ -176,12 +180,16 @@ static void clk_sam9x5_peripheral_disable(struct clk_hw *hw)
>  {
>  	struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw);
>  	struct at91_pmc *pmc = periph->pmc;
> +	u32 tmp;
>  
>  	if (periph->id < PERIPHERAL_ID_MIN)
>  		return;
>  
> -	pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK) |
> -				     AT91_PMC_PCR_CMD);
> +	pmc_lock(pmc);
> +	pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK));
> +	tmp = pmc_read(pmc, AT91_PMC_PCR) & ~AT91_PMC_PCR_EN;
> +	pmc_write(pmc, AT91_PMC_PCR, tmp | AT91_PMC_PCR_CMD);
> +	pmc_unlock(pmc);
>  }
>  
>  static int clk_sam9x5_peripheral_is_enabled(struct clk_hw *hw)



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2015-06-17 14:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 12:40 [PATCH v2 1/2] clk: at91: cleanup PMC header file for PCR register fields Nicolas Ferre
2015-06-17 12:40 ` [PATCH v2 2/2] clk: at91: modify PMC peripheral clock to deal with newer register layout Nicolas Ferre
2015-06-17 14:39   ` Boris Brezillon [this message]
2015-06-17 14:37 ` [PATCH v2 1/2] clk: at91: cleanup PMC header file for PCR register fields Boris Brezillon

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=20150617163901.721cfdd0@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=josh.wu@atmel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@atmel.com \
    --cc=mturquette@linaro.org \
    --cc=nicolas.ferre@atmel.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