Hello,
This series cleans up the at91_adc devicetree bindings. This mainly
moves back the resolution options and names and the triggers description
back in the driver.
There are also other cleanups, like removing platform data support, this
was pending for a while.
Changes in v2:
- separated out the dt-binding change to give a chance to Rob to actually
review them.
- Dropped "iio: adc: at91_adc: use devm_input_allocate_device"
- Collected tags
- use of_device_get_match_data instead of device_get_match_data
- include backportable sam9rl trigger fix
Alexandre Belloni (10):
iio: adc: at91_adc: remove platform data
iio: adc: at91_adc: rework resolution selection
dt-bindings:iio:adc:remove atmel,adc-res and atmel,adc-res-names
iio: adc: at91_adc: rework trigger definition
dt-bindings:iio:adc:remove triggers
iio: adc: at91_adc: merge at91_adc_probe_dt back in at91_adc_probe
iio: adc: at91_adc: remove forward declaration
ARM: dts: at91: sama5d3: use proper ADC compatible
ARM: dts: at91: at91sam9rl: fix ADC triggers
ARM: dts: at91: remove deprecated ADC properties
Jonathan Cameron (1):
dt-bindings:iio:adc:atmel,sama9260-adc: conversion to yaml from
at91_adc.txt
.../devicetree/bindings/iio/adc/at91_adc.txt | 83 -----
.../bindings/iio/adc/atmel,sama9260-adc.yaml | 121 ++++++
arch/arm/boot/dts/at91sam9260.dtsi | 25 --
arch/arm/boot/dts/at91sam9g45.dtsi | 27 --
arch/arm/boot/dts/at91sam9rl.dtsi | 25 --
arch/arm/boot/dts/at91sam9x5.dtsi | 28 --
arch/arm/boot/dts/sama5d3.dtsi | 26 +-
arch/arm/boot/dts/sama5d4.dtsi | 22 --
drivers/iio/adc/at91_adc.c | 351 +++++++-----------
include/linux/platform_data/at91_adc.h | 49 ---
10 files changed, 256 insertions(+), 501 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/iio/adc/at91_adc.txt
create mode 100644 Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml
delete mode 100644 include/linux/platform_data/at91_adc.h
--
2.28.0
Move the possible resolution values back to the driver. This removes the
atmel,adc-res and atmel,adc-res-names properties, leaving only
atmel,adc-use-res. As atmel,adc-res-names had to contain "lowres" and
"highres", those where already the only allowed values for
atmel,adc-use-res.
Also introduce a new compatible string for the sama5d3 as this is the only
one with a different resolution. Also it doesn't even have the LOWRES
bit.
Signed-off-by: Alexandre Belloni <[email protected]>
Reviewed-by: Ludovic Desroches <[email protected]>
---
drivers/iio/adc/at91_adc.c | 97 ++++++++++++++++----------------------
1 file changed, 40 insertions(+), 57 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 62bd35af8b13..0d67c812ef3d 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -204,6 +204,9 @@ struct at91_adc_caps {
u32 (*calc_startup_ticks)(u32 startup_time, u32 adc_clk_khz);
u8 num_channels;
+
+ u8 low_res_bits;
+ u8 high_res_bits;
struct at91_adc_reg_desc registers;
};
@@ -229,7 +232,6 @@ struct at91_adc_state {
bool use_external;
u32 vref_mv;
u32 res; /* resolution used for convertions */
- bool low_res; /* the resolution corresponds to the lowest one */
wait_queue_head_t wq_data_avail;
struct at91_adc_caps *caps;
@@ -754,58 +756,6 @@ static int at91_adc_read_raw(struct iio_dev *idev,
return -EINVAL;
}
-static int at91_adc_of_get_resolution(struct iio_dev *idev,
- struct platform_device *pdev)
-{
- struct at91_adc_state *st = iio_priv(idev);
- struct device_node *np = pdev->dev.of_node;
- int count, i, ret = 0;
- char *res_name, *s;
- u32 *resolutions;
-
- count = of_property_count_strings(np, "atmel,adc-res-names");
- if (count < 2) {
- dev_err(&idev->dev, "You must specified at least two resolution names for "
- "adc-res-names property in the DT\n");
- return count;
- }
-
- resolutions = kmalloc_array(count, sizeof(*resolutions), GFP_KERNEL);
- if (!resolutions)
- return -ENOMEM;
-
- if (of_property_read_u32_array(np, "atmel,adc-res", resolutions, count)) {
- dev_err(&idev->dev, "Missing adc-res property in the DT.\n");
- ret = -ENODEV;
- goto ret;
- }
-
- if (of_property_read_string(np, "atmel,adc-use-res", (const char **)&res_name))
- res_name = "highres";
-
- for (i = 0; i < count; i++) {
- if (of_property_read_string_index(np, "atmel,adc-res-names", i, (const char **)&s))
- continue;
-
- if (strcmp(res_name, s))
- continue;
-
- st->res = resolutions[i];
- if (!strcmp(res_name, "lowres"))
- st->low_res = true;
- else
- st->low_res = false;
-
- dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
- goto ret;
- }
-
- dev_err(&idev->dev, "There is no resolution for %s\n", res_name);
-
-ret:
- kfree(resolutions);
- return ret;
-}
static u32 calc_startup_ticks_9260(u32 startup_time, u32 adc_clk_khz)
{
@@ -891,6 +841,7 @@ static int at91_adc_probe_dt(struct iio_dev *idev,
struct device_node *trig_node;
int i = 0, ret;
u32 prop;
+ char *s;
st->caps = (struct at91_adc_caps *)
of_match_device(at91_adc_dt_ids, &pdev->dev)->data;
@@ -924,9 +875,13 @@ static int at91_adc_probe_dt(struct iio_dev *idev,
}
st->vref_mv = prop;
- ret = at91_adc_of_get_resolution(idev, pdev);
- if (ret)
- goto error_ret;
+ st->res = st->caps->high_res_bits;
+ if (st->caps->low_res_bits &&
+ !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
+ && !strcmp(s, "lowres"))
+ st->res = st->caps->low_res_bits;
+
+ dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
st->registers = &st->caps->registers;
st->num_channels = st->caps->num_channels;
@@ -1248,7 +1203,7 @@ static int at91_adc_probe(struct platform_device *pdev)
reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;
- if (st->low_res)
+ if (st->res == st->caps->low_res_bits)
reg |= AT91_ADC_LOWRES;
if (st->sleep_mode)
reg |= AT91_ADC_SLEEP;
@@ -1363,6 +1318,8 @@ static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
static struct at91_adc_caps at91sam9260_caps = {
.calc_startup_ticks = calc_startup_ticks_9260,
.num_channels = 4,
+ .low_res_bits = 8,
+ .high_res_bits = 10,
.registers = {
.channel_base = AT91_ADC_CHR(0),
.drdy_mask = AT91_ADC_DRDY,
@@ -1377,6 +1334,8 @@ static struct at91_adc_caps at91sam9rl_caps = {
.has_ts = true,
.calc_startup_ticks = calc_startup_ticks_9260, /* same as 9260 */
.num_channels = 6,
+ .low_res_bits = 8,
+ .high_res_bits = 10,
.registers = {
.channel_base = AT91_ADC_CHR(0),
.drdy_mask = AT91_ADC_DRDY,
@@ -1391,6 +1350,8 @@ static struct at91_adc_caps at91sam9g45_caps = {
.has_ts = true,
.calc_startup_ticks = calc_startup_ticks_9260, /* same as 9260 */
.num_channels = 8,
+ .low_res_bits = 8,
+ .high_res_bits = 10,
.registers = {
.channel_base = AT91_ADC_CHR(0),
.drdy_mask = AT91_ADC_DRDY,
@@ -1408,6 +1369,8 @@ static struct at91_adc_caps at91sam9x5_caps = {
.ts_pen_detect_sensitivity = 2,
.calc_startup_ticks = calc_startup_ticks_9x5,
.num_channels = 12,
+ .low_res_bits = 8,
+ .high_res_bits = 10,
.registers = {
.channel_base = AT91_ADC_CDR0_9X5,
.drdy_mask = AT91_ADC_SR_DRDY_9X5,
@@ -1419,11 +1382,31 @@ static struct at91_adc_caps at91sam9x5_caps = {
},
};
+static struct at91_adc_caps sama5d3_caps = {
+ .has_ts = true,
+ .has_tsmr = true,
+ .ts_filter_average = 3,
+ .ts_pen_detect_sensitivity = 2,
+ .calc_startup_ticks = calc_startup_ticks_9x5,
+ .num_channels = 12,
+ .low_res_bits = 0,
+ .high_res_bits = 12,
+ .registers = {
+ .channel_base = AT91_ADC_CDR0_9X5,
+ .drdy_mask = AT91_ADC_SR_DRDY_9X5,
+ .status_register = AT91_ADC_SR_9X5,
+ .trigger_register = AT91_ADC_TRGR_9X5,
+ .mr_prescal_mask = AT91_ADC_PRESCAL_9G45,
+ .mr_startup_mask = AT91_ADC_STARTUP_9X5,
+ },
+};
+
static const struct of_device_id at91_adc_dt_ids[] = {
{ .compatible = "atmel,at91sam9260-adc", .data = &at91sam9260_caps },
{ .compatible = "atmel,at91sam9rl-adc", .data = &at91sam9rl_caps },
{ .compatible = "atmel,at91sam9g45-adc", .data = &at91sam9g45_caps },
{ .compatible = "atmel,at91sam9x5-adc", .data = &at91sam9x5_caps },
+ { .compatible = "atmel,sama5d3-adc", .data = &sama5d3_caps },
{},
};
MODULE_DEVICE_TABLE(of, at91_adc_dt_ids);
--
2.28.0
Remove the forward declaration of at91_adc_dt_ids by using
of_device_get_match_data. Also add const were possible since it is not
discarded by the cast anymore.
Signed-off-by: Alexandre Belloni <[email protected]>
Reviewed-by: Ludovic Desroches <[email protected]>
---
Changes in v2:
- use of_device_get_match_data instead of device_get_match_data
drivers/iio/adc/at91_adc.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 347464844263..4c1b3b67445d 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -224,7 +224,6 @@ struct at91_adc_state {
struct mutex lock;
u8 num_channels;
void __iomem *reg_base;
- struct at91_adc_reg_desc *registers;
u32 startup_time;
u8 sample_hold_time;
bool sleep_mode;
@@ -233,7 +232,8 @@ struct at91_adc_state {
u32 vref_mv;
u32 res; /* resolution used for convertions */
wait_queue_head_t wq_data_avail;
- struct at91_adc_caps *caps;
+ const struct at91_adc_caps *caps;
+ const struct at91_adc_reg_desc *registers;
/*
* Following ADC channels are shared by touchscreen:
@@ -569,7 +569,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
{
struct iio_dev *idev = iio_trigger_get_drvdata(trig);
struct at91_adc_state *st = iio_priv(idev);
- struct at91_adc_reg_desc *reg = st->registers;
+ const struct at91_adc_reg_desc *reg = st->registers;
u32 status = at91_adc_readl(st, reg->trigger_register);
int value;
u8 bit;
@@ -796,8 +796,6 @@ static u32 calc_startup_ticks_9x5(u32 startup_time, u32 adc_clk_khz)
return ticks;
}
-static const struct of_device_id at91_adc_dt_ids[];
-
static int at91_adc_probe_dt_ts(struct device_node *node,
struct at91_adc_state *st, struct device *dev)
{
@@ -1011,8 +1009,7 @@ static int at91_adc_probe(struct platform_device *pdev)
st = iio_priv(idev);
- st->caps = (struct at91_adc_caps *)
- of_match_device(at91_adc_dt_ids, &pdev->dev)->data;
+ st->caps = of_device_get_match_data(&pdev->dev);
st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
--
2.28.0
The triggers for the ADC were taken from at91sam9260 dtsi but are not
correct.
Fixes: a4c1d6c75822 ("ARM: at91/dt: sam9rl: add lcd, adc, usb gadget and pwm support")
Signed-off-by: Alexandre Belloni <[email protected]>
---
arch/arm/boot/dts/at91sam9rl.dtsi | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/arch/arm/boot/dts/at91sam9rl.dtsi b/arch/arm/boot/dts/at91sam9rl.dtsi
index 5653e70c84b4..36a42a9fe195 100644
--- a/arch/arm/boot/dts/at91sam9rl.dtsi
+++ b/arch/arm/boot/dts/at91sam9rl.dtsi
@@ -282,23 +282,26 @@ adc0: adc@fffd0000 {
atmel,adc-use-res = "highres";
trigger0 {
- trigger-name = "timer-counter-0";
+ trigger-name = "external-rising";
trigger-value = <0x1>;
+ trigger-external;
};
+
trigger1 {
- trigger-name = "timer-counter-1";
- trigger-value = <0x3>;
+ trigger-name = "external-falling";
+ trigger-value = <0x2>;
+ trigger-external;
};
trigger2 {
- trigger-name = "timer-counter-2";
- trigger-value = <0x5>;
+ trigger-name = "external-any";
+ trigger-value = <0x3>;
+ trigger-external;
};
trigger3 {
- trigger-name = "external";
- trigger-value = <0x13>;
- trigger-external;
+ trigger-name = "continuous";
+ trigger-value = <0x6>;
};
};
--
2.28.0
at91_adc_probe_dt is now small enough to be merged back in at91_adc_probe.
Signed-off-by: Alexandre Belloni <[email protected]>
Reviewed-by: Ludovic Desroches <[email protected]>
---
drivers/iio/adc/at91_adc.c | 117 ++++++++++++++++---------------------
1 file changed, 49 insertions(+), 68 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 83539422b704..347464844263 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -833,70 +833,6 @@ static int at91_adc_probe_dt_ts(struct device_node *node,
}
}
-static int at91_adc_probe_dt(struct iio_dev *idev,
- struct platform_device *pdev)
-{
- struct at91_adc_state *st = iio_priv(idev);
- struct device_node *node = pdev->dev.of_node;
- int ret;
- u32 prop;
- char *s;
-
- st->caps = (struct at91_adc_caps *)
- of_match_device(at91_adc_dt_ids, &pdev->dev)->data;
-
- st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
-
- if (of_property_read_u32(node, "atmel,adc-channels-used", &prop)) {
- dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n");
- ret = -EINVAL;
- goto error_ret;
- }
- st->channels_mask = prop;
-
- st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode");
-
- if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) {
- dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n");
- ret = -EINVAL;
- goto error_ret;
- }
- st->startup_time = prop;
-
- prop = 0;
- of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop);
- st->sample_hold_time = prop;
-
- if (of_property_read_u32(node, "atmel,adc-vref", &prop)) {
- dev_err(&idev->dev, "Missing adc-vref property in the DT.\n");
- ret = -EINVAL;
- goto error_ret;
- }
- st->vref_mv = prop;
-
- st->res = st->caps->high_res_bits;
- if (st->caps->low_res_bits &&
- !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
- && !strcmp(s, "lowres"))
- st->res = st->caps->low_res_bits;
-
- dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
-
- st->registers = &st->caps->registers;
- st->num_channels = st->caps->num_channels;
-
- /* Check if touchscreen is supported. */
- if (st->caps->has_ts)
- return at91_adc_probe_dt_ts(node, st, &idev->dev);
- else
- dev_info(&idev->dev, "not support touchscreen in the adc compatible string.\n");
-
- return 0;
-
-error_ret:
- return ret;
-}
-
static const struct iio_info at91_adc_info = {
.read_raw = &at91_adc_read_raw,
};
@@ -1062,10 +998,12 @@ static void at91_ts_unregister(struct at91_adc_state *st)
static int at91_adc_probe(struct platform_device *pdev)
{
unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
+ struct device_node *node = pdev->dev.of_node;
int ret;
struct iio_dev *idev;
struct at91_adc_state *st;
- u32 reg;
+ u32 reg, prop;
+ char *s;
idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
if (!idev)
@@ -1073,9 +1011,52 @@ static int at91_adc_probe(struct platform_device *pdev)
st = iio_priv(idev);
- ret = at91_adc_probe_dt(idev, pdev);
- if (ret)
- return ret;
+ st->caps = (struct at91_adc_caps *)
+ of_match_device(at91_adc_dt_ids, &pdev->dev)->data;
+
+ st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
+
+ if (of_property_read_u32(node, "atmel,adc-channels-used", &prop)) {
+ dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n");
+ return -EINVAL;
+ }
+ st->channels_mask = prop;
+
+ st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode");
+
+ if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) {
+ dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n");
+ return -EINVAL;
+ }
+ st->startup_time = prop;
+
+ prop = 0;
+ of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop);
+ st->sample_hold_time = prop;
+
+ if (of_property_read_u32(node, "atmel,adc-vref", &prop)) {
+ dev_err(&idev->dev, "Missing adc-vref property in the DT.\n");
+ return -EINVAL;
+ }
+ st->vref_mv = prop;
+
+ st->res = st->caps->high_res_bits;
+ if (st->caps->low_res_bits &&
+ !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
+ && !strcmp(s, "lowres"))
+ st->res = st->caps->low_res_bits;
+
+ dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
+
+ st->registers = &st->caps->registers;
+ st->num_channels = st->caps->num_channels;
+
+ /* Check if touchscreen is supported. */
+ if (st->caps->has_ts) {
+ ret = at91_adc_probe_dt_ts(node, st, &idev->dev);
+ if (ret)
+ return ret;
+ }
platform_set_drvdata(pdev, idev);
--
2.28.0
On Tue, 17 Nov 2020 15:06:45 +0100
Alexandre Belloni <[email protected]> wrote:
> Hello,
>
> This series cleans up the at91_adc devicetree bindings. This mainly
> moves back the resolution options and names and the triggers description
> back in the driver.
>
> There are also other cleanups, like removing platform data support, this
> was pending for a while.
LGTM. I'll let it sit for a little while longer to give Rob H (and anyone
else who fancies it) time to take a look.
Give me a poke if I seem to have lost it (happens all too often :(
Thanks,
Jonathan
>
> Changes in v2:
> - separated out the dt-binding change to give a chance to Rob to actually
> review them.
> - Dropped "iio: adc: at91_adc: use devm_input_allocate_device"
> - Collected tags
> - use of_device_get_match_data instead of device_get_match_data
> - include backportable sam9rl trigger fix
>
> Alexandre Belloni (10):
> iio: adc: at91_adc: remove platform data
> iio: adc: at91_adc: rework resolution selection
> dt-bindings:iio:adc:remove atmel,adc-res and atmel,adc-res-names
> iio: adc: at91_adc: rework trigger definition
> dt-bindings:iio:adc:remove triggers
> iio: adc: at91_adc: merge at91_adc_probe_dt back in at91_adc_probe
> iio: adc: at91_adc: remove forward declaration
> ARM: dts: at91: sama5d3: use proper ADC compatible
> ARM: dts: at91: at91sam9rl: fix ADC triggers
> ARM: dts: at91: remove deprecated ADC properties
>
> Jonathan Cameron (1):
> dt-bindings:iio:adc:atmel,sama9260-adc: conversion to yaml from
> at91_adc.txt
>
> .../devicetree/bindings/iio/adc/at91_adc.txt | 83 -----
> .../bindings/iio/adc/atmel,sama9260-adc.yaml | 121 ++++++
> arch/arm/boot/dts/at91sam9260.dtsi | 25 --
> arch/arm/boot/dts/at91sam9g45.dtsi | 27 --
> arch/arm/boot/dts/at91sam9rl.dtsi | 25 --
> arch/arm/boot/dts/at91sam9x5.dtsi | 28 --
> arch/arm/boot/dts/sama5d3.dtsi | 26 +-
> arch/arm/boot/dts/sama5d4.dtsi | 22 --
> drivers/iio/adc/at91_adc.c | 351 +++++++-----------
> include/linux/platform_data/at91_adc.h | 49 ---
> 10 files changed, 256 insertions(+), 501 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/iio/adc/at91_adc.txt
> create mode 100644 Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml
> delete mode 100644 include/linux/platform_data/at91_adc.h
>
On Tue, 17 Nov 2020 15:06:52 +0100
Alexandre Belloni <[email protected]> wrote:
> at91_adc_probe_dt is now small enough to be merged back in at91_adc_probe.
>
> Signed-off-by: Alexandre Belloni <[email protected]>
> Reviewed-by: Ludovic Desroches <[email protected]>
This proved a little more interesting to apply, but I think that is just
down to Alexandru having already made the match_data related change.
Please check I got it right!
Thanks,
Jonathan
> ---
> drivers/iio/adc/at91_adc.c | 117 ++++++++++++++++---------------------
> 1 file changed, 49 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 83539422b704..347464844263 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -833,70 +833,6 @@ static int at91_adc_probe_dt_ts(struct device_node *node,
> }
> }
>
> -static int at91_adc_probe_dt(struct iio_dev *idev,
> - struct platform_device *pdev)
> -{
> - struct at91_adc_state *st = iio_priv(idev);
> - struct device_node *node = pdev->dev.of_node;
> - int ret;
> - u32 prop;
> - char *s;
> -
> - st->caps = (struct at91_adc_caps *)
> - of_match_device(at91_adc_dt_ids, &pdev->dev)->data;
> -
> - st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
> -
> - if (of_property_read_u32(node, "atmel,adc-channels-used", &prop)) {
> - dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n");
> - ret = -EINVAL;
> - goto error_ret;
> - }
> - st->channels_mask = prop;
> -
> - st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode");
> -
> - if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) {
> - dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n");
> - ret = -EINVAL;
> - goto error_ret;
> - }
> - st->startup_time = prop;
> -
> - prop = 0;
> - of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop);
> - st->sample_hold_time = prop;
> -
> - if (of_property_read_u32(node, "atmel,adc-vref", &prop)) {
> - dev_err(&idev->dev, "Missing adc-vref property in the DT.\n");
> - ret = -EINVAL;
> - goto error_ret;
> - }
> - st->vref_mv = prop;
> -
> - st->res = st->caps->high_res_bits;
> - if (st->caps->low_res_bits &&
> - !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
> - && !strcmp(s, "lowres"))
> - st->res = st->caps->low_res_bits;
> -
> - dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
> -
> - st->registers = &st->caps->registers;
> - st->num_channels = st->caps->num_channels;
> -
> - /* Check if touchscreen is supported. */
> - if (st->caps->has_ts)
> - return at91_adc_probe_dt_ts(node, st, &idev->dev);
> - else
> - dev_info(&idev->dev, "not support touchscreen in the adc compatible string.\n");
> -
> - return 0;
> -
> -error_ret:
> - return ret;
> -}
> -
> static const struct iio_info at91_adc_info = {
> .read_raw = &at91_adc_read_raw,
> };
> @@ -1062,10 +998,12 @@ static void at91_ts_unregister(struct at91_adc_state *st)
> static int at91_adc_probe(struct platform_device *pdev)
> {
> unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
> + struct device_node *node = pdev->dev.of_node;
> int ret;
> struct iio_dev *idev;
> struct at91_adc_state *st;
> - u32 reg;
> + u32 reg, prop;
> + char *s;
>
> idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
> if (!idev)
> @@ -1073,9 +1011,52 @@ static int at91_adc_probe(struct platform_device *pdev)
>
> st = iio_priv(idev);
>
> - ret = at91_adc_probe_dt(idev, pdev);
> - if (ret)
> - return ret;
> + st->caps = (struct at91_adc_caps *)
> + of_match_device(at91_adc_dt_ids, &pdev->dev)->data;
> +
> + st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers");
> +
> + if (of_property_read_u32(node, "atmel,adc-channels-used", &prop)) {
> + dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n");
> + return -EINVAL;
> + }
> + st->channels_mask = prop;
> +
> + st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode");
> +
> + if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) {
> + dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n");
> + return -EINVAL;
> + }
> + st->startup_time = prop;
> +
> + prop = 0;
> + of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop);
> + st->sample_hold_time = prop;
> +
> + if (of_property_read_u32(node, "atmel,adc-vref", &prop)) {
> + dev_err(&idev->dev, "Missing adc-vref property in the DT.\n");
> + return -EINVAL;
> + }
> + st->vref_mv = prop;
> +
> + st->res = st->caps->high_res_bits;
> + if (st->caps->low_res_bits &&
> + !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s)
> + && !strcmp(s, "lowres"))
> + st->res = st->caps->low_res_bits;
> +
> + dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
> +
> + st->registers = &st->caps->registers;
> + st->num_channels = st->caps->num_channels;
> +
> + /* Check if touchscreen is supported. */
> + if (st->caps->has_ts) {
> + ret = at91_adc_probe_dt_ts(node, st, &idev->dev);
> + if (ret)
> + return ret;
> + }
>
> platform_set_drvdata(pdev, idev);
>