From patchwork Thu Dec 6 03:55:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10715235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33B1C13BF for ; Thu, 6 Dec 2018 03:57:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20EE52DEF0 for ; Thu, 6 Dec 2018 03:57:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 135912DFCB; Thu, 6 Dec 2018 03:57:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C52F2DEF0 for ; Thu, 6 Dec 2018 03:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EJVZEFeFU6cd27yE4M6bpAVD9nU4PWOw1k0N44wThus=; b=XfQQIX2y3pgmQos6zBoRYkX3gw etbDlAqMGcsvBAW7Qik9An4q8yaRZowrE2i0E50dEBKpQLw77OvJQIBGPECsara5PuYrRDcRltCv1 sHv0hXMvCg7xhY9pBXG4hkbwhJFt/20BHsGXKRm5VAATKRb6DwlXXGNejYygIo1RHHMCXe+LjCPzL Kxt3q7jQuXL8ySvO4QA0O4sSq4sl0X3F3Hi18nZYfVLUNFKq+Sjo7DdXvNTwzdvin9IbCQKsiyjxw l0vzPEtS/S0kCC9/wX7sY1CHcrZ/q9hx3JloFU2hHagxpOYu0+9vfhGw59wsDBVn/efUzWvXPieEC OVhrkV1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmz-0003Dq-F0; Thu, 06 Dec 2018 03:57:25 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmO-0002fn-Ps for linux-arm-kernel@bombadil.infradead.org; Thu, 06 Dec 2018 03:56:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2y2cw2qzebvkA+Mtv/XDf/lXFAsgLnN70QsGjRHK68c=; b=tuyQ3PWieN+IvqWHGQwooMI9S TdYog9e3MLmFIooY6KdBC4mklB20SvzpGdd3Jta0jPhEIZoWE3k1vT8VFU8H+8K3vdfaADfBcnT+I j3dm3jL0XQjOs9hgUj6cmxp6cI2Sd1vZBDYCpLuZPVLj2RMsP03xjSIRSQpa22PC5cbbnCCuSt3tF 4VyM3fN9rZAgWSTa3m+NsjbhNoxnbRY3OQUfmqHXAj0bJB6jDRr8ESjzP52T3BKbnqDQ4Yq2ZVvKN 78IaOw27M/ysbSS3tUj7arzh72Xyfe1xtleY9wEUfFpkYjILZWw03WaMpkf9obGnWStgPSjNyfzA3 r+ejru1xQ==; Received: from conuserg-09.nifty.com ([210.131.2.76]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmE-0003kk-5L for linux-arm-kernel@lists.infradead.org; Thu, 06 Dec 2018 03:56:46 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id wB63trS6007398; Thu, 6 Dec 2018 12:55:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com wB63trS6007398 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544068555; bh=2y2cw2qzebvkA+Mtv/XDf/lXFAsgLnN70QsGjRHK68c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPHi2dOEi3qWH6h8XKwY274U9vnp6zKg7l3nNiKvf+kib3GV6+hakUNhgUnJJv/NF QHc/hlsIotcEtGB5VC2dt/W9jOMZqqbgx8hd5vZ3ylxiudEBtz8JnBgUwak7qri5rt Zpt+7C4FpNFZjl8l8IW8KZNAfoQ1ZMIV8KPl+Aiiilu2M+0j9fYu5OskyJ4UINipp7 kdkbPwV862Vny5wy2cJZ1alQv9PL7LDEz2AIMbYuPxYGX7ZvElrn9bsnDorMCu/2CW oWeUxwZPvHto49Ojo8gn5cZ4aIXQT+MsT1D4wDwCF9w4GI/LiHEO9CTKWOrP9c6CJ/ 1zoDG2ayu67Zw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-i2c@vger.kernel.org Subject: [PATCH 1/4] i2c: uniphier-f: fix timeout error after reading 8 bytes Date: Thu, 6 Dec 2018 12:55:25 +0900 Message-Id: <1544068528-27657-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> References: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181205_225638_793856_18A685B0 X-CRM114-Status: GOOD ( 17.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP I was totally screwed up in commit eaba68785c2d ("i2c: uniphier-f: fix race condition when IRQ is cleared"). Since that commit, if the number of read bytes is multiple of the FIFO size (8, 16, 24... bytes), the STOP condition could be issued twice, depending on the timing. If this happens, the controller will go wrong, resulting in the timeout error. It was more than 3 years ago when I wrote this driver, so my memory about this hardware was vague. Please let me correct the description in the commit log of eaba68785c2d. Clearing the IRQ status on exiting the IRQ handler is absolutely fine. This controller makes a pause while any IRQ status is asserted. If the IRQ status is cleared first, the hardware may start the next transaction before the IRQ handler finishes what it supposed to do. This partially reverts the bad commit with clear comments so that I will never repeat this mistake. I also investigated what is happening at the last moment of the read mode. The UNIPHIER_FI2C_INT_RF interrupt is asserted a bit earlier (by half a period of the clock cycle) than UNIPHIER_FI2C_INT_RB. I consulted a hardware engineer, and I got the following information: UNIPHIER_FI2C_INT_RF asserted at the falling edge of SCL at the 8th bit. UNIPHIER_FI2C_INT_RB asserted at the rising edge of SCL at the 9th (ACK) bit. In order to avoid calling uniphier_fi2c_stop() twice, check the latter interrupt. I also commented this because it is obscure hardware internal. Fixes: eaba68785c2d ("i2c: uniphier-f: fix race condition when IRQ is cleared") Signed-off-by: Masahiro Yamada --- drivers/i2c/busses/i2c-uniphier-f.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index dd38474..fad2b00 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -173,8 +173,6 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) "interrupt: enabled_irqs=%04x, irq_status=%04x\n", priv->enabled_irqs, irq_status); - uniphier_fi2c_clear_irqs(priv, irq_status); - if (irq_status & UNIPHIER_FI2C_INT_STOP) goto complete; @@ -214,7 +212,13 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) if (irq_status & (UNIPHIER_FI2C_INT_RF | UNIPHIER_FI2C_INT_RB)) { uniphier_fi2c_drain_rxfifo(priv); - if (!priv->len) + /* + * If the number of bytes to read is multiple of the FIFO size + * (msg->len == 8, 16, 24, ...), the INT_RF bit is set a little + * earlier than INT_RB. We wait for INT_RB to confirm the + * completion of the current message. + */ + if (!priv->len && (irq_status & UNIPHIER_FI2C_INT_RB)) goto data_done; if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) { @@ -253,6 +257,13 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) } handled: + /* + * This controller makes a pause while any bit of the IRQ status is + * asserted. Clear the asserted bit to kick the controller just before + * exiting the handler. + */ + uniphier_fi2c_clear_irqs(priv, irq_status); + spin_unlock(&priv->lock); return IRQ_HANDLED; From patchwork Thu Dec 6 03:55:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10715239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7611113BF for ; Thu, 6 Dec 2018 04:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EC812DA88 for ; Thu, 6 Dec 2018 04:10:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5163B2DA8B; Thu, 6 Dec 2018 04:10:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EA412DA88 for ; Thu, 6 Dec 2018 04:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+QxeLb2r7MFtHKAkyl8ZZKi0VeRjLu7hT8ajDP8lbqI=; b=QsE/0QeJGl+WvIK5NOjllJqEsz E0xXiyXkpAMttQmIwV424BLnt0jx0Cud7rbLxQrDjL9ev7gC9TtthrRIJZerZcgDXKBbV0M9Hv1YT ZSyzfpaBEtJxDiS7qoQcs+AEJL2fOSo6HGT66q0KIk/Pu3BZ1UThlf3OWUrtjA2mZNAFafWywQU2K DPOhUJPjibXEgxdwIG2TMnfrLsguxmJ7aG9SmmDi/gJu2GMJxQfybZsFlN+xMMuRtJ6v++CZgzyau KYZUwS0h+Ww/s4vzHPo2vN3yJY4/bd8GlFEEVurMo4x/okfz0kbnhg1sGQp8zYVRr9HC6PC35I3cN LzJaHBag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkzy-0007pO-39; Thu, 06 Dec 2018 04:10:50 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmO-0002fm-Q9 for linux-arm-kernel@bombadil.infradead.org; Thu, 06 Dec 2018 03:56:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=i2ojI7R92ngd4Xq06C6mSR5SZWE8QuYiZ8bI+8Q1qyI=; b=VJTSoB6ykMkvz2kpua8nCwbl7 3CMHJQrYsMmb9ZTmEN3UCvPJp5Y7YqwR3o1zwRPsU/nA/3drjhUfV/wJvRmGfhFsyTKjxQKxySYCw vzz6D5EkytQwz65CpsxcJ8I5ScpIuAUFXgeaXYfZoBXA/YXkkC2Qh1obPUMfHIHwX+Gy+ueqQJ/bI enwiVeJNGlq7ztWmpeHkfuU2AdYwjSG7vrklRMHMdSoMmws2nbZEKfUXEEx+BFcnNYvn84geX713a iYqFk+1z0bJoJgSSXGsnmFEQS9DsIMvw7BiueUi7QLz3zALikUwvq0XUwMvu6Gso4pqclDQ1FN5RN 0ZjUZj1lA==; Received: from conuserg-09.nifty.com ([210.131.2.76]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmE-0003kh-6R for linux-arm-kernel@lists.infradead.org; Thu, 06 Dec 2018 03:56:46 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id wB63trS7007398; Thu, 6 Dec 2018 12:55:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com wB63trS7007398 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544068555; bh=i2ojI7R92ngd4Xq06C6mSR5SZWE8QuYiZ8bI+8Q1qyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lw3qleMFLx7MX5hI2QHV+N1op9V3rzX2NxKj4ltz9br1n2EUdhJgOO8Yy6UW3yGC6 40hSFYWCpcX+5XzSj4zpC9S1lSqy2tpPL+yx+5+YfpARAVQn/DmH8bAKL99Fekh1g/ eRsyOBwGoeREpuLOF1KfwqmezRX7VYC9lPVrLobqkEdJbkvaIED8WKo0yw4WkD9MST HcggJZHWRxMtXgutDem94exOe41dzM3hmorTTUeQx8Of5tOMB1G70fSBB/KitdNQAj HEtQ8boE90NnN9IBzcXYSCW+Cbgxn90D06lZqVC6tDaBs8l69PTBmE1YMcbPH76eRX kaQh/KGg0/wqg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-i2c@vger.kernel.org Subject: [PATCH 2/4] i2c: uniphier-f: fill TX-FIFO only in IRQ handler for repeated START Date: Thu, 6 Dec 2018 12:55:26 +0900 Message-Id: <1544068528-27657-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> References: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181205_225638_795115_C304D350 X-CRM114-Status: GOOD ( 14.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP - For a repeated START condition, this controller starts data transfer immediately after the slave address is written to the TX-FIFO. - Once the TX-FIFO empty interrupt is asserted, the controller makes a pause even if additional data are written to the TX-FIFO. Given those circumstances, the data after a repeated START may not be transferred if the interrupt is asserted while the TX-FIFO is being filled up. A more reliable way is to append TX data only in the interrupt handler. Signed-off-by: Masahiro Yamada --- drivers/i2c/busses/i2c-uniphier-f.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index fad2b00..d8a5db14 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -269,7 +269,8 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static void uniphier_fi2c_tx_init(struct uniphier_fi2c_priv *priv, u16 addr) +static void uniphier_fi2c_tx_init(struct uniphier_fi2c_priv *priv, u16 addr, + bool repeat) { priv->enabled_irqs |= UNIPHIER_FI2C_INT_TE; uniphier_fi2c_set_irqs(priv); @@ -279,8 +280,12 @@ static void uniphier_fi2c_tx_init(struct uniphier_fi2c_priv *priv, u16 addr) /* set slave address */ writel(UNIPHIER_FI2C_DTTX_CMD | addr << 1, priv->membase + UNIPHIER_FI2C_DTTX); - /* first chunk of data */ - uniphier_fi2c_fill_txfifo(priv, true); + /* + * First chunk of data. For a repeated START condition, do not write + * data to the TX fifo here to avoid the timing issue. + */ + if (!repeat) + uniphier_fi2c_fill_txfifo(priv, true); } static void uniphier_fi2c_rx_init(struct uniphier_fi2c_priv *priv, u16 addr) @@ -361,7 +366,7 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, if (is_read) uniphier_fi2c_rx_init(priv, msg->addr); else - uniphier_fi2c_tx_init(priv, msg->addr); + uniphier_fi2c_tx_init(priv, msg->addr, repeat); dev_dbg(&adap->dev, "start condition\n"); /* From patchwork Thu Dec 6 03:55:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10715229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BDBF13BB for ; Thu, 6 Dec 2018 03:56:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86B232DEF0 for ; Thu, 6 Dec 2018 03:56:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77F4A2DFCB; Thu, 6 Dec 2018 03:56:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E024D2DEF0 for ; Thu, 6 Dec 2018 03:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wIya2b7yvMk9uPTbz6hTnP23onoJXG14bxNoWh/ShX0=; b=sbdX8oQyqRpz9OjFzCQ+djXd57 n2xoy5+ZWX+rXLpa9DApg7ZQR1NCQ2noc4ImWshkQYdsTA72dlxjiNgrFoyBV2m5RB0oyhsnFPNTq 12ffhM72GQ0NkI1ioNmZBQz/EVMMvpyD2PGg9FtCZQSy6Sa12Wl4OVCtbfyXc8KdCmHn5bnqzxdDN aYm6TcWh6uLojVwVXW66YpsNMOEo0HmVlHONmde5Qj/0DVHcQOoObUcmlf71bHyTyKCob/LathFqd 4RBCMN+2m2dZ9X0iziYsbYMoff7/hNd0J//dQst61pmVwX33KaOigoDXJDNKd6iuqGRdKK0yAiUAb idwc8qUw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmC-0002WG-0k; Thu, 06 Dec 2018 03:56:36 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUklw-0002Fw-6B for linux-arm-kernel@lists.infradead.org; Thu, 06 Dec 2018 03:56:33 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id wB63trS8007398; Thu, 6 Dec 2018 12:55:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com wB63trS8007398 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544068556; bh=i2DTwxcgMHeHYcJ2f2azxuoZs+0qhk4Q7YQ7oWQJxew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N5WC2H/19yIcfPFEM11mY3qrS+Dnr9VtgGLKAPEEzKvosZOQB6FhhFkTUJ+ME17cq qVTZX3NojjlORMZn4SUYlKzCLSyiT+jOJSjEEbeq2m6jv9ipvDARy7mgPgfaBUvp0e RzYLffsbwNhdGywqJFTlJC3BKLEsFHI5/Zj37Oslp7noqh+S8yMRWAVJQSq50+Zfyi uXP0DA3VZTRrxrJLxJ9MclnSUZIUqUT6wWt5SkTF3SzsQC8af322i9bmWcUqbhn73Y BcewCncPKUhKKsp8htfrvPQ9dit9hmtx9vwyyGqNCJ0qJKUfUKVbOBmNU/0iWdE2IS mWgghyI6yiowg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-i2c@vger.kernel.org Subject: [PATCH 3/4] i2c: uniphier: fix violation of tLOW requirement for Fast-mode Date: Thu, 6 Dec 2018 12:55:27 +0900 Message-Id: <1544068528-27657-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> References: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181205_195620_862714_4B739FC0 X-CRM114-Status: UNSURE ( 9.26 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the clock duty is set as tLOW/tHIGH = 1/1. For Fast-mode, tLOW is set to 1.25 us while the I2C spec requires tLOW >= 1.3 us. tLOW/tHIGH = 5/4 would meet both Standard-mode and Fast-mode: Standard-mode: tLOW = 5.56 us, tHIGH = 4.44 us Fast-mode: tLOW = 1.39 us, tHIGH = 1.11 us Signed-off-by: Masahiro Yamada --- drivers/i2c/busses/i2c-uniphier.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-uniphier.c b/drivers/i2c/busses/i2c-uniphier.c index 454f914..c488e55 100644 --- a/drivers/i2c/busses/i2c-uniphier.c +++ b/drivers/i2c/busses/i2c-uniphier.c @@ -320,7 +320,13 @@ static void uniphier_i2c_hw_init(struct uniphier_i2c_priv *priv) uniphier_i2c_reset(priv, true); - writel((cyc / 2 << 16) | cyc, priv->membase + UNIPHIER_I2C_CLK); + /* + * Bit30-16: clock cycles of tLOW. + * Standard-mode: tLOW = 4.7 us, tHIGH = 4.0 us + * Fast-mode: tLOW = 1.3 us, tHIGH = 0.6 us + * "tLow/tHIGH = 5/4" meets both. + */ + writel((cyc * 5 / 9 << 16) | cyc, priv->membase + UNIPHIER_I2C_CLK); uniphier_i2c_reset(priv, false); } From patchwork Thu Dec 6 03:55:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10715231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 463B813BB for ; Thu, 6 Dec 2018 03:56:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32FFB2DEF0 for ; Thu, 6 Dec 2018 03:56:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2155F2DFCB; Thu, 6 Dec 2018 03:56:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 76C9C2DEF0 for ; Thu, 6 Dec 2018 03:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MNdWTBsscH/J/PwClGdTV5dJ9JzkA21e0+HbyFbC01U=; b=thUKaMYedLT7/LcRIdnb/dGl2g INk0F4O7enLEGL3RoWejAKiermmy6Gx1lC7j+8Iw102SxmVYGymZhB1s5dsNJhmEWVDj5hj3DoUHS f/CIWgdJC68Fjz4GO1RuaxhWHx2u8IOZcKu6QnCdmMy7OW29CttU/ohhOz23C2HGO+ybLbDW2Y9p5 972793PfB3fcaaWpOlB8FHURy/RsSs1mVZXoMjhQbDO3pCBylT9G83bY8bZT/FYknqbU0Iivzq88B xxL0fFXc6a2ArXuDuYfDducy0xgAnFHcy/RY0Th/Zp6/DAVS7Uq17bfR+4Fy1aqwaeQ/8Vt+1JQFw mVPxqIrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmR-0002ii-N3; Thu, 06 Dec 2018 03:56:51 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmK-0002cc-TO for linux-arm-kernel@bombadil.infradead.org; Thu, 06 Dec 2018 03:56:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vq9iTJECSWUXoTz65/XclZ3Mf1gaCLqGMYaa34hNQzo=; b=QVJCzibUrFg/Y+ICsSkLCsl2G uAegqCgdS8+5CVhDyXEQX8ih266mncLCXVfoyEUbLDyNzXHfmjusnADPfl6Fjl2R8nJyqv936Qybh 5QC4lDKPSEHriMUjOqdvS3k3Lzq+6bTeMmaO1gyOa/Yi+CFwtBV1wHR8Yk2CLkoLjOuDMvnryBvKu HYxnxmGxAC6n72lSm1My8qkJQ5AVzu/lM7W4nDWpFy+6uYnHjOczPVPoqxputAqhMKg0dkxhVE7h1 MOJ72RxcyhaLXlydO6RrtqHMK2sZd4p60zyDMmrzprPo3eHrZS8PLeEURuwID1dMDj6zIKtMEnvIN GL/HF7jxA==; Received: from conuserg-09.nifty.com ([210.131.2.76]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUkmE-0003ki-5t for linux-arm-kernel@lists.infradead.org; Thu, 06 Dec 2018 03:56:43 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id wB63trS9007398; Thu, 6 Dec 2018 12:55:56 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com wB63trS9007398 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544068556; bh=vq9iTJECSWUXoTz65/XclZ3Mf1gaCLqGMYaa34hNQzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1ewxlKKR/XsG0V3d2Akt8g4TCv+aHm8a3OUtlC8uoyfqlPwXE86mMbvpBNYHAlGk BFw+pLk33zxTefChgiYmvRz76SlVxWnBLj35a8HUEWMpcUJvqzCTkbzMoN2pUZkxVO Aqgk9SixT51vdYPldt7PYFF3ed0DzNmduOj+Q644GKI6qusqPACK6k1PxU+L4pmCMi qJHrijhwNA+bowo36nqA7rR6QrV4MySgNH/FvcX0nvGW4lGgfRtR/KRfMYth4XZPhf VIM1lNbkIJWyYvU3QofXTnynRpj/7Xjn0nbU2rsVxvBhaxfCe/4mWpILRNuQCp570B x4fQeA+ztAolA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-i2c@vger.kernel.org Subject: [PATCH 4/4] i2c: uniphier-f: fix violation of tLOW requirement for Fast-mode Date: Thu, 6 Dec 2018 12:55:28 +0900 Message-Id: <1544068528-27657-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> References: <1544068528-27657-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181205_225638_790295_A696D938 X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the clock duty is set as tLOW/tHIGH = 1/1. For Fast-mode, tLOW is set to 1.25 us while the I2C spec requires tLOW >= 1.3 us. tLOW/tHIGH = 5/4 would meet both Standard-mode and Fast-mode: Standard-mode: tLOW = 5.56 us, tHIGH = 4.44 us Fast-mode: tLOW = 1.39 us, tHIGH = 1.11 us Signed-off-by: Masahiro Yamada --- drivers/i2c/busses/i2c-uniphier-f.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index d8a5db14..03da4a5 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -518,9 +518,26 @@ static void uniphier_fi2c_hw_init(struct uniphier_fi2c_priv *priv) uniphier_fi2c_reset(priv); + /* + * Standard-mode: tLOW + tHIGH = 10 us + * Fast-mode: tLOW + tHIGH = 2.5 us + */ writel(cyc, priv->membase + UNIPHIER_FI2C_CYC); - writel(cyc / 2, priv->membase + UNIPHIER_FI2C_LCTL); + /* + * Standard-mode: tLOW = 4.7 us, tHIGH = 4.0 us, tBUF = 4.7 us + * Fast-mode: tLOW = 1.3 us, tHIGH = 0.6 us, tBUF = 1.3 us + * "tLow/tHIGH = 5/4" meets both. + */ + writel(cyc * 5 / 9, priv->membase + UNIPHIER_FI2C_LCTL); + /* + * Standard-mode: tHD;STA = 4.0 us, tSU;STA = 4.7 us, tSU;STO = 4.0 us + * Fast-mode: tHD;STA = 0.6 us, tSU;STA = 0.6 us, tSU;STO = 0.6 us + */ writel(cyc / 2, priv->membase + UNIPHIER_FI2C_SSUT); + /* + * Standard-mode: tSU;DAT = 250 ns + * Fast-mode: tSU;DAT = 100 ns + */ writel(cyc / 16, priv->membase + UNIPHIER_FI2C_DSUT); uniphier_fi2c_prepare_operation(priv);