sunxi: spl: support DM I2C PMIC bus
Subsystems (3)
PATCH 1/1 sunxi: spl: support DM I2C PMIC bus
sunxi_board_init() may need to configure AXP regulators before DRAM is available. The legacy I2C SPL path calls i2c_init_board() before sunxi_board_init(), which enables the TWI clock/reset and pinmux. Do the same when SPL DM I2C is enabled, but keep i2c_init() limited to the legacy I2C path.
Expose i2c_init_board() to DM I2C callers through the I2C header instead of adding a local sunxi prototype.
The AXP PMIC bus helper path used when SPL_PMIC_AXP is disabled also still used the legacy I2C accessors. Add a DM I2C path by resolving the PMIC bus and chip address from the control FDT, then using dm_i2c_read() and dm_i2c_write(). Return an error if the PMIC node is not present in the control FDT rather than guessing at the first I2C bus.
Do not cache the DM bus in static storage: this path runs before DRAM init in SPL, and SPL BSS may live in DRAM. Resolve the bus locally instead so the early PMIC path does not depend on pre-DRAM BSS.
--- arch/arm/mach-sunxi/board.c | 5 +- arch/arm/mach-sunxi/pmic_bus.c | 127 +++++++++++++++++++++++++++++++++ include/i2c.h | 3 +- 3 files changed, 133 insertions(+), 2 deletions(-)
arch/arm/mach-sunxi/board.c +4 -1
@@ -483,10 +483,13 @@ void board_init_f(ulong dummy)spl_init ();preloader_console_init (); -#if CONFIG_IS_ENABLED (I2C ) &&CONFIG_IS_ENABLED (SYS_I2C_LEGACY ) +#if CONFIG_IS_ENABLED (I2C ) && \ + (CONFIG_IS_ENABLED (SYS_I2C_LEGACY ) ||CONFIG_IS_ENABLED (DM_I2C ))/* Needed early by sunxi_board_init if PMU is enabled */ i2c_init_board (); +#if CONFIG_IS_ENABLED (SYS_I2C_LEGACY )i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +#endif #endif sunxi_board_init (); }
arch/arm/mach-sunxi/pmic_bus.c +127 -0
171 lines not on this page · raw message
include/i2c.h +2 -1
@@ -613,6 +613,8 @@ int acpi_i2c_of_to_plat(struct udevice *dev);void i2c_early_init_f (void );#endif +void i2c_init_board (void ); +#if !CONFIG_IS_ENABLED (DM_I2C )/*
@@ -700,7 +702,6 @@ struct i2c_adapter *i2c_get_adapter(int index);* repeatedly to change the speed and slave addresses. */ void i2c_init (int speed,int slaveaddr); -void i2c_init_board (void );#if CONFIG_IS_ENABLED (SYS_I2C_LEGACY )/*
Signature · 1 line
2.53.0