[PATCH 6/10] deadbat-cpu-200.patch

Werner Almesberger werner at openmoko.org
Tue Jul 15 13:02:14 CEST 2008


Raise the CPU clock (FCLK) from 200MHz to 400MHz only after we've established
that we have a good power source.

That way, the little bit of processing that are done in wait_for_power cause
less spikes in current consumption, which decreases the risk of running out
of power while waiting for USB signaling or similar.

We also save about 7mA of static consumption.

We need to do this awkward two-step process, once in board_init and then
again in board_late_init, since various clocks that depend on PCLK are
calculated after board_init (and start.S uses yet another set of different
settings).

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 22:57:51.000000000 -0300
+++ u-boot/board/neo1973/gta02/gta02.c	2008-07-14 23:16:31.000000000 -0300
@@ -103,16 +103,18 @@
  * Miscellaneous platform dependent initialisations
  */
 
-int board_init(void)
+static void cpu_speed(int mdiv, int pdiv, int sdiv, int clkdivn)
 {
 	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
-	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+	/* clock divide */
+	clk_power->CLKDIVN = clkdivn;
 
 	/* to reduce PLL lock time, adjust the LOCKTIME register */
 	clk_power->LOCKTIME = 0xFFFFFF;
 
 	/* configure MPLL */
-	clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
+	clk_power->MPLLCON = ((mdiv << 12) + (pdiv << 4) + sdiv);
 
 	/* some delay between MPLL and UPLL */
 	delay (4000);
@@ -120,11 +122,16 @@
 	/* configure UPLL */
 	clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
 
-	/* clock divide */
-	clk_power->CLKDIVN = 0x05; /* 1:4:8 */
-
 	/* some delay between MPLL and UPLL */
 	delay (8000);
+}
+
+int board_init(void)
+{
+	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
+
+	/* FCLK = 200MHz values from cpu/arm920t/start.S */
+	cpu_speed(142, 7, 1, 3); /* 200MHZ, 1:2:4 */
 
 	/* set up the I/O ports */
 #if CONFIG_GTA02_REVISION == 1
@@ -437,6 +444,7 @@
 
 	wait_for_power();
 	pcf50633_late_init();
+	cpu_speed(M_MDIV, M_PDIV, M_SDIV, 5); /* 400MHZ, 1:4:8 */
 
 	/* issue a short pulse with the vibrator */
 	neo1973_led(GTA02_LED_AUX_RED, 1);




More information about the openmoko-kernel mailing list