Convert the generic i2c PMIC init code to use the new da9063 driver. Signed-off-by: Robert Beckett <bob.beck...@collabora.com> --- board/ge/bx50v3/bx50v3.c | 81 ++++++++++--------------------------- configs/ge_bx50v3_defconfig | 3 ++ 2 files changed, 24 insertions(+), 60 deletions(-)
diff --git a/board/ge/bx50v3/bx50v3.c b/board/ge/bx50v3/bx50v3.c index aa4a3598c6..f93135c041 100644 --- a/board/ge/bx50v3/bx50v3.c +++ b/board/ge/bx50v3/bx50v3.c @@ -13,7 +13,6 @@ #include <linux/errno.h> #include <linux/libfdt.h> #include <asm/gpio.h> -#include <asm/mach-imx/mxc_i2c.h> #include <asm/mach-imx/iomux-v3.h> #include <asm/mach-imx/boot_mode.h> #include <asm/mach-imx/video.h> @@ -26,7 +25,8 @@ #include <asm/arch/crm_regs.h> #include <asm/io.h> #include <asm/arch/sys_proto.h> -#include <i2c.h> +#include <power/regulator.h> +#include <power/da9063_pmic.h> #include <input.h> #include <pwm.h> #include <version.h> @@ -460,65 +460,26 @@ static const struct boot_mode board_boot_modes[] = { void pmic_init(void) { -#define DA9063_I2C_ADDR 0x58 -#define DA9063_REG_BCORE2_CFG 0x9D -#define DA9063_REG_BCORE1_CFG 0x9E -#define DA9063_REG_BPRO_CFG 0x9F -#define DA9063_REG_BIO_CFG 0xA0 -#define DA9063_REG_BMEM_CFG 0xA1 -#define DA9063_REG_BPERI_CFG 0xA2 -#define DA9063_BUCK_MODE_MASK 0xC0 -#define DA9063_BUCK_MODE_MANUAL 0x00 -#define DA9063_BUCK_MODE_SLEEP 0x40 -#define DA9063_BUCK_MODE_SYNC 0x80 -#define DA9063_BUCK_MODE_AUTO 0xC0 - - uchar val; - struct udevice *dev, *bus; - int ret; - - // TODO: Add a da9063 DM PMIC driver and use that. - ret = uclass_get_device_by_name(UCLASS_I2C, "i2c@21a8000", &bus); - if (ret) { - printf("%s: Unable to get I2C bus: %d\n", __func__, ret); - return; - } - - ret = dm_i2c_probe(bus, DA9063_I2C_ADDR, 0, &dev); - if (ret) { - printf("%s: Unable to get PMIC device: %d\n", __func__, ret); - return; + struct udevice *reg; + int ret, i; + static const char * const bucks[] = { + "bcore1", + "bcore2", + "bpro", + "bmem", + "bio", + "bperi", + }; + + for (i = 0; i < ARRAY_SIZE(bucks); i++) { + ret = regulator_get_by_devname(bucks[i], ®); + if (reg < 0) { + printf("%s(): Unable to get regulator %s: %d\n", + __func__, bucks[i], ret); + continue; + } + regulator_set_mode(reg, DA9063_BUCKMODE_SYNC); } - - dm_i2c_read(dev, DA9063_REG_BCORE2_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BCORE2_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BCORE1_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BCORE1_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BPRO_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BPRO_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BIO_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BIO_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BMEM_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BMEM_CFG, &val, 1); - - dm_i2c_read(dev, DA9063_REG_BPERI_CFG, &val, 1); - val &= ~DA9063_BUCK_MODE_MASK; - val |= DA9063_BUCK_MODE_SYNC; - dm_i2c_write(dev, DA9063_REG_BPERI_CFG, &val, 1); } int board_late_init(void) diff --git a/configs/ge_bx50v3_defconfig b/configs/ge_bx50v3_defconfig index 8acb41c046..e9ef2de24f 100644 --- a/configs/ge_bx50v3_defconfig +++ b/configs/ge_bx50v3_defconfig @@ -61,8 +61,11 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_IMX6=y CONFIG_PWM_IMX=y CONFIG_DM_PWM=y +CONFIG_DM_PMIC=y +CONFIG_DM_PMIC_DA9063=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_DM_REGULATOR_DA9063=y CONFIG_DM_RTC=y CONFIG_RTC_RX8010SJ=y # CONFIG_REQUIRE_SERIAL_CONSOLE is not set -- 2.20.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot