summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2016-09-07 10:11:48 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-09-08 06:14:51 -0700
commit8cbf285173916bb12426d7fcc241d27e9b658362 (patch)
treed442bd14087f8fe995fa4df76f47cea8894bcff1
parent3798d8e8cc02105136f197a7bdc7ed8489213d44 (diff)
downloadchrome-ec-8cbf285173916bb12426d7fcc241d27e9b658362.tar.gz
npcx: Better download time for sysjump by increasing clock freq.
In order to improve the performance of sysjump, the CL increases the clock freq of ec to 50M HZ (The maximum freq rate for SPI flash.). Once ec jumps into the other region successfully, the clock freq is restored to the default value (15MHz) in main routine. Modified sources: 1. clock.c: Add clock_turbo for speed up clock's freq to max. 2. clock_chip.h: The declarartion for clock_turbo. 3. system.c: Speed up clock rate before downloading FW. BRANCH=none BUG=chrome-os-partner:34346 TEST=make BOARD=npcx_evb; test nuvoton IC specific drivers Change-Id: I996e35fff336e6292599497feb1ee6c2f95becba Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/381799 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--chip/npcx/clock.c28
-rw-r--r--chip/npcx/clock_chip.h5
-rw-r--r--chip/npcx/system.c7
3 files changed, 40 insertions, 0 deletions
diff --git a/chip/npcx/clock.c b/chip/npcx/clock.c
index f6a65cb02f..044afad142 100644
--- a/chip/npcx/clock.c
+++ b/chip/npcx/clock.c
@@ -164,6 +164,34 @@ void clock_init(void)
gpio_config_module(MODULE_CLOCK, 1);
}
+
+/**
+ * Set the CPU clock to maximum freq for better performance.
+ */
+void clock_turbo(void)
+{
+ /* Configure Frequency multiplier values to 50MHz */
+ NPCX_HFCGN = 0x02;
+ NPCX_HFCGML = 0xEC;
+ NPCX_HFCGMH = 0x0B;
+
+ /* Load M and N values into the frequency multiplier */
+ SET_BIT(NPCX_HFCGCTRL, NPCX_HFCGCTRL_LOAD);
+
+ /* Wait for stable */
+ while (IS_BIT_SET(NPCX_HFCGCTRL, NPCX_HFCGCTRL_CLK_CHNG))
+ ;
+
+ /* Keep Core CLK & FMCLK are the same if Core CLK exceed 33MHz */
+ NPCX_HFCGP = 0x00;
+
+ /*
+ * Let APB2 equals Core CLK/2 if default APB2 clock is divisible
+ * by 1MHz
+ */
+ NPCX_HFCBCD = NPCX_HFCBCD & 0xF3;
+}
+
/**
* Return the current clock frequency in Hz.
*/
diff --git a/chip/npcx/clock_chip.h b/chip/npcx/clock_chip.h
index 09be04d007..d1ad63bdcc 100644
--- a/chip/npcx/clock_chip.h
+++ b/chip/npcx/clock_chip.h
@@ -21,4 +21,9 @@ int clock_get_apb1_freq(void);
*/
int clock_get_apb2_freq(void);
+/**
+ * Set the CPU clock to maximum freq for better performance.
+ */
+void clock_turbo(void);
+
#endif /* __CROS_EC_CLOCK_CHIP_H */
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index f25bf35fca..f6f4804c35 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -19,6 +19,7 @@
#include "gpio.h"
#include "hwtimer_chip.h"
#include "system_chip.h"
+#include "clock_chip.h"
#include "rom_chip.h"
/* Flags for BBRM_DATA_INDEX_WAKE */
@@ -870,6 +871,12 @@ void system_jump_to_booter(void)
addr_entry = *(uintptr_t *)(flash_offset +
CONFIG_MAPPED_STORAGE_BASE + 4);
+ /*
+ * Speed up FW download time by increasing clock freq of EC. It will
+ * restore to default in clock_init() later.
+ */
+ clock_turbo();
+
download_from_flash(
flash_offset, /* The offset of the data in spi flash */
CONFIG_PROGRAM_MEMORY_BASE, /* RAM Addr of downloaded data */