From patchwork Mon Apr 9 06:40:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133003 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp884692ljb; Sun, 8 Apr 2018 23:41:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx49TINPrXwq2EVAdsM4rC0U7ON5VdVXEaNrwVh7DV5q10eKspmFkj/eO28wsVT73LIUgQqHa X-Received: by 2002:a17:902:68c2:: with SMTP id x2-v6mr37315068plm.129.1523256091322; Sun, 08 Apr 2018 23:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523256091; cv=none; d=google.com; s=arc-20160816; b=Tic+966A/rJot57dF3+8fJCOwsY35ARj7pm76J0ISdNxoa83NQwKTaB84v5L2x8IJe 1T+ZraPDXpWuwImBSWUqx78yGXVAzI6ESQpISWsahzZolQr6e4EU0WG6y+obZBF/V6UH ljTN4ZqdNDPWtsJsIuszpJXH10pwT/bFnjXyRdj73vW7dYXWJHLGqb65IHJ8+NR9dL3q i+eTypXsHZaJ9lFjveQJw0cG5qsm9rOz+I8e8nJUk0gjuiuzlBKl4Md/JmyAHcGc4CWb 3Q2J1iLvEIdjzW023phHKmxfvkLaxAtj5EHgN3n5Qx9xBeNihGjRKmwpqQX+ime1Soi8 TDKA== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=PRa4Wsz9y3RtOVRcDA1jzYOZbGMhcbATshfqMSXwY4o=; b=B93vgcmIJUfeHbvThfhEXc5gl2Ai7ReihShfS/gZYG4ZdZZnvnxW+3sqFVoZhX11Nc B9zue+Bn5+R7olATmMZrKT3om79d4yl64ghxO4iQUjt9gDn/qiqJVPLdbV3lW8aSLSHl 28r38b1Zw0+UH8K2yhoZ9QH102o4+T36IdHELRelyzhwOaPTGoUQ2hnTwmDuQ96gJt5/ eY3m8lPyCRGTbPeR0zbWyw+sFhFh3I8wEpzNDE8aYOhvgDFNANQUKnl57ejLTDtDlivA pzKASPeqzVstTvqWIj877q6ZaMCcJt8rpzbVUtsyoJm403gvvEh03XmAnkRu/C8aRSe/ +vUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QjT7u8vY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12si1753974pgr.128.2018.04.08.23.41.31; Sun, 08 Apr 2018 23:41:31 -0700 (PDT) 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=@linaro.org header.s=google header.b=QjT7u8vY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752539AbeDIGl0 (ORCPT + 29 others); Mon, 9 Apr 2018 02:41:26 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:45040 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752499AbeDIGlY (ORCPT ); Mon, 9 Apr 2018 02:41:24 -0400 Received: by mail-pl0-f67.google.com with SMTP id b6-v6so4546622pla.11 for ; Sun, 08 Apr 2018 23:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=PRa4Wsz9y3RtOVRcDA1jzYOZbGMhcbATshfqMSXwY4o=; b=QjT7u8vYAJBsq1nkJ+96hcStsBnbR4WmdJHywDssLUinRAr5sYDM5fYrGRgktaa2hl T9luzrZfE6+rwldxra239A0I4mz0mUq9P8ZCOqH2BtRgycD1b40XKuw5UY4H3MmnSkV3 Jk9fCYCoV+kH4zYVUiRI08yI83/oHnkpBtfR0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=PRa4Wsz9y3RtOVRcDA1jzYOZbGMhcbATshfqMSXwY4o=; b=jk+czCWbpJNAB2PPf/pGWqC/WizUFGE0+2Ciip7wn1zEMrE7+9TFelxoqEc8gQgl4m b47F6J7LP91QlhfpUQT4Ao0H6OOxrBvNBKLsODxQ4VkohOLxZqGoc59fZOsmTtr3w6kI dL76G/0pC1y6K4NO8NC1UC4KVas4skBeL0IZP0vSFzrie8vO3gXt0AcNXP5+AbzRFc1d 0tXf1tkkTgUTJWgK9zGxLAsoA6igBRxudN+gCoSX/56HrzCsWMQ7xYqekcKRi0yec5+N PaXNAbb1IWghIRqt6ve6lEwTe4eQPxfJDkjkiegVnHMimBuRTfayWEn0cqQk/IrfdqCs B9sw== X-Gm-Message-State: AElRT7FHkZHPcxDfa9Ptczp+MTwoXqpHqg7adf62Tj0Vwd+TQ2SE+VMK DPDmJgEyMndiQWoQlMSGlVd0/Q== X-Received: by 2002:a17:902:6b03:: with SMTP id o3-v6mr31698094plk.183.1523256083477; Sun, 08 Apr 2018 23:41:23 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id y14sm32517490pff.81.2018.04.08.23.41.21 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Apr 2018 23:41:23 -0700 (PDT) From: Baolin Wang To: wsa@the-dreams.de Cc: broonie@kernel.org, baolin.wang@linaro.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] i2c: sprd: Fix the i2c count issue Date: Mon, 9 Apr 2018 14:40:55 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <99031524fa147e72451d26f54b24f36093c0d3fa.1523255712.git.baolin.wang@linaro.org> References: <99031524fa147e72451d26f54b24f36093c0d3fa.1523255712.git.baolin.wang@linaro.org> In-Reply-To: <99031524fa147e72451d26f54b24f36093c0d3fa.1523255712.git.baolin.wang@linaro.org> References: <99031524fa147e72451d26f54b24f36093c0d3fa.1523255712.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We found the I2C controller count register is unreliable sometimes, that will cause I2C to lose data. Thus we can read the data count from 'i2c_dev->count' instead of the I2C controller count register. Signed-off-by: Baolin Wang --- drivers/i2c/busses/i2c-sprd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 1.7.9.5 diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c index 2fdad63..4053259 100644 --- a/drivers/i2c/busses/i2c-sprd.c +++ b/drivers/i2c/busses/i2c-sprd.c @@ -368,13 +368,12 @@ static irqreturn_t sprd_i2c_isr_thread(int irq, void *dev_id) struct sprd_i2c *i2c_dev = dev_id; struct i2c_msg *msg = i2c_dev->msg; bool ack = !(readl(i2c_dev->base + I2C_STATUS) & I2C_RX_ACK); - u32 i2c_count = readl(i2c_dev->base + I2C_COUNT); u32 i2c_tran; if (msg->flags & I2C_M_RD) i2c_tran = i2c_dev->count >= I2C_FIFO_FULL_THLD; else - i2c_tran = i2c_count; + i2c_tran = i2c_dev->count; /* * If we got one ACK from slave when writing data, and we did not @@ -412,14 +411,13 @@ static irqreturn_t sprd_i2c_isr(int irq, void *dev_id) { struct sprd_i2c *i2c_dev = dev_id; struct i2c_msg *msg = i2c_dev->msg; - u32 i2c_count = readl(i2c_dev->base + I2C_COUNT); bool ack = !(readl(i2c_dev->base + I2C_STATUS) & I2C_RX_ACK); u32 i2c_tran; if (msg->flags & I2C_M_RD) i2c_tran = i2c_dev->count >= I2C_FIFO_FULL_THLD; else - i2c_tran = i2c_count; + i2c_tran = i2c_dev->count; /* * If we did not get one ACK from slave when writing data, then we