From nobody Tue Jun 30 10:57:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16905C433F5 for ; Tue, 18 Jan 2022 20:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349020AbiARUAM (ORCPT ); Tue, 18 Jan 2022 15:00:12 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:56546 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348963AbiARUAH (ORCPT ); Tue, 18 Jan 2022 15:00:07 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Jdfks4PZxz9j; Tue, 18 Jan 2022 21:00:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1642536005; bh=H6E7bG7YJrXsY/7wmkDfz/7IsC41zhil28AHTN5V508=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=GGo2KTkMD8qSCh1tZ0Q4bTHemnxccXjLuBphOwN+QW4ZrS98r73JvE6nW6e2FA+gJ xIVeK40yPeb0Gqyu34UdsmGQM72qJhsG1qRY94vCshBf2Xixgha4O96YTIRxO8hygk cjzhmLkdtCY811CMJWsjQ0S7GBI50ng84WwRRJ37P2/YcthLJ7QJR1hoTE0UDNhAof EGX/YFEvedIxiWsL9OpgaytWgUcHJpGIaANN+C/jRkZvgfGweQJKYg0RoSYGtk972w 13Qla0HMGUhloiazQh9DZ7rOpJu97iamgasl2ier0zKG61p+aPSR3tqxiWYaJXQOem b21Uccq0Lv+nQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.4 at mail Date: Tue, 18 Jan 2022 21:00:05 +0100 Message-Id: In-Reply-To: References: Subject: [PATCH v2 1/2] i2c: tegra: allow DVC support to be compiled out MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Laxman Dewangan , Dmitry Osipenko , Thierry Reding , Jonathan Hunter Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Save a bit of code for newer Tegra platforms by compiling out DVC's I2C mode support that's used only for Tegra2. $ size i2c-tegra.o text data bss dec hex filename - 10385 240 8 10633 2989 i2c-tegra.o + 9617 240 8 9865 2689 i2c-tegra.o Reviewed-by: Dmitry Osipenko --- v2: remove KConfig symbol as per Dmitry Osipenko's suggestion. (Assuming that for Tegra20 the DVC part will be used anyway.) Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/i2c/busses/i2c-tegra.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index b3184c422826..96bfe7013d85 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -294,6 +294,8 @@ struct tegra_i2c_dev { bool is_vi; }; =20 +#define IS_DVC(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && dev->is_dvc) + static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned int reg) { @@ -311,7 +313,7 @@ static u32 dvc_readl(struct tegra_i2c_dev *i2c_dev, uns= igned int reg) */ static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int = reg) { - if (i2c_dev->is_dvc) + if (IS_DVC(i2c_dev)) reg +=3D (reg >=3D I2C_TX_FIFO) ? 0x10 : 0x40; else if (i2c_dev->is_vi) reg =3D 0xc00 + (reg << 2); @@ -621,7 +623,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) err =3D reset_control_reset(i2c_dev->rst); WARN_ON_ONCE(err); =20 - if (i2c_dev->is_dvc) + if (IS_DVC(i2c_dev)) tegra_dvc_init(i2c_dev); =20 val =3D I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN | @@ -685,7 +687,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) return err; } =20 - if (!i2c_dev->is_dvc && !i2c_dev->is_vi) { + if (!IS_DVC(i2c_dev) && !i2c_dev->is_vi) { u32 sl_cfg =3D i2c_readl(i2c_dev, I2C_SL_CNFG); =20 sl_cfg |=3D I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; @@ -915,7 +917,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) } =20 i2c_writel(i2c_dev, status, I2C_INT_STATUS); - if (i2c_dev->is_dvc) + if (IS_DVC(i2c_dev)) dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); =20 /* @@ -954,7 +956,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) =20 i2c_writel(i2c_dev, status, I2C_INT_STATUS); =20 - if (i2c_dev->is_dvc) + if (IS_DVC(i2c_dev)) dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); =20 if (i2c_dev->dma_mode) { @@ -1616,7 +1618,9 @@ static const struct of_device_id tegra_i2c_of_match[]= =3D { { .compatible =3D "nvidia,tegra114-i2c", .data =3D &tegra114_i2c_hw, }, { .compatible =3D "nvidia,tegra30-i2c", .data =3D &tegra30_i2c_hw, }, { .compatible =3D "nvidia,tegra20-i2c", .data =3D &tegra20_i2c_hw, }, +#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) { .compatible =3D "nvidia,tegra20-i2c-dvc", .data =3D &tegra20_i2c_hw, }, +#endif {}, }; MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); @@ -1635,7 +1639,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *= i2c_dev) multi_mode =3D of_property_read_bool(np, "multi-master"); i2c_dev->multimaster_mode =3D multi_mode; =20 - if (of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) + if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && + of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) i2c_dev->is_dvc =3D true; =20 if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) --=20 2.30.2 From nobody Tue Jun 30 10:57:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0949C433EF for ; Tue, 18 Jan 2022 20:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349021AbiARUAO (ORCPT ); Tue, 18 Jan 2022 15:00:14 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:51039 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348976AbiARUAH (ORCPT ); Tue, 18 Jan 2022 15:00:07 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Jdfkt03XJzK5; Tue, 18 Jan 2022 21:00:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1642536006; bh=1NsUG/BObcKgzkj5/bYLxmNDT9t3TKYn2+OPiCW/G7s=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=LU8M68+rcfJtDvyGrCu+EOKWLIGmIuYHu4kGlZHPtlcEq5dd66Fo3UIhpIJNPVOwc XaTd0JRBnEQHdCN5osd+Kcfep8kII5hOKyqcU9MMWdKp2uVKdbWk3vOJA0v03aC8zD wPDoNjaTiKaGaGtPDx/PCzjt43OAxmG0cuU/FF+YJI/fFP6XgYgJX3iP8xayyONFCa vPdSWgKVCtwKysFCFDjf8BbaQBKpk5qMrqYbYXdP3Fb2Tq+OjQGBqHMovJ5YyBEga9 nmkSCXapnivw4BzffbualDXm0CywOCrRZdxQU7ossqtflB+c5sv+ZTn/AccDDquCvK kmvmMNAyKUvEQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.4 at mail Date: Tue, 18 Jan 2022 21:00:05 +0100 Message-Id: In-Reply-To: References: Subject: [PATCH v2 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: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Laxman Dewangan , Dmitry Osipenko , Thierry Reding , Jonathan Hunter Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@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) --- v2: remove KConfig symbol as per Dmitry Osipenko's suggestion. (Assuming that for Tegra210 the VI part will be used anyway.) Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/i2c/busses/i2c-tegra.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 96bfe7013d85..6ced964c83b2 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -295,6 +295,7 @@ struct tegra_i2c_dev { }; =20 #define IS_DVC(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && dev->is_dvc) +#define IS_VI(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) && dev->is_vi) =20 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 +=3D (reg >=3D I2C_TX_FIFO) ? 0x10 : 0x40; - else if (i2c_dev->is_vi) + else if (IS_VI(i2c_dev)) reg =3D 0xc00 + (reg << 2); =20 return reg; @@ -444,7 +445,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c= _dev) u32 *dma_buf; int err; =20 - if (!i2c_dev->hw->has_apb_dma || i2c_dev->is_vi) + if (!i2c_dev->hw->has_apb_dma || IS_VI(i2c_dev)) return 0; =20 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); =20 - if (i2c_dev->is_vi) + if (IS_VI(i2c_dev)) tegra_i2c_vi_init(i2c_dev); =20 switch (i2c_dev->bus_clk_rate) { @@ -687,7 +688,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) return err; } =20 - if (!IS_DVC(i2c_dev) && !i2c_dev->is_vi) { + if (!IS_DVC(i2c_dev) && !IS_VI(i2c_dev)) { u32 sl_cfg =3D i2c_readl(i2c_dev, I2C_SL_CNFG); =20 sl_cfg |=3D I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; @@ -1612,7 +1613,9 @@ static const struct tegra_i2c_hw_feature tegra194_i2c= _hw =3D { static const struct of_device_id tegra_i2c_of_match[] =3D { { .compatible =3D "nvidia,tegra194-i2c", .data =3D &tegra194_i2c_hw, }, { .compatible =3D "nvidia,tegra186-i2c", .data =3D &tegra186_i2c_hw, }, +#if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) { .compatible =3D "nvidia,tegra210-i2c-vi", .data =3D &tegra210_i2c_hw, }, +#endif { .compatible =3D "nvidia,tegra210-i2c", .data =3D &tegra210_i2c_hw, }, { .compatible =3D "nvidia,tegra124-i2c", .data =3D &tegra124_i2c_hw, }, { .compatible =3D "nvidia,tegra114-i2c", .data =3D &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 =3D true; =20 - if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) + if (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) && + of_device_is_compatible(np, "nvidia,tegra210-i2c-vi")) i2c_dev->is_vi =3D true; } =20 @@ -1656,7 +1660,7 @@ static int tegra_i2c_init_clocks(struct tegra_i2c_dev= *i2c_dev) if (i2c_dev->hw =3D=3D &tegra20_i2c_hw || i2c_dev->hw =3D=3D &tegra30_i2c= _hw) i2c_dev->clocks[i2c_dev->nclocks++].id =3D "fast-clk"; =20 - if (i2c_dev->is_vi) + if (IS_VI(i2c_dev)) i2c_dev->clocks[i2c_dev->nclocks++].id =3D "slow"; =20 err =3D devm_clk_bulk_get(i2c_dev->dev, i2c_dev->nclocks, @@ -1777,7 +1781,7 @@ static int tegra_i2c_probe(struct platform_device *pd= ev) * 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); =20 pm_runtime_enable(i2c_dev->dev); @@ -1850,7 +1854,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(st= ruct 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 =3D tegra_i2c_init(i2c_dev); if (err) goto disable_clocks; --=20 2.30.2