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: 152983 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10074247ljp; Wed, 5 Dec 2018 19:56:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/U48lpubRi1NV7QhPtWjf3hNJ6MV5tm4Xs3YcvF6lI8FUH2wolFoHX0vg7lSCbS6Z1e1Woj X-Received: by 2002:a63:1f1c:: with SMTP id f28mr22848793pgf.193.1544068617197; Wed, 05 Dec 2018 19:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544068617; cv=none; d=google.com; s=arc-20160816; b=K8g6wriu3kO34hr1KOCoemjrnz38+A4FZvNLicJM/PKCO3FWkcwIYo7SxDqCy4eJ1T 9WJYGoAKuyM+Ou6slnCrd7CY6ifKNOqaY1CVj8vu4boKeLslxQsT78pk0ph12tq240rz yz3fGoSM8M6/vJOB9bjAXmrezuG75kgdPMkqxkBnnRqpRcCrMdpLvIHg2Su9J26/rx0J PNv2DB8HX2L0Rr+sDWzZ9pa+WlugycI4XbCj+S6WwTURj48kBszuF+jg8GX9puOlyEwE Mb1IPbJCqYLAkGpdd3Ap+s06x4pPeZTV/Ay6kVvln8xQoYadBW+S4o2d/qPEvbY5/Cz2 ushg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=i2ojI7R92ngd4Xq06C6mSR5SZWE8QuYiZ8bI+8Q1qyI=; b=TSFc9Lr9CPglbDYYF1W8HbhrJCo6+dUqjb53c3sY6Amlm5eQpM1N0lgqgV3vp2xOEM u4MlIT262nWMuvgHwe5HwqftW2TwHQJfNzvvSqjP71Zedxg4zT/znHAA9jUh8YFPSXch s/9whoWWuefkfYEnc+HTDj3EJ/ks0KXm8nDTYkExLLFDnzKUVE9UkXoS20jWlcXo5UBO ci2ykbgwrJXzAVEESI7qRxNcfVgIqwFmGdS/Kpv3BVarWkdmBfs0fNjPiWv+Cxzy9w4A paf18MXfneBYten5Vxo88Q6kkCGzvojEPec/Z90Kqe2Zwm5/EKHVPpxBfh1QlaMSLZ3b it2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=lw3qleMF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q66si21497796pfb.231.2018.12.05.19.56.56; Wed, 05 Dec 2018 19:56:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=lw3qleMF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729080AbeLFD4v (ORCPT + 31 others); Wed, 5 Dec 2018 22:56:51 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:59210 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729057AbeLFD4s (ORCPT ); Wed, 5 Dec 2018 22:56:48 -0500 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 Cc: Masahiro Yamada , linux-arm-kernel@lists.infradead.org, linux-kernel@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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - 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(-) -- 2.7.4 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"); /*