aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/twl6040.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-08-31 12:48:19 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-09-02 04:30:14 -0400
commitc6f39257c952bc7da974bf93255936ff2ece2c34 (patch)
tree934b363a903dc4a80248b260d319b6f20992597d /drivers/mfd/twl6040.c
parent921a2c870faa0a88c34e5c8c2afbd898fe8d325d (diff)
mfd: twl6040: Use regmap for register cache
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> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/twl6040.c')
-rw-r--r--drivers/mfd/twl6040.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
index 492ee2cd3400..c7df66a208d4 100644
--- a/drivers/mfd/twl6040.c
+++ b/drivers/mfd/twl6040.c
@@ -63,15 +63,9 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
63 int ret; 63 int ret;
64 unsigned int val; 64 unsigned int val;
65 65
66 /* Vibra control registers from cache */ 66 ret = regmap_read(twl6040->regmap, reg, &val);
67 if (unlikely(reg == TWL6040_REG_VIBCTLL || 67 if (ret < 0)
68 reg == TWL6040_REG_VIBCTLR)) { 68 return ret;
69 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
70 } else {
71 ret = regmap_read(twl6040->regmap, reg, &val);
72 if (ret < 0)
73 return ret;
74 }
75 69
76 return val; 70 return val;
77} 71}
@@ -82,9 +76,6 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
82 int ret; 76 int ret;
83 77
84 ret = regmap_write(twl6040->regmap, reg, val); 78 ret = regmap_write(twl6040->regmap, reg, val);
85 /* Cache the vibra control registers */
86 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
87 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
88 79
89 return ret; 80 return ret;
90} 81}
@@ -461,9 +452,20 @@ EXPORT_SYMBOL(twl6040_get_sysclk);
461/* Get the combined status of the vibra control register */ 452/* Get the combined status of the vibra control register */
462int twl6040_get_vibralr_status(struct twl6040 *twl6040) 453int twl6040_get_vibralr_status(struct twl6040 *twl6040)
463{ 454{
455 unsigned int reg;
456 int ret;
464 u8 status; 457 u8 status;
465 458
466 status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1]; 459 ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLL, &reg);
460 if (ret != 0)
461 return ret;
462 status = reg;
463
464 ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLR, &reg);
465 if (ret != 0)
466 return ret;
467 status |= reg;
468
467 status &= (TWL6040_VIBENA | TWL6040_VIBSEL); 469 status &= (TWL6040_VIBENA | TWL6040_VIBSEL);
468 470
469 return status; 471 return status;
@@ -490,12 +492,27 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg)
490 return true; 492 return true;
491} 493}
492 494
495static bool twl6040_volatile_reg(struct device *dev, unsigned int reg)
496{
497 switch (reg) {
498 case TWL6040_REG_VIBCTLL:
499 case TWL6040_REG_VIBCTLR:
500 case TWL6040_REG_INTMR:
501 return false;
502 default:
503 return true;
504 }
505}
506
493static struct regmap_config twl6040_regmap_config = { 507static struct regmap_config twl6040_regmap_config = {
494 .reg_bits = 8, 508 .reg_bits = 8,
495 .val_bits = 8, 509 .val_bits = 8,
496 .max_register = TWL6040_REG_STATUS, /* 0x2e */ 510 .max_register = TWL6040_REG_STATUS, /* 0x2e */
497 511
498 .readable_reg = twl6040_readable_reg, 512 .readable_reg = twl6040_readable_reg,
513 .volatile_reg = twl6040_volatile_reg,
514
515 .cache_type = REGCACHE_RBTREE,
499}; 516};
500 517
501static const struct regmap_irq twl6040_irqs[] = { 518static const struct regmap_irq twl6040_irqs[] = {