aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYadwinder Singh Brar <yadi.brar01@gmail.com>2012-07-06 07:32:55 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-07-09 09:13:42 -0400
commitc1516f840dcd91e76712a047993e09d95034a66d (patch)
tree8aedaf38d74ea987ff38ca9de81731b59ccd3d8f
parent2b40459b7ee502c970d9f1dcf94dfa4d58ec1d85 (diff)
mfd: Add device tree support for max77686
This patch adds device tree support for mfd driver and adds Documentation/devicetree/bindings/mfd/max77686.txt. This patch also intialize max77686 pointer to NULL in max77686_i2c_probe to silent a compile time warning. Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--Documentation/devicetree/bindings/mfd/max77686.txt59
-rw-r--r--drivers/mfd/max77686.c45
2 files changed, 98 insertions, 6 deletions
diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt b/Documentation/devicetree/bindings/mfd/max77686.txt
new file mode 100644
index 000000000000..c6a3469d3436
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max77686.txt
@@ -0,0 +1,59 @@
1Maxim MAX77686 multi-function device
2
3MAX77686 is a Mulitifunction device with PMIC, RTC and Charger on chip. It is
4interfaced to host controller using i2c interface. PMIC and Charger submodules
5are addressed using same i2c slave address whereas RTC submodule uses
6different i2c slave address,presently for which we are statically creating i2c
7client while probing.This document describes the binding for mfd device and
8PMIC submodule.
9
10Required properties:
11- compatible : Must be "maxim,max77686";
12- reg : Specifies the i2c slave address of PMIC block.
13- interrupts : This i2c device has an IRQ line connected to the main SoC.
14- interrupt-parent : The parent interrupt controller.
15
16Optional node:
17- voltage-regulators : The regulators of max77686 have to be instantiated
18 under subnode named "voltage-regulators" using the following format.
19
20 regulator_name {
21 regulator-compatible = LDOn/BUCKn
22 standard regulator constraints....
23 };
24 refer Documentation/devicetree/bindings/regulator/regulator.txt
25
26 The regulator-compatible property of regulator should initialized with string
27to get matched with their hardware counterparts as follow:
28
29 -LDOn : for LDOs, where n can lie in range 1 to 26.
30 example: LDO1, LDO2, LDO26.
31 -BUCKn : for BUCKs, where n can lie in range 1 to 9.
32 example: BUCK1, BUCK5, BUCK9.
33
34Example:
35
36 max77686@09 {
37 compatible = "maxim,max77686";
38 interrupt-parent = <&wakeup_eint>;
39 interrupts = <26 0>;
40 reg = <0x09>;
41
42 voltage-regulators {
43 ldo11_reg {
44 regulator-compatible = "LDO11";
45 regulator-name = "vdd_ldo11";
46 regulator-min-microvolt = <1900000>;
47 regulator-max-microvolt = <1900000>;
48 regulator-always-on;
49 };
50
51 buck1_reg {
52 regulator-compatible = "BUCK1";
53 regulator-name = "vdd_mif";
54 regulator-min-microvolt = <950000>;
55 regulator-max-microvolt = <1300000>;
56 regulator-always-on;
57 regulator-boot-on;
58 };
59 }
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index c66639d681e9..3e31d05906b2 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -34,6 +34,11 @@
34 34
35#define I2C_ADDR_RTC (0x0C >> 1) 35#define I2C_ADDR_RTC (0x0C >> 1)
36 36
37static struct of_device_id __devinitdata max77686_pmic_dt_match[] = {
38 {.compatible = "maxim,max77686", .data = 0},
39 {},
40};
41
37static struct mfd_cell max77686_devs[] = { 42static struct mfd_cell max77686_devs[] = {
38 { .name = "max77686-pmic", }, 43 { .name = "max77686-pmic", },
39 { .name = "max77686-rtc", }, 44 { .name = "max77686-rtc", },
@@ -44,14 +49,46 @@ static struct regmap_config max77686_regmap_config = {
44 .val_bits = 8, 49 .val_bits = 8,
45}; 50};
46 51
52#ifdef CONFIG_OF
53static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
54 *dev)
55{
56 struct max77686_platform_data *pd;
57
58 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
59 if (!pd) {
60 dev_err(dev, "could not allocate memory for pdata\n");
61 return NULL;
62 }
63
64 dev->platform_data = pd;
65 return pd;
66}
67#else
68static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
69 *dev)
70{
71 return 0;
72}
73#endif
74
47static int max77686_i2c_probe(struct i2c_client *i2c, 75static int max77686_i2c_probe(struct i2c_client *i2c,
48 const struct i2c_device_id *id) 76 const struct i2c_device_id *id)
49{ 77{
50 struct max77686_dev *max77686; 78 struct max77686_dev *max77686 = NULL;
51 struct max77686_platform_data *pdata = i2c->dev.platform_data; 79 struct max77686_platform_data *pdata = i2c->dev.platform_data;
52 unsigned int data; 80 unsigned int data;
53 int ret = 0; 81 int ret = 0;
54 82
83 if (i2c->dev.of_node)
84 pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
85
86 if (!pdata) {
87 ret = -EIO;
88 dev_err(&i2c->dev, "No platform data found.\n");
89 goto err;
90 }
91
55 max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL); 92 max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL);
56 if (max77686 == NULL) 93 if (max77686 == NULL)
57 return -ENOMEM; 94 return -ENOMEM;
@@ -70,11 +107,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
70 max77686->i2c = i2c; 107 max77686->i2c = i2c;
71 max77686->type = id->driver_data; 108 max77686->type = id->driver_data;
72 109
73 if (!pdata) {
74 ret = -EIO;
75 goto err;
76 }
77
78 max77686->wakeup = pdata->wakeup; 110 max77686->wakeup = pdata->wakeup;
79 max77686->irq_gpio = pdata->irq_gpio; 111 max77686->irq_gpio = pdata->irq_gpio;
80 max77686->irq = i2c->irq; 112 max77686->irq = i2c->irq;
@@ -130,6 +162,7 @@ static struct i2c_driver max77686_i2c_driver = {
130 .driver = { 162 .driver = {
131 .name = "max77686", 163 .name = "max77686",
132 .owner = THIS_MODULE, 164 .owner = THIS_MODULE,
165 .of_match_table = of_match_ptr(max77686_pmic_dt_match),
133 }, 166 },
134 .probe = max77686_i2c_probe, 167 .probe = max77686_i2c_probe,
135 .remove = max77686_i2c_remove, 168 .remove = max77686_i2c_remove,