[PATCH] charger fixes * Always charge with at least 100mA to support stupid chargers * don't call cpu_idle because it breaks USB communication * flash LED only for 10ms * don't wait 1s if battery is charged already for faster startup * fixed some comments
Philipp Hug
philipp at hug.cx
Fri Jan 9 00:18:32 CET 2009
---
board/neo1973/gta02/gta02.c | 55 ++++++++++++++++++++++---------------=
-----
1 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/board/neo1973/gta02/gta02.c b/board/neo1973/gta02/gta02.c
index a59a513..4255caa 100644
--- a/board/neo1973/gta02/gta02.c
+++ b/board/neo1973/gta02/gta02.c
@@ -322,6 +322,11 @@ static void set_revision(void)
=20
static void poll_charger(void)
{
+ /* charge with at least 100 mA otherwise dumb chargers won't work*/
+ if (udc_usb_maxcurrent < 100) {
+ udc_usb_maxcurrent =3D 100;
+ }
+
if (pcf50633_read_charger_type() =3D=3D 1000)
pcf50633_usb_maxcurrent(1000);
else /* track what the time-critical udc callback allows us */
@@ -406,46 +411,38 @@ static int battery_is_good(void)
=20
static int wait_for_power(void)
{
- /*
- * TODO: this function should also check if charger is still attached
- * it makes no sense to wait otherwise.
- */
-
int seconds =3D 0;
int led_cycle =3D 1;
int power =3D 1;
=20
while (1) {
poll_charger();
+ #if 0
+ /* Print current power setting for debugging */
+ printf("wait_for_power %i\n",pcf50633_usb_last_maxcurrent);
+ #endif
=20
/* we have plenty of external power but no visible battery ->
* don't hang around trying to charge, try to boot */
if (!battery_is_present() && (pcf50633_usb_last_maxcurrent >=3D 500))
break;
=20
- /* cpu_idle sits with interrupts off destroying USB operation
- * don't run it unless we are in trouble
+ /*
+ * Probe the battery only if the current LED cycle is
+ * about to end, so that it had time to discharge.
+ * This only works, if the charger is off before
+ * wait_for_power is called.
+ * Reason: 1s faster startup time
*/
- if (!battery_is_good())
- cpu_idle();
- else
- udelay(1000000);
+ if (led_cycle && battery_is_good())
+ break;
=20
- if (neo1973_new_second()) {
- /*
- * Probe the battery only if the current LED cycle is
- * about to end, so that it had time to discharge.
- */
- if (led_cycle && battery_is_good())
- break;
-
- /* check if charger is present, otherwise stop start up */
- if (!charger_is_present()) {
- power =3D 0;
- break;
- }
- seconds++;
+ /* check if charger is present, otherwise stop start up */
+ if (!charger_is_present()) {
+ power =3D 0;
+ break;
}
+ seconds++;
=20
led_cycle =3D !seconds || (seconds & 1);
=20
@@ -465,6 +462,12 @@ static int wait_for_power(void)
* didn't kill us then don't let it kill us later
*/
pcf50633_reg_write(PCF50633_REG_OOCSHDWN, 4);
+
+ if (led_cycle)
+ udelay(10000);
+ else
+ udelay(1000000);
+
}
=20
/* switch off the AUX LED */
@@ -564,7 +567,7 @@ woken_by_reset:
neo1973_poweroff();
=20
continue_boot:
- /* Power off if no battery is present and only 100mA is available */
+ /* Power off if no battery is present */
if (!wait_for_power())
neo1973_poweroff();
=20
--=20
1.6.0.4
------=_20090109121104_82139--
More information about the devel
mailing list