aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/wm8350-regmap.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-03 08:37:22 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-07-08 18:16:10 -0400
commit52b461b86a9f6c7a86bdcb858e1bbef089fbe6a0 (patch)
tree9c839b3ce945fb75249d0be0cbde503b44334351 /drivers/mfd/wm8350-regmap.c
parentb0ab907d325f99054eb2700a8f8c50776ebfeaf9 (diff)
mfd: Add regmap cache support for wm8350
Use the most simple possible transformation on the existing code so keep the table sitting around, further patches in this series will delete the existing cache code - the main purpose of this patch is to ensure that we always have a cache for bisection. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/wm8350-regmap.c')
-rw-r--r--drivers/mfd/wm8350-regmap.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
index e965139e5cd5..7974cadaa422 100644
--- a/drivers/mfd/wm8350-regmap.c
+++ b/drivers/mfd/wm8350-regmap.c
@@ -3433,3 +3433,59 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
3433 { 0x0000, 0x0000, 0x0000 }, /* R254 */ 3433 { 0x0000, 0x0000, 0x0000 }, /* R254 */
3434 { 0x0000, 0x0000, 0x0000 }, /* R255 */ 3434 { 0x0000, 0x0000, 0x0000 }, /* R255 */
3435}; 3435};
3436
3437static bool wm8350_readable(struct device *dev, unsigned int reg)
3438{
3439 return wm8350_reg_io_map[reg].readable;
3440}
3441
3442static bool wm8350_writeable(struct device *dev, unsigned int reg)
3443{
3444 struct wm8350 *wm8350 = dev_get_drvdata(dev);
3445
3446 if (!wm8350->unlocked) {
3447 if ((reg >= WM8350_GPIO_FUNCTION_SELECT_1 &&
3448 reg <= WM8350_GPIO_FUNCTION_SELECT_4) ||
3449 (reg >= WM8350_BATTERY_CHARGER_CONTROL_1 &&
3450 reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
3451 return false;
3452 }
3453
3454 return wm8350_reg_io_map[reg].writable;
3455}
3456
3457static bool wm8350_volatile(struct device *dev, unsigned int reg)
3458{
3459 return wm8350_reg_io_map[reg].vol;
3460}
3461
3462static bool wm8350_precious(struct device *dev, unsigned int reg)
3463{
3464 switch (reg) {
3465 case WM8350_SYSTEM_INTERRUPTS:
3466 case WM8350_INT_STATUS_1:
3467 case WM8350_INT_STATUS_2:
3468 case WM8350_POWER_UP_INT_STATUS:
3469 case WM8350_UNDER_VOLTAGE_INT_STATUS:
3470 case WM8350_OVER_CURRENT_INT_STATUS:
3471 case WM8350_GPIO_INT_STATUS:
3472 case WM8350_COMPARATOR_INT_STATUS:
3473 return true;
3474
3475 default:
3476 return false;
3477 }
3478}
3479
3480const struct regmap_config wm8350_regmap = {
3481 .reg_bits = 8,
3482 .val_bits = 16,
3483
3484 .cache_type = REGCACHE_RBTREE,
3485
3486 .max_register = WM8350_MAX_REGISTER,
3487 .readable_reg = wm8350_readable,
3488 .writeable_reg = wm8350_writeable,
3489 .volatile_reg = wm8350_volatile,
3490 .precious_reg = wm8350_precious,
3491};