Patchwork [U-Boot] power:bat:trats: Break battery charging with ctrl+C

login
register
mail settings
Submitter Łukasz Majewski
Date June 25, 2013, 1:28 p.m.
Message ID <1372166895-29861-1-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/254152/
State Accepted
Delegated to: Minkyu Kang
Headers show

Comments

Łukasz Majewski - June 25, 2013, 1:28 p.m.
Add support for disabling battery charging with ctrl+C keyboard
combination pressed.
Moreover the battery update is done more frequently.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Cc: Tom Rini <trini@ti.com>
---
 drivers/power/battery/bat_trats.c |   13 +++++++++----
 drivers/power/power_core.c        |    3 ++-
 2 files changed, 11 insertions(+), 5 deletions(-)
Minkyu Kang - July 5, 2013, 9:48 a.m.
On 25/06/13 22:28, Lukasz Majewski wrote:
> Add support for disabling battery charging with ctrl+C keyboard
> combination pressed.
> Moreover the battery update is done more frequently.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Tom Rini <trini@ti.com>
> ---
>  drivers/power/battery/bat_trats.c |   13 +++++++++----
>  drivers/power/power_core.c        |    3 ++-
>  2 files changed, 11 insertions(+), 5 deletions(-)
> 

applied to u-boot-samsung.

Thanks,
Minkyu Kang.

Patch

diff --git a/drivers/power/battery/bat_trats.c b/drivers/power/battery/bat_trats.c
index ca0d214..97a9661 100644
--- a/drivers/power/battery/bat_trats.c
+++ b/drivers/power/battery/bat_trats.c
@@ -41,18 +41,23 @@  static int power_battery_charge(struct pmic *bat)
 	for (k = 0; bat->chrg->chrg_bat_present(p_bat->chrg) &&
 		     bat->chrg->chrg_type(p_bat->muic) &&
 		     battery->state_of_chrg < 100; k++) {
-		udelay(10000000);
-		puts(".");
+		udelay(2000000);
+		if (!(k % 5))
+			puts(".");
 		bat->fg->fg_battery_update(p_bat->fg, bat);
 
-		if (k == 100) {
+		if (k == 200) {
 			debug(" %d [V]", battery->voltage_uV);
 			puts("\n");
 			k = 0;
 		}
 
+		if (ctrlc()) {
+			printf("\nCharging disabled on request.\n");
+			goto exit;
+		}
 	}
-
+ exit:
 	bat->chrg->chrg_state(p_bat->chrg, CHARGER_DISABLE, 0);
 
 	return 0;
diff --git a/drivers/power/power_core.c b/drivers/power/power_core.c
index 90df2c5..f16b9dc 100644
--- a/drivers/power/power_core.c
+++ b/drivers/power/power_core.c
@@ -205,7 +205,8 @@  int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		if (strcmp(argv[3], "charge") == 0) {
 			if (p->pbat) {
-				printf("PRINT BAT charge %s\n", p->name);
+				printf("BAT: %s charging (ctrl+c to break)\n",
+				       p->name);
 				if (p->low_power_mode)
 					p->low_power_mode();
 				if (p->pbat->battery_charge)