aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/wm8994-core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-03 12:10:32 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-12 11:11:13 -0500
commit346978980a781a5b434c48531cf29cadf5b83999 (patch)
treec2f80a16e77aaca02dff57fc47bb61bce97f00df /drivers/mfd/wm8994-core.c
parentc3f1386171a100d27d9fb978f474a6a330888af5 (diff)
mfd: Initialise WM8994 register cache after reading chip ID registers
The different devices handled by the WM8994 can be distinguished using their ID registers so we don't need to rely on the user having registered the device correctly. Instead do the initial regmap setup with a minimal configuration only supporting physical I/O and then configure the cache once we have identified the device. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/wm8994-core.c')
-rw-r--r--drivers/mfd/wm8994-core.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index aafac5b5f3a5..f9c4016baea6 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -334,6 +334,7 @@ static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
334static int wm8994_device_init(struct wm8994 *wm8994, int irq) 334static int wm8994_device_init(struct wm8994 *wm8994, int irq)
335{ 335{
336 struct wm8994_pdata *pdata = wm8994->dev->platform_data; 336 struct wm8994_pdata *pdata = wm8994->dev->platform_data;
337 struct regmap_config *regmap_config;
337 const char *devname; 338 const char *devname;
338 int ret, i; 339 int ret, i;
339 int pulls = 0; 340 int pulls = 0;
@@ -465,6 +466,28 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
465 466
466 dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + ret); 467 dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + ret);
467 468
469 switch (wm8994->type) {
470 case WM1811:
471 regmap_config = &wm1811_regmap_config;
472 break;
473 case WM8994:
474 regmap_config = &wm8994_regmap_config;
475 break;
476 case WM8958:
477 regmap_config = &wm8958_regmap_config;
478 break;
479 default:
480 dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type);
481 return -EINVAL;
482 }
483
484 ret = regmap_reinit_cache(wm8994->regmap, regmap_config);
485 if (ret != 0) {
486 dev_err(wm8994->dev, "Failed to reinit register cache: %d\n",
487 ret);
488 return ret;
489 }
490
468 if (pdata) { 491 if (pdata) {
469 wm8994->irq_base = pdata->irq_base; 492 wm8994->irq_base = pdata->irq_base;
470 wm8994->gpio_base = pdata->gpio_base; 493 wm8994->gpio_base = pdata->gpio_base;
@@ -556,7 +579,6 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
556 const struct i2c_device_id *id) 579 const struct i2c_device_id *id)
557{ 580{
558 struct wm8994 *wm8994; 581 struct wm8994 *wm8994;
559 struct regmap_config *regmap_config;
560 int ret; 582 int ret;
561 583
562 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL); 584 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL);
@@ -568,22 +590,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
568 wm8994->irq = i2c->irq; 590 wm8994->irq = i2c->irq;
569 wm8994->type = id->driver_data; 591 wm8994->type = id->driver_data;
570 592
571 switch (wm8994->type) { 593 wm8994->regmap = regmap_init_i2c(i2c, &wm8994_base_regmap_config);
572 case WM1811:
573 regmap_config = &wm1811_regmap_config;
574 break;
575 case WM8994:
576 regmap_config = &wm8994_regmap_config;
577 break;
578 case WM8958:
579 regmap_config = &wm8958_regmap_config;
580 break;
581 default:
582 dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type);
583 return -EINVAL;
584 }
585
586 wm8994->regmap = regmap_init_i2c(i2c, regmap_config);
587 if (IS_ERR(wm8994->regmap)) { 594 if (IS_ERR(wm8994->regmap)) {
588 ret = PTR_ERR(wm8994->regmap); 595 ret = PTR_ERR(wm8994->regmap);
589 dev_err(wm8994->dev, "Failed to allocate register map: %d\n", 596 dev_err(wm8994->dev, "Failed to allocate register map: %d\n",