aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/twl6040.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-09-02 04:31:08 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-09-02 04:31:08 -0400
commitf4388ca7f1e7c19a406700b3d1d3bfbf15d14115 (patch)
tree1edb8323d6cfe88620ac0c3f3c0f6c8e61134c7d /drivers/mfd/twl6040.c
parent62282180645a94f8686680bca464afd418511510 (diff)
parentc6f39257c952bc7da974bf93255936ff2ece2c34 (diff)
Merge branch 'topic/for-asoc'
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 4d8d3b74d4e3..daf66942071c 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)
58 int ret; 58 int ret;
59 unsigned int val; 59 unsigned int val;
60 60
61 /* Vibra control registers from cache */ 61 ret = regmap_read(twl6040->regmap, reg, &val);
62 if (unlikely(reg == TWL6040_REG_VIBCTLL || 62 if (ret < 0)
63 reg == TWL6040_REG_VIBCTLR)) { 63 return ret;
64 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
65 } else {
66 ret = regmap_read(twl6040->regmap, reg, &val);
67 if (ret < 0)
68 return ret;
69 }
70 64
71 return val; 65 return val;
72} 66}
@@ -77,9 +71,6 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
77 int ret; 71 int ret;
78 72
79 ret = regmap_write(twl6040->regmap, reg, val); 73 ret = regmap_write(twl6040->regmap, reg, val);
80 /* Cache the vibra control registers */
81 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
82 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
83 74
84 return ret; 75 return ret;
85} 76}
@@ -456,9 +447,20 @@ EXPORT_SYMBOL(twl6040_get_sysclk);
456/* Get the combined status of the vibra control register */ 447/* Get the combined status of the vibra control register */
457int twl6040_get_vibralr_status(struct twl6040 *twl6040) 448int twl6040_get_vibralr_status(struct twl6040 *twl6040)
458{ 449{
450 unsigned int reg;
451 int ret;
459 u8 status; 452 u8 status;
460 453
461 status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1]; 454 ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLL, &reg);
455 if (ret != 0)
456 return ret;
457 status = reg;
458
459 ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLR, &reg);
460 if (ret != 0)
461 return ret;
462 status |= reg;
463
462 status &= (TWL6040_VIBENA | TWL6040_VIBSEL); 464 status &= (TWL6040_VIBENA | TWL6040_VIBSEL);
463 465
464 return status; 466 return status;
@@ -485,12 +487,27 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg)
485 return true; 487 return true;
486} 488}
487 489
490static bool twl6040_volatile_reg(struct device *dev, unsigned int reg)
491{
492 switch (reg) {
493 case TWL6040_REG_VIBCTLL:
494 case TWL6040_REG_VIBCTLR:
495 case TWL6040_REG_INTMR:
496 return false;
497 default:
498 return true;
499 }
500}
501
488static struct regmap_config twl6040_regmap_config = { 502static struct regmap_config twl6040_regmap_config = {
489 .reg_bits = 8, 503 .reg_bits = 8,
490 .val_bits = 8, 504 .val_bits = 8,
491 .max_register = TWL6040_REG_STATUS, /* 0x2e */ 505 .max_register = TWL6040_REG_STATUS, /* 0x2e */
492 506
493 .readable_reg = twl6040_readable_reg, 507 .readable_reg = twl6040_readable_reg,
508 .volatile_reg = twl6040_volatile_reg,
509
510 .cache_type = REGCACHE_RBTREE,
494}; 511};
495 512
496static const struct regmap_irq twl6040_irqs[] = { 513static const struct regmap_irq twl6040_irqs[] = {