diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2017-03-17 10:05:18 +0000 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2017-03-23 11:45:50 +0000 |
commit | f6dd8449cd50de25881b76cecf1086bebeb11fe8 (patch) | |
tree | fa757139b73dc9a8e79e46952d93db19dd5e8068 /drivers/mfd/wm831x-spi.c | |
parent | c1ae3cfa0e89fa1a7ecc4c99031f5e9ae99d9201 (diff) | |
download | op-kernel-dev-f6dd8449cd50de25881b76cecf1086bebeb11fe8.zip op-kernel-dev-f6dd8449cd50de25881b76cecf1086bebeb11fe8.tar.gz |
mfd: wm831x: Add basic device tree binding
Add the basic ability to register the device through device tree, more
work is needed to get each individual sub-driver functioning correctly
but this is enough to get the device to probe from device tree.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/wm831x-spi.c')
-rw-r--r-- | drivers/mfd/wm831x-spi.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c index 80482ae..c332e28 100644 --- a/drivers/mfd/wm831x-spi.c +++ b/drivers/mfd/wm831x-spi.c @@ -14,6 +14,8 @@ #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/pm.h> #include <linux/spi/spi.h> #include <linux/regmap.h> @@ -23,12 +25,19 @@ static int wm831x_spi_probe(struct spi_device *spi) { + struct wm831x_pdata *pdata = dev_get_platdata(&spi->dev); const struct spi_device_id *id = spi_get_device_id(spi); + const struct of_device_id *of_id; struct wm831x *wm831x; enum wm831x_parent type; int ret; - type = (enum wm831x_parent)id->driver_data; + if (spi->dev.of_node) { + of_id = of_match_device(wm831x_of_match, &spi->dev); + type = (enum wm831x_parent)of_id->data; + } else { + type = (enum wm831x_parent)id->driver_data; + } wm831x = devm_kzalloc(&spi->dev, sizeof(struct wm831x), GFP_KERNEL); if (wm831x == NULL) @@ -38,6 +47,7 @@ static int wm831x_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm831x); wm831x->dev = &spi->dev; + wm831x->type = type; wm831x->regmap = devm_regmap_init_spi(spi, &wm831x_regmap_config); if (IS_ERR(wm831x->regmap)) { @@ -47,7 +57,10 @@ static int wm831x_spi_probe(struct spi_device *spi) return ret; } - return wm831x_device_init(wm831x, type, spi->irq); + if (pdata) + memcpy(&wm831x->pdata, pdata, sizeof(*pdata)); + + return wm831x_device_init(wm831x, spi->irq); } static int wm831x_spi_remove(struct spi_device *spi) @@ -97,6 +110,7 @@ static struct spi_driver wm831x_spi_driver = { .driver = { .name = "wm831x", .pm = &wm831x_spi_pm, + .of_match_table = of_match_ptr(wm831x_of_match), }, .id_table = wm831x_spi_ids, .probe = wm831x_spi_probe, |