linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible
@ 2018-09-24  1:31 David Lechner
  2018-09-25  6:04 ` Sekhar Nori
  0 siblings, 1 reply; 3+ messages in thread
From: David Lechner @ 2018-09-24  1:31 UTC (permalink / raw)
  To: Sekhar Nori
  Cc: David Lechner, Kevin Hilman, linux-arm-kernel, devicetree, linux-kernel

Due to the electrical design of the A/DC circuits on LEGO MINDSTORMS EV3,
if we are reading analog values as fast as possible (i.e. using DMA to
service the SPI) the A/DC chip will read incorrect values - as much as
0.1V off when the SPI is running at 10MHz. (This has to do with the
capacitor charge time when channels are muxed in the A/DC.)

This patch slows down the SPI as much as possible (if CPU is at 456MHz,
SPI runs at 1/2 of that, so 228MHz and has a max prescalar of 256, so
we could get ~891kHz, but we're just rounding it to 1MHz). We also use
the max allowable value for WDELAY to slow things down even more.

These changes reduce the error of the analog values to about 5mV, which
is tolerable.

Commits a3762b13a596 ("spi: spi-davinci: Add support for SPI_CS_WORD")
and e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce
CPU usage") introduce changes that allow DMA transfers to be used, so
this slow down is needed now.

Signed-off-by: David Lechner <david@lechnology.com>
---

FYI, this patch doesn't strictly depend on the other two mentioned. In fact, it
would better if it got merged before them, but the consequences are minimal, so
it doesn't seem worth it to me to try coordinating merges here.

Both of these patches mentioned have been picked up in the respective
subsystems.

 arch/arm/boot/dts/da850-lego-ev3.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/da850-lego-ev3.dts b/arch/arm/boot/dts/da850-lego-ev3.dts
index c4729d0e6c19..66fcadf0ba91 100644
--- a/arch/arm/boot/dts/da850-lego-ev3.dts
+++ b/arch/arm/boot/dts/da850-lego-ev3.dts
@@ -352,7 +352,8 @@
 		compatible = "ti,ads7957";
 		reg = <3>;
 		#io-channel-cells = <1>;
-		spi-max-frequency = <10000000>;
+		spi-max-frequency = <1000000>;
+		ti,spi-wdelay = <63>;
 		vref-supply = <&adc_ref>;
 	};
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible
  2018-09-24  1:31 [PATCH] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible David Lechner
@ 2018-09-25  6:04 ` Sekhar Nori
  2018-09-25 15:23   ` David Lechner
  0 siblings, 1 reply; 3+ messages in thread
From: Sekhar Nori @ 2018-09-25  6:04 UTC (permalink / raw)
  To: David Lechner; +Cc: Kevin Hilman, linux-arm-kernel, devicetree, linux-kernel

Hi David,

On Monday 24 September 2018 07:01 AM, David Lechner wrote:
> Due to the electrical design of the A/DC circuits on LEGO MINDSTORMS EV3,
> if we are reading analog values as fast as possible (i.e. using DMA to
> service the SPI) the A/DC chip will read incorrect values - as much as
> 0.1V off when the SPI is running at 10MHz. (This has to do with the
> capacitor charge time when channels are muxed in the A/DC.)

So you believe this is an issue with the board design rather than the
limitation of the ADC chip itself? Because if its the later, the fix
should be in the driver instead.

> 
> This patch slows down the SPI as much as possible (if CPU is at 456MHz,
> SPI runs at 1/2 of that, so 228MHz and has a max prescalar of 256, so
> we could get ~891kHz, but we're just rounding it to 1MHz). We also use
> the max allowable value for WDELAY to slow things down even more.
> 
> These changes reduce the error of the analog values to about 5mV, which
> is tolerable.
> 
> Commits a3762b13a596 ("spi: spi-davinci: Add support for SPI_CS_WORD")
> and e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce
> CPU usage") introduce changes that allow DMA transfers to be used, so
> this slow down is needed now.
> 
> Signed-off-by: David Lechner <david@lechnology.com>
> ---
> 
> FYI, this patch doesn't strictly depend on the other two mentioned. In fact, it
> would better if it got merged before them, but the consequences are minimal, so
> it doesn't seem worth it to me to try coordinating merges here.
> 
> Both of these patches mentioned have been picked up in the respective
> subsystems.

Is this needed for the -rc cycle or can wait for v4.20?

Thanks,
Sekhar

> 
>  arch/arm/boot/dts/da850-lego-ev3.dts | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/da850-lego-ev3.dts b/arch/arm/boot/dts/da850-lego-ev3.dts
> index c4729d0e6c19..66fcadf0ba91 100644
> --- a/arch/arm/boot/dts/da850-lego-ev3.dts
> +++ b/arch/arm/boot/dts/da850-lego-ev3.dts
> @@ -352,7 +352,8 @@
>  		compatible = "ti,ads7957";
>  		reg = <3>;
>  		#io-channel-cells = <1>;
> -		spi-max-frequency = <10000000>;
> +		spi-max-frequency = <1000000>;
> +		ti,spi-wdelay = <63>;
>  		vref-supply = <&adc_ref>;
>  	};
>  };
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible
  2018-09-25  6:04 ` Sekhar Nori
@ 2018-09-25 15:23   ` David Lechner
  0 siblings, 0 replies; 3+ messages in thread
From: David Lechner @ 2018-09-25 15:23 UTC (permalink / raw)
  To: Sekhar Nori; +Cc: Kevin Hilman, linux-arm-kernel, devicetree, linux-kernel



On 9/25/18 1:04 AM, Sekhar Nori wrote:
> Hi David,
> 
> On Monday 24 September 2018 07:01 AM, David Lechner wrote:
>> Due to the electrical design of the A/DC circuits on LEGO MINDSTORMS EV3,
>> if we are reading analog values as fast as possible (i.e. using DMA to
>> service the SPI) the A/DC chip will read incorrect values - as much as
>> 0.1V off when the SPI is running at 10MHz. (This has to do with the
>> capacitor charge time when channels are muxed in the A/DC.)
> 
> So you believe this is an issue with the board design rather than the
> limitation of the ADC chip itself? Because if its the later, the fix
> should be in the driver instead.

It is the board design. There are external 4.7k series resistors that 
make the RC charge time so long.

> 
>>
>> Both of these patches mentioned have been picked up in the respective
>> subsystems.
> 
> Is this needed for the -rc cycle or can wait for v4.20?

v4.20

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-25 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-24  1:31 [PATCH] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible David Lechner
2018-09-25  6:04 ` Sekhar Nori
2018-09-25 15:23   ` David Lechner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).