aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatil, Rachna <rachna@ti.com>2013-01-23 22:45:09 -0500
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-06-12 12:48:32 -0400
commita6543a1cb56ab1bf4f722226ae36dd51eeaea97e (patch)
treef14fe05ad204c304c9ec22b5c6652bc8006d20d8
parent0ead4fb22a5f1b31fee966117604e3be9cdeb2fb (diff)
mfd: ti_am335x_tscadc: Add DT support
Add DT support in the MFD core driver. The node name is "am3359" because it was tested on this platform. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Patil, Rachna <rachna@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-rw-r--r--drivers/mfd/ti_am335x_tscadc.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 1d6c74049590..292d34eaed54 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -22,6 +22,8 @@
22#include <linux/regmap.h> 22#include <linux/regmap.h>
23#include <linux/mfd/core.h> 23#include <linux/mfd/core.h>
24#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
25#include <linux/of.h>
26#include <linux/of_device.h>
25 27
26#include <linux/mfd/ti_am335x_tscadc.h> 28#include <linux/mfd/ti_am335x_tscadc.h>
27#include <linux/input/ti_am335x_tsc.h> 29#include <linux/input/ti_am335x_tsc.h>
@@ -90,20 +92,31 @@ static int ti_tscadc_probe(struct platform_device *pdev)
90 struct resource *res; 92 struct resource *res;
91 struct clk *clk; 93 struct clk *clk;
92 struct mfd_tscadc_board *pdata = pdev->dev.platform_data; 94 struct mfd_tscadc_board *pdata = pdev->dev.platform_data;
95 struct device_node *node = pdev->dev.of_node;
93 struct mfd_cell *cell; 96 struct mfd_cell *cell;
94 int err, ctrl; 97 int err, ctrl;
95 int clk_value, clock_rate; 98 int clk_value, clock_rate;
96 int tsc_wires, adc_channels = 0, total_channels; 99 int tsc_wires = 0, adc_channels = 0, total_channels;
97 100
98 if (!pdata) { 101 if (!pdata && !pdev->dev.of_node) {
99 dev_err(&pdev->dev, "Could not find platform data\n"); 102 dev_err(&pdev->dev, "Could not find platform data\n");
100 return -EINVAL; 103 return -EINVAL;
101 } 104 }
102 105
103 if (pdata->adc_init) 106 if (pdev->dev.platform_data) {
104 adc_channels = pdata->adc_init->adc_channels; 107 if (pdata->tsc_init)
108 tsc_wires = pdata->tsc_init->wires;
109
110 if (pdata->adc_init)
111 adc_channels = pdata->adc_init->adc_channels;
112 } else {
113 node = of_get_child_by_name(pdev->dev.of_node, "tsc");
114 of_property_read_u32(node, "ti,wires", &tsc_wires);
115
116 node = of_get_child_by_name(pdev->dev.of_node, "adc");
117 of_property_read_u32(node, "ti,adc-channels", &adc_channels);
118 }
105 119
106 tsc_wires = pdata->tsc_init->wires;
107 total_channels = tsc_wires + adc_channels; 120 total_channels = tsc_wires + adc_channels;
108 121
109 if (total_channels > 8) { 122 if (total_channels > 8) {
@@ -285,11 +298,18 @@ static const struct dev_pm_ops tscadc_pm_ops = {
285#define TSCADC_PM_OPS NULL 298#define TSCADC_PM_OPS NULL
286#endif 299#endif
287 300
301static const struct of_device_id ti_tscadc_dt_ids[] = {
302 { .compatible = "ti,am3359-tscadc", },
303 { }
304};
305MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids);
306
288static struct platform_driver ti_tscadc_driver = { 307static struct platform_driver ti_tscadc_driver = {
289 .driver = { 308 .driver = {
290 .name = "ti_tscadc", 309 .name = "ti_am3359-tscadc",
291 .owner = THIS_MODULE, 310 .owner = THIS_MODULE,
292 .pm = TSCADC_PM_OPS, 311 .pm = TSCADC_PM_OPS,
312 .of_match_table = of_match_ptr(ti_tscadc_dt_ids),
293 }, 313 },
294 .probe = ti_tscadc_probe, 314 .probe = ti_tscadc_probe,
295 .remove = ti_tscadc_remove, 315 .remove = ti_tscadc_remove,