Skip to content

Commit e614b14

Browse files
committed
i2c: tegra: allow VI support to be compiled out
JIRA: https://issues.redhat.com/browse/RHEL-50601 commit 4f5d68c Author: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= <mirq-linux@rere.qmqm.pl> Date: Sat, 6 May 2023 23:19:02 +0200 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> Signed-off-by: Mark Salter <msalter@redhat.com>
1 parent 7302d2b commit e614b14

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) {
@@ -637,7 +638,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
637638
i2c_writel(i2c_dev, val, I2C_CNFG);
638639
i2c_writel(i2c_dev, 0, I2C_INT_MASK);
639640

640-
if (i2c_dev->is_vi)
641+
if (IS_VI(i2c_dev))
641642
tegra_i2c_vi_init(i2c_dev);
642643

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

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

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

835-
if (i2c_dev->is_vi)
836+
if (IS_VI(i2c_dev))
836837
i2c_writesl_vi(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
837838
else
838839
i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
@@ -1628,7 +1629,9 @@ static const struct tegra_i2c_hw_feature tegra194_i2c_hw = {
16281629
static const struct of_device_id tegra_i2c_of_match[] = {
16291630
{ .compatible = "nvidia,tegra194-i2c", .data = &tegra194_i2c_hw, },
16301631
{ .compatible = "nvidia,tegra186-i2c", .data = &tegra186_i2c_hw, },
1632+
#if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC)
16311633
{ .compatible = "nvidia,tegra210-i2c-vi", .data = &tegra210_i2c_hw, },
1634+
#endif
16321635
{ .compatible = "nvidia,tegra210-i2c", .data = &tegra210_i2c_hw, },
16331636
{ .compatible = "nvidia,tegra124-i2c", .data = &tegra124_i2c_hw, },
16341637
{ .compatible = "nvidia,tegra114-i2c", .data = &tegra114_i2c_hw, },
@@ -1655,7 +1658,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev)
16551658
of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc"))
16561659
i2c_dev->is_dvc = true;
16571660

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

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

1687-
if (i2c_dev->is_vi)
1691+
if (IS_VI(i2c_dev))
16881692
i2c_dev->clocks[i2c_dev->nclocks++].id = "slow";
16891693

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

18081812
pm_runtime_enable(i2c_dev->dev);
@@ -1876,7 +1880,7 @@ static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
18761880
* power ON/OFF during runtime PM resume/suspend, meaning that
18771881
* controller needs to be re-initialized after power ON.
18781882
*/
1879-
if (i2c_dev->is_vi) {
1883+
if (IS_VI(i2c_dev)) {
18801884
err = tegra_i2c_init(i2c_dev);
18811885
if (err)
18821886
goto disable_clocks;

0 commit comments

Comments
 (0)