iio: ti_am335x_adc: Add optional DT properties for tscadc
Subsystems (3)
cover iio: ti_am335x_adc: Add optional DT properties for tscadc
Hi,
This patch adds optional DT properties for tscadc to set open delay, sample delay and number of averages per sample for each adc channel. Open delay, sample delay and averaging are some of the parameters that affect the sampling rate and accuracy of the tscadc. Decreasing delays and averaging helps to achieve higher sampling rates, while increasing this parameters provides greater accuracy. Hence, this patch provides DT properties to set the initial values for delays and number of averages per sample. User space control via sysfs can be added later.
Vignesh R (2):
iio: adc: ti_am335x_adc: refactor DT parsing into a function
iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT
parameters
.../bindings/input/touchscreen/ti-tsc-adc.txt | 24 +++++++ drivers/iio/adc/ti_am335x_adc.c | 83 +++++++++++++++++----- 2 files changed, 91 insertions(+), 16 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 iio: adc: ti_am335x_adc: refactor DT parsing into a function
Refactor DT parsing into a separate function from probe() to help addition of more DT parameters later.
No functional changes.
--- drivers/iio/adc/ti_am335x_adc.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/iio/adc/ti_am335x_adc.c +19 -10
@@ -396,16 +396,30 @@ static const struct iio_info tiadc_info = { .driver_module = THIS_MODULE, }; +static int tiadc_parse_dt (struct platform_device *pdev, +struct tiadc_device *adc_dev) +{ +struct device_node *node = pdev->dev.of_node; +struct property *prop; +const __be32 *cur; +int channels =0 ; +u32 val; + +of_property_for_each_u32 (node,"ti,adc-channels" , prop, cur, val) { + adc_dev->channel_line[channels] = val; + channels++; + } + + adc_dev->channels = channels; +return 0 ; +} +static int tiadc_probe (struct platform_device *pdev) {struct iio_dev *indio_dev;struct tiadc_device *adc_dev;struct device_node *node = pdev->dev.of_node; -struct property *prop; -const __be32 *cur;int err; -u32 val; -int channels =0 ;if (!node) {dev_err (&pdev->dev,"Could not find valid DT data.\n" );
@@ -421,12 +435,7 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev =iio_priv (indio_dev); adc_dev->mfd_tscadc =ti_tscadc_dev_get (pdev); - -of_property_for_each_u32 (node,"ti,adc-channels" , prop, cur, val) { - adc_dev->channel_line[channels] = val; - channels++; - } - adc_dev->channels = channels; +tiadc_parse_dt (pdev, adc_dev); indio_dev->dev.parent = &pdev->dev; indio_dev->name =dev_name (&pdev->dev);
Signature · 1 line
1.9.1
Jonathan Cameron
maintainerRe: [PATCH 1/2] iio: adc: ti_am335x_adc: refactor DT parsing into a function
Quoted 6 lines · Vignesh R
Refactor DT parsing into a separate function from
probe()to help addition of more DT parameters later.No functional changes.
Signed-off-by Vignesh R <[email protected]>
Clearly going to need this whatever the outcome of the second patch being reviewed.
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 58 lines
--- drivers/iio/adc/ti_am335x_adc.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)drivers/iio/adc/ti_am335x_adc.c +19
-10@@ -396,16 +396,30 @@ static const struct iio_info tiadc_info = { .driver_module = THIS_MODULE, }; +static int tiadc_parse_dt (struct platform_device *pdev, +struct tiadc_device *adc_dev) +{ +struct device_node *node = pdev->dev.of_node; +struct property *prop; +const __be32 *cur; +int channels =0 ; +u32 val; + +of_property_for_each_u32 (node,"ti,adc-channels" , prop, cur, val) { + adc_dev->channel_line[channels] = val; + channels++; + } + + adc_dev->channels = channels; +return 0 ; +} +static int tiadc_probe (struct platform_device *pdev) {struct iio_dev *indio_dev;struct tiadc_device *adc_dev;struct device_node *node = pdev->dev.of_node; -struct property *prop; -const __be32 *cur;int err; -u32 val; -int channels =0 ;if (!node) {dev_err (&pdev->dev,"Could not find valid DT data.\n" );@@ -421,12 +435,7 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev =iio_priv (indio_dev); adc_dev->mfd_tscadc =ti_tscadc_dev_get (pdev); - -of_property_for_each_u32 (node,"ti,adc-channels" , prop, cur, val) { - adc_dev->channel_line[channels] = val; - channels++; - } - adc_dev->channels = channels; +tiadc_parse_dt (pdev, adc_dev); indio_dev->dev.parent = &pdev->dev; indio_dev->name =dev_name (&pdev->dev);
PATCH 2/2 iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT parameters
In reply to Vignesh RAdd optional DT properties to set open delay, sample delay and number of averages per sample for each adc step. Open delay, sample delay and averaging are some of the parameters that affect the sampling rate and accuracy of the sample. Making these parameters configurable via DT will help in balancing speed vs accuracy.
--- .../bindings/input/touchscreen/ti-tsc-adc.txt | 24 ++++++++++ drivers/iio/adc/ti_am335x_adc.c | 54 +++++++++++++++++++--- 2 files changed, 72 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt +24 -0
@@ -42,6 +42,27 @@ Optional properties: hardware knob for adjusting the amount of "settling time". +- child "adc" + ti,chan-step-opendelay: List of open delays for each channel of + ADC in the order of ti,adc-channels. The + value corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. + Example: tscadc: tscadc@44e0d000 { compatible = "ti,am3359-tscadc";
@@ -55,5 +76,8 @@ Example: adc { ti,adc-channels = <4 5 6 7>; + ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>; + ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>; + ti,chan-step-avg = <16 2 4 8>; }; }
drivers/iio/adc/ti_am335x_adc.c +48 -6
89 lines not on this page · raw message
Signature · 1 line
1.9.1
Jonathan Cameron
maintainerRe: [PATCH 2/2] iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT parameters
Quoted 7 lines · Vignesh R
Add optional DT properties to set open delay, sample delay and number of averages per sample for each adc step. Open delay, sample delay and averaging are some of the parameters that affect the sampling rate and accuracy of the sample. Making these parameters configurable via DT will help in balancing speed vs accuracy.
Signed-off-by Vignesh R <[email protected]>
All looks fine to me, but I would ideally like a devicetree ack on this one.
Jonathan
Quoted 160 lines
--- .../bindings/input/touchscreen/ti-tsc-adc.txt | 24 ++++++++++ drivers/iio/adc/ti_am335x_adc.c | 54 +++++++++++++++++++--- 2 files changed, 72 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt +24
-0@@ -42,6 +42,27 @@ Optional properties: hardware knob for adjusting the amount of "settling time". +- child "adc" + ti,chan-step-opendelay: List of open delays for each channel of + ADC in the order of ti,adc-channels. The + value corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. + Example: tscadc: tscadc@44e0d000 { compatible = "ti,am3359-tscadc";@@ -55,5 +76,8 @@ Example: adc { ti,adc-channels = <4 5 6 7>; + ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>; + ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>; + ti,chan-step-avg = <16 2 4 8>; }; }drivers/iio/adc/ti_am335x_adc.c +64
-6@@ -37,6 +37,7 @@ struct tiadc_device {u8 channel_step[8 ];int buffer_en_ch_steps;u16 data[8 ]; +u32 open_delay[8 ], sample_delay[8 ], step_avg[8 ]; };static unsigned int tiadc_readl (struct tiadc_device *adc,unsigned int reg)@@ -85,6 +86,7 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)static void tiadc_step_config (struct iio_dev *indio_dev) {struct tiadc_device *adc_dev =iio_priv (indio_dev); +struct device *dev = adc_dev->mfd_tscadc->dev;unsigned int stepconfig;int i, steps =0 ;@@ -98,20 +100,47 @@ static void tiadc_step_config(struct iio_dev *indio_dev)* needs to be given to ADC to digitalize data. */ -if (iio_buffer_enabled (indio_dev)) - stepconfig =STEPCONFIG_AVG_16 |STEPCONFIG_FIFO1 - |STEPCONFIG_MODE_SWCNT ; -else - stepconfig =STEPCONFIG_AVG_16 |STEPCONFIG_FIFO1 ;for (i =0 ; i < adc_dev->channels; i++) {int chan; chan = adc_dev->channel_line[i]; + +if (adc_dev->step_avg[i] >STEPCONFIG_AVG_16 ) { +dev_warn (dev,"chan %d step_avg truncating to %d\n" , + chan,STEPCONFIG_AVG_16 ); + adc_dev->step_avg[i] =STEPCONFIG_AVG_16 ; + } + +if (adc_dev->step_avg[i]) + stepconfig = +STEPCONFIG_AVG (ffs (adc_dev->step_avg[i]) -1 ) | +STEPCONFIG_FIFO1 ; +else + stepconfig =STEPCONFIG_FIFO1 ; + +if (iio_buffer_enabled (indio_dev)) + stepconfig |=STEPCONFIG_MODE_SWCNT ; +tiadc_writel (adc_dev,REG_STEPCONFIG (steps), stepconfig |STEPCONFIG_INP (chan)); + + if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK)alue corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. { + dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n", + chan); + adc_dev->open_delay[i] =STEPDELAY_OPEN_MASK ; + } + +if (adc_dev->sample_delay[i] >0xFF ) { +dev_warn (dev,"chan %d sample delay truncating to 0xFF\n" , + chan); + adc_dev->sample_delay[i] =0xFF ; + } +tiadc_writel (adc_dev,REG_STEPDELAY (steps), -STEPCONFIG_OPENDLY ); +STEPDELAY_OPEN (adc_dev->open_delay[i]) | +STEPDELAY_SAMPLE (adc_dev->sample_delay[i])); + adc_dev->channel_step[i] = steps; steps++; }@@ -407,9 +436,22 @@ static int tiadc_parse_dt(struct platform_device *pdev,of_property_for_each_u32 (node,"ti,adc-channels" , prop, cur, val) { adc_dev->channel_line[channels] = val; + +/* Set Default values for optional DT parameters */ + adc_dev->open_delay[channels] =STEPCONFIG_OPENDLY ; + adc_dev->sample_delay[channels] =STEPCONFIG_SAMPLEDLY ; + adc_dev->step_avg[channels] =16 ; + channels++; } +of_property_read_u32_array (node,"ti,chan-step-avg" , + adc_dev->step_avg, channels); +of_property_read_u32_array (node,"ti,chan-step-opendelay" , + adc_dev->open_delay, channels); +of_property_read_u32_array (node,"ti,chan-step-sampledelay" , + adc_dev->sample_delay, channels); + adc_dev->channels = channels;return 0 ; }
Re: [PATCH 2/2] iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT parameters
Quoted 7 lines · Jonathan Cameron
Quoted 6 lines · Vignesh R
Add optional DT properties to set open delay, sample delay and number of averages per sample for each adc step. Open delay, sample delay and averaging are some of the parameters that affect the sampling rate and accuracy of the sample. Making these parameters configurable via DT will help in balancing speed vs accuracy.
Quoted 5 lines
Quoted 1 line
Signed-off-by Vignesh R <[email protected]>All looks fine to me, but I would ideally like a devicetree ack on this one.
Jonathan
Gentle ping...
Regards
Vignesh
Quoted 161 lines
Quoted 160 lines
--- .../bindings/input/touchscreen/ti-tsc-adc.txt | 24 ++++++++++ drivers/iio/adc/ti_am335x_adc.c | 54 +++++++++++++++++++--- 2 files changed, 72 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt +24
-0@@ -42,6 +42,27 @@ Optional properties: hardware knob for adjusting the amount of "settling time". +- child "adc" + ti,chan-step-opendelay: List of open delays for each channel of + ADC in the order of ti,adc-channels. The + value corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. + Example: tscadc: tscadc@44e0d000 { compatible = "ti,am3359-tscadc";@@ -55,5 +76,8 @@ Example: adc { ti,adc-channels = <4 5 6 7>; + ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>; + ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>; + ti,chan-step-avg = <16 2 4 8>; }; }drivers/iio/adc/ti_am335x_adc.c +64
-6@@ -37,6 +37,7 @@ struct tiadc_device {u8 channel_step[8 ];int buffer_en_ch_steps;u16 data[8 ]; +u32 open_delay[8 ], sample_delay[8 ], step_avg[8 ]; };static unsigned int tiadc_readl (struct tiadc_device *adc,unsigned int reg)@@ -85,6 +86,7 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)static void tiadc_step_config (struct iio_dev *indio_dev) {struct tiadc_device *adc_dev =iio_priv (indio_dev); +struct device *dev = adc_dev->mfd_tscadc->dev;unsigned int stepconfig;int i, steps =0 ;@@ -98,20 +100,47 @@ static void tiadc_step_config(struct iio_dev *indio_dev)* needs to be given to ADC to digitalize data. */ -if (iio_buffer_enabled (indio_dev)) - stepconfig =STEPCONFIG_AVG_16 |STEPCONFIG_FIFO1 - |STEPCONFIG_MODE_SWCNT ; -else - stepconfig =STEPCONFIG_AVG_16 |STEPCONFIG_FIFO1 ;for (i =0 ; i < adc_dev->channels; i++) {int chan; chan = adc_dev->channel_line[i]; + +if (adc_dev->step_avg[i] >STEPCONFIG_AVG_16 ) { +dev_warn (dev,"chan %d step_avg truncating to %d\n" , + chan,STEPCONFIG_AVG_16 ); + adc_dev->step_avg[i] =STEPCONFIG_AVG_16 ; + } + +if (adc_dev->step_avg[i]) + stepconfig = +STEPCONFIG_AVG (ffs (adc_dev->step_avg[i]) -1 ) | +STEPCONFIG_FIFO1 ; +else + stepconfig =STEPCONFIG_FIFO1 ; + +if (iio_buffer_enabled (indio_dev)) + stepconfig |=STEPCONFIG_MODE_SWCNT ; +tiadc_writel (adc_dev,REG_STEPCONFIG (steps), stepconfig |STEPCONFIG_INP (chan)); + + if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK)alue corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. { + dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n", + chan); + adc_dev->open_delay[i] =STEPDELAY_OPEN_MASK ; + } + +if (adc_dev->sample_delay[i] >0xFF ) { +dev_warn (dev,"chan %d sample delay truncating to 0xFF\n" , + chan); + adc_dev->sample_delay[i] =0xFF ; + } +tiadc_writel (adc_dev,REG_STEPDELAY (steps), -STEPCONFIG_OPENDLY ); +STEPDELAY_OPEN (adc_dev->open_delay[i]) | +STEPDELAY_SAMPLE (adc_dev->sample_delay[i])); + adc_dev->channel_step[i] = steps; steps++; }@@ -407,9 +436,22 @@ static int tiadc_parse_dt(struct platform_device *pdev,of_property_for_each_u32 (node,"ti,adc-channels" , prop, cur, val) { adc_dev->channel_line[channels] = val; + +/* Set Default values for optional DT parameters */ + adc_dev->open_delay[channels] =STEPCONFIG_OPENDLY ; + adc_dev->sample_delay[channels] =STEPCONFIG_SAMPLEDLY ; + adc_dev->step_avg[channels] =16 ; + channels++; } +of_property_read_u32_array (node,"ti,chan-step-avg" , + adc_dev->step_avg, channels); +of_property_read_u32_array (node,"ti,chan-step-opendelay" , + adc_dev->open_delay, channels); +of_property_read_u32_array (node,"ti,chan-step-sampledelay" , + adc_dev->sample_delay, channels); + adc_dev->channels = channels;return 0 ; }
Jonathan Cameron
maintainerRe: [PATCH 2/2] iio: adc: ti_am335x_adc: make sample delay, open delay, averaging DT parameters
Quoted 10 lines · Vignesh R
Quoted 7 lines · Jonathan Cameron
Quoted 6 lines · Vignesh R
Add optional DT properties to set open delay, sample delay and number of averages per sample for each adc step. Open delay, sample delay and averaging are some of the parameters that affect the sampling rate and accuracy of the sample. Making these parameters configurable via DT will help in balancing speed vs accuracy.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Vignesh R <[email protected]>All looks fine to me, but I would ideally like a devicetree ack on this one.
Jonathan
Gentle ping...
Thanks. Had forgotten about this one. Ah well, no device tree response...
Applied to the togreg branch of iio.git, initially pushed out as testing.
Thanks,
Jonathan
Quoted 169 lines
Regards
VigneshQuoted 149 lines
Quoted 149 lines
--- .../bindings/input/touchscreen/ti-tsc-adc.txt | 24 ++++++++++ drivers/iio/adc/ti_am335x_adc.c | 54 +++++++++++++++++++--- 2 files changed, 72 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt +24
-0@@ -42,6 +42,27 @@ Optional properties: hardware knob for adjusting the amount of "settling time". +- child "adc" + ti,chan-step-opendelay: List of open delays for each channel of + ADC in the order of ti,adc-channels. The + value corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. + Example: tscadc: tscadc@44e0d000 { compatible = "ti,am3359-tscadc";@@ -55,5 +76,8 @@ Example: adc { ti,adc-channels = <4 5 6 7>; + ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>; + ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>; + ti,chan-step-avg = <16 2 4 8>; }; }drivers/iio/adc/ti_am335x_adc.c +57
-6@@ -37,6 +37,7 @@ struct tiadc_device {u8 channel_step[8 ];int buffer_en_ch_steps;u16 data[8 ]; +u32 open_delay[8 ], sample_delay[8 ], step_avg[8 ]; };static unsigned int tiadc_readl (struct tiadc_device *adc,unsigned int reg)@@ -85,6 +86,7 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)static void tiadc_step_config (struct iio_dev *indio_dev) {struct tiadc_device *adc_dev =iio_priv (indio_dev); +struct device *dev = adc_dev->mfd_tscadc->dev;unsigned int stepconfig;int i, steps =0 ;@@ -98,20 +100,47 @@ static void tiadc_step_config(struct iio_dev *indio_dev)* needs to be given to ADC to digitalize data. */ -if (iio_buffer_enabled (indio_dev)) - stepconfig =STEPCONFIG_AVG_16 |STEPCONFIG_FIFO1 - |STEPCONFIG_MODE_SWCNT ; -else - stepconfig =STEPCONFIG_AVG_16 |STEPCONFIG_FIFO1 ;for (i =0 ; i < adc_dev->channels; i++) {int chan; chan = adc_dev->channel_line[i]; + +if (adc_dev->step_avg[i] >STEPCONFIG_AVG_16 ) { +dev_warn (dev,"chan %d step_avg truncating to %d\n" , + chan,STEPCONFIG_AVG_16 ); + adc_dev->step_avg[i] =STEPCONFIG_AVG_16 ; + } + +if (adc_dev->step_avg[i]) + stepconfig = +STEPCONFIG_AVG (ffs (adc_dev->step_avg[i]) -1 ) | +STEPCONFIG_FIFO1 ; +else + stepconfig =STEPCONFIG_FIFO1 ; + +if (iio_buffer_enabled (indio_dev)) + stepconfig |=STEPCONFIG_MODE_SWCNT ; +tiadc_writel (adc_dev,REG_STEPCONFIG (steps), stepconfig |STEPCONFIG_INP (chan)); + + if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK)alue corresponds to the number of ADC + clock cycles to wait after applying the + step configuration registers and before + sending the start of ADC conversion. + Maximum value is 0x3FFFF. + ti,chan-step-sampledelay: List of sample delays for each channel + of ADC in the order of ti,adc-channels. + The value corresponds to the number of + ADC clock cycles to sample (to hold + start of conversion high). + Maximum value is 0xFF. + ti,chan-step-avg: Number of averages to be performed for each + channel of ADC. If average is 16 then input + is sampled 16 times and averaged to get more + accurate value. This increases the time taken + by ADC to generate a sample. Valid range is 0 + average to 16 averages. Maximum value is 16. { + dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n", + chan); + adc_dev->open_delay[i] =STEPDELAY_OPEN_MASK ; + } + +if (adc_dev->sample_delay[i] >0xFF ) { +dev_warn (dev,"chan %d sample delay truncating to 0xFF\n" , + chan); + adc_dev->sample_delay[i] =0xFF ; + } +tiadc_writel (adc_dev,REG_STEPDELAY (steps), -STEPCONFIG_OPENDLY ); +STEPDELAY_OPEN (adc_dev->open_delay[i]) | +STEPDELAY_SAMPLE (adc_dev->sample_delay[i])); + adc_dev->channel_step[i] = steps; steps++; }@@ -407,9 +436,22 @@ static int tiadc_parse_dt(struct platform_device *pdev,of_property_for_each_u32 (node,"ti,adc-channels" , prop, cur, val) { adc_dev->channel_line[channels] = val; + +/* Set Default values for optional DT parameters */ + adc_dev->open_delay[channels] =STEPCONFIG_OPENDLY ; + adc_dev->sample_delay[channels] =STEPCONFIG_SAMPLEDLY ; + adc_dev->step_avg[channels] =16 ; + channels++; }Quoted 12 lines
drivers/iio/adc/ti_am335x_adc.c static int tiadc_parse_dt(struct platform_device *pdev, · line 457
Quoted 11 lines
drivers/iio/adc/ti_am335x_adc.c +7
-0+of_property_read_u32_array (node,"ti,chan-step-avg" , + adc_dev->step_avg, channels); +of_property_read_u32_array (node,"ti,chan-step-opendelay" , + adc_dev->open_delay, channels); +of_property_read_u32_array (node,"ti,chan-step-sampledelay" , + adc_dev->sample_delay, channels); + adc_dev->channels = channels;return 0 ; }--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html