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

Andre Przywara andre.przywara at arm.com
Tue Oct 12 12:47:24 CEST 2021


On Fri,  8 Oct 2021 00:17:17 -0500
Samuel Holland <samuel at sholland.org> wrote:

> 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>

I don't have the brain capacity right now to comment on the issue below,
but just for the sake of this patch:

Reviewed-by: Andre Przywara <andre.przywara at arm.com>

Cheers,
Andre

> ---
> 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



More information about the U-Boot mailing list