1
0
Fork 0
forked from len0rd/rockbox

Support for flash chip identification on the gmini

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5853 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jean-Philippe Bernardy 2005-02-08 15:12:25 +00:00
parent 9c6a549ad2
commit ed7c635bfc

View file

@ -237,6 +237,27 @@ unsigned short crc_16(const unsigned char* buf, unsigned len)
}
#if CONFIG_CPU == TCC730
extern int idatastart __attribute__ ((section(".idata")));
static unsigned flash_word_temp __attribute__ ((section (".idata")));
static void flash_write_word(unsigned addr, unsigned value) __attribute__ ((section(".icode")));
static void flash_write_word(unsigned addr, unsigned value) {
flash_word_temp = value;
long extAddr = (long)addr << 1;
ddma_transfer(1, 1, (char*)&flash_word_temp - (char*)&idatastart, extAddr, 2);
}
static unsigned flash_read_word(unsigned addr) __attribute__ ((section(".icode")));
static unsigned flash_read_word(unsigned addr) {
long extAddr = (long)addr << 1;
ddma_transfer(1, 1, (char*)&flash_word_temp - (char*)&idatastart, extAddr, 2);
return flash_word_temp;
}
#endif
/* Tool function to read the flash manufacturer and type, if available.
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,
{
unsigned not_manu, not_id; /* read values before switching to ID mode */
unsigned manu, id; /* read values when in ID mode */
#if CONFIG_CPU == TCC730
#define FLASH(addr) (flash_read_word(addr))
#define SET_FLASH(addr, val) (flash_write_word((addr), (val)))
#else
volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */
#define FLASH(addr) (flash[addr])
#define SET_FLASH(addr, val) (flash[addr] = val)
#endif
int old_level; /* saved interrupt level */
not_manu = flash[0]; /* read the normal content */
not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
not_manu = FLASH(0); /* read the normal content */
not_id = FLASH(1); /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
/* disable interrupts, prevent any stray flash access */
old_level = set_irq_level(HIGHEST_IRQ_LEVEL);
flash[addr1] = 0xAA; /* enter command mode */
flash[addr2] = 0x55;
flash[addr1] = 0x90; /* ID command */
SET_FLASH(addr1, 0xAA); /* enter command mode */
SET_FLASH(addr2, 0x55);
SET_FLASH(addr1, 0x90); /* ID command */
/* Atmel wants 20ms pause here */
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
manu = flash[0]; /* read the IDs */
id = flash[1];
manu = FLASH(0); /* read the IDs */
id = FLASH(1);
flash[0] = 0xF0; /* reset flash (back to normal read mode) */
SET_FLASH(0, 0xF0); /* reset flash (back to normal read mode) */
/* Atmel wants 20ms pause here */
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
@ -858,7 +887,7 @@ bool view_battery(void)
{
int view = 0;
int i, x, y;
int maxv, minv;
unsigned short maxv, minv;
char buf[32];
#ifdef HAVE_LCD_BITMAP
@ -1426,9 +1455,9 @@ static bool dbg_disk_info(void)
break;
case 2:
snprintf(buf, sizeof buf, "%d MB",
((unsigned)identify_info[61] << 16 |
(unsigned)identify_info[60]) / 2048 );
snprintf(buf, sizeof buf, "%ld MB",
((unsigned long)identify_info[61] << 16 |
(unsigned long)identify_info[60]) / 2048 );
lcd_puts(0, y++, "Size");
lcd_puts(0, y++, buf);
break;