FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/services/ffs/drv.c @ 223:0848c7f419fd
gsm-fw/configs: checking some configurations into source control,
now that we have some selectable features
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 07 Jan 2014 05:58:11 +0000 |
parents | fee45482aa2a |
children | 4d706a4134b0 |
rev | line source |
---|---|
209
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /****************************************************************************** |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Flash File System (ffs) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 * ffs low level flash driver |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 * |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 * $Id: drv.c 1.30.1.6.1.51.1.1.1.13.1.11 Tue, 06 Jan 2004 14:36:52 +0100 tsj $ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 * |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 ******************************************************************************/ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "../../include/config.h" |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "ffs.h" |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "drv.h" |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "ffstrace.h" |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #include "intctl.h" |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 #include "ramffs.h" |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #include <string.h> |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 /****************************************************************************** |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 * Macros |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 ******************************************************************************/ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 #define addr2offset(address) ( (int) (address) - (int) dev.base ) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 /****************************************************************************** |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 * Generic Driver Functions |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 ******************************************************************************/ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 // Note: This function is designed for little-endian memory addressing! |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 void ffsdrv_write_byte(void *dst, uint8 value) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 uint16 halfword; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 tw(tr(TR_FUNC, TrDrvWrite, "ffsdrv_write_byte(0x%05x, 0x%x)\n", |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 (int) (addr2offset(dst)), value)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 ttw(str(TTrDrvWrite, "wb" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 if ((int) dst & 1) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 halfword = (value << 8) | *((uint8 *) dst - 1); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 else |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 halfword = (*((uint8 *) dst + 1) << 8) | (value); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 ffsdrv.write_halfword((uint16 *) ((int) dst & ~1), halfword); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 void ffsdrv_generic_write(void *dst, const void *src, uint16 size) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 uint8 *mydst = dst; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 const uint8 *mysrc = src; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 if (size > 0) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 if ((unsigned int) mydst & 1) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 ffsdrv_write_byte(mydst++, *mysrc++); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 size--; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 while (size >= 2) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 ffsdrv.write_halfword((uint16 *) mydst, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 mysrc[0] | (mysrc[1] << 8)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 size -= 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 mysrc += 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 mydst += 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 if (size == 1) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 ffsdrv_write_byte(mydst++, *mysrc++); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 /****************************************************************************** |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 * Dummy Functions |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 ******************************************************************************/ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 int ffsdrv_null_init(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 ttw(ttr(TTrDrvOther, "ffsdrv_null_init()" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 return 0; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 void ffsdrv_null_erase(uint8 block) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 ttw(ttr(TTrDrvErase, "ffsdrv_null_erase(%d)" NL, block)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 void ffsdrv_null_write_halfword(volatile uint16 *addr, uint16 value) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 ttw(ttr(TTrDrvWrite, "ffsdrv_null_write_halfword(0x%x, 0x%x)" NL, addr, value)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 void ffsdrv_null_write(void *dst, const void *src, uint16 size) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 ttw(ttr(TTrDrvWrite, "ffsdrv_null_write(0x%x, 0x%x, %d)" NL, dst, src, size)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 void ffsdrv_null_erase_suspend(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 ttw(str(TTrDrvErase, "ffsdrv_null_erase_suspend()" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 void ffsdrv_null_erase_resume(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 ttw(str(TTrDrvErase, "ffsdrv_null_erase_resume()" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 void ffsdrv_null_write_end(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 ttw(str(TTrDrvWrite, "ffsdrv_null_write_end()" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 void ffsdrv_null_erase_end(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 ttw(str(TTrDrvErase, "ffsdrv_null_erase_end()" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 /* |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 * FreeCalypso change from TI: we only compile one flash "driver" type |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 * based on the build configuration. |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 */ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 #if FFS_IN_RAM |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 /****************************************************************************** |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 * RAM Family Functions |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 ******************************************************************************/ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 struct block_info_s ramffs_block_info[RAMFFS_NBLOCKS]; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 int ffsdrv_ram_init(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 unsigned i; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 uint32 offset; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 ttw(ttr(TTrDrvOther, "ffsdrv_ram_init()" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 memset(_RAMFFS_area, 0xFF, RAMFFS_TOTAL_SIZE); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 offset = 0; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 for (i = 0; i < RAMFFS_NBLOCKS; i++) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 ramffs_block_info[i].offset = offset; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 ramffs_block_info[i].size_ld = RAMFFS_BLKSIZE_LOG2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 offset += RAMFFS_BLKSIZE_BYTES; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 return 0; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 void ffsdrv_ram_write_halfword(volatile uint16 *dst, uint16 value) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 *dst = value; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 #if 0 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 /* duplicates ffsdrv_generic_write */ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 void ffsdrv_ram_write(void *dst, const void *src, uint16 size) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 uint8 *mydst = dst; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 const uint8 *mysrc = src; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 if (size == 0) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 return; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 else if (size == 1) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 ffsdrv_write_byte(mydst, *mysrc); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 else { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 if ((int) mydst & 1) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 ffsdrv_write_byte(mydst++, *mysrc++); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 size--; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 while (size >= 2) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 ffsdrv_ram_write_halfword((uint16 *) mydst, mysrc[0]|(mysrc[1] << 8)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 size -= 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 mysrc += 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 mydst += 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 if (size == 1) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 ffsdrv_write_byte(mydst++, *mysrc++); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 #endif |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 void ffsdrv_ram_erase(uint8 block) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 int i; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 char *addr; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 addr = block2addr(block); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 for (i = 0; i < (1 << dev.binfo[block].size_ld); i++) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 *addr++ = 0xFF; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 const struct ffsdrv_s ffsdrv = { |
218
fee45482aa2a
FFS: hopefully-correct initialization for the FFS_IN_RAM configuration
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
209
diff
changeset
|
192 ffsdrv_null_init, |
209
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 ffsdrv_ram_erase, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 ffsdrv_ram_write_halfword, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 ffsdrv_generic_write, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 ffsdrv_null_write_end, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 ffsdrv_null_erase_suspend, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 ffsdrv_null_erase_resume |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 }; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 #elif CONFIG_FLASH_WRITE |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 /****************************************************************************** |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 * AMD Dual/Multi Bank Driver Functions |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 ******************************************************************************/ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 // All erase and write operations are performed atomically (interrupts |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 // disabled). Otherwise we cannot trust the value of dev.state and we cannot |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 // determine exactly how many of the command words have already been |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 // written. |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 // in ffs_end() when we resume an erasure that was previously suspended, how |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 // does that affect multiple tasks doing that simultaneously? |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 void ffsdrv_amd_write_end(void); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 void ffsdrv_amd_erase_end(void); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
217 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 void ffsdrv_amd_write_halfword(volatile uint16 *addr, uint16 value) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 volatile char *flash = dev.base; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 uint32 cpsr; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
222 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 tlw(led_on(LED_WRITE)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 ttw(ttr(TTrDrvWrite, "wh(%x,%x)" NL, addr, value)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
225 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
226 dev.addr = addr; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 dev.data = value; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 if (~*addr & value) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 ttw(ttr(TTrFatal, "wh(%x,%x->%x) fatal" NL, addr, *addr, value)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 return; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 cpsr = int_disable(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
235 tlw(led_toggle(LED_WRITE_SUSPEND)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 dev.state = DEV_WRITE; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
237 flash[0xAAAA] = 0xAA; // unlock cycle 1 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 flash[0x5555] = 0x55; // unlock cycle 2 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 flash[0xAAAA] = 0xA0; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 *addr = value; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 int_enable(cpsr); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
242 tlw(led_toggle(LED_WRITE_SUSPEND)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 ffsdrv_amd_write_end(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 #if 0 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 /* duplicates ffsdrv_generic_write */ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 void ffsdrv_amd_write(void *dst, const void *src, uint16 size) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 uint8 *mydst = dst; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 const uint8 *mysrc = src; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 if (size > 0) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
255 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 if ((unsigned int) mydst & 1) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 ffsdrv_write_byte(mydst++, *mysrc++); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 size--; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 while (size >= 2) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
261 ffsdrv_amd_write_halfword((uint16 *) mydst, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 mysrc[0] | (mysrc[1] << 8)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 size -= 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
264 mysrc += 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 mydst += 2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
266 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 if (size == 1) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
268 ffsdrv_write_byte(mydst++, *mysrc++); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
269 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
270 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
271 #endif |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
272 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
273 void ffsdrv_amd_write_end(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
274 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
275 while ((*dev.addr ^ dev.data) & 0x80) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
276 tlw(led_toggle(LED_WRITE_SUSPEND)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
277 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
278 dev.state = DEV_READ; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
279 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
280 tlw(led_off(LED_WRITE)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
281 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
282 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
283 void ffsdrv_amd_erase(uint8 block) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
284 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
285 volatile char *flash = dev.base; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
286 uint32 cpsr; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
288 tlw(led_on(LED_ERASE)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
289 ttw(ttr(TTrDrvErase, "e(%d)" NL, block)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
290 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
291 dev.addr = (uint16 *) block2addr(block); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
292 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
293 cpsr = int_disable(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
294 dev.state = DEV_ERASE; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 flash[0xAAAA] = 0xAA; // unlock cycle 1 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
296 flash[0x5555] = 0x55; // unlock cycle 2 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
297 flash[0xAAAA] = 0x80; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
298 flash[0xAAAA] = 0xAA; // unlock cycle 1 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
299 flash[0x5555] = 0x55; // unlock cycle 2 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
300 *dev.addr = 0x30; // AMD erase sector command |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 int_enable(cpsr); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
302 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
303 ffsdrv_amd_erase_end(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
304 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
305 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
306 void ffsdrv_amd_erase_end(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
307 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
308 while ((*dev.addr & 0x80) == 0) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
309 ; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
310 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
311 dev.state = DEV_READ; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
312 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
313 tlw(led_off(LED_ERASE)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
314 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
315 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
316 void ffsdrv_amd_erase_suspend(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
317 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
318 uint32 cpsr; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
319 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
320 tlw(led_on(LED_ERASE_SUSPEND)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
321 ttw(str(TTrDrvErase, "es" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
322 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
323 // if erase has finished then all is ok |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
324 if (*dev.addr & 0x80) { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 ffsdrv_amd_erase_end(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 tlw(led_off(LED_ERASE_SUSPEND)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
327 return; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
328 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
329 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
330 // NOTEME: As there is no way to be absolutely certain that erase |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 // doesn't finish between last poll and the following erase suspend |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 // command, we assume that the erase suspend is safe even though the |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 // erase IS actually already finished. |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
334 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
335 cpsr = int_disable(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
336 dev.state = DEV_ERASE_SUSPEND; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 *dev.addr = 0xB0; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
338 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
339 // Wait for erase suspend to finish |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 while ((*dev.addr & 0x80) == 0) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 ; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
342 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
343 int_enable(cpsr); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
346 void ffsdrv_amd_erase_resume(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
347 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
348 uint32 cpsr; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
349 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 ttw(str(TTrDrvErase, "er" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
352 // NOTEME: See note in erase_suspend()... We assume that the erase |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 // resume is safe even though the erase IS actually already finished. |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 cpsr = int_disable(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
355 dev.state = DEV_ERASE; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
356 *dev.addr = 0x30; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
357 int_enable(cpsr); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
358 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
359 tlw(led_off(LED_ERASE_SUSPEND)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
360 } |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 const struct ffsdrv_s ffsdrv = { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
363 ffsdrv_null_init, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 ffsdrv_amd_erase, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 ffsdrv_amd_write_halfword, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
366 ffsdrv_generic_write, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
367 ffsdrv_amd_write_end, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
368 ffsdrv_amd_erase_suspend, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
369 ffsdrv_amd_erase_resume |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
370 }; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
371 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
372 #else |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
373 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
374 /* |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
375 * This part will get compiled if we have real FFS (FFS_IN_RAM=0), |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 * but not allowed to write to flash (CONFIG_FLASH_WRITE=0). |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
377 */ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
378 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
379 const struct ffsdrv_s ffsdrv = { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
380 ffsdrv_null_init, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
381 ffsdrv_null_erase, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
382 ffsdrv_null_write_halfword, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 ffsdrv_null_write, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
384 ffsdrv_null_write_end, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 ffsdrv_null_erase_suspend, |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
386 ffsdrv_null_erase_resume |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
387 }; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
388 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
389 #endif |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
390 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
391 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
392 /****************************************************************************** |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
393 * Initialization |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
394 * |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 * Significantly simplified in FreeCalypso. |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
396 * |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
397 ******************************************************************************/ |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
398 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
399 effs_t ffsdrv_init(void) |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
400 { |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
401 int error; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
402 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
403 tw(tr(TR_BEGIN, TrDrvInit, "drv_init() {\n")); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
404 ttw(str(TTrDrvOther, "ffsdrv_init() {" NL)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
405 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 dev.state = DEV_READ; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
407 dev.atomlog2 = FFS_ATOM_LOG2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 dev.atomsize = 1 << dev.atomlog2; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
409 dev.atomnotmask = dev.atomsize - 1; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
410 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
411 error = ffsdrv.init(); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
412 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
413 tw(tr(TR_FUNC, TrDrvInit, "dev.binfo = 0x%x\n", (unsigned int) dev.binfo)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
414 tw(tr(TR_FUNC, TrDrvInit, "dev.base = 0x%x\n", (unsigned int) dev.base)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
415 tw(tr(TR_FUNC, TrDrvInit, "dev.numblocks = %d\n", dev.numblocks)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
416 tw(tr(TR_FUNC, TrDrvInit, "dev.blocksize = %d\n", dev.blocksize)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
417 tw(tr(TR_FUNC, TrDrvInit, "dev.atomlog2/atomsize/atomnotmask = %d/%d/%x\n", |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 dev.atomlog2, dev.atomsize, dev.atomnotmask)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 tw(tr(TR_END, TrDrvInit, "} %d\n", error)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
420 ttw(ttr(TTrDrvOther, "} %d" NL, error)); |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
421 |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 return error; |
6f4a12b4582f
gsm-fw FFS: starting to integrate C code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
423 } |