summaryrefslogtreecommitdiff
path: root/board/samsung/trats/trats.c
diff options
context:
space:
mode:
authorƁukasz Majewski <l.majewski@samsung.com>2012-11-13 03:22:11 +0000
committerAnatolij Gustschin <agust@denx.de>2012-11-14 11:21:11 +0100
commitbdee9c8501837c80316a0febb5e9ff79f02767f0 (patch)
tree1f4bbc81550126b50d138d95a934ac6909cd6c76 /board/samsung/trats/trats.c
parent69ad72a10e1bf44be9cac369bb0489d8eb7b6975 (diff)
downloadu-boot-imx-bdee9c8501837c80316a0febb5e9ff79f02767f0.zip
u-boot-imx-bdee9c8501837c80316a0febb5e9ff79f02767f0.tar.gz
u-boot-imx-bdee9c8501837c80316a0febb5e9ff79f02767f0.tar.bz2
arm:trats:pmic: Support for charging battery at Samsung's TRATS board
The battery connected to Samsung's Trats development board is now charged when voltage drops below threshold. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Cc: Minkyu Kang <mk7.kang@samsung.com>
Diffstat (limited to 'board/samsung/trats/trats.c')
-rw-r--r--board/samsung/trats/trats.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index 226b529..e540190 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -298,7 +298,9 @@ static int pmic_init_max8997(void)
int power_init_board(void)
{
- int ret;
+ int chrg, ret;
+ struct power_battery *pb;
+ struct pmic *p_fg, *p_chrg, *p_muic, *p_bat;
ret = pmic_init(I2C_5);
ret |= pmic_init_max8997();
@@ -308,6 +310,51 @@ int power_init_board(void)
if (ret)
return ret;
+ p_fg = pmic_get("MAX17042_FG");
+ if (!p_fg) {
+ puts("MAX17042_FG: Not found\n");
+ return -ENODEV;
+ }
+
+ p_chrg = pmic_get("MAX8997_PMIC");
+ if (!p_chrg) {
+ puts("MAX8997_PMIC: Not found\n");
+ return -ENODEV;
+ }
+
+ p_muic = pmic_get("MAX8997_MUIC");
+ if (!p_muic) {
+ puts("MAX8997_MUIC: Not found\n");
+ return -ENODEV;
+ }
+
+ p_bat = pmic_get("BAT_TRATS");
+ if (!p_bat) {
+ puts("BAT_TRATS: Not found\n");
+ return -ENODEV;
+ }
+
+ p_fg->parent = p_bat;
+ p_chrg->parent = p_bat;
+ p_muic->parent = p_bat;
+
+ p_bat->low_power_mode = trats_low_power_mode;
+ p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic);
+
+ pb = p_bat->pbat;
+ chrg = p_muic->chrg->chrg_type(p_muic);
+ debug("CHARGER TYPE: %d\n", chrg);
+
+ if (!p_chrg->chrg->chrg_bat_present(p_chrg)) {
+ puts("No battery detected\n");
+ return -1;
+ }
+
+ p_fg->fg->fg_battery_check(p_fg, p_bat);
+
+ if (pb->bat->state == CHARGE && chrg == CHARGER_USB)
+ puts("CHARGE Battery !\n");
+
return 0;
}