[PATCH 2/8] sunxi: pmic_bus: support alternative I2C address
Andre Przywara
andre.przywara at arm.com
Fri Jan 17 02:45:31 CET 2025
Some of the X-Power AXP PMICs can be ordered with an alternative I2C
address, for instance an AXP717 could be shipped with address 0x34 or
with address 0x35.
The datasheets for the AXP717 and AXP803 list two possible addresses,
and they are always consecutive. For DM (DT) based drivers this is no
problem, but the Allwinner SPL code relies on a hardcoded address.
Add a Kconfig variable that will add "1" to the existing address if it
is set.
This enables to use the AXP717 as used on boards with the new Allwinner
A523 chip.
Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
arch/arm/mach-sunxi/pmic_bus.c | 7 ++++++-
drivers/power/Kconfig | 8 ++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c
index 8e19324c8ac..f0201f76f42 100644
--- a/arch/arm/mach-sunxi/pmic_bus.c
+++ b/arch/arm/mach-sunxi/pmic_bus.c
@@ -31,6 +31,11 @@ static struct udevice *pmic;
#else
static int pmic_i2c_address(void)
{
+ int i2c_offset = 0;
+
+ if (IS_ENABLED(CONFIG_AXP_ALT_I2C_ADDR))
+ i2c_offset = 1;
+
if (IS_ENABLED(CONFIG_AXP152_POWER))
return AXP152_I2C_ADDR;
if (IS_ENABLED(CONFIG_AXP305_POWER))
@@ -38,7 +43,7 @@ static int pmic_i2c_address(void)
if (IS_ENABLED(CONFIG_AXP313_POWER))
return AXP313_I2C_ADDR;
if (IS_ENABLED(CONFIG_AXP717_POWER))
- return AXP717_I2C_ADDR;
+ return AXP717_I2C_ADDR + i2c_offset;
/* Other AXP2xx and AXP8xx variants */
return AXP209_I2C_ADDR;
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 4b81aeb7497..4c2211097fd 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -142,6 +142,14 @@ config SY8106A_POWER
endchoice
+config AXP_ALT_I2C_ADDR
+ bool "use alternative I2C address"
+ depends on AXP717_POWER
+ ---help---
+ Some PMICs can be ordered with a different I2C address (+1), to avoid
+ address clashes or accommodate two PMICs on the same bus.
+ Select this to use the secondary I2C address for the AXP PMICs.
+
config AXP_DCDC1_VOLT
int "axp pmic dcdc1 voltage"
depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
--
2.46.2
More information about the U-Boot
mailing list