diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-07-18 02:20:47 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-07-24 18:36:53 -0400 |
commit | 75edd5af601800cf1c8797ed1da14f4ddbda6d47 (patch) | |
tree | 2494babc10b9d13a1bcf757f1ca2f5a3b2d0265d /drivers/mfd/tps6586x.c | |
parent | 1176b5be67692e910c8d4b055902c314e7249e36 (diff) |
mfd: Cache tps6586x register through regmap
To cache the interrupt mask register, use the regmap RB_TREE
cache-ing mechanism in place of implementing it locally.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/tps6586x.c')
-rw-r--r-- | drivers/mfd/tps6586x.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index 6f59594c6c11..d59bfb77326b 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c | |||
@@ -104,7 +104,6 @@ struct tps6586x { | |||
104 | struct mutex irq_lock; | 104 | struct mutex irq_lock; |
105 | int irq_base; | 105 | int irq_base; |
106 | u32 irq_en; | 106 | u32 irq_en; |
107 | u8 mask_cache[5]; | ||
108 | u8 mask_reg[5]; | 107 | u8 mask_reg[5]; |
109 | }; | 108 | }; |
110 | 109 | ||
@@ -276,12 +275,11 @@ static void tps6586x_irq_sync_unlock(struct irq_data *data) | |||
276 | int i; | 275 | int i; |
277 | 276 | ||
278 | for (i = 0; i < ARRAY_SIZE(tps6586x->mask_reg); i++) { | 277 | for (i = 0; i < ARRAY_SIZE(tps6586x->mask_reg); i++) { |
279 | if (tps6586x->mask_reg[i] != tps6586x->mask_cache[i]) { | 278 | int ret; |
280 | if (!WARN_ON(tps6586x_write(tps6586x->dev, | 279 | ret = tps6586x_write(tps6586x->dev, |
281 | TPS6586X_INT_MASK1 + i, | 280 | TPS6586X_INT_MASK1 + i, |
282 | tps6586x->mask_reg[i]))) | 281 | tps6586x->mask_reg[i]); |
283 | tps6586x->mask_cache[i] = tps6586x->mask_reg[i]; | 282 | WARN_ON(ret); |
284 | } | ||
285 | } | 283 | } |
286 | 284 | ||
287 | mutex_unlock(&tps6586x->irq_lock); | 285 | mutex_unlock(&tps6586x->irq_lock); |
@@ -328,7 +326,6 @@ static int __devinit tps6586x_irq_init(struct tps6586x *tps6586x, int irq, | |||
328 | 326 | ||
329 | mutex_init(&tps6586x->irq_lock); | 327 | mutex_init(&tps6586x->irq_lock); |
330 | for (i = 0; i < 5; i++) { | 328 | for (i = 0; i < 5; i++) { |
331 | tps6586x->mask_cache[i] = 0xff; | ||
332 | tps6586x->mask_reg[i] = 0xff; | 329 | tps6586x->mask_reg[i] = 0xff; |
333 | tps6586x_write(tps6586x->dev, TPS6586X_INT_MASK1 + i, 0xff); | 330 | tps6586x_write(tps6586x->dev, TPS6586X_INT_MASK1 + i, 0xff); |
334 | } | 331 | } |
@@ -478,10 +475,21 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien | |||
478 | } | 475 | } |
479 | #endif | 476 | #endif |
480 | 477 | ||
478 | static bool is_volatile_reg(struct device *dev, unsigned int reg) | ||
479 | { | ||
480 | /* Cache all interrupt mask register */ | ||
481 | if ((reg >= TPS6586X_INT_MASK1) && (reg <= TPS6586X_INT_MASK5)) | ||
482 | return false; | ||
483 | |||
484 | return true; | ||
485 | } | ||
486 | |||
481 | static const struct regmap_config tps6586x_regmap_config = { | 487 | static const struct regmap_config tps6586x_regmap_config = { |
482 | .reg_bits = 8, | 488 | .reg_bits = 8, |
483 | .val_bits = 8, | 489 | .val_bits = 8, |
484 | .max_register = TPS6586X_MAX_REGISTER - 1, | 490 | .max_register = TPS6586X_MAX_REGISTER - 1, |
491 | .volatile_reg = is_volatile_reg, | ||
492 | .cache_type = REGCACHE_RBTREE, | ||
485 | }; | 493 | }; |
486 | 494 | ||
487 | static int __devinit tps6586x_i2c_probe(struct i2c_client *client, | 495 | static int __devinit tps6586x_i2c_probe(struct i2c_client *client, |