From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Thu, 25 Apr 2019 15:22:47 +0200 Subject: [U-Boot] [PATCH] i2c: mvtwsi: Fix delay time for Turris Omnia Message-ID: <20190425132247.18483-1-marek.behun@nic.cz> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Commit c68c6243 ("i2c: mvtwsi: Make delay times frequency-dependent") broke the default configuration of the Turris Omnia target. With i2c frequency at 100kHz the twsi_wait function call to ndelay(tick) the tick variable is computed to 10340 (nanoseconds). Since ndelay calls udelay(DIV_ROUND_UP(10340, 1000), the result is udelay(11). For some reason this sometimes (cca every third boot) breaks the i2c controller on Turris Omnia completely (even kernel cannot use it, and soft reset does not help, only complete power off). Microcontroller watchdog cannot be disabled without i2c and the device is unusable. The original commit message mentions erratum FE-8471889. This is weird since Linux does not enable this erratum workaround for armada-38x. But the commit message says that it was tested on Armada MV88F6820. I therefore fix this in this unclean way only for Turris Omnia, because I do not know if it would not break other devices. Signed-off-by: Marek Beh=C3=BAn Cc: Mario Six Cc: Stefan Roese --- drivers/i2c/mvtwsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index b0f7c3e057..ef269f3b0c 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -176,9 +176,13 @@ enum mvtwsi_ack_flags { */ inline uint calc_tick(uint speed) { +#ifdef CONFIG_TARGET_TURRIS_OMNIA + return 10000; +#else /* One tick =3D the duration of a period at the specified speed in ns (we * add 100 ns to be on the safe side) */ return (1000000000u / speed) + 100; +#endif } =20 #ifndef CONFIG_DM_I2C --=20 2.21.0