diff options
author | Jaehoon Chung <jh80.chung@samsung.com> | 2017-01-09 14:47:50 +0900 |
---|---|---|
committer | Minkyu Kang <mk7.kang@samsung.com> | 2017-01-18 13:25:56 +0900 |
commit | 816d8b500814b26df318d724628f6b88da9aadbf (patch) | |
tree | 58e1009a5c8bb80c0fe42367a6c72ffbb9c86e35 /board/samsung/universal_c210 | |
parent | 3c385dceca445563ffc58888e25c8576770590b0 (diff) |
board: samsung: universal_210: use the driver model for max8998
Revmoe the "ifndef CONFIG_DM_I2C".
Intead, use the driver model for max8998.
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Diffstat (limited to 'board/samsung/universal_c210')
-rw-r--r-- | board/samsung/universal_c210/universal.c | 169 |
1 files changed, 94 insertions, 75 deletions
diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c index c3946ee891..0645843934 100644 --- a/board/samsung/universal_c210/universal.c +++ b/board/samsung/universal_c210/universal.c @@ -27,33 +27,21 @@ DECLARE_GLOBAL_DATA_PTR; unsigned int board_rev; +static int init_pmic_lcd(void); u32 get_board_rev(void) { return board_rev; } -static int get_hwrev(void) +int exynos_power_init(void) { - return board_rev & 0xFF; + return init_pmic_lcd(); } -int exynos_power_init(void) +static int get_hwrev(void) { -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ - int ret; - - /* - * For PMIC the I2C bus is named as I2C5, but it is connected - * to logical I2C adapter 0 - */ - ret = pmic_init(I2C_0); - if (ret) - return ret; - - init_pmic_lcd(); -#endif - return 0; + return board_rev & 0xFF; } static unsigned short get_adc_value(int channel) @@ -83,23 +71,29 @@ static unsigned short get_adc_value(int channel) static int adc_power_control(int on) { -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ + struct udevice *dev; int ret; - struct pmic *p = pmic_get("MAX8998_PMIC"); - if (!p) - return -ENODEV; + u8 reg; - if (pmic_probe(p)) - return -1; + ret = pmic_get("max8998-pmic", &dev); + if (ret) { + puts("Failed to get MAX8998!\n"); + return ret; + } - ret = pmic_set_output(p, - MAX8998_REG_ONOFF1, - MAX8998_LDO4, !!on); + reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); + if (on) + reg |= MAX8998_LDO4; + else + reg &= ~MAX8998_LDO4; + + ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); + if (ret) { + puts("MAX8998 LDO setting error\n"); + return -EINVAL; + } - return ret; -#else return 0; -#endif } static unsigned int get_hw_revision(void) @@ -147,39 +141,50 @@ static void check_hw_revision(void) #ifdef CONFIG_USB_GADGET static int s5pc210_phy_control(int on) { -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ - int ret = 0; - struct pmic *p = pmic_get("MAX8998_PMIC"); - if (!p) - return -ENODEV; + struct udevice *dev; + int ret; + u8 reg; - if (pmic_probe(p)) - return -1; + ret = pmic_get("max8998-pmic", &dev); + if (ret) { + puts("Failed to get MAX8998!\n"); + return ret; + } if (on) { - ret |= pmic_set_output(p, - MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, - MAX8998_SAFEOUT1, LDO_ON); - ret |= pmic_set_output(p, MAX8998_REG_ONOFF1, - MAX8998_LDO3, LDO_ON); - ret |= pmic_set_output(p, MAX8998_REG_ONOFF2, - MAX8998_LDO8, LDO_ON); + reg = pmic_reg_read(dev, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3); + reg |= MAX8998_SAFEOUT1; + ret |= pmic_reg_write(dev, + MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg); + + reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); + reg |= MAX8998_LDO3; + ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); + + reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); + reg |= MAX8998_LDO8; + ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); } else { - ret |= pmic_set_output(p, MAX8998_REG_ONOFF2, - MAX8998_LDO8, LDO_OFF); - ret |= pmic_set_output(p, MAX8998_REG_ONOFF1, - MAX8998_LDO3, LDO_OFF); - ret |= pmic_set_output(p, - MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, - MAX8998_SAFEOUT1, LDO_OFF); + reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); + reg &= ~MAX8998_LDO8; + ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); + + reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); + reg &= ~MAX8998_LDO3; + ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); + + reg = pmic_reg_read(dev, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3); + reg &= ~MAX8998_SAFEOUT1; + ret |= pmic_reg_write(dev, + MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg); } if (ret) { puts("MAX8998 LDO setting error!\n"); - return -1; + return -EINVAL; } -#endif + return 0; } @@ -205,27 +210,25 @@ int exynos_early_init_f(void) return 0; } -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ -static void init_pmic_lcd(void) +static int init_pmic_lcd(void) { + struct udevice *dev; unsigned char val; int ret = 0; - struct pmic *p = pmic_get("MAX8998_PMIC"); - - if (!p) - return; - - if (pmic_probe(p)) - return; + ret = pmic_get("max8998-pmic", &dev); + if (ret) { + puts("Failed to get MAX8998 for init_pmic_lcd()!\n"); + return ret; + } /* LDO7 1.8V */ val = 0x02; /* (1800 - 1600) / 100; */ - ret |= pmic_reg_write(p, MAX8998_REG_LDO7, val); + ret |= pmic_reg_write(dev, MAX8998_REG_LDO7, val); /* LDO17 3.0V */ val = 0xe; /* (3000 - 1600) / 100; */ - ret |= pmic_reg_write(p, MAX8998_REG_LDO17, val); + ret |= pmic_reg_write(dev, MAX8998_REG_LDO17, val); /* Disable unneeded regulators */ /* @@ -234,26 +237,29 @@ static void init_pmic_lcd(void) * LDO2 ON, LDO3 OFF, LDO4 OFF, LDO5 ON */ val = 0xB9; - ret |= pmic_reg_write(p, MAX8998_REG_ONOFF1, val); + ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, val); /* ONOFF2 * LDO6 OFF, LDO7 ON, LDO8 OFF, LDO9 ON, * LDO10 OFF, LDO11 OFF, LDO12 OFF, LDO13 OFF */ val = 0x50; - ret |= pmic_reg_write(p, MAX8998_REG_ONOFF2, val); + ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, val); /* ONOFF3 * LDO14 OFF, LDO15 OFF, LGO16 OFF, LDO17 OFF * EPWRHOLD OFF, EBATTMON OFF, ELBCNFG2 OFF, ELBCNFG1 OFF */ val = 0x00; - ret |= pmic_reg_write(p, MAX8998_REG_ONOFF3, val); + ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF3, val); - if (ret) + if (ret) { puts("LCD pmic initialisation error!\n"); + return -EINVAL; + } + + return 0; } -#endif void exynos_cfg_lcd_gpio(void) { @@ -310,18 +316,31 @@ void exynos_reset_lcd(void) void exynos_lcd_power_on(void) { -#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ - struct pmic *p = pmic_get("MAX8998_PMIC"); + struct udevice *dev; + int ret; + u8 reg; - if (!p) + ret = pmic_get("max8998-pmic", &dev); + if (ret) { + puts("Failed to get MAX8998!\n"); return; + } - if (pmic_probe(p)) + reg = pmic_reg_read(dev, MAX8998_REG_ONOFF3); + reg |= MAX8998_LDO17; + ret = pmic_reg_write(dev, MAX8998_REG_ONOFF3, reg); + if (ret) { + puts("MAX8998 LDO setting error\n"); return; + } - pmic_set_output(p, MAX8998_REG_ONOFF3, MAX8998_LDO17, LDO_ON); - pmic_set_output(p, MAX8998_REG_ONOFF2, MAX8998_LDO7, LDO_ON); -#endif + reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); + reg |= MAX8998_LDO7; + ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); + if (ret) { + puts("MAX8998 LDO setting error\n"); + return; + } } void exynos_cfg_ldo(void) |