aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/twl6040.c43
-rw-r--r--include/linux/mfd/twl6040.h1
2 files changed, 30 insertions, 14 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[] = {
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 7e7fbce7a308..2b7d26573431 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -229,7 +229,6 @@ struct twl6040 {
229 int audpwron; 229 int audpwron;
230 int power_count; 230 int power_count;
231 int rev; 231 int rev;
232 u8 vibra_ctrl_cache[2];
233 232
234 /* PLL configuration */ 233 /* PLL configuration */
235 int pll; 234 int pll;