Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2552234pxb; Mon, 17 Jan 2022 00:28:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZh9p1BouTprXWgMhTcFN9JDBWYpQQ6Oi98XCo9BTdA5BOy16bLWb/yD7u8JDHBISzKNBF X-Received: by 2002:a17:902:e544:b0:14a:586c:1336 with SMTP id n4-20020a170902e54400b0014a586c1336mr22249453plf.41.1642408117163; Mon, 17 Jan 2022 00:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642408117; cv=none; d=google.com; s=arc-20160816; b=lb3eywT/hXTYsaDhts8mANAd41pwgrwDQO6lmwyvxzrGicQgbQxMYQjbWc1/xdz/Mq 6Zxy7HxR5uFU1dALsMC3LFWDKVeBHTtjg28bjyQz0viC8mI20Ct5xCzIPjFYlPRH88aV MC6JTjnDBctRyEKrKgP1WqYHnxvQEi+r5bPc/5B8UwP7mOTL4a0Lw01qXL5orPgXxekD +gC7RU7JkEUgZB/iCkFO6katFTsZSGeAYxRFQliZ4pKkqeTBo+kgnxN5o6iwQ1YINcdE Kh/wAHuSNChWI4JN6ztRfgxLSBVeo0Rs503Kza8VW5XSenFHRB/Xa+UbP9fTt2RTwZb5 eIAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :subject:from:references:in-reply-to:message-id:date:dkim-signature; bh=GTwEMOjLAzWyVBVhKgYUnQOl+mkrHpqFJYpKSXD0Ceg=; b=t/1PhBrsEZMWDZppcJHbxMkP6EwSFJkDP/9yHdA094PmCVfixGw6K6siWH+DxHk+3q /21hgn0rg4PEjJrZdNbxPH5WLwZAWRCjQx3+CXvoRVW3oaEWAn34Y9d7L6Xx8aRRfC4i RS0hs/er1A9dQeBYEbyT/txjiw4xZlRNCAsEXQjovcNbw6HzwJe4k7qnq3wJnf1jGiEH NpqIi5eBxVTWzyHKqViH56gCk93ByTYni0XjQPEIv/dYZnJ5kO8QygPRxj6P+0MVYWx0 TcpISMAmJurto+BLKKUVr3DK+8mJdb8S1lbQ6C4sdLPfkGV5kW5SldyaGde8NPCpELJc pYyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=dKJmCZ1X; 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=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fs10si18289281pjb.75.2022.01.17.00.28.26; Mon, 17 Jan 2022 00:28:37 -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=@rere.qmqm.pl header.s=1 header.b=dKJmCZ1X; 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=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235551AbiAPQCX (ORCPT + 99 others); Sun, 16 Jan 2022 11:02:23 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:43762 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233440AbiAPQCV (ORCPT ); Sun, 16 Jan 2022 11:02:21 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4JcKYS0w7PzMc; Sun, 16 Jan 2022 17:02:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1642348940; bh=b+aXZUEZ/iu/vA0Z9GFMnzJiD2dDum0zArW4qRVtf2o=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=dKJmCZ1XudMh1ggQg5NMcX9+k5jU5RrNDShmOatiazuusXPFWFowhXS4jO9+kgBo+ Gl1lUFUpLRqS/r815J3UqfkLhII5OUbaRu6dbPcqwagD8GYaMbGDrMrXSmrgDceQJ0 GRdcyh7hRCtSRmc5jE4Mm2kRzG18p5gL+nZtHS1rAF5re+LMS/3zRQnZUBvaVcwZRk CDXvP+K63cUg+RKoFzSbDvxWwGt4ALR4bQsajQxlFviE/57XaV9tPeapxR9tiM7fBd U4/Vc53yWk8/2wiiv6ftvIIxq02WSPjS7+u+oPVvcy8mODYeDP0lGc6mZ3TSxxxBSP eraQ8ocKf6ypQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.4 at mail Date: Sun, 16 Jan 2022 17:02:19 +0100 Message-Id: In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 2/2] i2c: tegra: allow VI support to be compiled out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Laxman Dewangan , Dmitry Osipenko , Thierry Reding , Jonathan Hunter Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Save a bit of code for older Tegra platforms by compiling out VI's I2C mode support that's used only for Tegra210. $ size i2c-tegra.o text data bss dec hex filename 10385 240 8 10633 2989 i2c-tegra.o (full) 9617 240 8 9865 2689 i2c-tegra.o (no-dvc) 9389 240 8 9637 25a5 i2c-tegra.o (no-vi) 8617 240 8 8865 22a1 i2c-tegra.o (no-vi,no-dvc) Signed-off-by: Michał Mirosław --- drivers/i2c/busses/Kconfig | 8 ++++++++ drivers/i2c/busses/i2c-tegra.c | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index b557b832bfec..2dd5974acc14 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -1087,6 +1087,14 @@ config I2C_TEGRA_DVC If you say yes to this option, tegra-i2c will also support I2C controller that is part of DVC in Tegra20 SoCs. +config I2C_TEGRA_VI + bool "NVIDIA Tegra VI I2C controller" + depends on I2C_TEGRA + default y if ARCH_TEGRA_210_SOC + help + If you say yes to this option, tegra-i2c will also support + I2C controller that is part of VI in Tegra210 SoCs. + config I2C_TEGRA_BPMP tristate "NVIDIA Tegra BPMP I2C controller" depends on TEGRA_BPMP || COMPILE_TEST diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 60ecf6c9f649..140fbce203cb 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -295,6 +295,7 @@ struct tegra_i2c_dev { }; #define IS_DVC(dev) (IS_ENABLED(CONFIG_I2C_TEGRA_DVC) && dev->is_dvc) +#define IS_VI(dev) (IS_ENABLED(CONFIG_I2C_TEGRA_VI) && dev->is_vi) static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned int reg) @@ -315,7 +316,7 @@ static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int reg) { if (IS_DVC(i2c_dev)) reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40; - else if (i2c_dev->is_vi) + else if (IS_VI(i2c_dev)) reg = 0xc00 + (reg << 2); return reg; @@ -444,7 +445,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev) u32 *dma_buf; int err; - if (!i2c_dev->hw->has_apb_dma || i2c_dev->is_vi) + if (!i2c_dev->hw->has_apb_dma || IS_VI(i2c_dev)) return 0; if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA)) { @@ -635,7 +636,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) i2c_writel(i2c_dev, val, I2C_CNFG); i2c_writel(i2c_dev, 0, I2C_INT_MASK); - if (i2c_dev->is_vi) + if (IS_VI(i2c_dev)) tegra_i2c_vi_init(i2c_dev); switch (i2c_dev->bus_clk_rate) { @@ -687,7 +688,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) return err; } - if (!IS_DVC(i2c_dev) && !i2c_dev->is_vi) { + if (!IS_DVC(i2c_dev) && !IS_VI(i2c_dev)) { u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG); sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; @@ -1612,7 +1613,9 @@ static const struct tegra_i2c_hw_feature tegra194_i2c_hw = { static const struct of_device_id tegra_i2c_of_match[] = { { .compatible = "nvidia,tegra194-i2c", .data = &tegra194_i2c_hw, }, { .compatible = "nvidia,tegra186-i2c", .data = &tegra186_i2c_hw, }, +#if IS_ENABLED(CONFIG_I2C_TEGRA_VI) { .compatible = "nvidia,tegra210-i2c-vi", .data = &tegra210_i2c_hw, }, +#endif { .compatible = "nvidia,tegra210-i2c", .data = &tegra210_i2c_hw, }, { .compatible = "nvidia,tegra124-i2c", .data = &tegra124_i2c_hw, }, { .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, }, @@ -1643,7 +1646,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev) of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) i2c_dev->is_dvc = true; - if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) + if (IS_ENABLED(CONFIG_I2C_TEGRA_VI) && + of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) i2c_dev->is_vi = true; } @@ -1656,7 +1660,7 @@ static int tegra_i2c_init_clocks(struct tegra_i2c_dev *i2c_dev) if (i2c_dev->hw == &tegra20_i2c_hw || i2c_dev->hw == &tegra30_i2c_hw) i2c_dev->clocks[i2c_dev->nclocks++].id = "fast-clk"; - if (i2c_dev->is_vi) + if (IS_VI(i2c_dev)) i2c_dev->clocks[i2c_dev->nclocks++].id = "slow"; err = devm_clk_bulk_get(i2c_dev->dev, i2c_dev->nclocks, @@ -1777,7 +1781,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) * VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't * be used for atomic transfers. */ - if (!i2c_dev->is_vi) + if (!IS_VI(i2c_dev)) pm_runtime_irq_safe(i2c_dev->dev); pm_runtime_enable(i2c_dev->dev); @@ -1850,7 +1854,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) * power ON/OFF during runtime PM resume/suspend, meaning that * controller needs to be re-initialized after power ON. */ - if (i2c_dev->is_vi) { + if (IS_VI(i2c_dev)) { err = tegra_i2c_init(i2c_dev); if (err) goto disable_clocks; -- 2.30.2