21 #define MSPM0_FLASH_BASE_NONMAIN 0x41C00000
22 #define MSPM0_FLASH_END_NONMAIN 0x41C00400
23 #define MSPM0_FLASH_BASE_MAIN 0x0
24 #define MSPM0_FLASH_BASE_DATA 0x41D00000
27 #define MSPM0_FACTORYREGION 0x41C40000
28 #define MSPM0_TRACEID (MSPM0_FACTORYREGION + 0x000)
29 #define MSPM0_DID (MSPM0_FACTORYREGION + 0x004)
30 #define MSPM0_USERID (MSPM0_FACTORYREGION + 0x008)
31 #define MSPM0_SRAMFLASH (MSPM0_FACTORYREGION + 0x018)
34 #define FLASH_CONTROL_BASE 0x400CD000
35 #define FCTL_REG_DESC (FLASH_CONTROL_BASE + 0x10FC)
36 #define FCTL_REG_CMDEXEC (FLASH_CONTROL_BASE + 0x1100)
37 #define FCTL_REG_CMDTYPE (FLASH_CONTROL_BASE + 0x1104)
38 #define FCTL_REG_CMDADDR (FLASH_CONTROL_BASE + 0x1120)
39 #define FCTL_REG_CMDBYTEN (FLASH_CONTROL_BASE + 0x1124)
40 #define FCTL_REG_CMDDATA0 (FLASH_CONTROL_BASE + 0x1130)
41 #define FCTL_REG_CMDWEPROTA (FLASH_CONTROL_BASE + 0x11D0)
42 #define FCTL_REG_CMDWEPROTB (FLASH_CONTROL_BASE + 0x11D4)
43 #define FCTL_REG_CMDWEPROTNM (FLASH_CONTROL_BASE + 0x1210)
44 #define FCTL_REG_STATCMD (FLASH_CONTROL_BASE + 0x13D0)
47 #define FCTL_STATCMD_CMDDONE_MASK 0x00000001
48 #define FCTL_STATCMD_CMDDONE_STATDONE 0x00000001
51 #define FCTL_STATCMD_CMDPASS_MASK 0x00000002
52 #define FCTL_STATCMD_CMDPASS_STATPASS 0x00000002
58 #define FCTL_CMDEXEC_VAL_EXECUTE 0x00000001
61 #define FCTL_CMDTYPE_COMMAND_PROGRAM 0x00000001
62 #define FCTL_CMDTYPE_COMMAND_ERASE 0x00000002
65 #define FCTL_CMDTYPE_SIZE_ONEWORD 0x00000000
66 #define FCTL_CMDTYPE_SIZE_SECTOR 0x00000040
69 #define FCTL_FEATURE_VER_B 0xA
71 #define MSPM0_MAX_PROTREGS 3
73 #define MSPM0_FLASH_TIMEOUT_MS 8000
74 #define ERR_STRING_MAX 255
77 #define SYSCTL_BASE 0x400AF000
78 #define SYSCTL_SECCFG_SECSTATUS (SYSCTL_BASE + 0x00003048)
81 #define TI_MANUFACTURER_ID 0x17
84 #define MSPM0_NO_ID_FOUND 0
85 #define MSPM0_DEV_ID_FOUND 1
86 #define MSPM0_DEV_PART_ID_FOUND 2
132 {
"MSPM0L1105TDGS20R", 0x51DB, 0x16 },
133 {
"MSPM0L1105TDGS28R", 0x51DB, 0x83 },
134 {
"MSPM0L1105TDYYR", 0x51DB, 0x54 },
135 {
"MSPM0L1105TRGER", 0x51DB, 0x86 },
136 {
"MSPM0L1105TRHBR", 0x51DB, 0x68 },
137 {
"MSPM0L1106TDGS20R", 0x5552, 0x4B },
138 {
"MSPM0L1106TDGS28R", 0x5552, 0x98 },
139 {
"MSPM0L1106TDYYR", 0x5552, 0x9D },
140 {
"MSPM0L1106TRGER", 0x5552, 0x90 },
141 {
"MSPM0L1106TRHBR", 0x5552, 0x53 },
143 {
"MSPM0L1303SRGER", 0xef0, 0x17 },
144 {
"MSPM0L1303TRGER", 0xef0, 0xe2 },
145 {
"MSPM0L1304QDGS20R", 0xd717, 0x91 },
146 {
"MSPM0L1304QDGS28R", 0xd717, 0xb6 },
147 {
"MSPM0L1304QDYYR", 0xd717, 0xa0 },
148 {
"MSPM0L1304QRHBR", 0xd717, 0xa9 },
149 {
"MSPM0L1304SDGS20R", 0xd717, 0xfa },
150 {
"MSPM0L1304SDGS28R", 0xd717, 0x73 },
151 {
"MSPM0L1304SDYYR", 0xd717, 0xb7 },
152 {
"MSPM0L1304SRGER", 0xd717, 0x26 },
153 {
"MSPM0L1304SRHBR", 0xd717, 0xe4 },
154 {
"MSPM0L1304TDGS20R", 0xd717, 0x33 },
155 {
"MSPM0L1304TDGS28R", 0xd717, 0xa8 },
156 {
"MSPM0L1304TDYYR", 0xd717, 0xf9 },
157 {
"MSPM0L1304TRGER", 0xd717, 0xb7 },
158 {
"MSPM0L1304TRHBR", 0xd717, 0x5a },
159 {
"MSPM0L1305QDGS20R", 0x4d03, 0xb7 },
160 {
"MSPM0L1305QDGS28R", 0x4d03, 0x74 },
161 {
"MSPM0L1305QDYYR", 0x4d03, 0xec },
162 {
"MSPM0L1305QRHBR", 0x4d03, 0x78 },
163 {
"MSPM0L1305SDGS20R", 0x4d03, 0xc7 },
164 {
"MSPM0L1305SDGS28R", 0x4d03, 0x64 },
165 {
"MSPM0L1305SDYYR", 0x4d03, 0x91 },
166 {
"MSPM0L1305SRGER", 0x4d03, 0x73 },
167 {
"MSPM0L1305SRHBR", 0x4d03, 0x2d },
168 {
"MSPM0L1305TDGS20R", 0x4d03, 0xa0 },
169 {
"MSPM0L1305TDGS28R", 0x4d03, 0xfb },
170 {
"MSPM0L1305TDYYR", 0x4d03, 0xde },
171 {
"MSPM0L1305TRGER", 0x4d03, 0xea },
172 {
"MSPM0L1305TRHBR", 0x4d03, 0x85 },
173 {
"MSPM0L1306QDGS20R", 0xbb70, 0x59 },
174 {
"MSPM0L1306QDGS28R", 0xbb70, 0xf7 },
175 {
"MSPM0L1306QDYYR", 0xbb70, 0x9f },
176 {
"MSPM0L1306QRHBR", 0xbb70, 0xc2 },
177 {
"MSPM0L1306SDGS20R", 0xbb70, 0xf4 },
178 {
"MSPM0L1306SDGS28R", 0xbb70, 0x5 },
179 {
"MSPM0L1306SDYYR", 0xbb70, 0xe },
180 {
"MSPM0L1306SRGER", 0xbb70, 0x7f },
181 {
"MSPM0L1306SRHBR", 0xbb70, 0x3c },
182 {
"MSPM0L1306TDGS20R", 0xbb70, 0xa },
183 {
"MSPM0L1306TDGS28R", 0xbb70, 0x63 },
184 {
"MSPM0L1306TDYYR", 0xbb70, 0x35 },
185 {
"MSPM0L1306TRGER", 0xbb70, 0xaa },
186 {
"MSPM0L1306TRHBR", 0xbb70, 0x52 },
187 {
"MSPM0L1343TDGS20R", 0xb231, 0x2e },
188 {
"MSPM0L1344TDGS20R", 0x40b0, 0xd0 },
189 {
"MSPM0L1345TDGS28R", 0x98b4, 0x74 },
190 {
"MSPM0L1346TDGS28R", 0xf2b5, 0xef },
196 {
"MSPM0G1105TPTR", 0x8934, 0xD },
197 {
"MSPM0G1105TRGZR", 0x8934, 0xFE },
198 {
"MSPM0G1106TPMR", 0x477B, 0xD4 },
199 {
"MSPM0G1106TPTR", 0x477B, 0x71 },
200 {
"MSPM0G1106TRGZR", 0x477B, 0xBB },
201 {
"MSPM0G1106TRHBR", 0x477B, 0x01 },
202 {
"MSPM0G1106TYCJR", 0x477B, 0x09 },
203 {
"MSPM0G1107TDGS28R", 0x807B, 0x82 },
204 {
"MSPM0G1107TPMR", 0x807B, 0xB3 },
205 {
"MSPM0G1107TPTR", 0x807B, 0x32 },
206 {
"MSPM0G1107TRGER", 0x807B, 0x79 },
207 {
"MSPM0G1107TRGZR", 0x807B, 0x20 },
208 {
"MSPM0G1107TRHBR", 0x807B, 0xBC },
209 {
"MSPM0G1107TYCJR", 0x807B, 0x7A },
211 {
"MSPM0G1505SDGS28R", 0x13C4, 0x73 },
212 {
"MSPM0G1505SPMR", 0x13C4, 0x53 },
213 {
"MSPM0G1505SPTR", 0x13C4, 0x3E },
214 {
"MSPM0G1505SRGER", 0x13C4, 0x47 },
215 {
"MSPM0G1505SRGZR", 0x13C4, 0x34 },
216 {
"MSPM0G1505SRHBR", 0x13C4, 0x30 },
217 {
"MSPM0G1506SDGS28R", 0x5AE0, 0x3A },
218 {
"MSPM0G1506SPMR", 0x5AE0, 0xF6 },
219 {
"MSPM0G1506SRGER", 0x5AE0, 0x67 },
220 {
"MSPM0G1506SRGZR", 0x5AE0, 0x75 },
221 {
"MSPM0G1506SRHBR", 0x5AE0, 0x57 },
222 {
"MSPM0G1506SRPTR", 0x5AE0, 0x36 },
223 {
"MSPM0G1506SYCJR", 0x5AE0, 0x9E },
224 {
"MSPM0G1507SDGS28R", 0x2655, 0x6D },
225 {
"MSPM0G1507SPMR", 0x2655, 0x97 },
226 {
"MSPM0G1507SPTR", 0x2655, 0x2E },
227 {
"MSPM0G1507SRGER", 0x2655, 0x83 },
228 {
"MSPM0G1507SRGZR", 0x2655, 0xD3 },
229 {
"MSPM0G1507SRHBR", 0x2655, 0x4D },
230 {
"MSPM0G1507SYCJR", 0x2655, 0x65 },
232 {
"MSPM0G3105SDGS20R", 0x4749, 0x21 },
233 {
"MSPM0G3105SDGS28R", 0x4749, 0xDD },
234 {
"MSPM0G3105SRHBR", 0x4749, 0xBE },
235 {
"MSPM0G3106SDGS20R", 0x54C7, 0xD2 },
236 {
"MSPM0G3106SDGS28R", 0x54C7, 0xB9 },
237 {
"MSPM0G3106SRHBR", 0x54C7, 0x67 },
238 {
"MSPM0G3107SDGS20R", 0xAB39, 0x5C },
239 {
"MSPM0G3107SDGS28R", 0xAB39, 0xCC },
240 {
"MSPM0G3107SRHBR", 0xAB39, 0xB7 },
242 {
"MSPM0G3505SDGS28R", 0xc504, 0x8e },
243 {
"MSPM0G3505SPMR", 0xc504, 0x1d },
244 {
"MSPM0G3505SPTR", 0xc504, 0x93 },
245 {
"MSPM0G3505SRGZR", 0xc504, 0xc7 },
246 {
"MSPM0G3505SRHBR", 0xc504, 0xe7 },
247 {
"MSPM0G3506SDGS28R", 0x151f, 0x8 },
248 {
"MSPM0G3506SPMR", 0x151f, 0xd4 },
249 {
"MSPM0G3506SPTR", 0x151f, 0x39 },
250 {
"MSPM0G3506SRGZR", 0x151f, 0xfe },
251 {
"MSPM0G3506SRHBR", 0x151f, 0xb5 },
252 {
"MSPM0G3507SDGS28R", 0xae2d, 0xca },
253 {
"MSPM0G3507SPMR", 0xae2d, 0xc7 },
254 {
"MSPM0G3507SPTR", 0xae2d, 0x3f },
255 {
"MSPM0G3507SRGZR", 0xae2d, 0xf7 },
256 {
"MSPM0G3507SRHBR", 0xae2d, 0x4c },
258 {
"M0G3105QDGS20RQ1", 0x1349, 0xFB},
259 {
"M0G3105QDGS28RQ1", 0x1349, 0x1B},
260 {
"M0G3105QDGS32RQ1", 0x1349, 0x08},
261 {
"M0G3105QPMRQ1", 0x1349, 0xD0},
262 {
"M0G3105QPTRQ1", 0x1349, 0xEF},
263 {
"M0G3105QRGZRQ1", 0x1349, 0x70},
264 {
"M0G3105QRHBRQ1", 0x1349, 0x01},
265 {
"M0G3106QDGS20RQ1", 0x94AD, 0x6F},
266 {
"M0G3106QDGS28RQ1", 0x94AD, 0x03},
267 {
"M0G3106QDGS32RQ1", 0x94AD, 0x8D},
268 {
"M0G3106QPMRQ1", 0x54C7, 0x08},
269 {
"M0G3106QPTRQ1", 0x54C7, 0x3F},
270 {
"M0G3106QRGZRQ1", 0x94AD, 0xE6},
271 {
"M0G3106QRHBRQ1", 0x94AD, 0x20},
272 {
"M0G3107QDGS20RQ1", 0x4e2f, 0xfd},
273 {
"M0G3107QDGS28RQ1", 0x4e2f, 0x67},
274 {
"M0G3107QDGS28RQ1", 0x4e2f, 0xd5},
275 {
"M0G3107QPMRQ1", 0x4e2f, 0x51 },
276 {
"M0G3107QPTRQ1", 0x4e2f, 0xc7},
277 {
"M0G3107QRGZRQ1", 0x4e2f, 0x8a },
278 {
"M0G3107QRHBRQ1", 0x4e2f, 0x9a},
280 {
"M0G3505QDGS28RQ1", 0x704E, 0x4C },
281 {
"M0G3505QDGS32RQ1", 0x704E, 0x7F },
282 {
"M0G3505QPMRQ1", 0x704E, 0x7B },
283 {
"M0G3505QPTRQ1", 0x704E, 0x9C },
284 {
"M0G3505QRGZRQ1", 0x704E, 0xC9 },
285 {
"M0G3505QRHBRQ1", 0x704E, 0x26 },
286 {
"M0G3506QDGS28RQ1", 0xEE12, 0x71 },
287 {
"M0G3506QDGS32RQ1", 0xEE12, 0x6C },
288 {
"M0G3506QPMRQ1", 0xEE12, 0x7B },
289 {
"M0G3506QPTRQ1", 0xEE12, 0x5A },
290 {
"M0G3506QRGZRQ1", 0xEE12, 0xD2 },
291 {
"M0G3506QRHBRQ1", 0xEE12, 0xFC },
292 {
"M0G3507QDGS28RQ1", 0x34E0, 0xEA },
293 {
"M0G3507QDGS32RQ1", 0x34E0, 0xF6 },
294 {
"M0G3507QPMRQ1", 0x34E0, 0x26 },
295 {
"M0G3507QRGZRQ1", 0x34E0, 0xC5 },
296 {
"M0G3507QRHBRQ1", 0x34E0, 0xAC },
297 {
"M0G3507QSPTRQ1", 0x34E0, 0xE3 },
303 {
"MSPM0G1518SPMR", 0x2120, 0x13 },
304 {
"MSPM0G1518SPNR", 0x2120, 0x16 },
305 {
"MSPM0G1518SPTR", 0x2120, 0x12 },
306 {
"MSPM0G1518SPZR", 0x2120, 0x18 },
307 {
"MSPM0G1518SRGZR", 0x2120, 0x11 },
308 {
"MSPM0G1518SRHBR", 0x2120, 0x10 },
309 {
"MSPM0G1518SZAWR", 0x2120, 0x19 },
310 {
"MSPM0G1519SPMR", 0x2407, 0x13 },
311 {
"MSPM0G1519SPNR", 0x2407, 0x16 },
312 {
"MSPM0G1519SPTR", 0x2407, 0x12 },
313 {
"MSPM0G1519SPZR", 0x2407, 0x18 },
314 {
"MSPM0G1519SRGZR", 0x2407, 0x11 },
315 {
"MSPM0G1519SRHBR", 0x2407, 0x10 },
316 {
"MSPM0G1519SZAWR", 0x2407, 0x19 },
317 {
"MSPM0G3518SPMR", 0x1205, 0x13 },
318 {
"MSPM0G3518SPNR", 0x1205, 0x15 },
319 {
"MSPM0G3518SPTR", 0x1205, 0x12 },
320 {
"MSPM0G3518SPZR", 0x1205, 0x16 },
321 {
"MSPM0G3518SRGZR", 0x1205, 0x11 },
322 {
"MSPM0G3518SRHBR", 0x1205, 0x10 },
323 {
"MSPM0G3518SZAWR", 0x1205, 0x19 },
324 {
"MSPM0G3519SPMR", 0x1508, 0x13 },
325 {
"MSPM0G3519SPNR", 0x1508, 0x15 },
326 {
"MSPM0G3519SPTR", 0x1508, 0x12 },
327 {
"MSPM0G3519SPZR", 0x1508, 0x16 },
328 {
"MSPM0G3519SRGZR", 0x1508, 0x11 },
329 {
"MSPM0G3519SRHBR", 0x1508, 0x10 },
330 {
"MSPM0G3519SZAWR", 0x1508, 0x19 },
332 {
"M0G3518QPMRQ1", 0x4009, 0x13 },
333 {
"M0G3518QPNRQ1", 0x4009, 0x14 },
334 {
"M0G3518QPTRQ1", 0x4009, 0x12 },
335 {
"M0G3518QPZRQ1", 0x4009, 0x15 },
336 {
"M0G3518QRGZRQ1", 0x4009, 0x11 },
337 {
"M0G3518QRHBRQ1", 0x4009, 0x10 },
338 {
"M0G3519QPMRQ1", 0x3512, 0x13 },
339 {
"M0G3519AQPMRQ1", 0x3512, 0x16 },
340 {
"M0G3519QPNRQ1", 0x3512, 0x14 },
341 {
"M0G3519QPTRQ1", 0x3512, 0x12 },
342 {
"M0G3519QPZRQ1", 0x3512, 0x15 },
343 {
"M0G3519QRGZRQ1", 0x3512, 0x11 },
344 {
"M0G3519QRHBRQ1", 0x3512, 0x10 },
346 {
"M0G3529QPMRQ1", 0xF8D1, 0x13 },
352 {
"MSPM0G5187S28YCJR", 0x5610, 0x18 },
353 {
"MSPM0G5187SDGS20R", 0x5610, 0x16 },
354 {
"MSPM0G5187SPMR", 0x5610, 0x10 },
355 {
"MSPM0G5187SPTR", 0x5610, 0x11 },
356 {
"MSPM0G5187SRHBR", 0x5610, 0x13 },
357 {
"MSPM0G5187SRGER", 0x5610, 0x14 },
358 {
"MSPM0G5187SRGZR", 0x5610, 0x12 },
359 {
"MSPM0G5187SRUYR", 0x5610, 0x17 },
364 {
"MSPS003F4SPW20R", 0x57b3, 0x70},
365 {
"MSPM0C1104SDGS20R", 0x57b3, 0x71},
366 {
"MSPM0C1104SRUKR", 0x57b3, 0x73},
367 {
"MSPM0C1104SDYYR", 0x57b3, 0x75},
368 {
"MSPM0C1104SDDFR", 0x57b3, 0x77},
369 {
"MSPM0C1104SDSGR", 0x57b3, 0x79},
374 {
"MSPM0L1227SRGER", 0x7C32, 0xF1},
375 {
"MSPM0L1227SPTR", 0x7C32, 0xC9},
376 {
"MSPM0L1227SPMR", 0x7C32, 0x1C},
377 {
"MSPM0L1227SPNAR", 0x7C32, 0x91},
378 {
"MSPM0L1227SPNR", 0x7C32, 0x39},
379 {
"MSPM0L1228SRGER", 0x33F7, 0x13},
380 {
"MSPM0L1228SRHBR", 0x33F7, 0x3A},
381 {
"MSPM0L1228SRGZR", 0x33F7, 0xBC},
382 {
"MSPM0L1228SPTR", 0x33F7, 0xF8},
383 {
"MSPM0L1228SPMR", 0x33F7, 0xCE},
384 {
"MSPM0L1228SPNAR", 0x33F7, 0x59},
385 {
"MSPM0L1228SPNR", 0x33F7, 0x7},
386 {
"MSPM0L2227SRGZR", 0x5E8F, 0x90},
387 {
"MSPM0L2227SPTR", 0x5E8F, 0xA},
388 {
"MSPM0L2227SPMR", 0x5E8F, 0x6D},
389 {
"MSPM0L2227SPNAR", 0x5E8F, 0x24},
390 {
"MSPM0L2227SPNR", 0x5E8F, 0x68},
391 {
"MSPM0L2228SRGZR", 0x2C38, 0xB8},
392 {
"MSPM0L2228SPTR", 0x2C38, 0x25},
393 {
"MSPM0L2228SPMR", 0x2C38, 0x6E},
394 {
"MSPM0L2228SPNAR", 0x2C38, 0x63},
395 {
"MSPM0L2228SPNR", 0x2C38, 0x3C},
418 switch (
bank->base) {
430 LOG_ERROR(
"%s: Out of memory for mspm0_info!", __func__);
434 bank->driver_priv = mspm0_info;
448 if (mspm0_info->
did == 0)
452 "\nTI MSPM0 information: Chip is "
453 "%s rev %d Device Unique ID: 0x%" PRIu32
"\n",
457 "main flash: %uKiB in %u bank(s), sram: %uKiB, data flash: %uKiB",
468 return (var &
GENMASK(hi, lo)) >> lo;
498 LOG_ERROR(
"Failed to read sramflash register");
504 LOG_ERROR(
"Failed to read flashctl description register");
524 LOG_WARNING(
"Unknown Device ID[0x%" PRIx32
"], cannot identify target",
526 LOG_DEBUG(
"did 0x%" PRIx32
", traceid 0x%" PRIx32
", userid 0x%" PRIx32
527 ", flashram 0x%" PRIx32, did, mspm0_info->
traceid, userid,
533 unsigned char minfo_idx = 0xff;
547 unsigned char pinfo_idx = 0xff;
556 for (
unsigned int i = 0; i < minfo->
part_count; i++) {
579 switch (probe_status) {
581 mspm0_info->
name =
"mspm0x";
582 LOG_INFO(
"Unidentified PART[0x%x]/variant[0x%x"
583 "], unknown DeviceID[0x%x"
584 "]. Attempting to proceed as %s.", part, variant, pnum,
589 LOG_INFO(
"Unidentified PART[0x%x]/variant[0x%x"
590 "], known DeviceID[0x%x"
591 "]. Attempting to proceed as %s.", part, variant, pnum,
601 mspm0_info->
did = did;
617 LOG_DEBUG(
"Detected: main flash: %uKb in %u banks, sram: %uKb, data flash: %uKb",
627 static const struct {
631 { 2,
"CMDINPROGRESS" },
634 { 6,
"FAILILLADDR" },
647 return "FAILUNKNOWN";
651 unsigned int *
reg,
unsigned int *sector_mask)
656 unsigned int sector_num = (
addr >> 10);
657 unsigned int sector_in_bank = sector_num;
658 unsigned int phys_sector_num = sector_num;
659 uint32_t sysctl_sec_status;
660 unsigned int exec_upper_bank;
675 if (exec_upper_bank) {
696 switch (
bank->base) {
701 if (phys_sector_num < 32) {
702 *sector_mask =
BIT(phys_sector_num);
707 if (phys_sector_num >= 32 && sector_in_bank < 256) {
710 *sector_mask =
BIT(sector_in_bank / 8);
712 *sector_mask =
BIT((sector_in_bank - 32) / 8);
716 *sector_mask =
BIT((sector_in_bank / 8) % 32);
721 *sector_mask =
BIT(sector_num % 32);
734 LOG_ERROR(
"Unable to map sector protect reg for address 0x%08x",
addr);
751 switch (
bank->base) {
776 unsigned int reg = 0x0;
777 uint32_t sector_mask = 0x0;
783 LOG_ERROR(
"Unable to map sector protect reg for address 0x%08x",
addr);
786 LOG_ERROR(
"Unable to determine which bank to use 0x%08x",
addr);
824 uint32_t return_code = 0;
867 LOG_ERROR(
"Unprotecting sector of memory at address 0x%08" PRIx32
888 if (mspm0_info->
did == 0)
910 for (
unsigned int i = 0; i <
bank->num_sectors; i++)
911 bank->sectors[i].is_protected = 0;
924 LOG_ERROR(
"Please halt target for erasing flash");
928 if (mspm0_info->
did == 0)
935 &protect_reg_cache[i]);
937 LOG_ERROR(
"Failed saving flashctl protection status");
942 switch (
bank->base) {
944 for (
unsigned int csa = first; csa <= last; csa++) {
948 LOG_ERROR(
"Sector erase on MAIN failed at address 0x%08x "
949 "(sector: %u)",
addr, csa);
955 LOG_ERROR(
"Sector erase on NONMAIN failed");
958 for (
unsigned int csa = first; csa <= last; csa++) {
963 LOG_ERROR(
"Sector erase on DATA bank failed at address 0x%08x "
964 "(sector: %u)",
addr, csa);
968 LOG_ERROR(
"Invalid memory region access");
988 protect_reg_cache[i]);
990 LOG_ERROR(
"Failed re-applying protection status of flashctl");
1017 LOG_ERROR(
"Please halt target for programming flash");
1021 if (mspm0_info->
did == 0)
1032 &protect_reg_cache[i]);
1034 LOG_ERROR(
"Failed saving flashctl protection status");
1043 unsigned int num_bytes_to_write;
1054 num_bytes_to_write =
count;
1059 bytes_en = (1 << num_bytes_to_write) - 1;
1066 bytes_en |=
BIT(16);
1067 bytes_en |= (num_bytes_to_write > 8) ?
BIT(17) : 0;
1070 LOG_ERROR(
"Invalid flash_word_size_bytes %d",
1089 addr += num_bytes_to_write;
1090 buffer += num_bytes_to_write;
1091 count -= num_bytes_to_write;
1114 protect_reg_cache[i]);
1116 LOG_ERROR(
"Failed re-applying protection status of flashctl");
1132 if (mspm0_info->
did != 0)
1144 if (
bank->sectors) {
1145 free(
bank->sectors);
1149 bank->write_start_alignment = 4;
1150 bank->write_end_alignment = 4;
1152 switch (
bank->base) {
1155 bank->num_sectors = 0x1;
1177 LOG_INFO(
"Data region NOT available!");
1179 bank->num_sectors = 0x0;
1200 if (!
bank->sectors) {
1201 LOG_ERROR(
"Out of memory for sectors!");
1204 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
1207 bank->sectors[i].is_erased = -1;
1215 .flash_bank_command = mspm0_flash_bank_command,
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
uint64_t buffer
Pointer to data buffer to send over SPI.
#define ERROR_FLASH_BANK_INVALID
#define ERROR_FLASH_SECTOR_INVALID
#define ERROR_FLASH_BANK_NOT_PROBED
#define ERROR_FLASH_OPERATION_FAILED
#define ERROR_FLASH_DST_OUT_OF_BANK
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
#define FCTL_CMDEXEC_VAL_EXECUTE
static int mspm0_fctl_wait_cmd_ok(struct flash_bank *bank)
#define MSPM0_DEV_PART_ID_FOUND
static const struct mspm0_part_info mspm0g_parts_bb88[]
#define FCTL_CMDTYPE_SIZE_SECTOR
#define MSPM0_FLASH_TIMEOUT_MS
#define FCTL_STATCMD_CMDDONE_MASK
static const char * mspm0_fctl_translate_ret_err(unsigned int return_code)
#define MSPM0_FLASH_BASE_MAIN
static int get_mspm0_info(struct flash_bank *bank, struct command_invocation *cmd)
static int mspm0_write(struct flash_bank *bank, const unsigned char *buffer, unsigned int offset, unsigned int count)
static const struct mspm0_part_info mspm0lx22x_parts[]
const struct flash_driver mspm0_flash
static unsigned int mspm0_extract_val(unsigned int var, unsigned char hi, unsigned char lo)
#define MSPM0_MAX_PROTREGS
#define FCTL_REG_CMDBYTEN
#define FCTL_STATCMD_CMDPASS_MASK
static int mspm0_fctl_get_sector_reg(struct flash_bank *bank, unsigned int addr, unsigned int *reg, unsigned int *sector_mask)
static const struct mspm0_family_info mspm0_finf[]
#define MSPM0_FLASH_END_NONMAIN
static const struct mspm0_part_info mspm0l_parts[]
const unsigned char bit_offset
static int mspm0_fctl_unprotect_sector(struct flash_bank *bank, unsigned int addr)
static int mspm0_fctl_cfg_command(struct flash_bank *bank, uint32_t addr, uint32_t cmd, uint32_t byte_en)
static int mspm0_protect_check(struct flash_bank *bank)
static const struct mspm0_part_info mspm0g_parts_bba9[]
#define FCTL_REG_CMDWEPROTB
#define FCTL_CMDTYPE_COMMAND_ERASE
FLASH_BANK_COMMAND_HANDLER(mspm0_flash_bank_command)
static const struct mspm0_part_info mspm0c_parts[]
#define MSPM0_NO_ID_FOUND
#define TI_MANUFACTURER_ID
#define MSPM0_FLASH_BASE_DATA
#define FCTL_FEATURE_VER_B
static const struct mspm0_part_info mspm0g_parts_bbbc[]
#define FCTL_STATCMD_CMDPASS_STATPASS
#define FCTL_STATCMD_CMDDONE_STATDONE
static const struct @12 mspm0_fctl_fail_decode_strings[]
static int mspm0_probe(struct flash_bank *bank)
#define FCTL_REG_CMDWEPROTA
#define MSPM0_FLASH_BASE_NONMAIN
#define MSPM0_DEV_ID_FOUND
static int mspm0_read_part_info(struct flash_bank *bank)
#define SYSCTL_SECCFG_SECSTATUS
#define FCTL_CMDTYPE_SIZE_ONEWORD
static int mspm0_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
static int mspm0_address_check(struct flash_bank *bank, unsigned int addr)
#define FCTL_CMDTYPE_COMMAND_PROGRAM
#define FCTL_REG_CMDWEPROTNM
static int mspm0_fctl_sector_erase(struct flash_bank *bank, uint32_t addr)
#define FCTL_REG_CMDDATA0
target_addr_t addr
Start address to search for the control block.
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Provides details of a flash bank, available either on-chip or through a major interface.
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
Describes the geometry and status of a single flash sector within a flash bank.
const struct mspm0_part_info * part_info
unsigned int main_flash_num_banks
unsigned int protect_reg_base
unsigned int data_flash_size_kb
unsigned int protect_reg_count
unsigned int main_flash_size_kb
unsigned char flash_version
unsigned int sram_size_kb
unsigned char flash_word_size_bytes
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
#define ERROR_TARGET_NOT_HALTED
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.