diff options
Diffstat (limited to 'drivers/mfd/wm831x-i2c.c')
-rw-r--r-- | drivers/mfd/wm831x-i2c.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c index 824bcbaa9624..781af060f32d 100644 --- a/drivers/mfd/wm831x-i2c.c +++ b/drivers/mfd/wm831x-i2c.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/mfd/core.h> | 19 | #include <linux/mfd/core.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/of.h> | ||
23 | #include <linux/of_device.h> | ||
22 | #include <linux/regmap.h> | 24 | #include <linux/regmap.h> |
23 | 25 | ||
24 | #include <linux/mfd/wm831x/core.h> | 26 | #include <linux/mfd/wm831x/core.h> |
@@ -27,15 +29,26 @@ | |||
27 | static int wm831x_i2c_probe(struct i2c_client *i2c, | 29 | static int wm831x_i2c_probe(struct i2c_client *i2c, |
28 | const struct i2c_device_id *id) | 30 | const struct i2c_device_id *id) |
29 | { | 31 | { |
32 | struct wm831x_pdata *pdata = dev_get_platdata(&i2c->dev); | ||
33 | const struct of_device_id *of_id; | ||
30 | struct wm831x *wm831x; | 34 | struct wm831x *wm831x; |
35 | enum wm831x_parent type; | ||
31 | int ret; | 36 | int ret; |
32 | 37 | ||
38 | if (i2c->dev.of_node) { | ||
39 | of_id = of_match_device(wm831x_of_match, &i2c->dev); | ||
40 | type = (enum wm831x_parent)of_id->data; | ||
41 | } else { | ||
42 | type = (enum wm831x_parent)id->driver_data; | ||
43 | } | ||
44 | |||
33 | wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL); | 45 | wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL); |
34 | if (wm831x == NULL) | 46 | if (wm831x == NULL) |
35 | return -ENOMEM; | 47 | return -ENOMEM; |
36 | 48 | ||
37 | i2c_set_clientdata(i2c, wm831x); | 49 | i2c_set_clientdata(i2c, wm831x); |
38 | wm831x->dev = &i2c->dev; | 50 | wm831x->dev = &i2c->dev; |
51 | wm831x->type = type; | ||
39 | 52 | ||
40 | wm831x->regmap = devm_regmap_init_i2c(i2c, &wm831x_regmap_config); | 53 | wm831x->regmap = devm_regmap_init_i2c(i2c, &wm831x_regmap_config); |
41 | if (IS_ERR(wm831x->regmap)) { | 54 | if (IS_ERR(wm831x->regmap)) { |
@@ -45,7 +58,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, | |||
45 | return ret; | 58 | return ret; |
46 | } | 59 | } |
47 | 60 | ||
48 | return wm831x_device_init(wm831x, id->driver_data, i2c->irq); | 61 | if (pdata) |
62 | memcpy(&wm831x->pdata, pdata, sizeof(*pdata)); | ||
63 | |||
64 | return wm831x_device_init(wm831x, i2c->irq); | ||
49 | } | 65 | } |
50 | 66 | ||
51 | static int wm831x_i2c_remove(struct i2c_client *i2c) | 67 | static int wm831x_i2c_remove(struct i2c_client *i2c) |
@@ -94,6 +110,7 @@ static struct i2c_driver wm831x_i2c_driver = { | |||
94 | .driver = { | 110 | .driver = { |
95 | .name = "wm831x", | 111 | .name = "wm831x", |
96 | .pm = &wm831x_pm_ops, | 112 | .pm = &wm831x_pm_ops, |
113 | .of_match_table = of_match_ptr(wm831x_of_match), | ||
97 | }, | 114 | }, |
98 | .probe = wm831x_i2c_probe, | 115 | .probe = wm831x_i2c_probe, |
99 | .remove = wm831x_i2c_remove, | 116 | .remove = wm831x_i2c_remove, |