All of lore.kernel.org
 help / color / mirror / Atom feed
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] mfd: atmel-hlcdc: implement config synchronization
Date: Thu, 23 Jul 2015 15:46:01 +0100	[thread overview]
Message-ID: <20150723144601.GF3436@x1> (raw)
In-Reply-To: <1436289403-20524-1-git-send-email-boris.brezillon@free-electrons.com>

On Tue, 07 Jul 2015, Boris Brezillon wrote:

> Some HLCDC registers cannot be written until the hardware has finished
> applying the previous configuration request. If they are written while
> an action is still in progress, the new configuration might be silently
> ignored, resulting in unpredictable behavior.
> 
> Hide the config synchronization stuff in a regmap implementation and use
> this implementation instead of the generic mmio one.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> 
> ---
> Changes since v2:
>  - reword the commit message
> 
> Changes since v1:
>  - add a 100 usec timeout
> ---
>  drivers/mfd/atmel-hlcdc.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
> index cfd58f4..04e01cc 100644
> --- a/drivers/mfd/atmel-hlcdc.c
> +++ b/drivers/mfd/atmel-hlcdc.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include <linux/clk.h>
> +#include <linux/iopoll.h>
>  #include <linux/mfd/atmel-hlcdc.h>
>  #include <linux/mfd/core.h>
>  #include <linux/module.h>
> @@ -37,11 +38,41 @@ static const struct mfd_cell atmel_hlcdc_cells[] = {
>  	},
>  };
>  
> +static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg,
> +					unsigned int val)
> +{
> +	void __iomem *regs = context;
> +
> +	if (reg <= ATMEL_HLCDC_DIS) {
> +		u32 status;
> +
> +		readl_poll_timeout(regs + ATMEL_HLCDC_SR, status,
> +				   !(status & ATMEL_HLCDC_SIP), 1, 100);
> +	}
> +
> +	writel(val, regs + reg);
> +
> +	return 0;
> +}
> +
> +static int regmap_atmel_hlcdc_reg_read(void *context, unsigned int reg,
> +				       unsigned int *val)
> +{
> +	void __iomem *regs = context;
> +
> +	*val = readl(regs + reg);
> +
> +	return 0;
> +}
> +
>  static const struct regmap_config atmel_hlcdc_regmap_config = {
>  	.reg_bits = 32,
>  	.val_bits = 32,
>  	.reg_stride = 4,
>  	.max_register = ATMEL_HLCDC_REG_MAX,
> +	.reg_write = regmap_atmel_hlcdc_reg_write,
> +	.reg_read = regmap_atmel_hlcdc_reg_read,
> +	.fast_io = true,
>  };
>  
>  static int atmel_hlcdc_probe(struct platform_device *pdev)
> @@ -82,8 +113,8 @@ static int atmel_hlcdc_probe(struct platform_device *pdev)
>  		return PTR_ERR(hlcdc->slow_clk);
>  	}
>  
> -	hlcdc->regmap = devm_regmap_init_mmio(dev, regs,
> -					      &atmel_hlcdc_regmap_config);
> +	hlcdc->regmap = devm_regmap_init(dev, NULL, regs,
> +					 &atmel_hlcdc_regmap_config);
>  	if (IS_ERR(hlcdc->regmap))
>  		return PTR_ERR(hlcdc->regmap);
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v3] mfd: atmel-hlcdc: implement config synchronization
Date: Thu, 23 Jul 2015 15:46:01 +0100	[thread overview]
Message-ID: <20150723144601.GF3436@x1> (raw)
In-Reply-To: <1436289403-20524-1-git-send-email-boris.brezillon@free-electrons.com>

On Tue, 07 Jul 2015, Boris Brezillon wrote:

> Some HLCDC registers cannot be written until the hardware has finished
> applying the previous configuration request. If they are written while
> an action is still in progress, the new configuration might be silently
> ignored, resulting in unpredictable behavior.
> 
> Hide the config synchronization stuff in a regmap implementation and use
> this implementation instead of the generic mmio one.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> 
> ---
> Changes since v2:
>  - reword the commit message
> 
> Changes since v1:
>  - add a 100 usec timeout
> ---
>  drivers/mfd/atmel-hlcdc.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
> index cfd58f4..04e01cc 100644
> --- a/drivers/mfd/atmel-hlcdc.c
> +++ b/drivers/mfd/atmel-hlcdc.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include <linux/clk.h>
> +#include <linux/iopoll.h>
>  #include <linux/mfd/atmel-hlcdc.h>
>  #include <linux/mfd/core.h>
>  #include <linux/module.h>
> @@ -37,11 +38,41 @@ static const struct mfd_cell atmel_hlcdc_cells[] = {
>  	},
>  };
>  
> +static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg,
> +					unsigned int val)
> +{
> +	void __iomem *regs = context;
> +
> +	if (reg <= ATMEL_HLCDC_DIS) {
> +		u32 status;
> +
> +		readl_poll_timeout(regs + ATMEL_HLCDC_SR, status,
> +				   !(status & ATMEL_HLCDC_SIP), 1, 100);
> +	}
> +
> +	writel(val, regs + reg);
> +
> +	return 0;
> +}
> +
> +static int regmap_atmel_hlcdc_reg_read(void *context, unsigned int reg,
> +				       unsigned int *val)
> +{
> +	void __iomem *regs = context;
> +
> +	*val = readl(regs + reg);
> +
> +	return 0;
> +}
> +
>  static const struct regmap_config atmel_hlcdc_regmap_config = {
>  	.reg_bits = 32,
>  	.val_bits = 32,
>  	.reg_stride = 4,
>  	.max_register = ATMEL_HLCDC_REG_MAX,
> +	.reg_write = regmap_atmel_hlcdc_reg_write,
> +	.reg_read = regmap_atmel_hlcdc_reg_read,
> +	.fast_io = true,
>  };
>  
>  static int atmel_hlcdc_probe(struct platform_device *pdev)
> @@ -82,8 +113,8 @@ static int atmel_hlcdc_probe(struct platform_device *pdev)
>  		return PTR_ERR(hlcdc->slow_clk);
>  	}
>  
> -	hlcdc->regmap = devm_regmap_init_mmio(dev, regs,
> -					      &atmel_hlcdc_regmap_config);
> +	hlcdc->regmap = devm_regmap_init(dev, NULL, regs,
> +					 &atmel_hlcdc_regmap_config);
>  	if (IS_ERR(hlcdc->regmap))
>  		return PTR_ERR(hlcdc->regmap);
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  parent reply	other threads:[~2015-07-23 14:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 17:16 [PATCH v3] mfd: atmel-hlcdc: implement config synchronization Boris Brezillon
2015-07-07 17:16 ` Boris Brezillon
2015-07-17 11:56 ` Nicolas Ferre
2015-07-17 11:56   ` Nicolas Ferre
2015-07-23 14:46 ` Lee Jones [this message]
2015-07-23 14:46   ` Lee Jones

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=20150723144601.GF3436@x1 \
    --to=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.