[PATCH] lowbat-usb-power-levels
Mike Montour
mail at mmontour.net
Mon Aug 25 09:30:42 CEST 2008
This patch fixes the 100/500/1000 mA USB detection in the u-boot function
that handles booting with a low battery voltage. This version of the patch
is not yet suitable for merging into the stable tree.
diff --git a/board/neo1973/common/udc.c b/board/neo1973/common/udc.c
index d547cb8..fe146ee 100644
--- a/board/neo1973/common/udc.c
+++ b/board/neo1973/common/udc.c
@@ -5,7 +5,7 @@
#include <pcf50606.h>
#include <pcf50633.h>
-int udc_usb_maxcurrent = 0;
+int udc_usb_maxcurrent = 100;
void udc_ctrl(enum usbd_event event, int param)
{
@@ -39,7 +39,7 @@ void udc_ctrl(enum usbd_event event, int param)
if (param)
udc_usb_maxcurrent = 500;
else
- udc_usb_maxcurrent = 0;
+ udc_usb_maxcurrent = 100;
#endif
break;
default:
diff --git a/board/neo1973/gta02/gta02.c b/board/neo1973/gta02/gta02.c
index 6db164e..2369d95 100644
--- a/board/neo1973/gta02/gta02.c
+++ b/board/neo1973/gta02/gta02.c
@@ -320,12 +320,6 @@ static void set_revision(void)
#endif
}
-static void poll_charger(void)
-{
- if (pcf50633_read_charger_type() == 1000)
- pcf50633_usb_maxcurrent(1000);
-}
-
static int have_int(uint8_t mask1, uint8_t mask2);
static void clear_pmu_int(void)
@@ -395,11 +389,13 @@ static void wait_for_power(void)
int led_cycle = 1;
while (1) {
- poll_charger();
-
/* track what the time-critical udc callback allows us */
- if (pcf50633_usb_last_maxcurrent != udc_usb_maxcurrent)
- pcf50633_usb_maxcurrent(udc_usb_maxcurrent);
+ int new_max = udc_usb_maxcurrent;
+ if(pcf50633_read_charger_type() == 1000)
+ new_max = 1000;
+
+ if (pcf50633_usb_last_maxcurrent != new_max)
+ pcf50633_usb_maxcurrent(new_max);
/* we have plenty of external power -> try to boot */
if (pcf50633_usb_last_maxcurrent >= 500)
@@ -421,16 +417,30 @@ static void wait_for_power(void)
if (led_cycle && battery_is_good())
break;
seconds++;
+
+ /* TEMPORARY - Reset the 8s timeout counter which would otherwise
+ * shut us down. Should handle this in some other manner, e.g.
+ * masking interrupts or only resetting for some of the possible
+ * shutdown reasons.
+ */
+ pcf50633_reg_set_bit_mask(PCF50633_REG_OOCSHDWN, 0x04, 0x04);
}
led_cycle = !seconds || (seconds & 1);
/*
* Blink the AUX LED, unless it's broken (which is the case in
- * GTA02v5 it is) and draws excessive current, which we just
+ * some GTA02v5) and draws excessive current, which we just
* can't afford in this delicate situation.
+ *
*/
+#if 0
+ /* For prototype GTA02v5 */
if (gta02_revision > 5)
+#else
+ /* For mass-production GTA02v5 with LED rework*/
+ if (gta02_revision >= 5)
+#endif
neo1973_led(GTA02_LED_AUX_RED, led_cycle);
/* alternate LED and charger cycles */
--
1.5.2.4
--------------000800090609030004090709
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="0002-charger-dbg-blinkenlights.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="0002-charger-dbg-blinkenlights.patch"
More information about the openmoko-kernel
mailing list