#include <common.h>
#include <asm/processor.h>
+#include <asm/byteorder.h>
#include <linux/byteorder/swab.h>
#ifdef CFG_FLASH_CFI_DRIVER
#define AMD_CMD_WRITE 0xA0
#define AMD_CMD_ERASE_START 0x80
#define AMD_CMD_ERASE_SECTOR 0x30
+#define AMD_CMD_UNLOCK_START 0xAA
+#define AMD_CMD_UNLOCK_ACK 0x55
#define AMD_STATUS_TOGGLE 0x40
#define AMD_STATUS_ERROR 0x20
+#define AMD_ADDR_ERASE_START 0x555
+#define AMD_ADDR_START 0x555
+#define AMD_ADDR_ACK 0x2AA
#define FLASH_OFFSET_CFI 0x55
#define FLASH_OFFSET_CFI_RESP 0x10
flash_sect_t sect;
if (info->flash_id != FLASH_MAN_CFI) {
- printf ("Can't erase unknown flash type - aborted\n");
+ puts ("Can't erase unknown flash type - aborted\n");
return 1;
}
if ((s_first < 0) || (s_first > s_last)) {
- printf ("- no sectors to erase\n");
+ puts ("- no sectors to erase\n");
return 1;
}
if (prot) {
printf ("- Warning: %d protected sectors will not be erased!\n", prot);
} else {
- printf ("\n");
+ putc ('\n');
}
case CFI_CMDSET_AMD_STANDARD:
case CFI_CMDSET_AMD_EXTENDED:
flash_unlock_seq (info, sect);
- flash_write_cmd (info, sect, 0x555, AMD_CMD_ERASE_START);
+ flash_write_cmd (info, sect, AMD_ADDR_ERASE_START,
+ AMD_CMD_ERASE_START);
flash_unlock_seq (info, sect);
flash_write_cmd (info, sect, 0, AMD_CMD_ERASE_SECTOR);
break;
(info, sect, info->erase_blk_tout, "erase")) {
rcode = 1;
} else
- printf (".");
+ putc ('.');
}
}
- printf (" done\n");
+ puts (" done\n");
return rcode;
}
int i;
if (info->flash_id != FLASH_MAN_CFI) {
- printf ("missing or unknown FLASH type\n");
+ puts ("missing or unknown FLASH type\n");
return;
}
info->buffer_write_tout,
info->buffer_size);
- printf (" Sector Start Addresses:");
+ puts (" Sector Start Addresses:");
for (i = 0; i < info->sector_count; ++i) {
#ifdef CFG_FLASH_EMPTY_INFO
int k;
if ((i % 5) == 0)
printf ("\n ");
printf (" %08lX%s",
- info->start[i], info->protect[i] ? " (RO)" : " ");
+ info->start[i], info->protect[i] ? " (RO)" : " ");
#endif
}
- printf ("\n");
+ putc ('\n');
return;
}
#ifdef CFG_FLASH_USE_BUFFER_WRITE
int buffered_size;
#endif
- int x8mode = 0;
-
- /* special handling of 16 bit devices in 8 bit mode */
- if ((info->interface == FLASH_CFI_X8X16)
- && (info->chipwidth == FLASH_CFI_BY8)) {
- switch (info->vendor) {
- case CFI_CMDSET_INTEL_STANDARD:
- case CFI_CMDSET_INTEL_EXTENDED:
- x8mode = info->portwidth;
- info->portwidth >>= 1; /* XXX - Need to test on x9/x16 in parallel. */
- /*info->portwidth = FLASH_CFI_8BIT; */ /* XXX - Need to test on x9/x16 in parallel. */
- break;
- case CFI_CMDSET_AMD_STANDARD:
- case CFI_CMDSET_AMD_EXTENDED:
- default:
- break;
- }
- }
/* get lower aligned address */
/* get lower aligned address */
wp = (addr & ~(info->portwidth - 1));
flash_add_byte (info, &cword, (*(uchar *) cp));
}
- /* special handling of 16 bit devices in 8 bit mode */
- if (x8mode) {
- info->portwidth = x8mode;;
- }
return flash_write_cfiword (info, wp, cword);
}
printf ("Flash %s error at address %lx\n", prompt,
info->start[sector]);
if (flash_isset (info, sector, 0, FLASH_STATUS_ECLBS | FLASH_STATUS_PSLBS)) {
- printf ("Command Sequence Error.\n");
+ puts ("Command Sequence Error.\n");
} else if (flash_isset (info, sector, 0, FLASH_STATUS_ECLBS)) {
- printf ("Block Erase Error.\n");
+ puts ("Block Erase Error.\n");
retcode = ERR_NOT_ERASED;
} else if (flash_isset (info, sector, 0, FLASH_STATUS_PSLBS)) {
- printf ("Locking Error\n");
+ puts ("Locking Error\n");
}
if (flash_isset (info, sector, 0, FLASH_STATUS_DPS)) {
- printf ("Block locked.\n");
+ puts ("Block locked.\n");
retcode = ERR_PROTECTED;
}
if (flash_isset (info, sector, 0, FLASH_STATUS_VPENS))
- printf ("Vpp Low Error.\n");
+ puts ("Vpp Low Error.\n");
}
flash_write_cmd (info, sector, 0, FLASH_CMD_RESET);
break;
*(uint *) cmdbuf = __swab32 (stmpi);
break;
default:
- printf("WARNING: flash_make_cmd: unsuppported LittleEndian mode\n");
+ puts ("WARNING: flash_make_cmd: unsuppported LittleEndian mode\n");
break;
}
#endif
static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect)
{
- flash_write_cmd (info, sect, 0x555, 0xAA);
- flash_write_cmd (info, sect, 0x2AA, 0x55);
+ flash_write_cmd (info, sect, AMD_ADDR_START, AMD_CMD_UNLOCK_START);
+ flash_write_cmd (info, sect, AMD_ADDR_ACK, AMD_CMD_UNLOCK_ACK);
}
/*-----------------------------------------------------------------------
(tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
tmp >>= 16;
erase_region_count = (tmp & 0xffff) + 1;
- printf ("erase_region_count = %d erase_region_size = %d\n",
+ debug ("erase_region_count = %d erase_region_size = %d\n",
erase_region_count, erase_region_size);
for (j = 0; j < erase_region_count; j++) {
info->start[sect_cnt] = sector;
tmp = 1 << flash_read_uchar (info, FLASH_OFFSET_WTOUT);
info->write_tout = (tmp * (1 << flash_read_uchar (info, FLASH_OFFSET_WMAX_TOUT))) / 1000;
info->flash_id = FLASH_MAN_CFI;
+ if ((info->interface == FLASH_CFI_X8X16) && (info->chipwidth == FLASH_CFI_BY8)) {
+ info->portwidth >>= 1; /* XXX - Need to test on x8/x16 in parallel. */
+ }
}
flash_write_cmd (info, 0, 0, FLASH_CMD_RESET);
case CFI_CMDSET_AMD_EXTENDED:
case CFI_CMDSET_AMD_STANDARD:
flash_unlock_seq (info, 0);
- flash_write_cmd (info, 0, 0x555, AMD_CMD_WRITE);
+ flash_write_cmd (info, 0, AMD_ADDR_START, AMD_CMD_WRITE);
break;
}
int retcode;
volatile cfiptr_t src;
volatile cfiptr_t dst;
+ /* buffered writes in the AMD chip set is not supported yet */
+ if((info->vendor == CFI_CMDSET_AMD_STANDARD) ||
+ (info->vendor == CFI_CMDSET_AMD_EXTENDED))
+ return ERR_INVAL;
src.cp = cp;
dst.cp = (uchar *) dest;