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:
parent
9c6a549ad2
commit
ed7c635bfc
1 changed files with 41 additions and 12 deletions
|
|
@ -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.
|
/* Tool function to read the flash manufacturer and type, if available.
|
||||||
Only chips which could be reprogrammed in system will return values.
|
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 not_manu, not_id; /* read values before switching to ID mode */
|
||||||
unsigned manu, id; /* read values when in 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 */
|
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 */
|
int old_level; /* saved interrupt level */
|
||||||
|
|
||||||
not_manu = flash[0]; /* read the normal content */
|
not_manu = FLASH(0); /* read the normal content */
|
||||||
not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
|
not_id = FLASH(1); /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
|
||||||
|
|
||||||
/* disable interrupts, prevent any stray flash access */
|
/* disable interrupts, prevent any stray flash access */
|
||||||
old_level = set_irq_level(HIGHEST_IRQ_LEVEL);
|
old_level = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||||
|
|
||||||
flash[addr1] = 0xAA; /* enter command mode */
|
SET_FLASH(addr1, 0xAA); /* enter command mode */
|
||||||
flash[addr2] = 0x55;
|
SET_FLASH(addr2, 0x55);
|
||||||
flash[addr1] = 0x90; /* ID command */
|
SET_FLASH(addr1, 0x90); /* ID command */
|
||||||
/* Atmel wants 20ms pause here */
|
/* Atmel wants 20ms pause here */
|
||||||
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
|
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
|
||||||
|
|
||||||
manu = flash[0]; /* read the IDs */
|
manu = FLASH(0); /* read the IDs */
|
||||||
id = flash[1];
|
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 */
|
/* Atmel wants 20ms pause here */
|
||||||
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
|
/* sleep(HZ/50); no sleeping possible while interrupts are disabled */
|
||||||
|
|
||||||
|
|
@ -858,7 +887,7 @@ bool view_battery(void)
|
||||||
{
|
{
|
||||||
int view = 0;
|
int view = 0;
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
int maxv, minv;
|
unsigned short maxv, minv;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
@ -1426,9 +1455,9 @@ static bool dbg_disk_info(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
snprintf(buf, sizeof buf, "%d MB",
|
snprintf(buf, sizeof buf, "%ld MB",
|
||||||
((unsigned)identify_info[61] << 16 |
|
((unsigned long)identify_info[61] << 16 |
|
||||||
(unsigned)identify_info[60]) / 2048 );
|
(unsigned long)identify_info[60]) / 2048 );
|
||||||
lcd_puts(0, y++, "Size");
|
lcd_puts(0, y++, "Size");
|
||||||
lcd_puts(0, y++, buf);
|
lcd_puts(0, y++, buf);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue