public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: twl6040: Use regmap for register cache
@ 2013-08-31 16:48 Mark Brown
  2013-09-01 16:59 ` Peter Ujfalusi
  2013-09-02  8:17 ` Lee Jones
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Brown @ 2013-08-31 16:48 UTC (permalink / raw)
  To: Samuel Ortiz, Lee Jones, Peter Ujfalusi
  Cc: linux-kernel, linaro-kernel, Mark Brown

From: Mark Brown <broonie@linaro.org>

Rather then open coding a cache of the vibra control registers use the
regmap cache code.  Also cache the interrupt mask register, providing
a small performance improvement for the interrupt code.

Signed-off-by: Mark Brown <broonie@linaro.org>
---

I'm hoping to have some ASoC improvements to build on top of this (there
is ASoC level register caching for the device) so it might make sense to
apply this via ASoC.

 drivers/mfd/twl6040.c       | 43 ++++++++++++++++++++++++++++++-------------
 include/linux/mfd/twl6040.h |  1 -
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
index 4d8d3b7..daf6694 100644
--- a/drivers/mfd/twl6040.c
+++ b/drivers/mfd/twl6040.c
@@ -58,15 +58,9 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
 	int ret;
 	unsigned int val;
 
-	/* Vibra control registers from cache */
-	if (unlikely(reg == TWL6040_REG_VIBCTLL ||
-		     reg == TWL6040_REG_VIBCTLR)) {
-		val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
-	} else {
-		ret = regmap_read(twl6040->regmap, reg, &val);
-		if (ret < 0)
-			return ret;
-	}
+	ret = regmap_read(twl6040->regmap, reg, &val);
+	if (ret < 0)
+		return ret;
 
 	return val;
 }
@@ -77,9 +71,6 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
 	int ret;
 
 	ret = regmap_write(twl6040->regmap, reg, val);
-	/* Cache the vibra control registers */
-	if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
-		twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
 
 	return ret;
 }
@@ -456,9 +447,20 @@ EXPORT_SYMBOL(twl6040_get_sysclk);
 /* Get the combined status of the vibra control register */
 int twl6040_get_vibralr_status(struct twl6040 *twl6040)
 {
+	unsigned int reg;
+	int ret;
 	u8 status;
 
-	status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1];
+	ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLL, &reg);
+	if (ret != 0)
+		return ret;
+	status = reg;
+
+	ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLR, &reg);
+	if (ret != 0)
+		return ret;
+	status |= reg;
+
 	status &= (TWL6040_VIBENA | TWL6040_VIBSEL);
 
 	return status;
@@ -485,12 +487,27 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg)
 	return true;
 }
 
+static bool twl6040_volatile_reg(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case TWL6040_REG_VIBCTLL:
+	case TWL6040_REG_VIBCTLR:
+	case TWL6040_REG_INTMR:
+		return false;
+	default:
+		return true;
+	}
+}
+
 static struct regmap_config twl6040_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = TWL6040_REG_STATUS, /* 0x2e */
 
 	.readable_reg = twl6040_readable_reg,
+	.volatile_reg = twl6040_volatile_reg,
+
+	.cache_type = REGCACHE_RBTREE,
 };
 
 static const struct regmap_irq twl6040_irqs[] = {
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 6dd8893..81f639b 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -230,7 +230,6 @@ struct twl6040 {
 	int audpwron;
 	int power_count;
 	int rev;
-	u8 vibra_ctrl_cache[2];
 
 	/* PLL configuration */
 	int pll;
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: twl6040: Use regmap for register cache
  2013-08-31 16:48 [PATCH] mfd: twl6040: Use regmap for register cache Mark Brown
@ 2013-09-01 16:59 ` Peter Ujfalusi
  2013-09-02  8:17 ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2013-09-01 16:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Samuel Ortiz, Lee Jones, linux-kernel, linaro-kernel, Mark Brown

On 08/31/2013 07:48 PM, Mark Brown wrote:
> From: Mark Brown <broonie@linaro.org>
> 
> Rather then open coding a cache of the vibra control registers use the
> regmap cache code.  Also cache the interrupt mask register, providing
> a small performance improvement for the interrupt code.
> 
> Signed-off-by: Mark Brown <broonie@linaro.org>

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> ---
> 
> I'm hoping to have some ASoC improvements to build on top of this (there
> is ASoC level register caching for the device) so it might make sense to
> apply this via ASoC.
> 
>  drivers/mfd/twl6040.c       | 43 ++++++++++++++++++++++++++++++-------------
>  include/linux/mfd/twl6040.h |  1 -
>  2 files changed, 30 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
> index 4d8d3b7..daf6694 100644
> --- a/drivers/mfd/twl6040.c
> +++ b/drivers/mfd/twl6040.c
> @@ -58,15 +58,9 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
>  	int ret;
>  	unsigned int val;
>  
> -	/* Vibra control registers from cache */
> -	if (unlikely(reg == TWL6040_REG_VIBCTLL ||
> -		     reg == TWL6040_REG_VIBCTLR)) {
> -		val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
> -	} else {
> -		ret = regmap_read(twl6040->regmap, reg, &val);
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = regmap_read(twl6040->regmap, reg, &val);
> +	if (ret < 0)
> +		return ret;
>  
>  	return val;
>  }
> @@ -77,9 +71,6 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
>  	int ret;
>  
>  	ret = regmap_write(twl6040->regmap, reg, val);
> -	/* Cache the vibra control registers */
> -	if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
> -		twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
>  
>  	return ret;
>  }
> @@ -456,9 +447,20 @@ EXPORT_SYMBOL(twl6040_get_sysclk);
>  /* Get the combined status of the vibra control register */
>  int twl6040_get_vibralr_status(struct twl6040 *twl6040)
>  {
> +	unsigned int reg;
> +	int ret;
>  	u8 status;
>  
> -	status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1];
> +	ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLL, &reg);
> +	if (ret != 0)
> +		return ret;
> +	status = reg;
> +
> +	ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLR, &reg);
> +	if (ret != 0)
> +		return ret;
> +	status |= reg;
> +
>  	status &= (TWL6040_VIBENA | TWL6040_VIBSEL);
>  
>  	return status;
> @@ -485,12 +487,27 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg)
>  	return true;
>  }
>  
> +static bool twl6040_volatile_reg(struct device *dev, unsigned int reg)
> +{
> +	switch (reg) {
> +	case TWL6040_REG_VIBCTLL:
> +	case TWL6040_REG_VIBCTLR:
> +	case TWL6040_REG_INTMR:
> +		return false;
> +	default:
> +		return true;
> +	}
> +}
> +
>  static struct regmap_config twl6040_regmap_config = {
>  	.reg_bits = 8,
>  	.val_bits = 8,
>  	.max_register = TWL6040_REG_STATUS, /* 0x2e */
>  
>  	.readable_reg = twl6040_readable_reg,
> +	.volatile_reg = twl6040_volatile_reg,
> +
> +	.cache_type = REGCACHE_RBTREE,
>  };
>  
>  static const struct regmap_irq twl6040_irqs[] = {
> diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
> index 6dd8893..81f639b 100644
> --- a/include/linux/mfd/twl6040.h
> +++ b/include/linux/mfd/twl6040.h
> @@ -230,7 +230,6 @@ struct twl6040 {
>  	int audpwron;
>  	int power_count;
>  	int rev;
> -	u8 vibra_ctrl_cache[2];
>  
>  	/* PLL configuration */
>  	int pll;
> 


-- 
Péter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: twl6040: Use regmap for register cache
  2013-08-31 16:48 [PATCH] mfd: twl6040: Use regmap for register cache Mark Brown
  2013-09-01 16:59 ` Peter Ujfalusi
@ 2013-09-02  8:17 ` Lee Jones
  2013-09-02  8:29   ` Samuel Ortiz
  1 sibling, 1 reply; 5+ messages in thread
From: Lee Jones @ 2013-09-02  8:17 UTC (permalink / raw)
  To: Mark Brown
  Cc: Samuel Ortiz, Peter Ujfalusi, linux-kernel, linaro-kernel,
	Mark Brown

On Sat, 31 Aug 2013, Mark Brown wrote:

> From: Mark Brown <broonie@linaro.org>
> 
> Rather then open coding a cache of the vibra control registers use the
> regmap cache code.  Also cache the interrupt mask register, providing
> a small performance improvement for the interrupt code.
> 
> Signed-off-by: Mark Brown <broonie@linaro.org>
> ---
> 
> I'm hoping to have some ASoC improvements to build on top of this (there
> is ASoC level register caching for the device) so it might make sense to
> apply this via ASoC.
> 
>  drivers/mfd/twl6040.c       | 43 ++++++++++++++++++++++++++++++-------------
>  include/linux/mfd/twl6040.h |  1 -
>  2 files changed, 30 insertions(+), 14 deletions(-)

Applied with Peter's Ack, thanks.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: twl6040: Use regmap for register cache
  2013-09-02  8:17 ` Lee Jones
@ 2013-09-02  8:29   ` Samuel Ortiz
  2013-09-02  8:45     ` Lee Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Samuel Ortiz @ 2013-09-02  8:29 UTC (permalink / raw)
  To: Lee Jones
  Cc: Mark Brown, Peter Ujfalusi, linux-kernel, linaro-kernel,
	Mark Brown

Hi Lee,

On Mon, Sep 02, 2013 at 09:17:59AM +0100, Lee Jones wrote:
> On Sat, 31 Aug 2013, Mark Brown wrote:
> 
> > From: Mark Brown <broonie@linaro.org>
> > 
> > Rather then open coding a cache of the vibra control registers use the
> > regmap cache code.  Also cache the interrupt mask register, providing
> > a small performance improvement for the interrupt code.
> > 
> > Signed-off-by: Mark Brown <broonie@linaro.org>
> > ---
> > 
> > I'm hoping to have some ASoC improvements to build on top of this (there
> > is ASoC level register caching for the device) so it might make sense to
> > apply this via ASoC.
> > 
> >  drivers/mfd/twl6040.c       | 43 ++++++++++++++++++++++++++++++-------------
> >  include/linux/mfd/twl6040.h |  1 -
> >  2 files changed, 30 insertions(+), 14 deletions(-)
> 
> Applied with Peter's Ack, thanks.
Please hold on. I'm preparing a branch for Mark to pull from and it will
contain that patch.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: twl6040: Use regmap for register cache
  2013-09-02  8:29   ` Samuel Ortiz
@ 2013-09-02  8:45     ` Lee Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2013-09-02  8:45 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Mark Brown, Peter Ujfalusi, linux-kernel, linaro-kernel,
	Mark Brown

On Mon, 02 Sep 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Mon, Sep 02, 2013 at 09:17:59AM +0100, Lee Jones wrote:
> > On Sat, 31 Aug 2013, Mark Brown wrote:
> > 
> > > From: Mark Brown <broonie@linaro.org>
> > > 
> > > Rather then open coding a cache of the vibra control registers use the
> > > regmap cache code.  Also cache the interrupt mask register, providing
> > > a small performance improvement for the interrupt code.
> > > 
> > > Signed-off-by: Mark Brown <broonie@linaro.org>
> > > ---
> > > 
> > > I'm hoping to have some ASoC improvements to build on top of this (there
> > > is ASoC level register caching for the device) so it might make sense to
> > > apply this via ASoC.
> > > 
> > >  drivers/mfd/twl6040.c       | 43 ++++++++++++++++++++++++++++++-------------
> > >  include/linux/mfd/twl6040.h |  1 -
> > >  2 files changed, 30 insertions(+), 14 deletions(-)
> > 
> > Applied with Peter's Ack, thanks.
> Please hold on. I'm preparing a branch for Mark to pull from and it will
> contain that patch.

Ah, I thought that was another set.

No problem. I've removed it from my branch.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-02  8:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-31 16:48 [PATCH] mfd: twl6040: Use regmap for register cache Mark Brown
2013-09-01 16:59 ` Peter Ujfalusi
2013-09-02  8:17 ` Lee Jones
2013-09-02  8:29   ` Samuel Ortiz
2013-09-02  8:45     ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox