1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Spansion FM4 flash write 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, data, tmp1, tmp2, tmp3
19 ldrb \tmp1, [\addr] /* ignore */
20 and \tmp2, \data, #FLASH_DPOL
23 and \tmp3, \tmp1, #FLASH_DPOL
27 and \tmp3, \tmp1, #FLASH_TLOV
32 and \tmp3, \tmp1, #FLASH_DPOL
36 mov \res, #RESULT_TIMEOUT
42 .macro write_one, res, cmdseqaddr1, cmdseqaddr2, pa, pd, tmp1, tmp2, tmp3
45 strh \tmp1, [\cmdseqaddr1]
47 strh \tmp1, [\cmdseqaddr2]
49 strh \tmp1, [\cmdseqaddr1]
52 busy_wait \res, \pa, \pd, \tmp1, \tmp2, \tmp3
57 .macro write, cmdseqaddr1, cmdseqaddr2, dest, src, cnt, res, tmp1, tmp2, tmp3, tmp4
59 mov \res, #RESULT_NONE
64 write_one \res, \cmdseqaddr1, \cmdseqaddr2, \dest, \tmp1, \tmp2, \tmp3, \tmp4
71 mov \res, #RESULT_OKAY
83 write r0, r1, r2, r3, r4, r5, r6, r7, r8, r9