diff options
author | Max Krummenacher <max.oss.09@gmail.com> | 2014-08-16 18:01:33 +0200 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2014-08-18 16:44:15 +0200 |
commit | d518ee721d4f1cd35c913c17bf9f89a84532f37e (patch) | |
tree | 82310575517c9d0fecba64f00ee1a5ed98317373 | |
parent | 6c1b530c56c51bc422fc1545fffa6e03fc98f73f (diff) |
stmpe-adc: add device tree bindings
-rw-r--r-- | Documentation/devicetree/bindings/staging/iio/adc/stmpe-adc.txt | 30 | ||||
-rw-r--r-- | drivers/mfd/stmpe.c | 1 | ||||
-rw-r--r-- | drivers/staging/iio/adc/stmpe-adc.c | 43 |
3 files changed, 62 insertions, 12 deletions
diff --git a/Documentation/devicetree/bindings/staging/iio/adc/stmpe-adc.txt b/Documentation/devicetree/bindings/staging/iio/adc/stmpe-adc.txt new file mode 100644 index 000000000000..b73a1069ed8e --- /dev/null +++ b/Documentation/devicetree/bindings/staging/iio/adc/stmpe-adc.txt @@ -0,0 +1,30 @@ +STMPE ADC driver +---------------- + +Required properties: + - compatible: "st,stmpe-adc" + +Optional properties: +Note that the ADC is shared with the STMPE touchscreen, so if using both the +settings should be the same. +If they are not, the last one to be initialized will win. +- st,sample-time: ADC converstion time in number of clock. (0 -> 36 clocks, 1 -> + 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks, 4 -> 80 clocks, 5 -> 96 clocks, 6 + -> 144 clocks), recommended is 4. +- st,mod-12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC) +- st,ref-sel: ADC reference source (0 -> internal reference, 1 -> external + reference) +- st,adc-freq: ADC Clock speed (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz) + +Node name must be stmpe_adc and should be child node of stmpe node to +which it belongs. + +Example: + + stmpe_adc { + compatible = "st,stmpe-adc"; + st,sample-time = <4>; + st,mod-12b = <1>; + st,ref-sel = <0>; + st,adc-freq = <1>; + }; diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index b663f2a40b51..648fba4e4b4d 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -431,6 +431,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) |