aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/mfd/arizona.txt62
-rw-r--r--drivers/mfd/arizona-core.c69
-rw-r--r--drivers/mfd/arizona-i2c.c10
-rw-r--r--drivers/mfd/arizona-spi.c10
-rw-r--r--drivers/mfd/arizona.h12
5 files changed, 159 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
new file mode 100644
index 000000000000..0e295c9d8937
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -0,0 +1,62 @@
1Wolfson Arizona class audio SoCs
2
3These devices are audio SoCs with extensive digital capabilites and a range
4of analogue I/O.
5
6Required properties:
7
8 - compatible : one of the following chip-specific strings:
9 "wlf,wm5102"
10 "wlf,wm5110"
11 - reg : I2C slave address when connected using I2C, chip select number when
12 using SPI.
13
14 - interrupts : The interrupt line the /IRQ signal for the device is
15 connected to.
16 - interrupt-controller : Arizona class devices contain interrupt controllers
17 and may provide interrupt services to other devices.
18 - interrupt-parent : The parent interrupt controller.
19 - #interrupt-cells: the number of cells to describe an IRQ, this should be 2.
20 The first cell is the IRQ number.
21 The second cell is the flags, encoded as the trigger masks from
22 Documentation/devicetree/bindings/interrupts.txt
23
24 - gpio-controller : Indicates this device is a GPIO controller.
25 - #gpio-cells : Must be 2. The first cell is the pin number and the
26 second cell is used to specify optional parameters (currently unused).
27
28 - AVDD1-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply,
29 SPKVDDL-supply, SPKVDDR-supply : power supplies for the device, as covered
30 in Documentation/devicetree/bindings/regulator/regulator.txt
31
32Optional properties:
33
34 - wlf,reset : GPIO specifier for the GPIO controlling /RESET
35 - wlf,ldoena : GPIO specifier for the GPIO controlling LDOENA
36
37 - wlf,gpio-defaults : A list of GPIO configuration register values. If
38 absent, no configuration of these registers is performed. If any
39 entry has a value that is out of range for a 16 bit register then
40 the chip default will be used. If present exactly five values must
41 be specified.
42
43Example:
44
45codec: wm5102@1a {
46 compatible = "wlf,wm5102";
47 reg = <0x1a>;
48 interrupts = <347>;
49 #interrupt-cells = <2>;
50 interrupt-parent = <&gic>;
51
52 gpio-controller;
53 #gpio-cells = <2>;
54
55 wlf,gpio-defaults = <
56 0x00000000, /* AIF1TXLRCLK */
57 0xffffffff,
58 0xffffffff,
59 0xffffffff,
60 0xffffffff,
61 >;
62};
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 549db0ad7257..d8d30c0a488d 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -16,6 +16,9 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/mfd/core.h> 17#include <linux/mfd/core.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h>
20#include <linux/of_device.h>
21#include <linux/of_gpio.h>
19#include <linux/pm_runtime.h> 22#include <linux/pm_runtime.h>
20#include <linux/regmap.h> 23#include <linux/regmap.h>
21#include <linux/regulator/consumer.h> 24#include <linux/regulator/consumer.h>
@@ -462,6 +465,70 @@ const struct dev_pm_ops arizona_pm_ops = {
462}; 465};
463EXPORT_SYMBOL_GPL(arizona_pm_ops); 466EXPORT_SYMBOL_GPL(arizona_pm_ops);
464 467
468#ifdef CONFIG_OF
469int arizona_of_get_type(struct device *dev)
470{
471 const struct of_device_id *id = of_match_device(arizona_of_match, dev);
472
473 if (id)
474 return (int)id->data;
475 else
476 return 0;
477}
478EXPORT_SYMBOL_GPL(arizona_of_get_type);
479
480static int arizona_of_get_core_pdata(struct arizona *arizona)
481{
482 int ret, i;
483
484 arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,
485 "wlf,reset", 0);
486 if (arizona->pdata.reset < 0)
487 arizona->pdata.reset = 0;
488
489 arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
490 "wlf,ldoena", 0);
491 if (arizona->pdata.ldoena < 0)
492 arizona->pdata.ldoena = 0;
493
494 ret = of_property_read_u32_array(arizona->dev->of_node,
495 "wlf,gpio-defaults",
496 arizona->pdata.gpio_defaults,
497 ARRAY_SIZE(arizona->pdata.gpio_defaults));
498 if (ret >= 0) {
499 /*
500 * All values are literal except out of range values
501 * which are chip default, translate into platform
502 * data which uses 0 as chip default and out of range
503 * as zero.
504 */
505 for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) {
506 if (arizona->pdata.gpio_defaults[i] > 0xffff)
507 arizona->pdata.gpio_defaults[i] = 0;
508 if (arizona->pdata.gpio_defaults[i] == 0)
509 arizona->pdata.gpio_defaults[i] = 0x10000;
510 }
511 } else {
512 dev_err(arizona->dev, "Failed to parse GPIO defaults: %d\n",
513 ret);
514 }
515
516 return 0;
517}
518
519const struct of_device_id arizona_of_match[] = {
520 { .compatible = "wlf,wm5102", .data = (void *)WM5102 },
521 { .compatible = "wlf,wm5110", .data = (void *)WM5110 },
522 {},
523};
524EXPORT_SYMBOL_GPL(arizona_of_match);
525#else
526static inline int arizona_of_get_core_pdata(struct arizona *arizona)
527{
528 return 0;
529}
530#endif
531
465static struct mfd_cell early_devs[] = { 532static struct mfd_cell early_devs[] = {
466 { .name = "arizona-ldo1" }, 533 { .name = "arizona-ldo1" },
467}; 534};
@@ -495,6 +562,8 @@ int arizona_dev_init(struct arizona *arizona)
495 dev_set_drvdata(arizona->dev, arizona); 562 dev_set_drvdata(arizona->dev, arizona);
496 mutex_init(&arizona->clk_lock); 563 mutex_init(&arizona->clk_lock);
497 564
565 arizona_of_get_core_pdata(arizona);
566
498 if (dev_get_platdata(arizona->dev)) 567 if (dev_get_platdata(arizona->dev))
499 memcpy(&arizona->pdata, dev_get_platdata(arizona->dev), 568 memcpy(&arizona->pdata, dev_get_platdata(arizona->dev),
500 sizeof(arizona->pdata)); 569 sizeof(arizona->pdata));
diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
index 44a1bb969841..deb267ebf84e 100644
--- a/drivers/mfd/arizona-i2c.c
+++ b/drivers/mfd/arizona-i2c.c
@@ -27,9 +27,14 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
27{ 27{
28 struct arizona *arizona; 28 struct arizona *arizona;
29 const struct regmap_config *regmap_config; 29 const struct regmap_config *regmap_config;
30 int ret; 30 int ret, type;
31 31
32 switch (id->driver_data) { 32 if (i2c->dev.of_node)
33 type = arizona_of_get_type(&i2c->dev);
34 else
35 type = id->driver_data;
36
37 switch (type) {
33#ifdef CONFIG_MFD_WM5102 38#ifdef CONFIG_MFD_WM5102
34 case WM5102: 39 case WM5102:
35 regmap_config = &wm5102_i2c_regmap; 40 regmap_config = &wm5102_i2c_regmap;
@@ -84,6 +89,7 @@ static struct i2c_driver arizona_i2c_driver = {
84 .name = "arizona", 89 .name = "arizona",
85 .owner = THIS_MODULE, 90 .owner = THIS_MODULE,
86 .pm = &arizona_pm_ops, 91 .pm = &arizona_pm_ops,
92 .of_match_table = of_match_ptr(arizona_of_match),