[PATCH 10/10] deadbat-safe-voltage.patch

Werner Almesberger werner at openmoko.org
Tue Jul 15 13:06:35 CEST 2008


This patch finally enables the last bit of Matt's "safe battery voltage"
patch. Before the other changes in this series of patches, the
wait_for_power logic didn't really work anyway, but now we need this
protection.

I've lowered the safe voltage from 3.6V to 3.4V, since the system seems
to boot fine with 3.4V. A smaller threshold decreases the time the
system spends refusing to do anything but to charge.

Signed-off-by: Werner Almesberger <werner at openmoko.org>

Index: u-boot/board/neo1973/gta02/gta02.c
===================================================================
--- u-boot.orig/board/neo1973/gta02/gta02.c	2008-07-14 23:34:02.000000000 -0300
+++ u-boot/board/neo1973/gta02/gta02.c	2008-07-14 23:35:10.000000000 -0300
@@ -47,7 +47,7 @@
 #define POWER_KEY_SECONDS	1
 
 /* If the battery voltage is below this, we can't provide stable power */
-#define	SAVE_POWER_MILLIVOLT	3600
+#define	SAFE_POWER_MILLIVOLT	3400
 
 #if defined(CONFIG_ARCH_GTA02_v1)
 //#define M_MDIV	0x7f		/* Fout = 405.00MHz */
@@ -376,12 +376,15 @@
 
 static int battery_is_good(void)
 {
-	/* battery is present -> try to boot */
-	return !(pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1);
-/*
- * Consider adding this later to the above condition:
-	    pcf50633_read_battvolt() >= SAVE_POWER_MILLIVOLT)
- */
+	/* battery is absent -> don't boot */
+	if (pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1)
+		return 0;
+
+	/* we could try to boot, but we'll probably die on the way */
+	if (pcf50633_read_battvolt() < SAFE_POWER_MILLIVOLT)
+		return 0;
+
+	return 1;
 }
 
 static void wait_for_power(void)




More information about the openmoko-kernel mailing list