[PATCH] uboot-fix-reduce-post-boot-current-drastically.patch

Werner Almesberger werner at openmoko.org
Thu Jul 3 11:09:56 CEST 2008


We are required to keep consumption on average below 100mA @ 5V when
we came up off USB, until we get the signal that the host enumerated
us at 500mA.  This patch turns off LDOs and defers init of Glamo
and other assets to keep the average current at around 45mA in that
state.

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

 board/neo1973/gta02/gta02.c |   44 +++++++++++++++++++++++++++++++++++++++++--
 cpu/arm920t/start.S         |    2 +-
 drivers/video/smedia3362.c  |    3 ++-
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/board/neo1973/gta02/gta02.c b/board/neo1973/gta02/gta02.c
index 332a8cc..891e461 100644
--- a/board/neo1973/gta02/gta02.c
+++ b/board/neo1973/gta02/gta02.c
@@ -34,6 +34,7 @@
 #include <s3c2440.h>
 #include <i2c.h>
 #include <bootmenu.h>
+#include <asm/atomic.h>
 
 #include "../common/neo1973.h"
 #include "../common/jbt6k74.h"
@@ -106,6 +107,7 @@ int board_init(void)
 	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
 	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
+#if 0
 	/* to reduce PLL lock time, adjust the LOCKTIME register */
 	clk_power->LOCKTIME = 0xFFFFFF;
 
@@ -123,6 +125,7 @@ int board_init(void)
 
 	/* some delay between MPLL and UPLL */
 	delay (8000);
+#endif
 
 	/* set up the I/O ports */
 #if CONFIG_GTA02_REVISION == 1
@@ -318,8 +321,11 @@ static void poll_charger(void)
 static void wait_for_power(void)
 {
 	int seconds = 0;
+	unsigned long flags;
 
+	local_irq_save(flags);
 	while (1) {
+#if 0
 		/* battery is present -> try to boot */
 		if (!(pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1))
 			break;
@@ -333,12 +339,28 @@ static void wait_for_power(void)
 		/* we have plenty of external power -> try to boot */
 		if (pcf50633_usb_last_maxcurrent >= 500)
 			break;
+#endif
+#if 0
+	__pcf50633_reg_write(PCF50633_REG_MBCC1,
+	    neo1973_aux_key_pressed() ? 0x15 : 0x14);
+#endif
+	__pcf50633_reg_write(PCF50633_REG_MBCC7,
+	    neo1973_aux_key_pressed() ? 1 : 0); // 500 vs. 100mA
+
+{
+	S3C24X0_INTERRUPT * const intr = S3C24X0_GetBase_INTERRUPT();
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+	S3C24X0_CLOCK_POWER * const clk = S3C24X0_GetBase_CLOCK_POWER();
 
+	intr->INTMSK &= ~BIT_EINT8_23;
+	gpio->EINTMASK &= ~(1 << 9);
+	clk->CLKCON |= 1 << 2; /* IDLE */
+}
 		if (neo1973_new_second())
 			seconds++;
 
 		/* blink the AUX LED */
-		neo1973_led(GTA02_LED_AUX_RED, !seconds || (seconds & 1));
+		neo1973_led(GTA02_LED_AUX_RED, !(!seconds || (seconds & 1)));
 	}
 
 	/* switch off the AUX LED */
@@ -356,13 +378,23 @@ int board_late_init(void)
 
 	set_revision();
 
+
 	/* Initialize the Power Management Unit with a safe register set */
 	pcf50633_init();
 
+__pcf50633_reg_write(PCF50633_REG_MBCC1, 0x00); // charger disabled
+__pcf50633_reg_write(PCF50633_REG_MBCC7, 0x01); // 500mA
+__pcf50633_reg_write(PCF50633_REG_MBCC8, 0x00); // USB-SYS disabled
+
 	/* obtain wake-up reason */
 	int1 = pcf50633_reg_read(PCF50633_REG_INT1);
 	int2 = pcf50633_reg_read(PCF50633_REG_INT2);
 
+__pcf50633_reg_write(PCF50633_REG_LDO1ENA, 0); // GSENSOR_3V3
+__pcf50633_reg_write(PCF50633_REG_LDO2ENA, 0); // CODEC_3V3
+__pcf50633_reg_write(PCF50633_REG_LDO5ENA, 0); // RF_3V
+__pcf50633_reg_write(PCF50633_REG_LDO6ENA, 0); // LCM_3V
+
 	wait_for_power();
 
 	/* issue a short pulse with the vibrator */
@@ -559,7 +591,7 @@ static int pwr_int_pending(void)
 {
 	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-	return !(gpio->GPGDAT & (1 << 1));	/* EINT9/GPG1 */
+	return !(gpio->GPGDAT & (1 << 1));      /* EINT9/GPG1 */
 }
 
 static int have_int(uint8_t mask1, uint8_t mask2)
@@ -578,6 +610,14 @@ static int have_int(uint8_t mask1, uint8_t mask2)
 			ints[i] = pcf50633_reg_read(PCF50633_REG_INT1+i);
 		pending1 |= ints[0];
 		pending2 |= ints[1];
+{
+		S3C24X0_INTERRUPT * const intr = S3C24X0_GetBase_INTERRUPT();
+		S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+		gpio->EINTPEND = 1 << 9;
+		intr->SRCPND = BIT_EINT8_23;
+		intr->INTPND = BIT_EINT8_23;
+}
 	}
 	if (pending1 & mask1) {
 		pending1 &= ~mask1;
diff --git a/cpu/arm920t/start.S b/cpu/arm920t/start.S
index ffed67e..93bf7e9 100644
--- a/cpu/arm920t/start.S
+++ b/cpu/arm920t/start.S
@@ -217,7 +217,7 @@ copyex:
 # define INTSUBMSK_val        0xffff
 # if (CONFIG_SYS_CLK_FREQ == 12000000)
 #  define MPLLCON_val ((142 << 12) + (7 << 4) + 1)
-#  define UPLLCON_val   (( 88 << 12) + (8 << 4) + 2)
+#  define UPLLCON_val   (( 88 << 12) + (4 << 4) + 2)
 # elif (CONFIG_SYS_CLK_FREQ == 16934400)
 #  define MPLLCON_val   ((181 << 12) + (14<< 4) + 1)
 #  define UPLLCON_val   (( 26 << 12) + (4 << 4) + 1)
diff --git a/drivers/video/smedia3362.c b/drivers/video/smedia3362.c
index 2acc60a..27a46e7 100644
--- a/drivers/video/smedia3362.c
+++ b/drivers/video/smedia3362.c
@@ -213,7 +213,7 @@ void * video_hw_init(void)
 		glamo_reg_read(GLAMO_REG_DEVICE_ID),
 		glamo_reg_read(GLAMO_REG_REVISION_ID));
 
-	glamo_core_init();
+//	glamo_core_init();
 
 	pGD->winSizeX = pGD->plnSizeX = 480;
 	pGD->winSizeY = pGD->plnSizeY = 640;
@@ -223,6 +223,7 @@ void * video_hw_init(void)
 	pGD->frameAdrs = CONFIG_GLAMO_BASE + 0x00800000;
 	pGD->memSize = 0x200000; /* 480x640x16bit = 614400 bytes */
 
+return pGD;
 #ifdef CONFIG_GTA02_REVISION_do_this_in_board_late_init
 	/* bring up the LCM */
 	smedia3362_lcm_reset(1);





More information about the openmoko-kernel mailing list