From patchwork Thu Apr 25 13:22:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1090791 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="KnW6+CdF"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44qdD84l3kz9sBr for ; Thu, 25 Apr 2019 23:23:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 19932C21DD7; Thu, 25 Apr 2019 13:23:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8619AC21E34; Thu, 25 Apr 2019 13:23:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6CCCAC21DA2; Thu, 25 Apr 2019 13:22:52 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 93DD1C21D4A for ; Thu, 25 Apr 2019 13:22:48 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [172.20.6.125]) by mail.nic.cz (Postfix) with ESMTP id 282C4633CE; Thu, 25 Apr 2019 15:22:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1556198568; bh=j2H38SOHLGS0l54De4YdRW6W4HvCRoStuEfh9esVJF4=; h=From:To:Date; b=KnW6+CdFeDtGWh0dbWN+0zsO/uTgpTkJe+SfZOLVn2KieW/B11DOPrmF1Dc+X8ssS hN6fLnVS4JLN+Y8nbQkvCaJV1yoV4utTctbODvhd+lsgJB3tctisbar9wwEM24d9Ld jPhZ83ZIoXgQ1xfGeaHjCHx4M8fnt31v9QhV+nc4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Thu, 25 Apr 2019 15:22:47 +0200 Message-Id: <20190425132247.18483-1-marek.behun@nic.cz> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH] i2c: mvtwsi: Fix delay time for Turris Omnia X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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Ășn 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 = 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 } #ifndef CONFIG_DM_I2C