[PATCH v2 04/12] sunxi: Only initialize legacy I2C when enabled

Samuel Holland samuel at sholland.org
Fri Oct 8 07:17:17 CEST 2021


CONFIG_SPL_I2C is the wrong symbol to use here. It is the top-level
Kconfig symbol (not specific to either legacy or DM I2C), whereas the
i2c_init() function is specific to legacy I2C. This change fixes a
build failure when enabling SPL_I2C but not SPL_SYS_I2C_LEGACY.

Signed-off-by: Samuel Holland <samuel at sholland.org>
---
Actually, I think this commit raises a larger issue:

For some reason, SPL_SYS_I2C_LEGACY does not depend on SPL_I2C. When
SPL_SYS_I2C_LEGACY was added in commit 55dabcc8f245 ("Convert
CONFIG_SYS_I2C_LEGACY to Kconfig and add CONFIG_[ST]PL_SYS_I2C_LEGACY"),
SPL_I2C wasn't added to the board configs.

But since commit 537892065ac1 ("Makefile: Move drivers/i2c/ into
drivers/Makefile"), drivers/i2c is only compiled if SPL_I2C is enabled.

So the combination of these two commits appears to have accidentally
removed I2C support from SPL for many boards.

The impact here is that checking CONFIG_IS_ENABLED(SYS_I2C_LEGACY) is
not always enough, even though it should be. Because if CONFIG_SPL_I2C=n
then i2c_init is undefined because drivers/i2c/i2c_core.c is not built.

Changes in v2:
- New patch to account for I2C Kconfig changes

 arch/arm/mach-sunxi/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index d9b04f75fc4..b74ad4074df 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -339,7 +339,7 @@ void board_init_f(ulong dummy)
 	spl_init();
 	preloader_console_init();
 
-#ifdef CONFIG_SPL_I2C
+#if CONFIG_IS_ENABLED(I2C) && CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
 	/* Needed early by sunxi_board_init if PMU is enabled */
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
-- 
2.32.0



More information about the U-Boot mailing list