aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/wm8994-core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-11 13:11:51 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-04-18 18:35:21 -0400
commit20fb277250816d6c3ff326552be0fea4173fd8ca (patch)
tree8810ab54abd76480877b26540d87d59f99c527e3 /drivers/mfd/wm8994-core.c
parent39aa3b5a59ab1baff809821ed1db9682a8245656 (diff)
mfd: wm8994: Add some OF properties
Add properties for some of the more important bits of platform data and fill out the binding document. Not all of the current platform data is suitable for the sort of fixed configuration that is done using DT, some of it should have runtime mechanisms added instead and some is unlikely to ever be used in practical systems. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Tested-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/wm8994-core.c')
-rw-r--r--drivers/mfd/wm8994-core.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 3f8d591e9fe2..00e4fe2f3c75 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -19,6 +19,9 @@
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/mfd/core.h> 21#include <linux/mfd/core.h>
22#include <linux/of.h>
23#include <linux/of_device.h>
24#include <linux/of_gpio.h>
22#include <linux/pm_runtime.h> 25#include <linux/pm_runtime.h>
23#include <linux/regmap.h> 26#include <linux/regmap.h>
24#include <linux/regulator/consumer.h> 27#include <linux/regulator/consumer.h>
@@ -396,6 +399,60 @@ static const struct reg_default wm1811_reva_patch[] = {
396 { 0x102, 0x0 }, 399 { 0x102, 0x0 },
397}; 400};
398 401
402#ifdef CONFIG_OF
403static int wm8994_set_pdata_from_of(struct wm8994 *wm8994)
404{
405 struct device_node *np = wm8994->dev->of_node;
406 struct wm8994_pdata *pdata = &wm8994->pdata;
407 int i;
408
409 if (!np)
410 return 0;
411
412 if (of_property_read_u32_array(np, "wlf,gpio-cfg", pdata->gpio_defaults,
413 ARRAY_SIZE(pdata->gpio_defaults)) >= 0) {
414 for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
415 if (wm8994->pdata.gpio_defaults[i] == 0)
416 pdata->gpio_defaults[i]
417 = WM8994_CONFIGURE_GPIO;
418 }
419 }
420
421 of_property_read_u32_array(np, "wlf,micbias-cfg", pdata->micbias,
422 ARRAY_SIZE(pdata->micbias));
423
424 pdata->lineout1_diff = true;
425 pdata->lineout2_diff = true;
426 if (of_find_property(np, "wlf,lineout1-se", NULL))
427 pdata->lineout1_diff = false;
428 if (of_find_property(np, "wlf,lineout2-se", NULL))
429 pdata->lineout2_diff = false;
430
431 if (of_find_property(np, "wlf,lineout1-feedback", NULL))
432 pdata->lineout1fb = true;
433 if (of_find_property(np, "wlf,lineout2-feedback", NULL))
434 pdata->lineout2fb = true;
435
436 if (of_find_property(np, "wlf,ldoena-always-driven", NULL))
437 pdata->lineout2fb = true;
438
439 pdata->ldo[0].enable = of_get_named_gpio(np, "wlf,ldo1ena", 0);
440 if (pdata->ldo[0].enable < 0)
441 pdata->ldo[0].enable = 0;
442
443 pdata->ldo[1].enable = of_get_named_gpio(np, "wlf,ldo2ena", 0);
444 if (pdata->ldo[1].enable < 0)
445 pdata->ldo[1].enable = 0;
446
447 return 0;
448}
449#else
450static int wm8994_set_pdata_from_of(struct wm8994 *wm8994)
451{
452 return 0;
453}
454#endif
455
399/* 456/*
400 * Instantiate the generic non-control parts of the device. 457 * Instantiate the generic non-control parts of the device.
401 */ 458 */
@@ -414,6 +471,10 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
414 } 471 }
415 pdata = &wm8994->pdata; 472 pdata = &wm8994->pdata;
416 473
474 ret = wm8994_set_pdata_from_of(wm8994);
475 if (ret != 0)
476 return ret;
477
417 dev_set_drvdata(wm8994->dev, wm8994); 478 dev_set_drvdata(wm8994->dev, wm8994);
418 479
419 /* Add the on-chip regulators first for bootstrapping */ 480 /* Add the on-chip regulators first for bootstrapping */
@@ -683,6 +744,7 @@ MODULE_DEVICE_TABLE(of, wm8994_of_match);
683static int wm8994_i2c_probe(struct i2c_client *i2c, 744static int wm8994_i2c_probe(struct i2c_client *i2c,
684 const struct i2c_device_id *id) 745 const struct i2c_device_id *id)
685{ 746{
747 const struct of_device_id *of_id;
686 struct wm8994 *wm8994; 748 struct wm8994 *wm8994;
687 int ret; 749 int ret;
688 750
@@ -693,7 +755,14 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
693 i2c_set_clientdata(i2c, wm8994); 755 i2c_set_clientdata(i2c, wm8994);
694 wm8994->dev = &i2c->dev; 756 wm8994->dev = &i2c->dev;
695 wm8994->irq = i2c->irq; 757 wm8994->irq = i2c->irq;
696 wm8994->type = id->driver_data; 758
759 if (i2c->dev.of_node) {
760 of_id = of_match_device(wm8994_of_match, &i2c->dev);
761 if (of_id)
762 wm8994->type = (int)of_id->data;
763 } else {
764 wm8994->type = id->driver_data;
765 }
697 766
698 wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config); 767 wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config);
699 if (IS_ERR(wm8994->regmap)) { 768 if (IS_ERR(wm8994->regmap)) {
@@ -733,7 +802,7 @@ static struct i2c_driver wm8994_i2c_driver = {
733 .name = "wm8994", 802 .name = "wm8994",
734 .owner = THIS_MODULE, 803 .owner = THIS_MODULE,
735 .pm = &wm8994_pm_ops, 804 .pm = &wm8994_pm_ops,
736 .of_match_table = wm8994_of_match, 805 .of_match_table = of_match_ptr(wm8994_of_match),
737 }, 806 },
738 .probe = wm8994_i2c_probe, 807 .probe = wm8994_i2c_probe,
739 .remove = wm8994_i2c_remove, 808 .remove = wm8994_i2c_remove,