diff options
author | Ćukasz Majewski <l.majewski@samsung.com> | 2012-11-13 03:21:55 +0000 |
---|---|---|
committer | Anatolij Gustschin <agust@denx.de> | 2012-11-14 11:21:09 +0100 |
commit | c7336815078ff3745e3130aeff35991e3e98e61e (patch) | |
tree | 8ace1a85705cbd5b6484a45fefd093161a7a5b05 /board | |
parent | 452329f1d57fe7cbc54e65617e84d5bb1f93f631 (diff) | |
download | u-boot-imx-c7336815078ff3745e3130aeff35991e3e98e61e.zip u-boot-imx-c7336815078ff3745e3130aeff35991e3e98e61e.tar.gz u-boot-imx-c7336815078ff3745e3130aeff35991e3e98e61e.tar.bz2 |
pmic: Extend PMIC framework to support multiple instances of PMIC devices
The PMIC framework has been extended to support multiple instances of
the variety of devices responsible for power management.
This change allows supporting of e.g. fuel gauge, charger, MUIC (Micro USB
Interface Circuit).
Power related includes have been moved to ./include/power directory.
This is a first of a series of patches - in the future "pmic" will be
replaced with "power".
Two important issues:
1. The PMIC needs to be initialized just after malloc is configured
2. It uses list to hold information about available PMIC devices
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'board')
-rw-r--r-- | board/davedenx/qong/qong.c | 12 | ||||
-rw-r--r-- | board/freescale/mx31pdk/mx31pdk.c | 12 | ||||
-rw-r--r-- | board/freescale/mx35pdk/mx35pdk.c | 14 | ||||
-rw-r--r-- | board/freescale/mx51evk/mx51evk.c | 12 | ||||
-rw-r--r-- | board/freescale/mx53evk/mx53evk.c | 12 | ||||
-rw-r--r-- | board/freescale/mx53loco/mx53loco.c | 21 | ||||
-rw-r--r-- | board/genesi/mx51_efikamx/efikamx.c | 12 | ||||
-rw-r--r-- | board/hale/tt01/tt01.c | 14 | ||||
-rw-r--r-- | board/samsung/goni/goni.c | 11 | ||||
-rw-r--r-- | board/samsung/trats/trats.c | 18 | ||||
-rw-r--r-- | board/samsung/universal_c210/universal.c | 14 | ||||
-rw-r--r-- | board/ttcontrol/vision2/vision2.c | 12 |
12 files changed, 119 insertions, 45 deletions
diff --git a/board/davedenx/qong/qong.c b/board/davedenx/qong/qong.c index c41f11d..a3079db 100644 --- a/board/davedenx/qong/qong.c +++ b/board/davedenx/qong/qong.c @@ -28,11 +28,12 @@ #include <asm/arch/sys_proto.h> #include <asm/io.h> #include <nand.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_pmic.h> #include <asm/gpio.h> #include "qong_fpga.h" #include <watchdog.h> +#include <errno.h> DECLARE_GLOBAL_DATA_PTR; @@ -172,10 +173,15 @@ int board_late_init(void) { u32 val; struct pmic *p; + int ret; - pmic_init(); - p = get_pmic(); + ret = pmic_init(I2C_PMIC); + if (ret) + return ret; + p = pmic_get("FSL_PMIC"); + if (!p) + return -ENODEV; /* Enable RTC battery */ pmic_reg_read(p, REG_POWER_CTL0, &val); pmic_reg_write(p, REG_POWER_CTL0, val | COINCHEN); diff --git a/board/freescale/mx31pdk/mx31pdk.c b/board/freescale/mx31pdk/mx31pdk.c index 9f8bc53..bc60632 100644 --- a/board/freescale/mx31pdk/mx31pdk.c +++ b/board/freescale/mx31pdk/mx31pdk.c @@ -30,8 +30,9 @@ #include <asm/arch/imx-regs.h> #include <asm/arch/sys_proto.h> #include <watchdog.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_pmic.h> +#include <errno.h> DECLARE_GLOBAL_DATA_PTR; @@ -83,10 +84,15 @@ int board_late_init(void) { u32 val; struct pmic *p; + int ret; - pmic_init(); - p = get_pmic(); + ret = pmic_init(I2C_PMIC); + if (ret) + return ret; + p = pmic_get("FSL_PMIC"); + if (!p) + return -ENODEV; /* Enable RTC battery */ pmic_reg_read(p, REG_POWER_CTL0, &val); pmic_reg_write(p, REG_POWER_CTL0, val | COINCHEN); diff --git a/board/freescale/mx35pdk/mx35pdk.c b/board/freescale/mx35pdk/mx35pdk.c index a12531f..c835b0e 100644 --- a/board/freescale/mx35pdk/mx35pdk.c +++ b/board/freescale/mx35pdk/mx35pdk.c @@ -31,7 +31,7 @@ #include <asm/arch/mx35_pins.h> #include <asm/arch/iomux.h> #include <i2c.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_pmic.h> #include <mmc.h> #include <fsl_esdhc.h> @@ -207,7 +207,9 @@ int board_init(void) static inline int pmic_detect(void) { unsigned int id; - struct pmic *p = get_pmic(); + struct pmic *p = pmic_get("FSL_PMIC"); + if (!p) + return -ENODEV; pmic_reg_read(p, REG_IDENTIFICATION, &id); @@ -231,10 +233,14 @@ int board_late_init(void) u8 val; u32 pmic_val; struct pmic *p; + int ret; + + ret = pmic_init(I2C_PMIC); + if (ret) + return ret; - pmic_init(); if (pmic_detect()) { - p = get_pmic(); + p = pmic_get("FSL_PMIC"); mxc_request_iomux(MX35_PIN_WATCHDOG_RST, MUX_CONFIG_SION | MUX_CONFIG_ALT1); diff --git a/board/freescale/mx51evk/mx51evk.c b/board/freescale/mx51evk/mx51evk.c index 421d8c2..5504636 100644 --- a/board/freescale/mx51evk/mx51evk.c +++ b/board/freescale/mx51evk/mx51evk.c @@ -33,7 +33,7 @@ #include <i2c.h> #include <mmc.h> #include <fsl_esdhc.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_pmic.h> #include <mc13892.h> #include <usb/ehci-fsl.h> @@ -252,9 +252,15 @@ static void power_init(void) unsigned int val; struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE; struct pmic *p; + int ret; + + ret = pmic_init(I2C_PMIC); + if (ret) + return; - pmic_init(); - p = get_pmic(); + p = pmic_get("FSL_PMIC"); + if (!p) + return; /* Write needed to Power Gate 2 register */ pmic_reg_read(p, REG_POWER_MISC, &val); diff --git a/board/freescale/mx53evk/mx53evk.c b/board/freescale/mx53evk/mx53evk.c index bb4621d..1273501 100644 --- a/board/freescale/mx53evk/mx53evk.c +++ b/board/freescale/mx53evk/mx53evk.c @@ -34,7 +34,7 @@ #include <i2c.h> #include <mmc.h> #include <fsl_esdhc.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_pmic.h> #include <asm/gpio.h> #include <mc13892.h> @@ -123,9 +123,15 @@ void power_init(void) { unsigned int val; struct pmic *p; + int ret; + + ret = pmic_init(I2C_PMIC); + if (ret) + return; - pmic_init(); - p = get_pmic(); + p = pmic_get("FSL_PMIC"); + if (!p) + return; /* Set VDDA to 1.25V */ pmic_reg_read(p, REG_SW_2, &val); diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c index a11e883..f4a9b08 100644 --- a/board/freescale/mx53loco/mx53loco.c +++ b/board/freescale/mx53loco/mx53loco.c @@ -36,7 +36,7 @@ #include <mmc.h> #include <fsl_esdhc.h> #include <asm/gpio.h> -#include <pmic.h> +#include <power/pmic.h> #include <dialog_pmic.h> #include <fsl_pmic.h> #include <linux/fb.h> @@ -344,10 +344,16 @@ static int power_init(void) unsigned int val; int ret = -1; struct pmic *p; + int retval; if (!i2c_probe(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR)) { - pmic_dialog_init(); - p = get_pmic(); + retval = pmic_dialog_init(I2C_PMIC); + if (retval) + return retval; + + p = pmic_get("DIALOG_PMIC"); + if (!p) + return -ENODEV; /* Set VDDA to 1.25V */ val = DA9052_BUCKCORE_BCOREEN | DA_BUCKCORE_VBCORE_1_250V; @@ -363,8 +369,13 @@ static int power_init(void) } if (!i2c_probe(CONFIG_SYS_FSL_PMIC_I2C_ADDR)) { - pmic_init(); - p = get_pmic(); + retval = pmic_init(I2C_PMIC); + if (retval) + return retval; + + p = pmic_get("DIALOG_PMIC"); + if (!p) + return -ENODEV; /* Set VDDGP to 1.25V for 1GHz on SW1 */ pmic_reg_read(p, REG_SW_0, &val); diff --git a/board/genesi/mx51_efikamx/efikamx.c b/board/genesi/mx51_efikamx/efikamx.c index c2b2823..69d41db 100644 --- a/board/genesi/mx51_efikamx/efikamx.c +++ b/board/genesi/mx51_efikamx/efikamx.c @@ -33,7 +33,7 @@ #include <i2c.h> #include <mmc.h> #include <fsl_esdhc.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_pmic.h> #include <mc13892.h> @@ -173,9 +173,15 @@ static void power_init(void) unsigned int val; struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE; struct pmic *p; + int ret; + + ret = pmic_init(I2C_PMIC); + if (ret) + return; - pmic_init(); - p = get_pmic(); + p = pmic_get("FSL_PMIC"); + if (!p) + return; /* Write needed to Power Gate 2 register */ pmic_reg_read(p, REG_POWER_MISC, &val); diff --git a/board/hale/tt01/tt01.c b/board/hale/tt01/tt01.c index 143fcef..0c2cb79 100644 --- a/board/hale/tt01/tt01.c +++ b/board/hale/tt01/tt01.c @@ -25,12 +25,13 @@ #include <common.h> #include <netdev.h> #include <command.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_pmic.h> #include <mc13783.h> #include <asm/arch/clock.h> #include <asm/arch/sys_proto.h> #include <asm/io.h> +#include <errno.h> DECLARE_GLOBAL_DATA_PTR; @@ -195,14 +196,21 @@ int board_mmc_init(bd_t *bis) { u32 val; struct pmic *p; + int ret; /* * this is the first driver to use the pmic, so call * pmic_init() here. board_late_init() is too late for * the MMC driver. */ - pmic_init(); - p = get_pmic(); + + ret = pmic_init(I2C_PMIC); + if (ret) + return ret; + + p = pmic_get("FSL_PMIC"); + if (!p) + return -ENODEV; /* configure pins for SDHC1 only */ mx31_gpio_mux(IOMUX_MODE(MUX_CTL_SD1_CLK, MUX_CTL_FUNC)); diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c index e8fb1ea..71ed618 100644 --- a/board/samsung/goni/goni.c +++ b/board/samsung/goni/goni.c @@ -25,10 +25,10 @@ #include <common.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> -#include <pmic.h> +#include <power/pmic.h> #include <usb/s3c_udc.h> #include <asm/arch/cpu.h> -#include <max8998_pmic.h> +#include <power/max8998_pmic.h> DECLARE_GLOBAL_DATA_PTR; static struct s5pc110_gpio *s5pc110_gpio; @@ -42,8 +42,9 @@ int board_init(void) gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; #if defined(CONFIG_PMIC) - pmic_init(); + pmic_init(I2C_5); #endif + return 0; } @@ -108,7 +109,9 @@ static int s5pc1xx_phy_control(int on) { int ret; static int status; - struct pmic *p = get_pmic(); + struct pmic *p = pmic_get("MAX8998_PMIC"); + if (!p) + return -ENODEV; if (pmic_probe(p)) return -1; diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c index e11a892..e0a9890 100644 --- a/board/samsung/trats/trats.c +++ b/board/samsung/trats/trats.c @@ -34,9 +34,9 @@ #include <asm/arch/mipi_dsim.h> #include <asm/arch/watchdog.h> #include <asm/arch/power.h> -#include <pmic.h> +#include <power/pmic.h> #include <usb/s3c_udc.h> -#include <max8997_pmic.h> +#include <power/max8997_pmic.h> #include <libtizen.h> #include "setup.h" @@ -69,7 +69,7 @@ int board_init(void) printf("HW Revision:\t0x%x\n", board_rev); #if defined(CONFIG_PMIC) - pmic_init(); + pmic_init(I2C_5); #endif return 0; @@ -238,7 +238,9 @@ static int s5pc210_phy_control(int on) { int ret = 0; u32 val = 0; - struct pmic *p = get_pmic(); + struct pmic *p = pmic_get("MAX8997_PMIC"); + if (!p) + return -ENODEV; if (pmic_probe(p)) return -1; @@ -413,7 +415,9 @@ static void lcd_reset(void) static int lcd_power(void) { int ret = 0; - struct pmic *p = get_pmic(); + struct pmic *p = pmic_get("MAX8997_PMIC"); + if (!p) + return -ENODEV; if (pmic_probe(p)) return 0; @@ -473,7 +477,9 @@ static struct mipi_dsim_lcd_device mipi_lcd_device = { static int mipi_power(void) { int ret = 0; - struct pmic *p = get_pmic(); + struct pmic *p = pmic_get("MAX8997_PMIC"); + if (!p) + return -ENODEV; if (pmic_probe(p)) return 0; diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c index 90fff5c..c4950dd 100644 --- a/board/samsung/universal_c210/universal.c +++ b/board/samsung/universal_c210/universal.c @@ -27,10 +27,10 @@ #include <asm/arch/adc.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> -#include <pmic.h> +#include <power/pmic.h> #include <usb/s3c_udc.h> #include <asm/arch/cpu.h> -#include <max8998_pmic.h> +#include <power/max8998_pmic.h> DECLARE_GLOBAL_DATA_PTR; @@ -59,7 +59,7 @@ int board_init(void) gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; #if defined(CONFIG_PMIC) - pmic_init(); + pmic_init(I2C_5); #endif check_hw_revision(); @@ -112,7 +112,9 @@ static unsigned short get_adc_value(int channel) static int adc_power_control(int on) { int ret; - struct pmic *p = get_pmic(); + struct pmic *p = pmic_get("MAX8998_PMIC"); + if (!p) + return -ENODEV; if (pmic_probe(p)) return -1; @@ -280,7 +282,9 @@ int board_mmc_init(bd_t *bis) static int s5pc210_phy_control(int on) { int ret = 0; - struct pmic *p = get_pmic(); + struct pmic *p = pmic_get("MAX8998_PMIC"); + if (!p) + return -ENODEV; if (pmic_probe(p)) return -1; diff --git a/board/ttcontrol/vision2/vision2.c b/board/ttcontrol/vision2/vision2.c index abdd1aa..a471fec 100644 --- a/board/ttcontrol/vision2/vision2.c +++ b/board/ttcontrol/vision2/vision2.c @@ -34,7 +34,7 @@ #include <asm/arch/sys_proto.h> #include <i2c.h> #include <mmc.h> -#include <pmic.h> +#include <power/pmic.h> #include <fsl_esdhc.h> #include <fsl_pmic.h> #include <mc13892.h> @@ -306,9 +306,15 @@ static void power_init_mx51(void) { unsigned int val; struct pmic *p; + int ret; + + ret = pmic_init(I2C_PMIC); + if (ret) + return; - pmic_init(); - p = get_pmic(); + p = pmic_get("FSL_PMIC"); + if (!p) + return; /* Write needed to Power Gate 2 register */ pmic_reg_read(p, REG_POWER_MISC, &val); |