Revision f8be67ee
b/hw/pflash_cfi02.c | ||
---|---|---|
103 | 103 |
pfl->cmd = 0; |
104 | 104 |
} |
105 | 105 |
|
106 |
static uint32_t pflash_read (pflash_t *pfl, uint32_t offset, int width)
|
|
106 |
static uint32_t pflash_read (pflash_t *pfl, target_phys_addr_t offset, int width)
|
|
107 | 107 |
{ |
108 |
uint32_t boff;
|
|
108 |
target_phys_addr_t boff;
|
|
109 | 109 |
uint32_t ret; |
110 | 110 |
uint8_t *p; |
111 | 111 |
|
112 |
DPRINTF("%s: offset " TARGET_FMT_lx "\n", __func__, offset); |
|
112 |
DPRINTF("%s: offset " TARGET_FMT_plx "\n", __func__, offset);
|
|
113 | 113 |
ret = -1; |
114 | 114 |
if (pfl->rom_mode) { |
115 | 115 |
/* Lazy reset of to ROMD mode */ |
... | ... | |
184 | 184 |
default: |
185 | 185 |
goto flash_read; |
186 | 186 |
} |
187 |
DPRINTF("%s: ID " TARGET_FMT_ld " %x\n", __func__, boff, ret); |
|
187 |
DPRINTF("%s: ID " TARGET_FMT_pld " %x\n", __func__, boff, ret);
|
|
188 | 188 |
break; |
189 | 189 |
case 0xA0: |
190 | 190 |
case 0x10: |
... | ... | |
222 | 222 |
} |
223 | 223 |
} |
224 | 224 |
|
225 |
static void pflash_write (pflash_t *pfl, uint32_t offset, uint32_t value,
|
|
226 |
int width) |
|
225 |
static void pflash_write (pflash_t *pfl, target_phys_addr_t offset,
|
|
226 |
uint32_t value, int width)
|
|
227 | 227 |
{ |
228 |
uint32_t boff;
|
|
228 |
target_phys_addr_t boff;
|
|
229 | 229 |
uint8_t *p; |
230 | 230 |
uint8_t cmd; |
231 | 231 |
|
... | ... | |
237 | 237 |
#endif |
238 | 238 |
goto reset_flash; |
239 | 239 |
} |
240 |
DPRINTF("%s: offset " TARGET_FMT_lx " %08x %d %d\n", __func__, |
|
240 |
DPRINTF("%s: offset " TARGET_FMT_plx " %08x %d %d\n", __func__,
|
|
241 | 241 |
offset, value, width, pfl->wcycle); |
242 | 242 |
offset &= pfl->chip_len - 1; |
243 | 243 |
|
244 |
DPRINTF("%s: offset " TARGET_FMT_lx " %08x %d\n", __func__, |
|
244 |
DPRINTF("%s: offset " TARGET_FMT_plx " %08x %d\n", __func__,
|
|
245 | 245 |
offset, value, width); |
246 | 246 |
boff = offset & (pfl->sector_len - 1); |
247 | 247 |
if (pfl->width == 2) |
... | ... | |
263 | 263 |
return; |
264 | 264 |
} |
265 | 265 |
if (boff != pfl->unlock_addr[0] || cmd != 0xAA) { |
266 |
DPRINTF("%s: unlock0 failed " TARGET_FMT_lx " %02x %04x\n", |
|
266 |
DPRINTF("%s: unlock0 failed " TARGET_FMT_plx " %02x %04x\n",
|
|
267 | 267 |
__func__, boff, cmd, pfl->unlock_addr[0]); |
268 | 268 |
goto reset_flash; |
269 | 269 |
} |
... | ... | |
273 | 273 |
/* We started an unlock sequence */ |
274 | 274 |
check_unlock1: |
275 | 275 |
if (boff != pfl->unlock_addr[1] || cmd != 0x55) { |
276 |
DPRINTF("%s: unlock1 failed " TARGET_FMT_lx " %02x\n", __func__, |
|
276 |
DPRINTF("%s: unlock1 failed " TARGET_FMT_plx " %02x\n", __func__,
|
|
277 | 277 |
boff, cmd); |
278 | 278 |
goto reset_flash; |
279 | 279 |
} |
... | ... | |
282 | 282 |
case 2: |
283 | 283 |
/* We finished an unlock sequence */ |
284 | 284 |
if (!pfl->bypass && boff != pfl->unlock_addr[0]) { |
285 |
DPRINTF("%s: command failed " TARGET_FMT_lx " %02x\n", __func__, |
|
285 |
DPRINTF("%s: command failed " TARGET_FMT_plx " %02x\n", __func__,
|
|
286 | 286 |
boff, cmd); |
287 | 287 |
goto reset_flash; |
288 | 288 |
} |
... | ... | |
307 | 307 |
/* We need another unlock sequence */ |
308 | 308 |
goto check_unlock0; |
309 | 309 |
case 0xA0: |
310 |
DPRINTF("%s: write data offset " TARGET_FMT_lx " %08x %d\n", |
|
310 |
DPRINTF("%s: write data offset " TARGET_FMT_plx " %08x %d\n",
|
|
311 | 311 |
__func__, offset, value, width); |
312 | 312 |
p = pfl->storage; |
313 | 313 |
switch (width) { |
... | ... | |
378 | 378 |
switch (cmd) { |
379 | 379 |
case 0x10: |
380 | 380 |
if (boff != pfl->unlock_addr[0]) { |
381 |
DPRINTF("%s: chip erase: invalid address " TARGET_FMT_lx "\n", |
|
381 |
DPRINTF("%s: chip erase: invalid address " TARGET_FMT_plx "\n",
|
|
382 | 382 |
__func__, offset); |
383 | 383 |
goto reset_flash; |
384 | 384 |
} |
... | ... | |
395 | 395 |
/* Sector erase */ |
396 | 396 |
p = pfl->storage; |
397 | 397 |
offset &= ~(pfl->sector_len - 1); |
398 |
DPRINTF("%s: start sector erase at " TARGET_FMT_lx "\n", __func__, |
|
398 |
DPRINTF("%s: start sector erase at " TARGET_FMT_plx "\n", __func__,
|
|
399 | 399 |
offset); |
400 | 400 |
memset(p + offset, 0xFF, pfl->sector_len); |
401 | 401 |
pflash_update(pfl, offset, pfl->sector_len); |
Also available in: Unified diff