diff options
author | Max Krummenacher <max.oss.09@gmail.com> | 2014-08-16 18:01:33 +0200 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2017-01-10 23:11:15 +0100 |
commit | 6f88e1d8c28585002d51f4c4232abea61a022763 (patch) | |
tree | 22a070feb67da48608f0cf23c004094b447b57ec /drivers | |
parent | 6b542ac0446a5822b6b0549a074725dc50e3cab3 (diff) |
stmpe-adc: add device tree bindings
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
(cherry picked from commit 16692ff50af0d7a216d71ff39b69d8971b08b690)
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mfd/stmpe.c | 1 | ||||
-rw-r--r-- | drivers/staging/iio/adc/stmpe-adc.c | 43 |
2 files changed, 32 insertions, 12 deletions
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 3f07cac9af04..cd3ad2482c5e 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -432,6 +432,7 @@ static struct resource stmpe_adc_resources[] = { static struct mfd_cell stmpe_adc_cell = { .name = "stmpe-adc", + .of_compatible = "st,stmpe-adc", .resources = stmpe_adc_resources, .num_resources = ARRAY_SIZE(stmpe_adc_resources), }; diff --git a/drivers/staging/iio/adc/stmpe-adc.c b/drivers/staging/iio/adc/stmpe-adc.c index 1ec494f299a6..9669240cc87f 100644 --- a/drivers/staging/iio/adc/stmpe-adc.c +++ b/drivers/staging/iio/adc/stmpe-adc.c @@ -236,12 +236,40 @@ static int stmpe_adc_init_hw(struct stmpe_adc *adc) return 0; } +static void stmpe_adc_get_platform_info(struct platform_device *pdev, + struct stmpe_adc *adc) +{ + struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); + struct device_node *np = pdev->dev.of_node; + struct stmpe_adc_platform_data *adc_pdata = NULL; + + adc->stmpe = stmpe; + + if (stmpe->pdata && stmpe->pdata->adc) + { + adc_pdata = stmpe->pdata->adc; + + adc->sample_time = adc_pdata->sample_time; + adc->mod_12b = adc_pdata->mod_12b; + adc->ref_sel = adc_pdata->ref_sel; + adc->adc_freq = adc_pdata->adc_freq; + } else if (np) { + u32 val; + + if (!of_property_read_u32(np, "st,sample-time", &val)) + adc->sample_time = val; + if (!of_property_read_u32(np, "st,mod-12b", &val)) + adc->mod_12b = val; + if (!of_property_read_u32(np, "st,ref-sel", &val)) + adc->ref_sel = val; + if (!of_property_read_u32(np, "st,adc-freq", &val)) + adc->adc_freq = val; + } +} static int stmpe_adc_probe(struct platform_device *pdev) { struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); - struct stmpe_platform_data *pdata = stmpe->pdata; - struct stmpe_adc_platform_data *adc_pdata = NULL; struct stmpe_adc *info = NULL; struct iio_dev *indio_dev = NULL; int ret = -ENODEV; @@ -259,7 +287,6 @@ static int stmpe_adc_probe(struct platform_device *pdev) info = iio_priv(indio_dev); info->irq = irq; - info->stmpe = stmpe; init_completion(&info->completion); ret = request_threaded_irq(info->irq, NULL, stmpe_adc_isr, IRQF_ONESHOT, @@ -283,15 +310,7 @@ static int stmpe_adc_probe(struct platform_device *pdev) indio_dev->channels = stmpe_adc_all_iio_channels; indio_dev->num_channels = ARRAY_SIZE(stmpe_adc_iio_channels); - if (pdata) - adc_pdata = pdata->adc; - - if (adc_pdata) { - info->sample_time = adc_pdata->sample_time; - info->mod_12b = adc_pdata->mod_12b; - info->ref_sel = adc_pdata->ref_sel; - info->adc_freq = adc_pdata->adc_freq; - } + stmpe_adc_get_platform_info(pdev, info); ret = stmpe_adc_init_hw(info); if (ret) |