Skip to content

Commit 7302d2b

Browse files
committed
i2c: tegra: allow DVC support to be compiled out
JIRA: https://issues.redhat.com/browse/RHEL-50601 commit a55efa7 Author: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= <mirq-linux@rere.qmqm.pl> Date: Sat, 6 May 2023 23:19:01 +0200 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 - 11381 292 8 11681 2da1 i2c-tegra.o + 10193 292 8 10493 28fd i2c-tegra.o Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Wolfram Sang <wsa@kernel.org> Signed-off-by: Mark Salter <msalter@redhat.com>
1 parent 0acbeb2 commit 7302d2b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/i2c/busses/i2c-tegra.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ struct tegra_i2c_dev {
296296
bool is_vi;
297297
};
298298

299+
#define IS_DVC(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && (dev)->is_dvc)
300+
299301
static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val,
300302
unsigned int reg)
301303
{
@@ -313,7 +315,7 @@ static u32 dvc_readl(struct tegra_i2c_dev *i2c_dev, unsigned int reg)
313315
*/
314316
static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int reg)
315317
{
316-
if (i2c_dev->is_dvc)
318+
if (IS_DVC(i2c_dev))
317319
reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40;
318320
else if (i2c_dev->is_vi)
319321
reg = 0xc00 + (reg << 2);
@@ -623,7 +625,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
623625

624626
WARN_ON_ONCE(err);
625627

626-
if (i2c_dev->is_dvc)
628+
if (IS_DVC(i2c_dev))
627629
tegra_dvc_init(i2c_dev);
628630

629631
val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN |
@@ -687,7 +689,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
687689
return err;
688690
}
689691

690-
if (!i2c_dev->is_dvc && !i2c_dev->is_vi) {
692+
if (!IS_DVC(i2c_dev) && !i2c_dev->is_vi) {
691693
u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
692694

693695
sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
@@ -917,7 +919,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
917919
}
918920

919921
i2c_writel(i2c_dev, status, I2C_INT_STATUS);
920-
if (i2c_dev->is_dvc)
922+
if (IS_DVC(i2c_dev))
921923
dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
922924

923925
/*
@@ -956,7 +958,7 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
956958

957959
i2c_writel(i2c_dev, status, I2C_INT_STATUS);
958960

959-
if (i2c_dev->is_dvc)
961+
if (IS_DVC(i2c_dev))
960962
dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
961963

962964
if (i2c_dev->dma_mode) {
@@ -1632,7 +1634,9 @@ static const struct of_device_id tegra_i2c_of_match[] = {
16321634
{ .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, },
16331635
{ .compatible = "nvidia,tegra30-i2c", .data = &tegra30_i2c_hw, },
16341636
{ .compatible = "nvidia,tegra20-i2c", .data = &tegra20_i2c_hw, },
1637+
#if IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC)
16351638
{ .compatible = "nvidia,tegra20-i2c-dvc", .data = &tegra20_i2c_hw, },
1639+
#endif
16361640
{},
16371641
};
16381642
MODULE_DEVICE_TABLE(of, tegra_i2c_of_match);
@@ -1647,7 +1651,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev)
16471651
multi_mode = device_property_read_bool(i2c_dev->dev, "multi-master");
16481652
i2c_dev->multimaster_mode = multi_mode;
16491653

1650-
if (of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc"))
1654+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
1655+
of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc"))
16511656
i2c_dev->is_dvc = true;
16521657

16531658
if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi"))

0 commit comments

Comments
 (0)