summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2018-03-02 08:55:51 +0100
committerchrome-bot <chrome-bot@chromium.org>2018-03-05 00:21:21 -0800
commit29c2aa329489eca44490a6445ef591d6c661b74e (patch)
tree484804a2d93409b30511f5813e1e364bb25c0eb0 /chip
parent55855fd593912aa82cb59c9fa0eafe9c6990d91d (diff)
downloadchrome-ec-29c2aa329489eca44490a6445ef591d6c661b74e.tar.gz
stm32h7: enable the fast PLL on-demand
Add a new module ID 'MODULE_FAST_CPU'. When it is enabled with clock_enable_module(MODULE_FAST_CPU, 1), switch the system clocking to the fast 400-Mhz PLL. For now, I consider that a single task/user is calling clock_enable_module(MODULE_FAST_CPU, x), so we don't need to count users (in a complicated atomic fashion). It's good enough for the current use-case and we can add the complexity later if we have a real need. BRANCH=none BUG=b:67081508 TEST=on ZerbleBarn, with follow-up CL setting clock_enable_module(MODULE_FAST_CPU,x) around the computation block, see that computations are fast and the clock goes back to HSI after. Change-Id: I2aef3ad673ddbffd6fc64c591c54297e94896fa6 Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/945688 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/stm32/clock-stm32h7.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/chip/stm32/clock-stm32h7.c b/chip/stm32/clock-stm32h7.c
index edbbb6ea32..f0fcdf8f37 100644
--- a/chip/stm32/clock-stm32h7.c
+++ b/chip/stm32/clock-stm32h7.c
@@ -180,25 +180,9 @@ static void clock_set_osc(enum clock_osc osc)
void clock_enable_module(enum module_id module, int enable)
{
- static uint32_t clock_mask;
- int new_mask;
-
- if (enable)
- new_mask = clock_mask | (1 << module);
- else
- new_mask = clock_mask & ~(1 << module);
-
- /* Only change clock if needed */
- if ((!!new_mask) != (!!clock_mask)) {
-
- /* Flush UART before switching clock speed */
- cflush();
-#if 0 /* Power management policy: TODO(b/67081508) not implemented for now */
- clock_set_osc(new_mask ? OSC_PLL : OSC_CSI);
-#endif
- }
-
- clock_mask = new_mask;
+ /* Assume we have a single task using MODULE_FAST_CPU */
+ if (module == MODULE_FAST_CPU)
+ clock_set_osc(enable ? OSC_PLL : OSC_HSI);
}
void clock_init(void)
@@ -224,10 +208,6 @@ void clock_init(void)
/* Use more optimized flash latency settings for ACLK = HSI = 64 Mhz */
clock_flash_latency(FLASH_ACLK_64MHZ);
-
-#if 0 /* Keep default for now: HSI at 64 Mhz */
- clock_set_osc(OSC_PLL);
-#endif
}
static int command_clock(int argc, char **argv)