diff options
author | Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> | 2012-04-15 12:01:50 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-01 06:00:23 -0400 |
commit | 58d114b669d2b86aa79eac6688590c808072579b (patch) | |
tree | a91d8f027d73ee924f75fef8e0f5f093b5748ff3 | |
parent | 465c29d384f60c5fd9bcbc92efb9e249e585740a (diff) |
mfd: Add device-tree support for da9502 i2c driver
This patch adds device-tree support for dialog MFD and the binding
documentations.
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Ashish Jangam <ashish.jangam@kpitcummins.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | Documentation/devicetree/bindings/mfd/da9052-i2c.txt | 60 | ||||
-rw-r--r-- | drivers/mfd/da9052-i2c.c | 50 |
2 files changed, 102 insertions, 8 deletions
diff --git a/Documentation/devicetree/bindings/mfd/da9052-i2c.txt b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt new file mode 100644 index 000000000000..1857f4a6b9a9 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/da9052-i2c.txt | |||
@@ -0,0 +1,60 @@ | |||
1 | * Dialog DA9052/53 Power Management Integrated Circuit (PMIC) | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : Should be "dlg,da9052", "dlg,da9053-aa", | ||
5 | "dlg,da9053-ab", or "dlg,da9053-bb" | ||
6 | |||
7 | Sub-nodes: | ||
8 | - regulators : Contain the regulator nodes. The DA9052/53 regulators are | ||
9 | bound using their names as listed below: | ||
10 | |||
11 | buck0 : regulator BUCK0 | ||
12 | buck1 : regulator BUCK1 | ||
13 | buck2 : regulator BUCK2 | ||
14 | buck3 : regulator BUCK3 | ||
15 | ldo4 : regulator LDO4 | ||
16 | ldo5 : regulator LDO5 | ||
17 | ldo6 : regulator LDO6 | ||
18 | ldo7 : regulator LDO7 | ||
19 | ldo8 : regulator LDO8 | ||
20 | ldo9 : regulator LDO9 | ||
21 | ldo10 : regulator LDO10 | ||
22 | ldo11 : regulator LDO11 | ||
23 | ldo12 : regulator LDO12 | ||
24 | ldo13 : regulator LDO13 | ||
25 | |||
26 | The bindings details of individual regulator device can be found in: | ||
27 | Documentation/devicetree/bindings/regulator/regulator.txt | ||
28 | |||
29 | Examples: | ||
30 | |||
31 | i2c@63fc8000 { /* I2C1 */ | ||
32 | status = "okay"; | ||
33 | |||
34 | pmic: dialog@48 { | ||
35 | compatible = "dlg,da9053-aa"; | ||
36 | reg = <0x48>; | ||
37 | |||
38 | regulators { | ||
39 | buck0 { | ||
40 | regulator-min-microvolt = <500000>; | ||
41 | regulator-max-microvolt = <2075000>; | ||
42 | }; | ||
43 | |||
44 | buck1 { | ||
45 | regulator-min-microvolt = <500000>; | ||
46 | regulator-max-microvolt = <2075000>; | ||
47 | }; | ||
48 | |||
49 | buck2 { | ||
50 | regulator-min-microvolt = <925000>; | ||
51 | regulator-max-microvolt = <2500000>; | ||
52 | }; | ||
53 | |||
54 | buck3 { | ||
55 | regulator-min-microvolt = <925000>; | ||
56 | regulator-max-microvolt = <2500000>; | ||
57 | }; | ||
58 | }; | ||
59 | }; | ||
60 | }; | ||
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c index 36b88e395499..d8abdb35161e 100644 --- a/drivers/mfd/da9052-i2c.c +++ b/drivers/mfd/da9052-i2c.c | |||
@@ -22,6 +22,11 @@ | |||
22 | #include <linux/mfd/da9052/da9052.h> | 22 | #include <linux/mfd/da9052/da9052.h> |
23 | #include <linux/mfd/da9052/reg.h> | 23 | #include <linux/mfd/da9052/reg.h> |
24 | 24 | ||
25 | #ifdef CONFIG_OF | ||
26 | #include <linux/of.h> | ||
27 | #include <linux/of_device.h> | ||
28 | #endif | ||
29 | |||
25 | static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) | 30 | static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) |
26 | { | 31 | { |
27 | int reg_val, ret; | 32 | int reg_val, ret; |
@@ -41,6 +46,24 @@ static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) | |||
41 | return 0; | 46 | return 0; |
42 | } | 47 | } |
43 | 48 | ||
49 | static struct i2c_device_id da9052_i2c_id[] = { | ||
50 | {"da9052", DA9052}, | ||
51 | {"da9053-aa", DA9053_AA}, | ||
52 | {"da9053-ba", DA9053_BA}, | ||
53 | {"da9053-bb", DA9053_BB}, | ||
54 | {} | ||
55 | }; | ||
56 | |||
57 | #ifdef CONFIG_OF | ||
58 | static const struct of_device_id dialog_dt_ids[] = { | ||
59 | { .compatible = "dlg,da9052", .data = &da9052_i2c_id[0] }, | ||
60 | { .compatible = "dlg,da9053-aa", .data = &da9052_i2c_id[1] }, | ||
61 | { .compatible = "dlg,da9053-ab", .data = &da9052_i2c_id[2] }, | ||
62 | { .compatible = "dlg,da9053-bb", .data = &da9052_i2c_id[3] }, | ||
63 | { /* sentinel */ } | ||
64 | }; | ||
65 | #endif | ||
66 | |||
44 | static int __devinit da9052_i2c_probe(struct i2c_client *client, | 67 | static int __devinit da9052_i2c_probe(struct i2c_client *client, |
45 | const struct i2c_device_id *id) | 68 | const struct i2c_device_id *id) |
46 | { | 69 | { |
@@ -76,6 +99,22 @@ static int __devinit da9052_i2c_probe(struct i2c_client *client, | |||
76 | if (ret < 0) | 99 | if (ret < 0) |
77 | goto err_regmap; | 100 | goto err_regmap; |
78 | 101 | ||
102 | #ifdef CONFIG_OF | ||
103 | if (!id) { | ||
104 | struct device_node *np = client->dev.of_node; | ||
105 | const struct of_device_id *deviceid; | ||
106 | |||
107 | deviceid = of_match_node(np, dialog_dt_ids); | ||
108 | id = (const struct i2c_device_id *)deviceid->data; | ||
109 | } | ||
110 | #endif | ||
111 | |||
112 | if (!id) { | ||
113 | ret = -ENODEV; | ||
114 | dev_err(&client->dev, "id is null.\n"); | ||
115 | goto err_regmap; | ||
116 | } | ||
117 | |||
79 | ret = da9052_device_init(da9052, id->driver_data); | 118 | ret = da9052_device_init(da9052, id->driver_data); |
80 | if (ret != 0) | 119 | if (ret != 0) |
81 | goto err_regmap; | 120 | goto err_regmap; |
@@ -100,14 +139,6 @@ static int __devexit da9052_i2c_remove(struct i2c_client *client) | |||
100 | return 0; | 139 | return 0; |
101 | } | 140 | } |
102 | 141 | ||
103 | static struct i2c_device_id da9052_i2c_id[] = { | ||
104 | {"da9052", DA9052}, | ||
105 | {"da9053-aa", DA9053_AA}, | ||
106 | {"da9053-ba", DA9053_BA}, | ||
107 | {"da9053-bb", DA9053_BB}, | ||
108 | {} | ||
109 | }; | ||
110 | |||
111 | static struct i2c_driver da9052_i2c_driver = { | 142 | static struct i2c_driver da9052_i2c_driver = { |
112 | .probe = da9052_i2c_probe, | 143 | .probe = da9052_i2c_probe, |
113 | .remove = __devexit_p(da9052_i2c_remove), | 144 | .remove = __devexit_p(da9052_i2c_remove), |
@@ -115,6 +146,9 @@ static struct i2c_driver da9052_i2c_driver = { | |||
115 | .driver = { | 146 | .driver = { |
116 | .name = "da9052", | 147 | .name = "da9052", |
117 | .owner = THIS_MODULE, | 148 | .owner = THIS_MODULE, |
149 | #ifdef CONFIG_OF | ||
150 | .of_match_table = dialog_dt_ids, | ||
151 | #endif | ||
118 | }, | 152 | }, |
119 | }; | 153 | }; |
120 | 154 | ||