nand: Set the A1CR depending on the flash chip used

This means that the U-Boot now needs to stop to set these
values. I have manually tested this with BTS #1 and micron
flash. "MICRON" was printed on the serial console.
This commit is contained in:
Holger Hans Peter Freyther 2014-07-08 18:23:52 +02:00
parent e564034a60
commit d1c87ee29d
1 changed files with 44 additions and 4 deletions

48
nand.c
View File

@ -362,20 +362,23 @@ nand_read_ecc(void)
/* Get details of the NAND flash used from the id and the table of NAND
* devices. */
static int
nand_get_details(void)
nand_get_details(uint8_t *out_manID, uint8_t *out_deviceID)
{
uint32_t deviceID, i, j;
uint32_t manID, deviceID, i, j;
/* Issue device read ID command. */
flash_write_cmd(NAND_RDID);
flash_write_addr(NAND_RDIDADD);
/* Read ID bytes */
j = flash_read_data() & 0xFF;
manID = flash_read_data() & 0xFF;
deviceID = flash_read_data() & 0xFF;
j = flash_read_data() & 0xFF;
j = flash_read_data() & 0xFF;
*out_manID = manID;
*out_deviceID = deviceID;
uart_send_str(" ID:");
uart_send_hexnum(deviceID, 2);
if (nand_info.bus_width == BUS_16BIT)
@ -481,6 +484,39 @@ nand_get_details(void)
return E_FAIL;
}
static int
nand_set_a1cr(uint8_t manID, uint8_t deviceID)
{
if (deviceID != 0xA1) {
log_info( "Unsupported NAND device" );
return E_FAIL;
}
switch (manID) {
/* ST/Numonyx */
case 0x20:
AEMIF->A1CR = 0x1844431C;
break;
/* Micron */
case 0x2C:
AEMIF->A1CR = 0x102442EC;
break;
/* Spansion */
case 0x01:
AEMIF->A1CR = 0x1844437C;
break;
/* Toshiba */
case 0x98:
AEMIF->A1CR = 0x102442DC;
break;
default:
log_info( "Unsupported NAND device" );
return E_FAIL;
}
return E_PASS;
}
static void
nand_write_spare(uint32_t eccvalue)
{
@ -852,6 +888,7 @@ nand_init(void)
{
uint32_t width;
uint32_t *CSRegs;
uint8_t manID, deviceID;
log_info("Initializing NAND flash:");
@ -887,7 +924,10 @@ nand_init(void)
if (nand_wait_for_ready(NAND_TIMEOUT) != E_PASS)
return E_FAIL;
return nand_get_details();
if (nand_get_details(&manID, &deviceID) != E_PASS)
return E_FAIL;
return nand_set_a1cr(manID, deviceID);
}
static int