summaryrefslogtreecommitdiff
path: root/drivers/power/pmic/pmic_tps62362.c
diff options
context:
space:
mode:
authorJean-Jacques Hiblot <jjhiblot@ti.com>2018-12-07 16:50:46 +0300
committerHeiko Schocher <hs@denx.de>2018-12-10 08:17:30 +0300
commitfb1b7712ad3f375f83e74629f03236c300b0b896 (patch)
treecc21eacc979ff5f7d2f5a7c2f336a4fcb8561e75 /drivers/power/pmic/pmic_tps62362.c
parent2b30b38b269e87cbd727862a08ae99843c3ab29e (diff)
downloadu-boot-fb1b7712ad3f375f83e74629f03236c300b0b896.tar.xz
power: make most tps drivers and the twl4030 driver compatible with DM_I2C
Those driver are not DM drivers per se (not using the PMIC/regulator framework) and are using the legacy I2C API. Make them compatible with the DM_I2C API. This impacts the following drivers: - palmas (used by am57xx/dra7xx evms) - tps65218 (used by am43xx evms) - tps65217 and tps65910 (used by am335x evms and am335x boneblack vboot) - twl4030 (used by omap3_logicpd) - tps65217 (used by brppt1) - twl6030 Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/power/pmic/pmic_tps62362.c')
-rw-r--r--drivers/power/pmic/pmic_tps62362.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/power/pmic/pmic_tps62362.c b/drivers/power/pmic/pmic_tps62362.c
index f2987de48e..c3977fccc3 100644
--- a/drivers/power/pmic/pmic_tps62362.c
+++ b/drivers/power/pmic/pmic_tps62362.c
@@ -10,6 +10,10 @@
#include <power/pmic.h>
#include <power/tps62362.h>
+#ifdef CONFIG_DM_I2C
+struct udevice *tps62362_dev __attribute__((section(".data"))) = NULL;
+#endif
+
/**
* tps62362_voltage_update() - Function to change a voltage level, as this
* is a multi-step process.
@@ -22,9 +26,16 @@ int tps62362_voltage_update(unsigned char reg, unsigned char volt_sel)
if (reg > TPS62362_NUM_REGS)
return 1;
+#ifndef CONFIG_DM_I2C
return i2c_write(TPS62362_I2C_ADDR, reg, 1, &volt_sel, 1);
+#else
+ if (!tps62362_dev)
+ return -ENODEV;
+ return dm_i2c_reg_write(tps62362_dev, reg, volt_sel);
+#endif
}
+#ifndef CONFIG_DM_I2C
int power_tps62362_init(unsigned char bus)
{
static const char name[] = "TPS62362";
@@ -44,3 +55,16 @@ int power_tps62362_init(unsigned char bus)
return 0;
}
+#else
+int power_tps62362_init(unsigned char bus)
+{
+ struct udevice *dev = NULL;
+ int rc;
+
+ rc = i2c_get_chip_for_busnum(bus, TPS62362_I2C_ADDR, 1, &dev);
+ if (rc)
+ return rc;
+ tps62362_dev = dev;
+ return 0;
+}
+#endif