aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/max8925-i2c.c
diff options
context:
space:
mode:
authorQing Xu <qingx@marvell.com>2013-02-04 10:40:42 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-02-13 18:23:00 -0500
commit4e405ae256b7e04f7c1213136f3bfd9fb76e2023 (patch)
treef821f9b999202d623c50eafcb9db5431937f1f46 /drivers/mfd/max8925-i2c.c
parentdcd560c8587171bb22c75c41ac2a70986bbbde7f (diff)
mfd: max8925: Add irqdomain for dt
Add irqdomains for max8925's main irq, wrap irq register operations into irqdomain's map func. it is necessary for dt support. Also, add dt support for max8925 driver. Signed-off-by: Qing Xu <qingx@marvell.com> Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/max8925-i2c.c')
-rw-r--r--drivers/mfd/max8925-i2c.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 00b5b456063d..92bbebd31598 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -135,13 +135,37 @@ static const struct i2c_device_id max8925_id_table[] = {
135}; 135};
136MODULE_DEVICE_TABLE(i2c, max8925_id_table); 136MODULE_DEVICE_TABLE(i2c, max8925_id_table);
137 137
138static int max8925_dt_init(struct device_node *np, struct device *dev,
139 struct max8925_platform_data *pdata)
140{
141 int ret;
142
143 ret = of_property_read_u32(np, "maxim,tsc-irq", &pdata->tsc_irq);
144 if (ret) {
145 dev_err(dev, "Not found maxim,tsc-irq property\n");
146 return -EINVAL;
147 }
148 return 0;
149}
150
138static int max8925_probe(struct i2c_client *client, 151static int max8925_probe(struct i2c_client *client,
139 const struct i2c_device_id *id) 152 const struct i2c_device_id *id)
140{ 153{
141 struct max8925_platform_data *pdata = client->dev.platform_data; 154 struct max8925_platform_data *pdata = client->dev.platform_data;
142 static struct max8925_chip *chip; 155 static struct max8925_chip *chip;
143 156 struct device_node *node = client->dev.of_node;
144 if (!pdata) { 157
158 if (node && !pdata) {
159 /* parse DT to get platform data */
160 pdata = devm_kzalloc(&client->dev,
161 sizeof(struct max8925_platform_data),
162 GFP_KERNEL);
163 if (!pdata)
164 return -ENOMEM;
165
166 if (max8925_dt_init(node, &client->dev, pdata))
167 return -EINVAL;
168 } else if (!pdata) {
145 pr_info("%s: platform data is missing\n", __func__); 169 pr_info("%s: platform data is missing\n", __func__);
146 return -EINVAL; 170 return -EINVAL;
147 } 171 }
@@ -203,11 +227,18 @@ static int max8925_resume(struct device *dev)
203 227
204static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume); 228static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume);
205 229
230static const struct of_device_id max8925_dt_ids[] = {
231 { .compatible = "maxim,max8925", },
232 {},
233};
234MODULE_DEVICE_TABLE(of, max8925_dt_ids);
235
206static struct i2c_driver max8925_driver = { 236static struct i2c_driver max8925_driver = {
207 .driver = { 237 .driver = {
208 .name = "max8925", 238 .name = "max8925",
209 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
210 .pm = &max8925_pm_ops, 240 .pm = &max8925_pm_ops,
241 .of_match_table = of_match_ptr(max8925_dt_ids),
211 }, 242 },
212 .probe = max8925_probe, 243 .probe = max8925_probe,
213 .remove = max8925_remove, 244 .remove = max8925_remove,
@@ -217,7 +248,6 @@ static struct i2c_driver max8925_driver = {
217static int __init max8925_i2c_init(void) 248static int __init max8925_i2c_init(void)
218{ 249{
219 int ret; 250 int ret;
220
221 ret = i2c_add_driver(&max8925_driver); 251 ret = i2c_add_driver(&max8925_driver);
222 if (ret != 0) 252 if (ret != 0)
223 pr_err("Failed to register MAX8925 I2C driver: %d\n", ret); 253 pr_err("Failed to register MAX8925 I2C driver: %d\n", ret);