[U-Boot] [PATCH u-boot-marvell v2.1 15/15] i2c: mvtwsi: fix reading status register after interrupt
Heiko Schocher
hs at denx.de
Thu May 2 05:24:37 UTC 2019
Hello Marek,
Am 01.05.2019 um 23:09 schrieb Marek BehĂșn:
> The twsi_wait function reads the control register for interrupt flag,
> and if interrupt flag is present, it immediately reads status register.
>
> On our device this sometimes causes bad value being read from status
> register, as if the value was not yet updated.
>
> My theory is that the controller does approximately this:
> 1. sets interrupt flag in control register,
> 2. sets the value of status register,
> 3. causes an interrupt
>
> In U-Boot we do not use interrupts, so I think that it is possible that
> sometimes the status register in the twsi_wait function is read between
> points 1 and 2.
>
> The bug does not appear if I add a small delay before reading status
> register.
>
> Wait 100ns (which in U-Boot currently means 1 us, because ndelay(i)
> function calls udelay(DIV_ROUND_UP(i, 1000))) before reading the status
> register.
>
> Signed-off-by: Marek BehĂșn <marek.behun at nic.cz>
> Acked-by: Heiko Schocher <hs at denx.de>
> Cc: Mario Six <mario.six at gdsys.cc>
> Cc: Stefan Roese <sr at denx.de>
> Cc: Baruch Siach <baruch at tkos.co.il>
> ---
> drivers/i2c/mvtwsi.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
Thanks for adding the comment
Reviewed-by: Heiko Schocher <hs at denx.de>
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
More information about the U-Boot
mailing list