stm32l0|l1: don't corrupt RCC registers
authorFelipe Balbi <balbi@kernel.org>
Thu, 14 Jul 2016 13:32:10 +0000 (16:32 +0300)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Fri, 18 Oct 2019 08:17:33 +0000 (09:17 +0100)
instead of overwriting Reset settings, let's
read-modify-write RCC registers.

Change-Id: I21b7e26e6007d3c3d73803c681c980c6947f5910
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Reviewed-on: http://openocd.zylin.com/3601
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
tcl/target/stm32l0.cfg
tcl/target/stm32l1.cfg

index ec5d5463ebb1828c07fddf35427f06d4343136ee..e09af80018d6504d070f5bc1c1f1b019b39e3fbe 100644 (file)
@@ -61,10 +61,13 @@ proc stm32l0_enable_HSI16 {} {
        echo "STM32L0: Enabling HSI16"
 
        # Set HSI16ON in RCC_CR (leave MSI enabled)
-       mww 0x40021000 0x00000101
+    mmw 0x40021000 0x00000101 0
 
        # Set HSI16 as SYSCLK (RCC_CFGR)
-       mww 0x4002100c 0x00000001
+       mmw 0x4002100c 0x00000001 0
+
+       # Wait until System clock switches to HSI16
+       while { ([ mrw 0x4002100c ] & 0x0c) != 0x04 } { }
 
        # Increase speed
        adapter_khz 2500
index 054fa9b74f64667d5093f8ebbaef6e0b8a6899f9..0933151a0e9bf2feb80fb45c2533ac3907ac270d 100644 (file)
@@ -73,10 +73,10 @@ proc stm32l_enable_HSI {} {
        echo "STM32L: Enabling HSI"
 
        # Set HSION in RCC_CR
-       mww 0x40023800 0x00000101
+       mmw 0x40023800 0x00000101 0
 
        # Set HSI as SYSCLK
-       mww 0x40023808 0x00000001
+       mmw 0x40023808 0x00000001 0
 
        # Increase JTAG speed
        adapter_khz 2000