Skip to content

Commit 4f5d68c

Browse files
osctobewsakernel
authored andcommitted
i2c: tegra: allow VI support to be compiled out
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 11381 292 8 11681 2da1 i2c-tegra.o (full) 10193 292 8 10493 28fd i2c-tegra.o (no-dvc) 9145 292 8 9445 24e5 i2c-tegra.o (no-vi,no-dvc) 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>
1 parent a55efa7 commit 4f5d68c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

drivers/i2c/busses/i2c-tegra.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ struct tegra_i2c_dev {
297297
};
298298

299299
#define IS_DVC(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && (dev)->is_dvc)
300+
#define IS_VI(dev) (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) && (dev)->is_vi)
300301

301302
static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val,
302303
unsigned int reg)
@@ -317,7 +318,7 @@ static u32 tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev, unsigned int reg)
317318
{
318319
if (IS_DVC(i2c_dev))
319320
reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40;
320-
else if (i2c_dev->is_vi)
321+
else if (IS_VI(i2c_dev))
321322
reg = 0xc00 + (reg << 2);
322323

323324
return reg;
@@ -330,7 +331,7 @@ static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned int reg)
330331
/* read back register to make sure that register writes completed */
331332
if (reg != I2C_TX_FIFO)
332333
readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg));
333-
else if (i2c_dev->is_vi)
334+
else if (IS_VI(i2c_dev))
334335
readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, I2C_INT_STATUS));
335336
}
336337

@@ -438,7 +439,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
438439
u32 *dma_buf;
439440
int err;
440441

441-
if (i2c_dev->is_vi)
442+
if (IS_VI(i2c_dev))
442443
return 0;
443444

444445
if (!i2c_dev->hw->has_apb_dma) {
@@ -636,7 +637,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
636637
i2c_writel(i2c_dev, val, I2C_CNFG);
637638
i2c_writel(i2c_dev, 0, I2C_INT_MASK);
638639

639-
if (i2c_dev->is_vi)
640+
if (IS_VI(i2c_dev))
640641
tegra_i2c_vi_init(i2c_dev);
641642

642643
switch (t->bus_freq_hz) {
@@ -688,7 +689,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
688689
return err;
689690
}
690691

691-
if (!IS_DVC(i2c_dev) && !i2c_dev->is_vi) {
692+
if (!IS_DVC(i2c_dev) && !IS_VI(i2c_dev)) {
692693
u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
693694

694695
sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
@@ -831,7 +832,7 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev)
831832
i2c_dev->msg_buf_remaining = buf_remaining;
832833
i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD;
833834

834-
if (i2c_dev->is_vi)
835+
if (IS_VI(i2c_dev))
835836
i2c_writesl_vi(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
836837
else
837838
i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
@@ -1627,7 +1628,9 @@ static const struct tegra_i2c_hw_feature tegra194_i2c_hw = {
16271628
static const struct of_device_id tegra_i2c_of_match[] = {
16281629
{ .compatible = "nvidia,tegra194-i2c", .data = &tegra194_i2c_hw, },
16291630
{ .compatible = "nvidia,tegra186-i2c", .data = &tegra186_i2c_hw, },
1631+
#if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC)
16301632
{ .compatible = "nvidia,tegra210-i2c-vi", .data = &tegra210_i2c_hw, },
1633+
#endif
16311634
{ .compatible = "nvidia,tegra210-i2c", .data = &tegra210_i2c_hw, },
16321635
{ .compatible = "nvidia,tegra124-i2c", .data = &tegra124_i2c_hw, },
16331636
{ .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, },
@@ -1654,7 +1657,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev)
16541657
of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc"))
16551658
i2c_dev->is_dvc = true;
16561659

1657-
if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi"))
1660+
if (IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) &&
1661+
of_device_is_compatible(np, "nvidia,tegra210-i2c-vi"))
16581662
i2c_dev->is_vi = true;
16591663
}
16601664

@@ -1683,7 +1687,7 @@ static int tegra_i2c_init_clocks(struct tegra_i2c_dev *i2c_dev)
16831687
if (i2c_dev->hw == &tegra20_i2c_hw || i2c_dev->hw == &tegra30_i2c_hw)
16841688
i2c_dev->clocks[i2c_dev->nclocks++].id = "fast-clk";
16851689

1686-
if (i2c_dev->is_vi)
1690+
if (IS_VI(i2c_dev))
16871691
i2c_dev->clocks[i2c_dev->nclocks++].id = "slow";
16881692

16891693
err = devm_clk_bulk_get(i2c_dev->dev, i2c_dev->nclocks,
@@ -1801,7 +1805,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
18011805
* VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't
18021806
* be used for atomic transfers.
18031807
*/
1804-
if (!i2c_dev->is_vi)
1808+
if (!IS_VI(i2c_dev))
18051809
pm_runtime_irq_safe(i2c_dev->dev);
18061810

18071811
pm_runtime_enable(i2c_dev->dev);
@@ -1873,7 +1877,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
18731877
* power ON/OFF during runtime PM resume/suspend, meaning that
18741878
* controller needs to be re-initialized after power ON.
18751879
*/
1876-
if (i2c_dev->is_vi) {
1880+
if (IS_VI(i2c_dev)) {
18771881
err = tegra_i2c_init(i2c_dev);
18781882
if (err)
18791883
goto disable_clocks;

0 commit comments

Comments
 (0)