contrib: replace the GPLv2-or-later license tag
[fw/openocd] / contrib / loaders / watchdog / armv7m_kinetis_wdog.s
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2015 Tomas Vanek                                        *
5  *   vanekt@fbl.cz                                                         *
6  ***************************************************************************/
7
8 /*
9         Disable watchdog for Kinetis Kx and KVx
10         Parameters:
11                 r0 ... WDOG base (in)
12
13         Used instruction set should work on both Cortex-M4 and M0+
14 */
15
16         .text
17         .syntax unified
18         .cpu cortex-m0
19         .thumb
20
21 /* WDOG registers offsets */
22 WDOG_STCTRLH    = 0
23 WDOG_UNLOCK     = 0x0e
24
25 WDOG_KEY1       = 0xc520
26 WDOG_KEY2       = 0xd928
27
28         .thumb_func
29 start:
30 /* WDOG_UNLOCK = 0xC520 */
31         ldr     r2, =WDOG_KEY1
32         strh    r2, [r0, WDOG_UNLOCK]
33 /* WDOG_UNLOCK = 0xD928 */
34         ldr     r2, =WDOG_KEY2
35         strh    r2, [r0, WDOG_UNLOCK]
36 /* WDOG_STCTRLH clear bit 0 */
37         movs    r4, #1
38         ldrh    r2, [r0, WDOG_STCTRLH]
39         bics    r2, r4
40         strh    r2, [r0, WDOG_STCTRLH]
41 /* OpenOCD checks exit point address. Jump to the very end. */
42         b       done
43
44         .pool
45
46 /* Avoid padding at .text segment end. Otherwise exit point check fails. */
47         .skip   ( . - start + 2) & 2, 0
48 done:
49         bkpt    #0
50
51         .end