2 * Spansion FM4 flash write algorithm
4 * Copyright (c) 2015 Andreas Färber
6 * Based on S6E2CC_MN709-00007 for S6E2CC/C5/C4/C3/C2/C1 series
13 #define RESULT_TIMEOUT 2
15 .macro busy_wait, res, addr, data, tmp1, tmp2, tmp3
17 ldrb \tmp1, [\addr] /* ignore */
18 and \tmp2, \data, #FLASH_DPOL
21 and \tmp3, \tmp1, #FLASH_DPOL
25 and \tmp3, \tmp1, #FLASH_TLOV
30 and \tmp3, \tmp1, #FLASH_DPOL
34 mov \res, #RESULT_TIMEOUT
40 .macro write_one, res, cmdseqaddr1, cmdseqaddr2, pa, pd, tmp1, tmp2, tmp3
43 strh \tmp1, [\cmdseqaddr1]
45 strh \tmp1, [\cmdseqaddr2]
47 strh \tmp1, [\cmdseqaddr1]
50 busy_wait \res, \pa, \pd, \tmp1, \tmp2, \tmp3
55 .macro write, cmdseqaddr1, cmdseqaddr2, dest, src, cnt, res, tmp1, tmp2, tmp3, tmp4
57 mov \res, #RESULT_NONE
62 write_one \res, \cmdseqaddr1, \cmdseqaddr2, \dest, \tmp1, \tmp2, \tmp3, \tmp4
69 mov \res, #RESULT_OKAY
81 write r0, r1, r2, r3, r4, r5, r6, r7, r8, r9