1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Spansion FM4 flash sector erase algorithm
6 * Copyright (c) 2015 Andreas Färber
8 * Based on S6E2CC_MN709-00007 for S6E2CC/C5/C4/C3/C2/C1 series
15 #define RESULT_TIMEOUT 2
17 .macro busy_wait, res, addr, tmp1, tmp2, tmp3
19 ldrb \tmp1, [\addr] /* ignore */
24 and \tmp3, \tmp1, #FLASH_TOGG
25 and \tmp2, \tmp2, #FLASH_TOGG
29 and \tmp2, \tmp1, #FLASH_TLOV
36 and \tmp3, \tmp1, #FLASH_TOGG
37 and \tmp2, \tmp2, #FLASH_TOGG
41 mov \res, #RESULT_TIMEOUT
44 mov \res, #RESULT_OKAY
49 .macro erase, cmdseqaddr1, cmdseqaddr2, sa, res, tmp1, tmp2, tmp3
51 mov \res, #RESULT_NONE
54 strh \tmp1, [\cmdseqaddr1]
56 strh \tmp2, [\cmdseqaddr2]
58 strh \tmp3, [\cmdseqaddr1]
59 strh \tmp1, [\cmdseqaddr1]
60 strh \tmp2, [\cmdseqaddr2]
64 busy_wait \res, \sa, \tmp1, \tmp2, \tmp3
75 erase r0, r1, r2, r3, r4, r5, r6