contrib: replace the GPLv2-or-later license tag
[fw/openocd] / contrib / loaders / flash / str7x.s
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2010 by Spencer Oliver                                  *
5  *   spen@spen-soft.co.uk                                                  *
6  ***************************************************************************/
7
8         .text
9         .arm
10         .arch armv4t
11
12         .section .init
13 /*
14         r0 source address
15         r1 address
16         r2 FLASH_CR0
17         r3 dword count
18         r4 result
19         r5 busy mask
20 */
21
22 write:
23         mov             r4, #0x10000000                 /* set DWPG bit */
24         str             r4, [r2, #0x0]                  /* FLASH_CR0 */
25         str             r1, [r2, #0x10]                 /* FLASH_AR */
26         ldr             r4, [r0], #4                    /* load data */
27         str             r4, [r2, #0x8]                  /* FLASH_DR0 */
28         ldr             r4, [r0], #4                    /* load data */
29         str             r4, [r2, #0xc]                  /* FLASH_DR1 */
30         mov             r4, #0x90000000                 /* set DWPG and WMS bits */
31         str             r4, [r2, #0x0]                  /* FLASH_CR0 */
32 busy:
33         ldr             r4, [r2, #0x0]                  /* FLASH_CR0 */
34         tst             r4, r5
35         bne             busy
36         ldr             r4, [r2, #0x14]                 /* FLASH_ER */
37         tst             r4, #0xff                               /* do we have errors */
38         tsteq   r4, #0x100                      /* write protection set */
39         bne             exit
40         add             r1, r1, #0x8                    /* next 8 bytes */
41         subs    r3, r3, #1                              /* decrement dword count */
42         bne             write
43 exit:
44         b               exit
45
46         .end