[U-Boot] [PATCH 15/16] arm:trats:pmic: Support for charging battery at Samsung's TRATS board
Lukasz Majewski
l.majewski at samsung.com
Fri Sep 14 17:40:14 CEST 2012
The battery connected to Samsung's Trats development board is now
charged when voltage drops below threshold.
Signed-off-by: Lukasz Majewski <l.majewski at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
Cc: Minkyu Kang <mk7.kang at samsung.com>
---
board/samsung/trats/trats.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index 6462b30..21050c8 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -39,6 +39,7 @@
#include <power/max8997_pmic.h>
#include <libtizen.h>
#include <power/max8997_muic.h>
+#include <power/power_chrg.h>
#include <power/max17042_fg.h>
#include "setup.h"
@@ -240,6 +241,8 @@ static int pmic_init_max8997(void)
#ifdef CONFIG_POWER_INIT
int power_board_init(void)
{
+ int chrg, k;
+ struct battery bat;
#ifdef CONFIG_PMIC
pmic_init(I2C_5);
@@ -247,6 +250,40 @@ int power_board_init(void)
pmic_init_max8997();
power_fg_init(I2C_9);
power_muic_init(I2C_5);
+
+ chrg = power_chrg_get_type();
+ debug("CHARGER TYPE: %d\n", chrg);
+
+ if (!pmic_charger_bat_present()) {
+ puts("No battery detected\n");
+ return -1;
+ }
+
+ power_check_battery(&bat);
+
+ if (bat.state == CHARGE && chrg == CHARGER_USB) {
+ puts("CHARGER ENABLE\n");
+ if (pmic_charger_state(CHARGER_ENABLE, 450))
+ return -1;
+
+ for (k = 0; pmic_charger_bat_present() &&
+ power_chrg_get_type() &&
+ bat.state_of_chrg < 5; k++) {
+ udelay(10000000);
+ puts(".");
+ power_update_battery(&bat);
+
+ if (k == 100) {
+ printf(" %d [V]\n", bat.voltage_uV);
+ k = 0;
+ }
+
+ }
+
+ puts("CHARGER DISABLE\n");
+ pmic_charger_state(CHARGER_DISABLE, 0);
+ }
+
return 0;
}
#endif
--
1.7.2.3
More information about the U-Boot
mailing list