diff options
author | Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com> | 2005-02-08 15:12:25 +0000 |
---|---|---|
committer | Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com> | 2005-02-08 15:12:25 +0000 |
commit | ed7c635bfcfd59825ab5e4c1aeba51208e40258f (patch) | |
tree | dd90cc6b67da6fbf350d3952cf13080c0c6c4c4d /apps | |
parent | 9c6a549ad2118cb93e4b9e638f0db1673cea6034 (diff) | |
download | rockbox-ed7c635bfcfd59825ab5e4c1aeba51208e40258f.tar.gz rockbox-ed7c635bfcfd59825ab5e4c1aeba51208e40258f.zip |
Support for flash chip identification on the gmini
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5853 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a41baf6753..97a3f9a9f4 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -237,6 +237,27 @@ unsigned short crc_16(const unsigned char* buf, unsigned len) | |||
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | #if CONFIG_CPU == TCC730 | ||
241 | extern int idatastart __attribute__ ((section(".idata"))); | ||
242 | static unsigned flash_word_temp __attribute__ ((section (".idata"))); | ||
243 | |||
244 | static void flash_write_word(unsigned addr, unsigned value) __attribute__ ((section(".icode"))); | ||
245 | static void flash_write_word(unsigned addr, unsigned value) { | ||
246 | flash_word_temp = value; | ||
247 | |||
248 | long extAddr = (long)addr << 1; | ||
249 | ddma_transfer(1, 1, (char*)&flash_word_temp - (char*)&idatastart, extAddr, 2); | ||
250 | } | ||
251 | |||
252 | static unsigned flash_read_word(unsigned addr) __attribute__ ((section(".icode"))); | ||
253 | static unsigned flash_read_word(unsigned addr) { | ||
254 | long extAddr = (long)addr << 1; | ||
255 | ddma_transfer(1, 1, (char*)&flash_word_temp - (char*)&idatastart, extAddr, 2); | ||
256 | return flash_word_temp; | ||
257 | } | ||
258 | |||
259 | #endif | ||
260 | |||
240 | 261 | ||
241 | /* Tool function to read the flash manufacturer and type, if available. | 262 | /* Tool function to read the flash manufacturer and type, if available. |
242 | Only chips which could be reprogrammed in system will return values. | 263 | Only chips which could be reprogrammed in system will return values. |
@@ -251,25 +272,33 @@ bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | |||
251 | { | 272 | { |
252 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | 273 | unsigned not_manu, not_id; /* read values before switching to ID mode */ |
253 | unsigned manu, id; /* read values when in ID mode */ | 274 | unsigned manu, id; /* read values when in ID mode */ |
275 | #if CONFIG_CPU == TCC730 | ||
276 | #define FLASH(addr) (flash_read_word(addr)) | ||
277 | #define SET_FLASH(addr, val) (flash_write_word((addr), (val))) | ||
278 | #else | ||
254 | volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */ | 279 | volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */ |
280 | #define FLASH(addr) (flash[addr]) | ||
281 | #define SET_FLASH(addr, val) (flash[addr] = val) | ||
282 | |||
283 | #endif | ||
255 | int old_level; /* saved interrupt level */ | 284 | int old_level; /* saved interrupt level */ |
256 | 285 | ||
257 | not_manu = flash[0]; /* read the normal content */ | 286 | not_manu = FLASH(0); /* read the normal content */ |
258 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | 287 | not_id = FLASH(1); /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ |
259 | 288 | ||
260 | /* disable interrupts, prevent any stray flash access */ | 289 | /* disable interrupts, prevent any stray flash access */ |
261 | old_level = set_irq_level(HIGHEST_IRQ_LEVEL); | 290 | old_level = set_irq_level(HIGHEST_IRQ_LEVEL); |
262 | 291 | ||
263 | flash[addr1] = 0xAA; /* enter command mode */ | 292 | SET_FLASH(addr1, 0xAA); /* enter command mode */ |
264 | flash[addr2] = 0x55; | 293 | SET_FLASH(addr2, 0x55); |
265 | flash[addr1] = 0x90; /* ID command */ | 294 | SET_FLASH(addr1, 0x90); /* ID command */ |
266 | /* Atmel wants 20ms pause here */ | 295 | /* Atmel wants 20ms pause here */ |
267 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | 296 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ |
268 | 297 | ||
269 | manu = flash[0]; /* read the IDs */ | 298 | manu = FLASH(0); /* read the IDs */ |
270 | id = flash[1]; | 299 | id = FLASH(1); |
271 | 300 | ||
272 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | 301 | SET_FLASH(0, 0xF0); /* reset flash (back to normal read mode) */ |
273 | /* Atmel wants 20ms pause here */ | 302 | /* Atmel wants 20ms pause here */ |
274 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | 303 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ |
275 | 304 | ||
@@ -858,7 +887,7 @@ bool view_battery(void) | |||
858 | { | 887 | { |
859 | int view = 0; | 888 | int view = 0; |
860 | int i, x, y; | 889 | int i, x, y; |
861 | int maxv, minv; | 890 | unsigned short maxv, minv; |
862 | char buf[32]; | 891 | char buf[32]; |
863 | 892 | ||
864 | #ifdef HAVE_LCD_BITMAP | 893 | #ifdef HAVE_LCD_BITMAP |
@@ -1426,9 +1455,9 @@ static bool dbg_disk_info(void) | |||
1426 | break; | 1455 | break; |
1427 | 1456 | ||
1428 | case 2: | 1457 | case 2: |
1429 | snprintf(buf, sizeof buf, "%d MB", | 1458 | snprintf(buf, sizeof buf, "%ld MB", |
1430 | ((unsigned)identify_info[61] << 16 | | 1459 | ((unsigned long)identify_info[61] << 16 | |
1431 | (unsigned)identify_info[60]) / 2048 ); | 1460 | (unsigned long)identify_info[60]) / 2048 ); |
1432 | lcd_puts(0, y++, "Size"); | 1461 | lcd_puts(0, y++, "Size"); |
1433 | lcd_puts(0, y++, buf); | 1462 | lcd_puts(0, y++, buf); |
1434 | break; | 1463 | break; |