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)
89 #define SYSCTL_MCLKCFG (SYSCTL_BASE + 0x00001104)
90 #define SYSCTL_MCLKCFG_USEHSCLK BIT(16)
91 #define SYSCTL_MCLKCFG_FLASHWAIT_MASK GENMASK(11, 8)
92 #define SYSCTL_MCLKCFG_FLASHWAIT_2 (2U << 8)
95 #define TI_MANUFACTURER_ID 0x17
98 #define MSPM0_NO_ID_FOUND 0
99 #define MSPM0_DEV_ID_FOUND 1
100 #define MSPM0_DEV_PART_ID_FOUND 2
146 {
"MSPM0L1105TDGS20R", 0x51DB, 0x16 },
147 {
"MSPM0L1105TDGS28R", 0x51DB, 0x83 },
148 {
"MSPM0L1105TDYYR", 0x51DB, 0x54 },
149 {
"MSPM0L1105TRGER", 0x51DB, 0x86 },
150 {
"MSPM0L1105TRHBR", 0x51DB, 0x68 },
151 {
"MSPM0L1106TDGS20R", 0x5552, 0x4B },
152 {
"MSPM0L1106TDGS28R", 0x5552, 0x98 },
153 {
"MSPM0L1106TDYYR", 0x5552, 0x9D },
154 {
"MSPM0L1106TRGER", 0x5552, 0x90 },
155 {
"MSPM0L1106TRHBR", 0x5552, 0x53 },
157 {
"MSPM0L1303SRGER", 0xef0, 0x17 },
158 {
"MSPM0L1303TRGER", 0xef0, 0xe2 },
159 {
"MSPM0L1304QDGS20R", 0xd717, 0x91 },
160 {
"MSPM0L1304QDGS28R", 0xd717, 0xb6 },
161 {
"MSPM0L1304QDYYR", 0xd717, 0xa0 },
162 {
"MSPM0L1304QRHBR", 0xd717, 0xa9 },
163 {
"MSPM0L1304SDGS20R", 0xd717, 0xfa },
164 {
"MSPM0L1304SDGS28R", 0xd717, 0x73 },
165 {
"MSPM0L1304SDYYR", 0xd717, 0xb7 },
166 {
"MSPM0L1304SRGER", 0xd717, 0x26 },
167 {
"MSPM0L1304SRHBR", 0xd717, 0xe4 },
168 {
"MSPM0L1304TDGS20R", 0xd717, 0x33 },
169 {
"MSPM0L1304TDGS28R", 0xd717, 0xa8 },
170 {
"MSPM0L1304TDYYR", 0xd717, 0xf9 },
171 {
"MSPM0L1304TRGER", 0xd717, 0xb7 },
172 {
"MSPM0L1304TRHBR", 0xd717, 0x5a },
173 {
"MSPM0L1305QDGS20R", 0x4d03, 0xb7 },
174 {
"MSPM0L1305QDGS28R", 0x4d03, 0x74 },
175 {
"MSPM0L1305QDYYR", 0x4d03, 0xec },
176 {
"MSPM0L1305QRHBR", 0x4d03, 0x78 },
177 {
"MSPM0L1305SDGS20R", 0x4d03, 0xc7 },
178 {
"MSPM0L1305SDGS28R", 0x4d03, 0x64 },
179 {
"MSPM0L1305SDYYR", 0x4d03, 0x91 },
180 {
"MSPM0L1305SRGER", 0x4d03, 0x73 },
181 {
"MSPM0L1305SRHBR", 0x4d03, 0x2d },
182 {
"MSPM0L1305TDGS20R", 0x4d03, 0xa0 },
183 {
"MSPM0L1305TDGS28R", 0x4d03, 0xfb },
184 {
"MSPM0L1305TDYYR", 0x4d03, 0xde },
185 {
"MSPM0L1305TRGER", 0x4d03, 0xea },
186 {
"MSPM0L1305TRHBR", 0x4d03, 0x85 },
187 {
"MSPM0L1306QDGS20R", 0xbb70, 0x59 },
188 {
"MSPM0L1306QDGS28R", 0xbb70, 0xf7 },
189 {
"MSPM0L1306QDYYR", 0xbb70, 0x9f },
190 {
"MSPM0L1306QRHBR", 0xbb70, 0xc2 },
191 {
"MSPM0L1306SDGS20R", 0xbb70, 0xf4 },
192 {
"MSPM0L1306SDGS28R", 0xbb70, 0x5 },
193 {
"MSPM0L1306SDYYR", 0xbb70, 0xe },
194 {
"MSPM0L1306SRGER", 0xbb70, 0x7f },
195 {
"MSPM0L1306SRHBR", 0xbb70, 0x3c },
196 {
"MSPM0L1306TDGS20R", 0xbb70, 0xa },
197 {
"MSPM0L1306TDGS28R", 0xbb70, 0x63 },
198 {
"MSPM0L1306TDYYR", 0xbb70, 0x35 },
199 {
"MSPM0L1306TRGER", 0xbb70, 0xaa },
200 {
"MSPM0L1306TRHBR", 0xbb70, 0x52 },
201 {
"MSPM0L1343TDGS20R", 0xb231, 0x2e },
202 {
"MSPM0L1344TDGS20R", 0x40b0, 0xd0 },
203 {
"MSPM0L1345TDGS28R", 0x98b4, 0x74 },
204 {
"MSPM0L1346TDGS28R", 0xf2b5, 0xef },
210 {
"MSPM0G1105TPTR", 0x8934, 0xD },
211 {
"MSPM0G1105TRGZR", 0x8934, 0xFE },
212 {
"MSPM0G1106TPMR", 0x477B, 0xD4 },
213 {
"MSPM0G1106TPTR", 0x477B, 0x71 },
214 {
"MSPM0G1106TRGZR", 0x477B, 0xBB },
215 {
"MSPM0G1106TRHBR", 0x477B, 0x01 },
216 {
"MSPM0G1106TYCJR", 0x477B, 0x09 },
217 {
"MSPM0G1107TDGS28R", 0x807B, 0x82 },
218 {
"MSPM0G1107TPMR", 0x807B, 0xB3 },
219 {
"MSPM0G1107TPTR", 0x807B, 0x32 },
220 {
"MSPM0G1107TRGER", 0x807B, 0x79 },
221 {
"MSPM0G1107TRGZR", 0x807B, 0x20 },
222 {
"MSPM0G1107TRHBR", 0x807B, 0xBC },
223 {
"MSPM0G1107TYCJR", 0x807B, 0x7A },
225 {
"MSPM0G1505SDGS28R", 0x13C4, 0x73 },
226 {
"MSPM0G1505SPMR", 0x13C4, 0x53 },
227 {
"MSPM0G1505SPTR", 0x13C4, 0x3E },
228 {
"MSPM0G1505SRGER", 0x13C4, 0x47 },
229 {
"MSPM0G1505SRGZR", 0x13C4, 0x34 },
230 {
"MSPM0G1505SRHBR", 0x13C4, 0x30 },
231 {
"MSPM0G1506SDGS28R", 0x5AE0, 0x3A },
232 {
"MSPM0G1506SPMR", 0x5AE0, 0xF6 },
233 {
"MSPM0G1506SRGER", 0x5AE0, 0x67 },
234 {
"MSPM0G1506SRGZR", 0x5AE0, 0x75 },
235 {
"MSPM0G1506SRHBR", 0x5AE0, 0x57 },
236 {
"MSPM0G1506SRPTR", 0x5AE0, 0x36 },
237 {
"MSPM0G1506SYCJR", 0x5AE0, 0x9E },
238 {
"MSPM0G1507SDGS28R", 0x2655, 0x6D },
239 {
"MSPM0G1507SPMR", 0x2655, 0x97 },
240 {
"MSPM0G1507SPTR", 0x2655, 0x2E },
241 {
"MSPM0G1507SRGER", 0x2655, 0x83 },
242 {
"MSPM0G1507SRGZR", 0x2655, 0xD3 },
243 {
"MSPM0G1507SRHBR", 0x2655, 0x4D },
244 {
"MSPM0G1507SYCJR", 0x2655, 0x65 },
246 {
"MSPM0G3105SDGS20R", 0x4749, 0x21 },
247 {
"MSPM0G3105SDGS28R", 0x4749, 0xDD },
248 {
"MSPM0G3105SRHBR", 0x4749, 0xBE },
249 {
"MSPM0G3106SDGS20R", 0x54C7, 0xD2 },
250 {
"MSPM0G3106SDGS28R", 0x54C7, 0xB9 },
251 {
"MSPM0G3106SRHBR", 0x54C7, 0x67 },
252 {
"MSPM0G3107SDGS20R", 0xAB39, 0x5C },
253 {
"MSPM0G3107SDGS28R", 0xAB39, 0xCC },
254 {
"MSPM0G3107SRHBR", 0xAB39, 0xB7 },
256 {
"MSPM0G3505SDGS28R", 0xc504, 0x8e },
257 {
"MSPM0G3505SPMR", 0xc504, 0x1d },
258 {
"MSPM0G3505SPTR", 0xc504, 0x93 },
259 {
"MSPM0G3505SRGZR", 0xc504, 0xc7 },
260 {
"MSPM0G3505SRHBR", 0xc504, 0xe7 },
261 {
"MSPM0G3506SDGS28R", 0x151f, 0x8 },
262 {
"MSPM0G3506SPMR", 0x151f, 0xd4 },
263 {
"MSPM0G3506SPTR", 0x151f, 0x39 },
264 {
"MSPM0G3506SRGZR", 0x151f, 0xfe },
265 {
"MSPM0G3506SRHBR", 0x151f, 0xb5 },
266 {
"MSPM0G3507SDGS28R", 0xae2d, 0xca },
267 {
"MSPM0G3507SPMR", 0xae2d, 0xc7 },
268 {
"MSPM0G3507SPTR", 0xae2d, 0x3f },
269 {
"MSPM0G3507SRGZR", 0xae2d, 0xf7 },
270 {
"MSPM0G3507SRHBR", 0xae2d, 0x4c },
272 {
"M0G3105QDGS20RQ1", 0x1349, 0xFB},
273 {
"M0G3105QDGS28RQ1", 0x1349, 0x1B},
274 {
"M0G3105QDGS32RQ1", 0x1349, 0x08},
275 {
"M0G3105QPMRQ1", 0x1349, 0xD0},
276 {
"M0G3105QPTRQ1", 0x1349, 0xEF},
277 {
"M0G3105QRGZRQ1", 0x1349, 0x70},
278 {
"M0G3105QRHBRQ1", 0x1349, 0x01},
279 {
"M0G3106QDGS20RQ1", 0x94AD, 0x6F},
280 {
"M0G3106QDGS28RQ1", 0x94AD, 0x03},
281 {
"M0G3106QDGS32RQ1", 0x94AD, 0x8D},
282 {
"M0G3106QPMRQ1", 0x54C7, 0x08},
283 {
"M0G3106QPTRQ1", 0x54C7, 0x3F},
284 {
"M0G3106QRGZRQ1", 0x94AD, 0xE6},
285 {
"M0G3106QRHBRQ1", 0x94AD, 0x20},
286 {
"M0G3107QDGS20RQ1", 0x4e2f, 0xfd},
287 {
"M0G3107QDGS28RQ1", 0x4e2f, 0x67},
288 {
"M0G3107QDGS28RQ1", 0x4e2f, 0xd5},
289 {
"M0G3107QPMRQ1", 0x4e2f, 0x51 },
290 {
"M0G3107QPTRQ1", 0x4e2f, 0xc7},
291 {
"M0G3107QRGZRQ1", 0x4e2f, 0x8a },
292 {
"M0G3107QRHBRQ1", 0x4e2f, 0x9a},
294 {
"M0G3505QDGS28RQ1", 0x704E, 0x4C },
295 {
"M0G3505QDGS32RQ1", 0x704E, 0x7F },
296 {
"M0G3505QPMRQ1", 0x704E, 0x7B },
297 {
"M0G3505QPTRQ1", 0x704E, 0x9C },
298 {
"M0G3505QRGZRQ1", 0x704E, 0xC9 },
299 {
"M0G3505QRHBRQ1", 0x704E, 0x26 },
300 {
"M0G3506QDGS28RQ1", 0xEE12, 0x71 },
301 {
"M0G3506QDGS32RQ1", 0xEE12, 0x6C },
302 {
"M0G3506QPMRQ1", 0xEE12, 0x7B },
303 {
"M0G3506QPTRQ1", 0xEE12, 0x5A },
304 {
"M0G3506QRGZRQ1", 0xEE12, 0xD2 },
305 {
"M0G3506QRHBRQ1", 0xEE12, 0xFC },
306 {
"M0G3507QDGS28RQ1", 0x34E0, 0xEA },
307 {
"M0G3507QDGS32RQ1", 0x34E0, 0xF6 },
308 {
"M0G3507QPMRQ1", 0x34E0, 0x26 },
309 {
"M0G3507QRGZRQ1", 0x34E0, 0xC5 },
310 {
"M0G3507QRHBRQ1", 0x34E0, 0xAC },
311 {
"M0G3507QSPTRQ1", 0x34E0, 0xE3 },
317 {
"MSPM0G1518SPMR", 0x2120, 0x13 },
318 {
"MSPM0G1518SPNR", 0x2120, 0x16 },
319 {
"MSPM0G1518SPTR", 0x2120, 0x12 },
320 {
"MSPM0G1518SPZR", 0x2120, 0x18 },
321 {
"MSPM0G1518SRGZR", 0x2120, 0x11 },
322 {
"MSPM0G1518SRHBR", 0x2120, 0x10 },
323 {
"MSPM0G1518SZAWR", 0x2120, 0x19 },
324 {
"MSPM0G1519SPMR", 0x2407, 0x13 },
325 {
"MSPM0G1519SPNR", 0x2407, 0x16 },
326 {
"MSPM0G1519SPTR", 0x2407, 0x12 },
327 {
"MSPM0G1519SPZR", 0x2407, 0x18 },
328 {
"MSPM0G1519SRGZR", 0x2407, 0x11 },
329 {
"MSPM0G1519SRHBR", 0x2407, 0x10 },
330 {
"MSPM0G1519SZAWR", 0x2407, 0x19 },
331 {
"MSPM0G3518SPMR", 0x1205, 0x13 },
332 {
"MSPM0G3518SPNR", 0x1205, 0x15 },
333 {
"MSPM0G3518SPTR", 0x1205, 0x12 },
334 {
"MSPM0G3518SPZR", 0x1205, 0x16 },
335 {
"MSPM0G3518SRGZR", 0x1205, 0x11 },
336 {
"MSPM0G3518SRHBR", 0x1205, 0x10 },
337 {
"MSPM0G3518SZAWR", 0x1205, 0x19 },
338 {
"MSPM0G3519SPMR", 0x1508, 0x13 },
339 {
"MSPM0G3519SPNR", 0x1508, 0x15 },
340 {
"MSPM0G3519SPTR", 0x1508, 0x12 },
341 {
"MSPM0G3519SPZR", 0x1508, 0x16 },
342 {
"MSPM0G3519SRGZR", 0x1508, 0x11 },
343 {
"MSPM0G3519SRHBR", 0x1508, 0x10 },
344 {
"MSPM0G3519SZAWR", 0x1508, 0x19 },
346 {
"M0G3518QPMRQ1", 0x4009, 0x13 },
347 {
"M0G3518QPNRQ1", 0x4009, 0x14 },
348 {
"M0G3518QPTRQ1", 0x4009, 0x12 },
349 {
"M0G3518QPZRQ1", 0x4009, 0x15 },
350 {
"M0G3518QRGZRQ1", 0x4009, 0x11 },
351 {
"M0G3518QRHBRQ1", 0x4009, 0x10 },
352 {
"M0G3519QPMRQ1", 0x3512, 0x13 },
353 {
"M0G3519AQPMRQ1", 0x3512, 0x16 },
354 {
"M0G3519QPNRQ1", 0x3512, 0x14 },
355 {
"M0G3519QPTRQ1", 0x3512, 0x12 },
356 {
"M0G3519QPZRQ1", 0x3512, 0x15 },
357 {
"M0G3519QRGZRQ1", 0x3512, 0x11 },
358 {
"M0G3519QRHBRQ1", 0x3512, 0x10 },
360 {
"M0G3529QPMRQ1", 0xF8D1, 0x13 },
366 {
"MSPM0G5187S28YCJR", 0x5610, 0x18 },
367 {
"MSPM0G5187SDGS20R", 0x5610, 0x16 },
368 {
"MSPM0G5187SPMR", 0x5610, 0x10 },
369 {
"MSPM0G5187SPTR", 0x5610, 0x11 },
370 {
"MSPM0G5187SRHBR", 0x5610, 0x13 },
371 {
"MSPM0G5187SRGER", 0x5610, 0x14 },
372 {
"MSPM0G5187SRGZR", 0x5610, 0x12 },
373 {
"MSPM0G5187SRUYR", 0x5610, 0x17 },
378 {
"MSPS003F4SPW20R", 0x57b3, 0x70},
379 {
"MSPM0C1104SDGS20R", 0x57b3, 0x71},
380 {
"MSPM0C1104SRUKR", 0x57b3, 0x73},
381 {
"MSPM0C1104SDYYR", 0x57b3, 0x75},
382 {
"MSPM0C1104SDDFR", 0x57b3, 0x77},
383 {
"MSPM0C1104SDSGR", 0x57b3, 0x79},
388 {
"MSPM0L1227SRGER", 0x7C32, 0xF1},
389 {
"MSPM0L1227SPTR", 0x7C32, 0xC9},
390 {
"MSPM0L1227SPMR", 0x7C32, 0x1C},
391 {
"MSPM0L1227SPNAR", 0x7C32, 0x91},
392 {
"MSPM0L1227SPNR", 0x7C32, 0x39},
393 {
"MSPM0L1228SRGER", 0x33F7, 0x13},
394 {
"MSPM0L1228SRHBR", 0x33F7, 0x3A},
395 {
"MSPM0L1228SRGZR", 0x33F7, 0xBC},
396 {
"MSPM0L1228SPTR", 0x33F7, 0xF8},
397 {
"MSPM0L1228SPMR", 0x33F7, 0xCE},
398 {
"MSPM0L1228SPNAR", 0x33F7, 0x59},
399 {
"MSPM0L1228SPNR", 0x33F7, 0x7},
400 {
"MSPM0L2227SRGZR", 0x5E8F, 0x90},
401 {
"MSPM0L2227SPTR", 0x5E8F, 0xA},
402 {
"MSPM0L2227SPMR", 0x5E8F, 0x6D},
403 {
"MSPM0L2227SPNAR", 0x5E8F, 0x24},
404 {
"MSPM0L2227SPNR", 0x5E8F, 0x68},
405 {
"MSPM0L2228SRGZR", 0x2C38, 0xB8},
406 {
"MSPM0L2228SPTR", 0x2C38, 0x25},
407 {
"MSPM0L2228SPMR", 0x2C38, 0x6E},
408 {
"MSPM0L2228SPNAR", 0x2C38, 0x63},
409 {
"MSPM0L2228SPNR", 0x2C38, 0x3C},
432 switch (
bank->base) {
444 LOG_ERROR(
"%s: Out of memory for mspm0_info!", __func__);
448 bank->driver_priv = mspm0_info;
462 if (mspm0_info->
did == 0)
466 "\nTI MSPM0 information: Chip is "
467 "%s rev %d Device Unique ID: 0x%" PRIu32
"\n",
471 "main flash: %uKiB in %u bank(s), sram: %uKiB, data flash: %uKiB",
482 return (var &
GENMASK(hi, lo)) >> lo;
502 uint32_t saved_mclkcfg = 0;
503 bool mclk_switched =
false;
507 LOG_ERROR(
"Failed to read SYSCTL_MCLKCFG to check FLASH_ERR_01");
513 saved_mclkcfg = mclkcfg;
517 mclk_switched =
true;
527 LOG_ERROR(
"MSPM0: FLASH_ERR_01 workaround: "
528 "readback flush failed");
532 LOG_DEBUG(
"MSPM0: FLASH_ERR_01 workaround ACTIVE: "
533 "Lowering MCLK before FACTORYREGION read");
535 LOG_ERROR(
"MSPM0: FLASH_ERR_01 workaround: "
536 "could not lower MCLK before FACTORYREGION read");
561 LOG_ERROR(
"Failed to read sramflash register");
569 LOG_ERROR(
"MSPM0: FLASH_ERR_01 workaround: "
570 "could not restore MCLK after FACTORYREGION read");
573 LOG_DEBUG(
"MSPM0: FLASH_ERR_01 workaround: "
574 "restored MCLK after FACTORYREGION read");
582 LOG_ERROR(
"Failed to read flashctl description register");
602 LOG_WARNING(
"Unknown Device ID[0x%" PRIx32
"], cannot identify target",
604 LOG_DEBUG(
"did 0x%" PRIx32
", traceid 0x%" PRIx32
", userid 0x%" PRIx32
605 ", flashram 0x%" PRIx32, did, mspm0_info->
traceid, userid,
611 unsigned char minfo_idx = 0xff;
625 unsigned char pinfo_idx = 0xff;
634 for (
unsigned int i = 0; i < minfo->
part_count; i++) {
657 switch (probe_status) {
659 mspm0_info->
name =
"mspm0x";
660 LOG_INFO(
"Unidentified PART[0x%x]/variant[0x%x"
661 "], unknown DeviceID[0x%x"
662 "]. Attempting to proceed as %s.", part, variant, pnum,
667 LOG_INFO(
"Unidentified PART[0x%x]/variant[0x%x"
668 "], known DeviceID[0x%x"
669 "]. Attempting to proceed as %s.", part, variant, pnum,
679 mspm0_info->
did = did;
695 LOG_DEBUG(
"Detected: main flash: %uKb in %u banks, sram: %uKb, data flash: %uKb",
705 static const struct {
709 { 2,
"CMDINPROGRESS" },
712 { 6,
"FAILILLADDR" },
725 return "FAILUNKNOWN";
729 unsigned int *
reg,
unsigned int *sector_mask)
734 unsigned int sector_num = (
addr >> 10);
735 unsigned int sector_in_bank = sector_num;
736 unsigned int phys_sector_num = sector_num;
737 uint32_t sysctl_sec_status;
738 unsigned int exec_upper_bank;
753 if (exec_upper_bank) {
774 switch (
bank->base) {
779 if (phys_sector_num < 32) {
780 *sector_mask =
BIT(phys_sector_num);
785 if (phys_sector_num >= 32 && sector_in_bank < 256) {
788 *sector_mask =
BIT(sector_in_bank / 8);
790 *sector_mask =
BIT((sector_in_bank - 32) / 8);
794 *sector_mask =
BIT((sector_in_bank / 8) % 32);
799 *sector_mask =
BIT(sector_num % 32);
812 LOG_ERROR(
"Unable to map sector protect reg for address 0x%08x",
addr);
829 switch (
bank->base) {
854 unsigned int reg = 0x0;
855 uint32_t sector_mask = 0x0;
861 LOG_ERROR(
"Unable to map sector protect reg for address 0x%08x",
addr);
864 LOG_ERROR(
"Unable to determine which bank to use 0x%08x",
addr);
902 uint32_t return_code = 0;
945 LOG_ERROR(
"Unprotecting sector of memory at address 0x%08" PRIx32
966 if (mspm0_info->
did == 0)
988 for (
unsigned int i = 0; i <
bank->num_sectors; i++)
989 bank->sectors[i].is_protected = 0;
1002 LOG_ERROR(
"Please halt target for erasing flash");
1006 if (mspm0_info->
did == 0)
1013 &protect_reg_cache[i]);
1015 LOG_ERROR(
"Failed saving flashctl protection status");
1020 switch (
bank->base) {
1022 for (
unsigned int csa = first; csa <= last; csa++) {
1026 LOG_ERROR(
"Sector erase on MAIN failed at address 0x%08x "
1027 "(sector: %u)",
addr, csa);
1033 LOG_ERROR(
"Sector erase on NONMAIN failed");
1036 for (
unsigned int csa = first; csa <= last; csa++) {
1041 LOG_ERROR(
"Sector erase on DATA bank failed at address 0x%08x "
1042 "(sector: %u)",
addr, csa);
1046 LOG_ERROR(
"Invalid memory region access");
1066 protect_reg_cache[i]);
1068 LOG_ERROR(
"Failed re-applying protection status of flashctl");
1095 LOG_ERROR(
"Please halt target for programming flash");
1099 if (mspm0_info->
did == 0)
1110 &protect_reg_cache[i]);
1112 LOG_ERROR(
"Failed saving flashctl protection status");
1121 unsigned int num_bytes_to_write;
1132 num_bytes_to_write =
count;
1137 bytes_en = (1 << num_bytes_to_write) - 1;
1144 bytes_en |=
BIT(16);
1145 bytes_en |= (num_bytes_to_write > 8) ?
BIT(17) : 0;
1148 LOG_ERROR(
"Invalid flash_word_size_bytes %d",
1167 addr += num_bytes_to_write;
1168 buffer += num_bytes_to_write;
1169 count -= num_bytes_to_write;
1192 protect_reg_cache[i]);
1194 LOG_ERROR(
"Failed re-applying protection status of flashctl");
1210 if (mspm0_info->
did != 0)
1222 if (
bank->sectors) {
1223 free(
bank->sectors);
1227 bank->write_start_alignment = 4;
1228 bank->write_end_alignment = 4;
1230 switch (
bank->base) {
1233 bank->num_sectors = 0x1;
1247 "FACTORYREGION data incomplete, scheduling re-probe");
1248 mspm0_info->
did = 0;
1268 LOG_INFO(
"Data region NOT available!");
1270 bank->num_sectors = 0x0;
1291 if (!
bank->sectors) {
1292 LOG_ERROR(
"Out of memory for sectors!");
1295 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
1298 bank->sectors[i].is_erased = -1;
1306 .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.
void alive_sleep(uint64_t ms)
#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
#define SYSCTL_MCLKCFG_USEHSCLK
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)
#define SYSCTL_MCLKCFG_FLASHWAIT_MASK
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)
#define SYSCTL_MCLKCFG_FLASHWAIT_2
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.