aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/tps65090.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/tps65090.c')
-rw-r--r--drivers/mfd/tps65090.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index 8d12a8e00d9c..98edb5be85c6 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -25,6 +25,8 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/mfd/core.h> 26#include <linux/mfd/core.h>
27#include <linux/mfd/tps65090.h> 27#include <linux/mfd/tps65090.h>
28#include <linux/of.h>
29#include <linux/of_device.h>
28#include <linux/err.h> 30#include <linux/err.h>
29 31
30#define NUM_INT_REG 2 32#define NUM_INT_REG 2
@@ -148,18 +150,31 @@ static const struct regmap_config tps65090_regmap_config = {
148 .volatile_reg = is_volatile_reg, 150 .volatile_reg = is_volatile_reg,
149}; 151};
150 152
153#ifdef CONFIG_OF
154static const struct of_device_id tps65090_of_match[] = {
155 { .compatible = "ti,tps65090",},
156 {},
157};
158MODULE_DEVICE_TABLE(of, tps65090_of_match);
159#endif
160
151static int tps65090_i2c_probe(struct i2c_client *client, 161static int tps65090_i2c_probe(struct i2c_client *client,
152 const struct i2c_device_id *id) 162 const struct i2c_device_id *id)
153{ 163{
154 struct tps65090_platform_data *pdata = client->dev.platform_data; 164 struct tps65090_platform_data *pdata = client->dev.platform_data;
165 int irq_base = 0;
155 struct tps65090 *tps65090; 166 struct tps65090 *tps65090;
156 int ret; 167 int ret;
157 168
158 if (!pdata) { 169 if (!pdata && !client->dev.of_node) {
159 dev_err(&client->dev, "tps65090 requires platform data\n"); 170 dev_err(&client->dev,
171 "tps65090 requires platform data or of_node\n");
160 return -EINVAL; 172 return -EINVAL;
161 } 173 }
162 174
175 if (pdata)
176 irq_base = pdata->irq_base;
177
163 tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL); 178 tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL);
164 if (!tps65090) { 179 if (!tps65090) {
165 dev_err(&client->dev, "mem alloc for tps65090 failed\n"); 180 dev_err(&client->dev, "mem alloc for tps65090 failed\n");
@@ -178,7 +193,7 @@ static int tps65090_i2c_probe(struct i2c_client *client,
178 193
179 if (client->irq) { 194 if (client->irq) {
180 ret = regmap_add_irq_chip(tps65090->rmap, client->irq, 195 ret = regmap_add_irq_chip(tps65090->rmap, client->irq,
181 IRQF_ONESHOT | IRQF_TRIGGER_LOW, pdata->irq_base, 196 IRQF_ONESHOT | IRQF_TRIGGER_LOW, irq_base,
182 &tps65090_irq_chip, &tps65090->irq_data); 197 &tps65090_irq_chip, &tps65090->irq_data);
183 if (ret) { 198 if (ret) {
184 dev_err(&client->dev, 199 dev_err(&client->dev,
@@ -189,7 +204,7 @@ static int tps65090_i2c_probe(struct i2c_client *client,
189 204
190 ret = mfd_add_devices(tps65090->dev, -1, tps65090s, 205 ret = mfd_add_devices(tps65090->dev, -1, tps65090s,
191 ARRAY_SIZE(tps65090s), NULL, 206 ARRAY_SIZE(tps65090s), NULL,
192 regmap_irq_chip_get_base(tps65090->irq_data), NULL); 207 0, regmap_irq_get_domain(tps65090->irq_data));
193 if (ret) { 208 if (ret) {
194 dev_err(&client->dev, "add mfd devices failed with err: %d\n", 209 dev_err(&client->dev, "add mfd devices failed with err: %d\n",
195 ret); 210 ret);
@@ -215,28 +230,6 @@ static int tps65090_i2c_remove(struct i2c_client *client)
215 return 0; 230 return 0;
216} 231}
217 232
218#ifdef CONFIG_PM_SLEEP
219static int tps65090_suspend(struct device *dev)
220{
221 struct i2c_client *client = to_i2c_client(dev);
222 if (client->irq)
223 disable_irq(client->irq);
224 return 0;
225}
226
227static int tps65090_resume(struct device *dev)
228{
229 struct i2c_client *client = to_i2c_client(dev);
230 if (client->irq)
231 enable_irq(client->irq);
232 return 0;
233}
234#endif
235
236static const struct dev_pm_ops tps65090_pm_ops = {
237 SET_SYSTEM_SLEEP_PM_OPS(tps65090_suspend, tps65090_resume)
238};
239
240static const struct i2c_device_id tps65090_id_table[] = { 233static const struct i2c_device_id tps65090_id_table[] = {
241 { "tps65090", 0 }, 234 { "tps65090", 0 },
242 { }, 235 { },
@@ -247,7 +240,7 @@ static struct i2c_driver tps65090_driver = {
247 .driver = { 240 .driver = {
248 .name = "tps65090", 241 .name = "tps65090",
249 .owner = THIS_MODULE, 242 .owner = THIS_MODULE,
250 .pm = &tps65090_pm_ops, 243 .of_match_table = of_match_ptr(tps65090_of_match),
251 }, 244 },
252 .probe = tps65090_i2c_probe, 245 .probe = tps65090_i2c_probe,
253 .remove = tps65090_i2c_remove, 246 .remove = tps65090_i2c_remove,