diff options
| -rw-r--r-- | drivers/mfd/ti_am335x_tscadc.c | 32 |
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 | ||
| 301 | static const struct of_device_id ti_tscadc_dt_ids[] = { | ||
| 302 | { .compatible = "ti,am3359-tscadc", }, | ||
| 303 | { } | ||
| 304 | }; | ||
| 305 | MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids); | ||
| 306 | |||
| 288 | static struct platform_driver ti_tscadc_driver = { | 307 | static 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, |
