#if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
cp_offset = info->portwidth - i;
#if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
cp_offset = info->portwidth - i;
/*-----------------------------------------------------------------------
* read a character at a port width address
*/
/*-----------------------------------------------------------------------
* read a character at a port width address
*/
/*-----------------------------------------------------------------------
* read a word at a port width address, assume 16bit bus
*/
/*-----------------------------------------------------------------------
* read a word at a port width address, assume 16bit bus
*/
/*-----------------------------------------------------------------------
* read a long word by picking the least significant byte of each maximum
* port size word. Swap for ppc format.
*/
/*-----------------------------------------------------------------------
* read a long word by picking the least significant byte of each maximum
* port size word. Swap for ppc format.
*/
#endif
#if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
retval = ((flash_read8(addr) << 16) |
#endif
#if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
retval = ((flash_read8(addr) << 16) |
switch (info->portwidth) {
case FLASH_CFI_8BIT:
debug("fwc addr %p cmd %x %x 8bit x %d bit\n", addr, cmd,
switch (info->portwidth) {
case FLASH_CFI_8BIT:
debug("fwc addr %p cmd %x %x 8bit x %d bit\n", addr, cmd,
flash_write8(cword.w8, addr);
break;
case FLASH_CFI_16BIT:
debug("fwc addr %p cmd %x %4.4x 16bit x %d bit\n", addr,
flash_write8(cword.w8, addr);
break;
case FLASH_CFI_16BIT:
debug("fwc addr %p cmd %x %4.4x 16bit x %d bit\n", addr,
flash_write16(cword.w16, addr);
break;
case FLASH_CFI_32BIT:
debug("fwc addr %p cmd %x %8.8x 32bit x %d bit\n", addr,
flash_write16(cword.w16, addr);
break;
case FLASH_CFI_32BIT:
debug("fwc addr %p cmd %x %8.8x 32bit x %d bit\n", addr,
print_longlong(str, cword.w64);
debug("fwrite addr %p cmd %x %s 64 bit x %d bit\n",
print_longlong(str, cword.w64);
debug("fwrite addr %p cmd %x %s 64 bit x %d bit\n",
flash_unmap(info, sect, offset, addr);
}
flash_unmap(info, sect, offset, addr);
}
{
flash_write_cmd(info, sect, info->addr_unlock1, AMD_CMD_UNLOCK_START);
flash_write_cmd(info, sect, info->addr_unlock2, AMD_CMD_UNLOCK_ACK);
{
flash_write_cmd(info, sect, info->addr_unlock1, AMD_CMD_UNLOCK_START);
flash_write_cmd(info, sect, info->addr_unlock2, AMD_CMD_UNLOCK_ACK);
-static int flash_isequal(flash_info_t * info, flash_sect_t sect,
- uint offset, uchar cmd)
+static int flash_isequal(flash_info_t *info, flash_sect_t sect, uint offset,
+ uchar cmd)
-static int flash_isset(flash_info_t * info, flash_sect_t sect,
- uint offset, uchar cmd)
+static int flash_isset(flash_info_t *info, flash_sect_t sect, uint offset,
+ uchar cmd)
-static int flash_toggle(flash_info_t * info, flash_sect_t sect,
- uint offset, uchar cmd)
+static int flash_toggle(flash_info_t *info, flash_sect_t sect, uint offset,
+ uchar cmd)
- retval = ( (flash_read32( addr ) != flash_read32( addr )) ||
- (flash_read32(addr+4) != flash_read32(addr+4)) );
+ retval = ((flash_read32(addr) != flash_read32(addr)) ||
+ (flash_read32(addr + 4) != flash_read32(addr + 4)));
#endif
if (info->sr_supported) {
flash_write_cmd(info, sect, info->addr_unlock1,
#endif
if (info->sr_supported) {
flash_write_cmd(info, sect, info->addr_unlock1,
retval = !flash_isset(info, sect, 0,
retval = !flash_isset(info, sect, 0,
} else {
retval = flash_toggle(info, sect, 0,
} else {
retval = flash_toggle(info, sect, 0,
* wait for XSR.7 to be set. Time out with an error if it does not.
* This routine does not set the flash to read-array mode.
*/
* wait for XSR.7 to be set. Time out with an error if it does not.
* This routine does not set the flash to read-array mode.
*/
-static int flash_status_check(flash_info_t * info, flash_sect_t sector,
- ulong tout, char *prompt)
+static int flash_status_check(flash_info_t *info, flash_sect_t sector,
+ ulong tout, char *prompt)
while (flash_is_busy(info, sector)) {
if (get_timer(start) > tout) {
printf("Flash %s timeout at address %lx data %lx\n",
while (flash_is_busy(info, sector)) {
if (get_timer(start) > tout) {
printf("Flash %s timeout at address %lx data %lx\n",
- prompt, info->start[sector],
- flash_read_long(info, sector, 0));
+ prompt, info->start[sector],
+ flash_read_long(info, sector, 0));
flash_write_cmd(info, sector, 0, info->cmd_reset);
udelay(1);
flash_write_cmd(info, sector, 0, info->cmd_reset);
udelay(1);
-static int flash_full_status_check(flash_info_t * info, flash_sect_t sector,
- ulong tout, char *prompt)
+static int flash_full_status_check(flash_info_t *info, flash_sect_t sector,
+ ulong tout, char *prompt)
case CFI_CMDSET_INTEL_PROG_REGIONS:
case CFI_CMDSET_INTEL_EXTENDED:
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_PROG_REGIONS:
case CFI_CMDSET_INTEL_EXTENDED:
case CFI_CMDSET_INTEL_STANDARD:
- if ((retcode == ERR_OK)
- && !flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
+ if (retcode == ERR_OK &&
+ !flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
if (flash_isset(info, sector, 0, FLASH_STATUS_ECLBS |
FLASH_STATUS_PSLBS)) {
puts("Command Sequence Error.\n");
if (flash_isset(info, sector, 0, FLASH_STATUS_ECLBS |
FLASH_STATUS_PSLBS)) {
puts("Command Sequence Error.\n");
if (get_timer(start) > tout) {
printf("Flash %s timeout at address %lx data %lx\n",
prompt, (ulong)dst, (ulong)flash_read8(dst));
if (get_timer(start) > tout) {
printf("Flash %s timeout at address %lx data %lx\n",
prompt, (ulong)dst, (ulong)flash_read8(dst));
* Loop through the sector table starting from the previously found sector.
* Searches forwards or backwards, dependent on the passed address.
*/
* Loop through the sector table starting from the previously found sector.
* Searches forwards or backwards, dependent on the passed address.
*/
{
static flash_sect_t saved_sector; /* previously found sector */
static flash_info_t *saved_info; /* previously used flash bank */
flash_sect_t sector = saved_sector;
{
static flash_sect_t saved_sector; /* previously found sector */
static flash_info_t *saved_info; /* previously used flash bank */
flash_sect_t sector = saved_sector;
-static int flash_write_cfibuffer(flash_info_t * info, ulong dest, uchar * cp,
- int len)
+static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
+ int len)
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ?
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ?
flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
flash_write_cmd(info, sector, 0, write_cmd);
retcode = flash_status_check(info, sector,
flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
flash_write_cmd(info, sector, 0, write_cmd);
retcode = flash_status_check(info, sector,
cnt = len >> shift;
flash_write_cmd(info, sector, 0, cnt - 1);
while (cnt-- > 0) {
cnt = len >> shift;
flash_write_cmd(info, sector, 0, cnt - 1);
while (cnt-- > 0) {
}
}
flash_write_cmd(info, sector, 0,
}
}
flash_write_cmd(info, sector, 0,
retcode = flash_full_status_check(
info, sector, info->buffer_write_tout,
"buffer write");
retcode = flash_full_status_check(
info, sector, info->buffer_write_tout,
"buffer write");
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
flash_write_cmd(info, sect, 0,
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
flash_write_cmd(info, sect, 0,
flash_write_cmd(info, sect, 0,
flash_write_cmd(info, sect, 0,
flash_write_cmd(info, sect, 0,
flash_write_cmd(info, sect, 0,
AMD_CMD_ERASE_START);
flash_unlock_seq(info, sect);
flash_write_cmd(info, sect, 0,
AMD_CMD_ERASE_START);
flash_unlock_seq(info, sect);
flash_write_cmd(info, sect, 0,
cword.w64 = 0xffffffffffffffffULL;
dest = flash_map(info, sect, 0);
st = flash_status_poll(info, &cword, dest,
cword.w64 = 0xffffffffffffffffULL;
dest = flash_map(info, sect, 0);
st = flash_status_poll(info, &cword, dest,
flash_unmap(info, sect, 0, dest);
flash_unmap(info, sect, 0, dest);
- info->name,
- (info->portwidth << 3), (info->chipwidth << 3));
- if (info->size < 1024*1024)
+ info->name,
+ (info->portwidth << 3), (info->chipwidth << 3));
+ if (info->size < 1024 * 1024)
- case CFI_CMDSET_INTEL_PROG_REGIONS:
- printf("Intel Prog Regions");
- break;
- case CFI_CMDSET_INTEL_STANDARD:
- printf("Intel Standard");
- break;
- case CFI_CMDSET_INTEL_EXTENDED:
- printf("Intel Extended");
- break;
- case CFI_CMDSET_AMD_STANDARD:
- printf("AMD Standard");
- break;
- case CFI_CMDSET_AMD_EXTENDED:
- printf("AMD Extended");
- break;
+ case CFI_CMDSET_INTEL_PROG_REGIONS:
+ printf("Intel Prog Regions");
+ break;
+ case CFI_CMDSET_INTEL_STANDARD:
+ printf("Intel Standard");
+ break;
+ case CFI_CMDSET_INTEL_EXTENDED:
+ printf("Intel Extended");
+ break;
+ case CFI_CMDSET_AMD_STANDARD:
+ printf("AMD Standard");
+ break;
+ case CFI_CMDSET_AMD_EXTENDED:
+ printf("AMD Extended");
+ break;
}
printf(" command set, Manufacturer ID: 0x%02X, Device ID: 0x",
}
printf(" command set, Manufacturer ID: 0x%02X, Device ID: 0x",
if ((info->device_id & 0xff) == 0x7E) {
printf(info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
if ((info->device_id & 0xff) == 0x7E) {
printf(info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
printf("\n Advanced Sector Protection (PPB) enabled");
printf("\n Erase timeout: %ld ms, write timeout: %ld ms\n",
printf("\n Advanced Sector Protection (PPB) enabled");
printf("\n Erase timeout: %ld ms, write timeout: %ld ms\n",
- printf(" Buffer write timeout: %ld ms, "
- "buffer size: %d bytes\n",
- info->buffer_write_tout,
- info->buffer_size);
+ printf(" Buffer write timeout: %ld ms, ",
+ info->buffer_write_tout);
+ printf("buffer size: %d bytes\n", info->buffer_size);
- info->start[i],
- sector_erased(info, i) ? 'E' : ' ',
- info->protect[i] ? "RO" : " ");
+ info->start[i],
+ sector_erased(info, i) ? 'E' : ' ',
+ info->protect[i] ? "RO" : " ");
#define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) \
if (flash_verbose) { \
dots -= dots_sub; \
#define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) \
if (flash_verbose) { \
dots -= dots_sub; \
-int write_buff(flash_info_t * info, uchar * src, ulong addr, ulong cnt)
+int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
cword.w32 = 0;
for (i = 0; i < info->portwidth; i++)
flash_add_byte(info, &cword, *src++);
cword.w32 = 0;
for (i = 0; i < info->portwidth; i++)
flash_add_byte(info, &cword, *src++);
- if ((rc = flash_write_cfibuffer(info, wp, src, i)) != ERR_OK)
+ rc = flash_write_cfibuffer(info, wp, src, i);
+ if (rc != ERR_OK)
- if (manufact_match(info, INTEL_MANUFACT)
- && info->device_id == NUMONYX_256MBIT) {
+ if (manufact_match(info, INTEL_MANUFACT) &&
+ info->device_id == NUMONYX_256MBIT) {
- case CFI_CMDSET_INTEL_PROG_REGIONS:
- case CFI_CMDSET_INTEL_STANDARD:
- case CFI_CMDSET_INTEL_EXTENDED:
- if (!cfi_protect_bugfix(info, sector, prot)) {
- flash_write_cmd(info, sector, 0,
- FLASH_CMD_CLEAR_STATUS);
- flash_write_cmd(info, sector, 0,
+ case CFI_CMDSET_INTEL_PROG_REGIONS:
+ case CFI_CMDSET_INTEL_STANDARD:
+ case CFI_CMDSET_INTEL_EXTENDED:
+ if (!cfi_protect_bugfix(info, sector, prot)) {
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_CLEAR_STATUS);
+ flash_write_cmd(info, sector, 0,
- if (prot)
- flash_write_cmd(info, sector, 0,
+ if (prot)
+ flash_write_cmd(info, sector, 0,
- else
- flash_write_cmd(info, sector, 0,
+ else
+ flash_write_cmd(info, sector, 0,
-
- }
- break;
- case CFI_CMDSET_AMD_EXTENDED:
- case CFI_CMDSET_AMD_STANDARD:
- /* U-Boot only checks the first byte */
- if (manufact_match(info, ATM_MANUFACT)) {
- if (prot) {
- flash_unlock_seq(info, 0);
- flash_write_cmd(info, 0,
- info->addr_unlock1,
- ATM_CMD_SOFTLOCK_START);
- flash_unlock_seq(info, 0);
- flash_write_cmd(info, sector, 0,
- ATM_CMD_LOCK_SECT);
- } else {
- flash_write_cmd(info, 0,
- info->addr_unlock1,
- AMD_CMD_UNLOCK_START);
- if (info->device_id == ATM_ID_BV6416)
- flash_write_cmd(info, sector,
+ }
+ break;
+ case CFI_CMDSET_AMD_EXTENDED:
+ case CFI_CMDSET_AMD_STANDARD:
+ /* U-Boot only checks the first byte */
+ if (manufact_match(info, ATM_MANUFACT)) {
+ if (prot) {
+ flash_unlock_seq(info, 0);
+ flash_write_cmd(info, 0,
+ info->addr_unlock1,
+ ATM_CMD_SOFTLOCK_START);
+ flash_unlock_seq(info, 0);
+ flash_write_cmd(info, sector, 0,
+ ATM_CMD_LOCK_SECT);
+ } else {
+ flash_write_cmd(info, 0,
+ info->addr_unlock1,
+ AMD_CMD_UNLOCK_START);
+ if (info->device_id == ATM_ID_BV6416)
+ flash_write_cmd(info, sector,
- if (info->legacy_unlock) {
- int flag = disable_interrupts();
- int lock_flag;
-
- flash_unlock_seq(info, 0);
- flash_write_cmd(info, 0, info->addr_unlock1,
- AMD_CMD_SET_PPB_ENTRY);
- lock_flag = flash_isset(info, sector, 0, 0x01);
- if (prot) {
- if (lock_flag) {
- flash_write_cmd(info, sector, 0,
+ }
+ if (info->legacy_unlock) {
+ int flag = disable_interrupts();
+ int lock_flag;
+
+ flash_unlock_seq(info, 0);
+ flash_write_cmd(info, 0, info->addr_unlock1,
+ AMD_CMD_SET_PPB_ENTRY);
+ lock_flag = flash_isset(info, sector, 0, 0x01);
+ if (prot) {
+ if (lock_flag) {
+ flash_write_cmd(info, sector, 0,
- flash_write_cmd(info, sector, 0,
+ flash_write_cmd(info, sector, 0,
- }
- debug("sector %ld %slocked\n", sector,
- lock_flag ? "" : "already ");
- } else {
- if (!lock_flag) {
- debug("unlock %ld\n", sector);
- flash_write_cmd(info, 0, 0,
+ }
+ debug("sector %ld %slocked\n", sector,
+ lock_flag ? "" : "already ");
+ } else {
+ if (!lock_flag) {
+ debug("unlock %ld\n", sector);
+ flash_write_cmd(info, 0, 0,
- flash_write_cmd(info, 0, 0,
+ flash_write_cmd(info, 0, 0,
- if (flag)
- enable_interrupts();
-
- if (flash_status_check(info, sector,
- info->erase_blk_tout,
- prot ? "protect" : "unprotect"))
- printf("status check error\n");
-
- flash_write_cmd(info, 0, 0,
- AMD_CMD_SET_PPB_EXIT_BC1);
- flash_write_cmd(info, 0, 0,
- AMD_CMD_SET_PPB_EXIT_BC2);
+ debug("sector %ld %sunlocked\n", sector,
+ !lock_flag ? "" : "already ");
+ if (flag)
+ enable_interrupts();
+
+ if (flash_status_check(info, sector,
+ info->erase_blk_tout,
+ prot ? "protect" : "unprotect"))
+ printf("status check error\n");
+
+ flash_write_cmd(info, 0, 0,
+ AMD_CMD_SET_PPB_EXIT_BC1);
+ flash_write_cmd(info, 0, 0,
+ AMD_CMD_SET_PPB_EXIT_BC2);
+ }
+ break;
- case CFI_CMDSET_AMD_LEGACY:
- flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
- flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT);
- if (prot)
- flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_SET);
- else
- flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
+ case CFI_CMDSET_AMD_LEGACY:
+ flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
+ flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT);
+ if (prot)
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT_SET);
+ else
+ flash_write_cmd(info, sector, 0,
+ FLASH_CMD_PROTECT_CLEAR);
* flash_full_status_check() to work correctly
*/
flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
* flash_full_status_check() to work correctly
*/
flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
- if ((retcode =
- flash_full_status_check(info, sector, info->erase_blk_tout,
- prot ? "protect" : "unprotect")) == 0) {
-
+ retcode = flash_full_status_check(info, sector, info->erase_blk_tout,
+ prot ? "protect" : "unprotect");
+ if (retcode == 0) {
info->protect[sector] = prot;
/*
* On some of Intel's flash chips (marked via legacy_unlock)
* unprotect unprotects all locking.
*/
info->protect[sector] = prot;
/*
* On some of Intel's flash chips (marked via legacy_unlock)
* unprotect unprotects all locking.
*/
/*-----------------------------------------------------------------------
* flash_read_user_serial - read the OneTimeProgramming cells
*/
/*-----------------------------------------------------------------------
* flash_read_user_serial - read the OneTimeProgramming cells
*/
-void flash_read_user_serial(flash_info_t * info, void *buffer, int offset,
- int len)
+void flash_read_user_serial(flash_info_t *info, void *buffer, int offset,
+ int len)
-void flash_read_factory_serial(flash_info_t * info, void *buffer, int offset,
- int len)
+void flash_read_factory_serial(flash_info_t *info, void *buffer, int offset,
+ int len)
- tmp = get_unaligned(&(qry->erase_region_info[i]));
- put_unaligned(get_unaligned(&(qry->erase_region_info[j])),
- &(qry->erase_region_info[i]));
- put_unaligned(tmp, &(qry->erase_region_info[j]));
+ tmp = get_unaligned(&qry->erase_region_info[i]);
+ put_unaligned(get_unaligned(&qry->erase_region_info[j]),
+ &qry->erase_region_info[i]);
+ put_unaligned(tmp, &qry->erase_region_info[j]);
flash_write_cmd(info, 0, 0, FLASH_CMD_READ_ID);
udelay(1000); /* some flash are slow to respond */
info->manufacturer_id = flash_read_uchar(info,
flash_write_cmd(info, 0, 0, FLASH_CMD_READ_ID);
udelay(1000); /* some flash are slow to respond */
info->manufacturer_id = flash_read_uchar(info,
info->device_id = (info->chipwidth == FLASH_CFI_16BIT) ?
flash_read_word(info, FLASH_OFFSET_DEVICE_ID) :
flash_read_uchar(info, FLASH_OFFSET_DEVICE_ID);
info->device_id = (info->chipwidth == FLASH_CFI_16BIT) ?
flash_read_word(info, FLASH_OFFSET_DEVICE_ID) :
flash_read_uchar(info, FLASH_OFFSET_DEVICE_ID);
uchar feature;
flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
uchar feature;
flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
udelay(1000); /* some flash are slow to respond */
flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
udelay(1000); /* some flash are slow to respond */
- while (manuId == FLASH_CONTINUATION_CODE && bankId < 0x800) {
- bankId += 0x100;
- manuId = flash_read_uchar(info,
- bankId | FLASH_OFFSET_MANUFACTURER_ID);
+ while (manu_id == FLASH_CONTINUATION_CODE && bank_id < 0x800) {
+ bank_id += 0x100;
+ manu_id = flash_read_uchar(info,
+ bank_id | FLASH_OFFSET_MANUFACTURER_ID);
debug("info->ext_addr = 0x%x, cfi_version = 0x%x\n",
info->ext_addr, info->cfi_version);
debug("info->ext_addr = 0x%x, cfi_version = 0x%x\n",
info->ext_addr, info->cfi_version);
if (info->device_id == 0x7E) {
/* AMD 3-byte (expanded) device ids */
info->device_id2 = flash_read_uchar(info,
if (info->device_id == 0x7E) {
/* AMD 3-byte (expanded) device ids */
info->device_id2 = flash_read_uchar(info,
info->device_id2 <<= 8;
info->device_id2 |= flash_read_uchar(info,
FLASH_OFFSET_DEVICE_ID3);
info->device_id2 <<= 8;
info->device_id2 |= flash_read_uchar(info,
FLASH_OFFSET_DEVICE_ID3);
if ((info->device_id & 0xff) == 0x7E) {
/* AMD 3-byte (expanded) device ids */
info->device_id2 = flash_read_uchar(info,
if ((info->device_id & 0xff) == 0x7E) {
/* AMD 3-byte (expanded) device ids */
info->device_id2 = flash_read_uchar(info,
info->device_id2 <<= 8;
info->device_id2 |= flash_read_uchar(info,
FLASH_OFFSET_DEVICE_ID3);
info->device_id2 <<= 8;
info->device_id2 |= flash_read_uchar(info,
FLASH_OFFSET_DEVICE_ID3);
if (board_flash_get_legacy(base, banknum, info)) {
/* board code may have filled info completely. If not, we
if (board_flash_get_legacy(base, banknum, info)) {
/* board code may have filled info completely. If not, we
}
flash_read_jedec_ids(info);
debug("JEDEC PROBE: ID %x %x %x\n",
}
flash_read_jedec_ids(info);
debug("JEDEC PROBE: ID %x %x %x\n",
case CFI_CMDSET_INTEL_PROG_REGIONS:
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
case CFI_CMDSET_INTEL_PROG_REGIONS:
case CFI_CMDSET_INTEL_STANDARD:
case CFI_CMDSET_INTEL_EXTENDED:
* detect if flash is compatible with the Common Flash Interface (CFI)
* http://www.jedec.org/download/search/jesd68.pdf
*/
* detect if flash is compatible with the Common Flash Interface (CFI)
* http://www.jedec.org/download/search/jesd68.pdf
*/
-static void flash_read_cfi(flash_info_t *info, void *buf,
- unsigned int start, size_t len)
+static void flash_read_cfi(flash_info_t *info, void *buf, unsigned int start,
+ size_t len)
udelay(1);
flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
}
udelay(1);
flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
}
for (cfi_offset = 0; cfi_offset < ARRAY_SIZE(flash_offset_cfi);
cfi_offset++) {
flash_write_cmd(info, 0, flash_offset_cfi[cfi_offset],
for (cfi_offset = 0; cfi_offset < ARRAY_SIZE(flash_offset_cfi);
cfi_offset++) {
flash_write_cmd(info, 0, flash_offset_cfi[cfi_offset],
- FLASH_CMD_CFI);
- if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q')
- && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R')
- && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
+ FLASH_CMD_CFI);
+ if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q') &&
+ flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R') &&
+ flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
info->interface = le16_to_cpu(qry->interface_desc);
info->cfi_offset = flash_offset_cfi[cfi_offset];
debug("device interface is %d\n",
info->interface = le16_to_cpu(qry->interface_desc);
info->cfi_offset = flash_offset_cfi[cfi_offset];
debug("device interface is %d\n",
- info->portwidth << CFI_FLASH_SHIFT_WIDTH,
- info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+ info->portwidth << CFI_FLASH_SHIFT_WIDTH,
+ info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
- if ( /* x8/x16 in x8 mode */
- ((info->chipwidth == FLASH_CFI_BY8) &&
- (info->interface == FLASH_CFI_X8X16)) ||
- /* x16/x32 in x16 mode */
- ((info->chipwidth == FLASH_CFI_BY16) &&
- (info->interface == FLASH_CFI_X16X32)))
- {
+ if (/* x8/x16 in x8 mode */
+ (info->chipwidth == FLASH_CFI_BY8 &&
+ info->interface == FLASH_CFI_X8X16) ||
+ /* x16/x32 in x16 mode */
+ (info->chipwidth == FLASH_CFI_BY16 &&
+ info->interface == FLASH_CFI_X16X32)) {
if (info->device_id == 0x5D23 || /* SST39VF3201B */
info->device_id == 0x5C23) { /* SST39VF3202B */
/* set sector granularity to 4KB */
if (info->device_id == 0x5D23 || /* SST39VF3201B */
info->device_id == 0x5C23) { /* SST39VF3202B */
/* set sector granularity to 4KB */
* There's an app note from Numonyx on this issue.
* So adjust the buffer size for M29EW while operating in 8-bit mode
*/
* There's an app note from Numonyx on this issue.
* So adjust the buffer size for M29EW while operating in 8-bit mode
*/
- if (((qry->max_buf_write_size) > 0x8) &&
- (info->device_id == 0x7E) &&
- (info->device_id2 == 0x2201 ||
- info->device_id2 == 0x2301 ||
- info->device_id2 == 0x2801 ||
- info->device_id2 == 0x4801)) {
- debug("Adjusted buffer size on Numonyx flash"
- " M29EW family in 8 bit mode\n");
+ if (qry->max_buf_write_size > 0x8 &&
+ info->device_id == 0x7E &&
+ (info->device_id2 == 0x2201 ||
+ info->device_id2 == 0x2301 ||
+ info->device_id2 == 0x2801 ||
+ info->device_id2 == 0x4801)) {
+ debug("Adjusted buffer size on Numonyx flash");
+ debug(" M29EW family in 8 bit mode\n");
info->start[0] = (ulong)map_physmem(base, info->portwidth, MAP_NOCACHE);
if (flash_detect_cfi(info, &qry)) {
info->start[0] = (ulong)map_physmem(base, info->portwidth, MAP_NOCACHE);
if (flash_detect_cfi(info, &qry)) {
- info->vendor = le16_to_cpu(get_unaligned(&(qry.p_id)));
- info->ext_addr = le16_to_cpu(get_unaligned(&(qry.p_adr)));
+ info->vendor = le16_to_cpu(get_unaligned(&qry.p_id));
+ info->ext_addr = le16_to_cpu(get_unaligned(&qry.p_adr));
/*
* Unfortunately, this means we don't know how
* to get the chip back to Read mode. Might
/*
* Unfortunately, this means we don't know how
* to get the chip back to Read mode. Might
- size_ratio, info->portwidth << CFI_FLASH_SHIFT_WIDTH,
- info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+ size_ratio, info->portwidth << CFI_FLASH_SHIFT_WIDTH,
+ info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
info->size = 1 << qry.dev_size;
/* multiply the size by the number of chips */
info->size *= size_ratio;
max_size = cfi_flash_bank_size(banknum);
info->size = 1 << qry.dev_size;
/* multiply the size by the number of chips */
info->size *= size_ratio;
max_size = cfi_flash_bank_size(banknum);
for (i = 0; i < num_erase_regions; i++) {
if (i > NUM_ERASE_REGIONS) {
printf("%d erase regions found, only %d used\n",
for (i = 0; i < num_erase_regions; i++) {
if (i > NUM_ERASE_REGIONS) {
printf("%d erase regions found, only %d used\n",
debug("erase region %u: 0x%08lx\n", i, tmp);
erase_region_count = (tmp & 0xffff) + 1;
tmp >>= 16;
erase_region_size =
(tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
debug("erase region %u: 0x%08lx\n", i, tmp);
erase_region_count = (tmp & 0xffff) + 1;
tmp >>= 16;
erase_region_size =
(tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
- debug("erase_region_count = %d erase_region_size = %d\n",
- erase_region_count, erase_region_size);
+ debug("erase_region_count = %d ", erase_region_count);
+ debug("erase_region_size = %d\n", erase_region_size);
FLASH_CMD_READ_ID);
info->protect[sect_cnt] =
flash_isset(info, sect_cnt,
FLASH_CMD_READ_ID);
info->protect[sect_cnt] =
flash_isset(info, sect_cnt,
flash_write_cmd(info, sect_cnt, 0,
FLASH_CMD_RESET);
break;
flash_write_cmd(info, sect_cnt, 0,
FLASH_CMD_RESET);
break;
/* round up when converting to ms */
info->write_tout = (tmp + 999) / 1000;
info->flash_id = FLASH_MAN_CFI;
/* round up when converting to ms */
info->write_tout = (tmp + 999) / 1000;
info->flash_id = FLASH_MAN_CFI;
#if (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE) && \
(!defined(CONFIG_MONITOR_IS_IN_RAM))
flash_protect(FLAG_PROTECT_SET,
#if (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE) && \
(!defined(CONFIG_MONITOR_IS_IN_RAM))
flash_protect(FLAG_PROTECT_SET,
- CONFIG_SYS_MONITOR_BASE,
- CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
- flash_get_info(CONFIG_SYS_MONITOR_BASE));
+ CONFIG_SYS_MONITOR_BASE,
+ CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
+ flash_get_info(CONFIG_SYS_MONITOR_BASE));
#endif
/* Environment protection ON by default */
#ifdef CONFIG_ENV_IS_IN_FLASH
flash_protect(FLAG_PROTECT_SET,
#endif
/* Environment protection ON by default */
#ifdef CONFIG_ENV_IS_IN_FLASH
flash_protect(FLAG_PROTECT_SET,
- CONFIG_ENV_ADDR,
- CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
- flash_get_info(CONFIG_ENV_ADDR));
+ CONFIG_ENV_ADDR,
+ CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
+ flash_get_info(CONFIG_ENV_ADDR));
#endif
/* Redundant environment protection ON by default */
#ifdef CONFIG_ENV_ADDR_REDUND
flash_protect(FLAG_PROTECT_SET,
#endif
/* Redundant environment protection ON by default */
#ifdef CONFIG_ENV_ADDR_REDUND
flash_protect(FLAG_PROTECT_SET,
- CONFIG_ENV_ADDR_REDUND,
- CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
- flash_get_info(CONFIG_ENV_ADDR_REDUND));
+ CONFIG_ENV_ADDR_REDUND,
+ CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
+ flash_get_info(CONFIG_ENV_ADDR_REDUND));
debug("autoprotecting from %08lx to %08lx\n",
apl[i].start, apl[i].start + apl[i].size - 1);
flash_protect(FLAG_PROTECT_SET,
debug("autoprotecting from %08lx to %08lx\n",
apl[i].start, apl[i].start + apl[i].size - 1);
flash_protect(FLAG_PROTECT_SET,
- apl[i].start,
- apl[i].start + apl[i].size - 1,
- flash_get_info(apl[i].start));
+ apl[i].start,
+ apl[i].start + apl[i].size - 1,
+ flash_get_info(apl[i].start));
size += flash_info[i].size;
if (flash_info[i].flash_id == FLASH_UNKNOWN) {
#ifndef CONFIG_SYS_FLASH_QUIET_TEST
size += flash_info[i].size;
if (flash_info[i].flash_id == FLASH_UNKNOWN) {
#ifndef CONFIG_SYS_FLASH_QUIET_TEST
- printf("## Unknown flash on Bank %d "
- "- Size = 0x%08lx = %ld MB\n",
- i+1, flash_info[i].size,
- flash_info[i].size >> 20);
+ printf("## Unknown flash on Bank %d ", i + 1);
+ printf("- Size = 0x%08lx = %ld MB\n",
+ flash_info[i].size,
+ flash_info[i].size >> 20);
* No legancy unlocking -> unlock all sectors
*/
flash_protect(FLAG_PROTECT_CLEAR,
* No legancy unlocking -> unlock all sectors
*/
flash_protect(FLAG_PROTECT_CLEAR,
- flash_info[i].start[0],
- flash_info[i].start[0]
- + flash_info[i].size - 1,
- &flash_info[i]);
+ flash_info[i].start[0],
+ flash_info[i].start[0]
+ + flash_info[i].size - 1,
+ &flash_info[i]);