r4189 - trunk/src/target/u-boot/patches

werner at sita.openmoko.org werner at sita.openmoko.org
Mon Mar 10 06:47:59 CET 2008


Author: werner
Date: 2008-03-10 06:47:55 +0100 (Mon, 10 Mar 2008)
New Revision: 4189

Added:
   trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch
Log:
First try at the wait for power loop. See discussion on openmoko-kernel.



Added: trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch
===================================================================
--- trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch	2008-03-09 21:32:13 UTC (rev 4188)
+++ trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch	2008-03-10 05:47:55 UTC (rev 4189)
@@ -0,0 +1,168 @@
+This patch tries to make the system stay in a mode where total power
+consumption is below 100mA until we have determined that it's safe to
+draw more power.
+
+This is work in progress. Don't use it.
+
+It makes the following changes:
+- keeps the system from booting unless we have 500mA USB power (this is
+  for testing)
+- flashes the red (AUX) LED during this
+- defers initialization of the video subsystem until we're about to
+  display something
+- leaves the LED boost converter turned off until we actually need it
+
+Known issues:
+- actually seems useless, because we don't seem to ever power up without
+  a battery present anyway
+- still burns way too much power, see
+  http://people.openmoko.org/werner/wait-for-power-try1/usb-batt.html
+
+Index: u-boot/board/neo1973/gta02/gta02.c
+===================================================================
+--- u-boot.orig/board/neo1973/gta02/gta02.c
++++ u-boot/board/neo1973/gta02/gta02.c
+@@ -63,6 +63,8 @@
+ #define U_M_SDIV 2
+ #endif
+ 
++extern void smedia3362_lcm_reset(int);
++
+ unsigned int neo1973_wakeup_cause;
+ extern unsigned char booted_from_nand;
+ extern unsigned char booted_from_nor;
+@@ -229,6 +231,34 @@
+ 	return 0;
+ }
+ 
++static void wait_for_power(void)
++{
++	int seconds = 0;
++
++	while (1) {
++#if 0
++		/* battery is present -> try to boot */
++		if (!(pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1))
++			break;
++#endif
++
++		/* @@@FIXME: have to check ADC for external charger */
++
++		/* we have plenty of external power -> try to boot */
++		if (pcf50633_usb_last_maxcurrent >= 500)
++			break;
++
++		if (neo1973_new_second())
++			seconds++;
++
++		/* blink the AUX LED */
++		neo1973_led(GTA02_LED_AUX_RED, !seconds || (seconds & 1));
++	}
++
++	/* switch off the AUX LED */
++	neo1973_led(GTA02_LED_AUX_RED, 0);
++}
++
+ int board_late_init(void)
+ {
+ 	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+@@ -236,6 +266,7 @@
+ 	char buf[32];
+ 	int menu_vote = 0; /* <= 0: no, > 0: yes */
+ 	int seconds = 0;
++	int enter_bootmenu;
+ 
+ 	/* Initialize the Power Management Unit with a safe register set */
+ 	pcf50633_init();
+@@ -244,8 +275,7 @@
+ 	int1 = pcf50633_reg_read(PCF50633_REG_INT1);
+ 	int2 = pcf50633_reg_read(PCF50633_REG_INT2);
+ 
+-	/* switch on one of the power led's */
+-	neo1973_led(GTA02_LED_PWR_ORANGE, 1);
++	wait_for_power();
+ 
+ 	/* issue a short pulse with the vibrator */
+ 	neo1973_vibrator(1);
+@@ -311,9 +341,15 @@
+ 	neo1973_poweroff();
+ 
+ continue_boot:
++	enter_bootmenu = menu_vote > 0 || booted_from_nor;
++	smedia3362_lcm_reset(1);
++	if (!enter_bootmenu && getenv("splashimage"))
++		run_command(getenv("splashimage"), 0);
+ 	jbt6k74_init();
+ 	jbt6k74_enter_state(JBT_STATE_NORMAL);
+ 	jbt6k74_display_onoff(1);
++	/* switch on the backlight */
++	neo1973_backlight(1);
+ 
+ #if 0
+ 	{
+@@ -324,7 +360,7 @@
+ 	}
+ #endif
+ 
+-	if (menu_vote > 0 || booted_from_nor) {
++	if (enter_bootmenu) {
+ 		extern struct bootmenu_setup bootmenu_setup;
+ 
+ 		if (booted_from_nand)
+Index: u-boot/board/neo1973/gta02/pcf50633.c
+===================================================================
+--- u-boot.orig/board/neo1973/gta02/pcf50633.c
++++ u-boot/board/neo1973/gta02/pcf50633.c
+@@ -58,7 +58,7 @@
+ 	[PCF50633_REG_MEMLDOENA] = 0x00,
+ 
+ 	[PCF50633_REG_LEDOUT]	= 0x2f,	/* full backlight power */
+-	[PCF50633_REG_LEDENA]	= 0x02,	/* enabled if GPIO1 = HIGH */
++	[PCF50633_REG_LEDENA]	= 0x00,	/* disabled */
+ 	[PCF50633_REG_LEDCTL]	= 0x05, /* ovp enabled, ocp 500mA */
+ 	[PCF50633_REG_LEDDIM]	= 0x20,	/* dimming curve */
+ 
+Index: u-boot/drivers/misc/pcf50633.c
+===================================================================
+--- u-boot.orig/drivers/misc/pcf50633.c
++++ u-boot/drivers/misc/pcf50633.c
+@@ -175,10 +175,13 @@
+ 	}
+ }
+ 
++int pcf50633_usb_last_maxcurrent = -1;
++
+ void pcf50633_usb_maxcurrent(unsigned int ma)
+ {
+ 	u_int8_t val;
+ 
++	pcf50633_usb_last_maxcurrent = ma;
+ 	if (ma < 100)
+ 		val = PCF50633_MBCC7_USB_SUSPEND;
+ 	else if (ma < 500)
+Index: u-boot/drivers/video/smedia3362.c
+===================================================================
+--- u-boot.orig/drivers/video/smedia3362.c
++++ u-boot/drivers/video/smedia3362.c
+@@ -223,7 +223,7 @@
+ 	pGD->frameAdrs = CONFIG_GLAMO_BASE + 0x00800000;
+ 	pGD->memSize = 0x200000; /* 480x640x16bit = 614400 bytes */
+ 
+-#ifdef CONFIG_GTA02_REVISION
++#ifdef CONFIG_GTA02_REVISION_do_this_in_board_late_init
+ 	/* bring up the LCM */
+ 	smedia3362_lcm_reset(1);
+ 	if (getenv("splashimage"))
+Index: u-boot/include/pcf50633.h
+===================================================================
+--- u-boot.orig/include/pcf50633.h
++++ u-boot/include/pcf50633.h
+@@ -387,6 +387,8 @@
+ /* this is to be provided by the board implementation */
+ extern const u_int8_t pcf50633_initial_regs[__NUM_PCF50633_REGS];
+ 
++extern int pcf50633_usb_last_maxcurrent; /* mA or -1 if unknown */
++
+ void pcf50633_reg_write(u_int8_t reg, u_int8_t val);
+ 
+ u_int8_t pcf50633_reg_read(u_int8_t reg);





More information about the commitlog mailing list