diff options
author | Jean-Jacques Hiblot <jjhiblot@ti.com> | 2018-12-07 16:50:46 +0300 |
---|---|---|
committer | Heiko Schocher <hs@denx.de> | 2018-12-10 08:17:30 +0300 |
commit | fb1b7712ad3f375f83e74629f03236c300b0b896 (patch) | |
tree | cc21eacc979ff5f7d2f5a7c2f336a4fcb8561e75 /drivers/power/twl6030.c | |
parent | 2b30b38b269e87cbd727862a08ae99843c3ab29e (diff) | |
download | u-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/twl6030.c')
-rw-r--r-- | drivers/power/twl6030.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/power/twl6030.c b/drivers/power/twl6030.c index e0cbda1f8c..103960d48d 100644 --- a/drivers/power/twl6030.c +++ b/drivers/power/twl6030.c @@ -268,3 +268,42 @@ void twl6030_usb_device_settings() value &= ~TWL6030_MISC2_VUSB_IN_PMID; twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_MISC2, value); } + +#ifdef CONFIG_DM_I2C +int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val) +{ + struct udevice *dev; + int ret; + + ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev); + if (ret) { + pr_err("unable to get I2C bus. ret %d\n", ret); + return ret; + } + ret = dm_i2c_reg_write(dev, reg, val); + if (ret) { + pr_err("writing to twl6030 failed. ret %d\n", ret); + return ret; + } + return 0; +} + +int twl6030_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp) +{ + struct udevice *dev; + int ret; + + ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev); + if (ret) { + pr_err("unable to get I2C bus. ret %d\n", ret); + return ret; + } + ret = dm_i2c_reg_read(dev, reg); + if (ret < 0) { + pr_err("reading from twl6030 failed. ret %d\n", ret); + return ret; + } + *valp = (u8)ret; + return 0; +} +#endif |