aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/sound/wm8994.txt58
-rw-r--r--drivers/mfd/wm8994-core.c73
2 files changed, 128 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/sound/wm8994.txt b/Documentation/devicetree/bindings/sound/wm8994.txt
index 7a7eb1e7bda6..f2f3e80934d2 100644
--- a/Documentation/devicetree/bindings/sound/wm8994.txt
+++ b/Documentation/devicetree/bindings/sound/wm8994.txt
@@ -5,14 +5,70 @@ on the board).
5 5
6Required properties: 6Required properties:
7 7
8 - compatible : "wlf,wm1811", "wlf,wm8994", "wlf,wm8958" 8 - compatible : One of "wlf,wm1811", "wlf,wm8994" or "wlf,wm8958".
9 9
10 - reg : the I2C address of the device for I2C, the chip select 10 - reg : the I2C address of the device for I2C, the chip select
11 number for SPI. 11 number for SPI.
12 12
13 - gpio-controller : Indicates this device is a GPIO controller.
14 - #gpio-cells : Must be 2. The first cell is the pin number and the
15 second cell is used to specify optional parameters (currently unused).
16
17 - AVDD2-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply,
18 SPKVDD1-supply, SPKVDD2-supply : power supplies for the device, as covered
19 in Documentation/devicetree/bindings/regulator/regulator.txt
20
21Optional properties:
22
23 - interrupts : The interrupt line the IRQ signal for the device is
24 connected to. This is optional, if it is not connected then none
25 of the interrupt related properties should be specified.
26 - interrupt-controller : These devices contain interrupt controllers
27 and may provide interrupt services to other devices if they have an
28 interrupt line connected.
29 - interrupt-parent : The parent interrupt controller.
30 - #interrupt-cells: the number of cells to describe an IRQ, this should be 2.
31 The first cell is the IRQ number.
32 The second cell is the flags, encoded as the trigger masks from
33 Documentation/devicetree/bindings/interrupts.txt
34
35 - wlf,gpio-cfg : A list of GPIO configuration register values. If absent,
36 no configuration of these registers is performed. If any value is
37 over 0xffff then the register will be left as default. If present 11
38 values must be supplied.
39
40 - wlf,micbias-cfg : Two MICBIAS register values for WM1811 or
41 WM8958. If absent the register defaults will be used.
42
43 - wlf,ldo1ena : GPIO specifier for control of LDO1ENA input to device.
44 - wlf,ldo2ena : GPIO specifier for control of LDO2ENA input to device.
45
46 - wlf,lineout1-se : If present LINEOUT1 is in single ended mode.
47 - wlf,lineout2-se : If present LINEOUT2 is in single ended mode.
48
49 - wlf,lineout1-feedback : If present LINEOUT1 has common mode feedback
50 connected.
51 - wlf,lineout2-feedback : If present LINEOUT2 has common mode feedback
52 connected.
53
54 - wlf,ldoena-always-driven : If present LDOENA is always driven.
55
13Example: 56Example:
14 57
15codec: wm8994@1a { 58codec: wm8994@1a {
16 compatible = "wlf,wm8994"; 59 compatible = "wlf,wm8994";
17 reg = <0x1a>; 60 reg = <0x1a>;
61
62 gpio-controller;
63 #gpio-cells = <2>;
64
65 lineout1-se;
66
67 AVDD2-supply = <&regulator>;
68 CPVDD-supply = <&regulator>;
69 DBVDD1-supply = <&regulator>;
70 DBVDD2-supply = <&regulator>;
71 DBVDD3-supply = <&regulator>;
72 SPKVDD1-supply = <&regulator>;
73 SPKVDD2-supply = <&regulator>;
18}; 74};
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,