Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3302194pxb; Tue, 12 Jan 2021 11:06:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5WI7jkmDPokMgHyGJzjbfyIC/drEZnXfKaYQy27uSA6gtuIx92YgCaiodXOKge99ogVxe X-Received: by 2002:a17:906:6c94:: with SMTP id s20mr216591ejr.0.1610478362316; Tue, 12 Jan 2021 11:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610478362; cv=none; d=google.com; s=arc-20160816; b=K7WI0DSb/9+wmA8iYeYyyVGiDuvUpDBMZ5jQBhplfMXHsvqipqJnJG8I/d5n5yMook TLGiLUKWAiKiGSVB5UAi8CtDRQmLEfWQkEsOcirP586liQS2IairQsolEuPWdsSP7O0G Jkww8evGUebRHKEQ95TYmcLcafxXdls2dBXmFLkB2l1KqendkcQ8KFLHs51aoACiJrL8 qnEJs28ncdlmx9NrwjJOwIWWr7QvmhW5ucaGg2E4IGUW9FUAKcgRXes7vRwCOAZiMbGW vccQXtE2jAaZDU6aQ5zrLN5tnyhhaT+wIujyXpc9jEeKh8/cKqPTglDuz+AtArK1+Weo aUqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=N8Z8QPncj3XHrc0hRnQALJ2m6I90W1MDete86aCTUr0=; b=Uw0WU7Lc/nEcEoghhFEkQzUKDl4M12ovh4E1XJJ7T9Jn53OlomJZ4iO20bTG33cY5O m8zFfnwqvOIUAtl6GH1DqbCHA57AkLL0ksz9UbrF/EjftpoDl2oj1lWu1sGnWu+ZCxRU RgKTspXk9hpAMpoaOKrMXfnDBvdSSmxZhbQX6hS7rRamJ4xT3ikX9SZLXINHNK+XbctN BTAUCWebsxK1ull1sHb5fV4dcvvogKhC09AaX5IVnulPd/I4AxJG1H36xfgdyTE8ZwLd iWrgHtN+jbfvhiqMTiHdQtEL9oRdC/V5emwAiBCBJZLiPz1cuy2REIVabCo9FYQ0V2Bm VSZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=hAtYHGBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si895253ejr.222.2021.01.12.11.05.26; Tue, 12 Jan 2021 11:06:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=hAtYHGBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406523AbhALTDX (ORCPT + 99 others); Tue, 12 Jan 2021 14:03:23 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:17664 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbhALTDW (ORCPT ); Tue, 12 Jan 2021 14:03:22 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 12 Jan 2021 11:02:42 -0800 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 12 Jan 2021 19:02:41 +0000 Received: from skomatineni-linux.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.13) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Tue, 12 Jan 2021 19:02:41 +0000 From: Sowjanya Komatineni To: , , , , CC: , , Subject: [PATCH v3] i2c: tegra: Create i2c_writesl_vi() to use with VI I2C for filling TX FIFO Date: Tue, 12 Jan 2021 11:02:41 -0800 Message-ID: <1610478161-4877-2-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610478161-4877-1-git-send-email-skomatineni@nvidia.com> References: <1610478161-4877-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1610478162; bh=N8Z8QPncj3XHrc0hRnQALJ2m6I90W1MDete86aCTUr0=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-NVConfidentiality:MIME-Version:Content-Type; b=hAtYHGBXtH14OIq53vnG3JCOx9yY5MFmzXTShx1e2uvb49iCtpjgygylzfxGE2rlu yxxHuW14wqy6hs3yqGV2+K7oWxJO4GZqvopdYyAQOwvx+WgzAPC8VP+W3XiuzoX52c JKm2E5nQVQrdmwlrGiuDqjZ5OhGA+IqrfKqiFhnu30KkyheoNecWunA7YyOYAtaCBP oDMfoTW4DjDlj9qp16p9ikrg6GlCf5zqstTPi+tdhT6c+QAFLaVOT6dnN5lgdPFsrE hVKp+GwsiaM2sZX57srbUtcibGU9cZVOIMihQUUAjdHHxB/TH7wLVUip0E7UyMmdhx kDa4aE8Ggk2cw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org VI I2C controller has known hardware bug where immediate multiple writes to TX_FIFO register gets stuck. Recommended software work around is to read I2C register after each write to TX_FIFO register to flush out the data. This patch implements this work around for VI I2C controller. Signed-off-by: Sowjanya Komatineni --- drivers/i2c/busses/i2c-tegra.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 6f08c0c..4a27782 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -326,6 +326,8 @@ static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned int reg) /* read back register to make sure that register writes completed */ if (reg != I2C_TX_FIFO) readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); + else if (i2c_dev->is_vi) + readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, I2C_INT_STATUS)); } static u32 i2c_readl(struct tegra_i2c_dev *i2c_dev, unsigned int reg) @@ -339,6 +341,21 @@ static void i2c_writesl(struct tegra_i2c_dev *i2c_dev, void *data, writesl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg), data, len); } +static void i2c_writesl_vi(struct tegra_i2c_dev *i2c_dev, void *data, + unsigned int reg, unsigned int len) +{ + u32 *data32 = data; + + /* + * VI I2C controller has known hardware bug where writes get stuck + * when immediate multiple writes happen to TX_FIFO register. + * Recommended software work around is to read I2C register after + * each write to TX_FIFO register to flush out the data. + */ + while (len--) + i2c_writel(i2c_dev, *data32++, reg); +} + static void i2c_readsl(struct tegra_i2c_dev *i2c_dev, void *data, unsigned int reg, unsigned int len) { @@ -811,7 +828,10 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) i2c_dev->msg_buf_remaining = buf_remaining; i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD; - i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); + if (i2c_dev->is_vi) + i2c_writesl_vi(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); + else + i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer); buf += words_to_transfer * BYTES_PER_FIFO_WORD; } -- 2.7.4