aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/da9052-i2c.c
diff options
context:
space:
mode:
authorYing-Chun Liu (PaulLiu) <paul.liu@linaro.org>2012-04-15 12:01:50 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-05-01 06:00:23 -0400
commit58d114b669d2b86aa79eac6688590c808072579b (patch)
treea91d8f027d73ee924f75fef8e0f5f093b5748ff3 /drivers/mfd/da9052-i2c.c
parent465c29d384f60c5fd9bcbc92efb9e249e585740a (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>
Diffstat (limited to 'drivers/mfd/da9052-i2c.c')
-rw-r--r--drivers/mfd/da9052-i2c.c50
1 files changed, 42 insertions, 8 deletions
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
25static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) 30static 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
49static 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
58static 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
44static int __devinit da9052_i2c_probe(struct i2c_client *client, 67static 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
103static 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
111static struct i2c_driver da9052_i2c_driver = { 142static 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