2019-11-13 02:27:38

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.19 087/209] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible

From: David Lechner <[email protected]>

[ Upstream commit aea4762fb46e048c059ff49565ee33da07c8aeb3 ]

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 <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
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 c4729d0e6c196..66fcadf0ba910 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.20.1


2019-11-13 19:07:04

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.19 087/209] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible

On 11/12/19 7:48 PM, Sasha Levin wrote:
> From: David Lechner <[email protected]>
>
> [ Upstream commit aea4762fb46e048c059ff49565ee33da07c8aeb3 ]
>
> 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.
>

I doubt that the commits above would be backported, so it does not
make sense to backport this patch.


2019-11-22 03:26:12

by Sasha Levin

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.19 087/209] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible

On Wed, Nov 13, 2019 at 10:10:30AM -0600, David Lechner wrote:
>On 11/12/19 7:48 PM, Sasha Levin wrote:
>>From: David Lechner <[email protected]>
>>
>>[ Upstream commit aea4762fb46e048c059ff49565ee33da07c8aeb3 ]
>>
>>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.
>>
>
>I doubt that the commits above would be backported, so it does not
>make sense to backport this patch.

I've dropped it, thanks!

--
Thanks,
Sasha