summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/cfi_flash.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2010-08-18 21:19:00 +0200
committerWolfgang Denk <wd@denx.de>2010-08-18 21:19:00 +0200
commit5549d22b656550d36b2cc46743c7220ab0e9dcc4 (patch)
treeacc88f5980b8ca5999e05e9a86429e5b397cdd7e /drivers/mtd/cfi_flash.c
parentae37a0704a8a27e47471f541a68b88370cd14aa8 (diff)
parent9ce2c4b7f79c5bdc1697a6979a0d33e51c3cf57d (diff)
downloadblackbird-obmc-uboot-5549d22b656550d36b2cc46743c7220ab0e9dcc4.tar.gz
blackbird-obmc-uboot-5549d22b656550d36b2cc46743c7220ab0e9dcc4.zip
Merge branch 'master' of /home/wd/git/u-boot/master
Diffstat (limited to 'drivers/mtd/cfi_flash.c')
-rw-r--r--drivers/mtd/cfi_flash.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 2d09caf738..1191ef02f8 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1096,8 +1096,30 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
return rcode;
}
-/*-----------------------------------------------------------------------
- */
+#ifdef CONFIG_SYS_FLASH_EMPTY_INFO
+static int sector_erased(flash_info_t *info, int i)
+{
+ int k;
+ int size;
+ volatile unsigned long *flash;
+
+ /*
+ * Check if whole sector is erased
+ */
+ size = flash_sector_size(info, i);
+ flash = (volatile unsigned long *) info->start[i];
+ /* divide by 4 for longword access */
+ size = size >> 2;
+
+ for (k = 0; k < size; k++) {
+ if (*flash++ != 0xffffffff)
+ return 0; /* not erased */
+ }
+
+ return 1; /* erased */
+}
+#endif /* CONFIG_SYS_FLASH_EMPTY_INFO */
+
void flash_print_info (flash_info_t * info)
{
int i;
@@ -1142,8 +1164,10 @@ void flash_print_info (flash_info_t * info)
printf ("Unknown (%d)", info->vendor);
break;
}
- printf (" command set, Manufacturer ID: 0x%02X, Device ID: 0x%02X",
- info->manufacturer_id, info->device_id);
+ printf (" command set, Manufacturer ID: 0x%02X, Device ID: 0x",
+ info->manufacturer_id);
+ printf (info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
+ info->device_id);
if (info->device_id == 0x7E) {
printf("%04X", info->device_id2);
}
@@ -1159,32 +1183,15 @@ void flash_print_info (flash_info_t * info)
puts ("\n Sector Start Addresses:");
for (i = 0; i < info->sector_count; ++i) {
+ if (ctrlc())
+ break;
if ((i % 5) == 0)
- printf ("\n");
+ putc('\n');
#ifdef CONFIG_SYS_FLASH_EMPTY_INFO
- int k;
- int size;
- int erased;
- volatile unsigned long *flash;
-
- /*
- * Check if whole sector is erased
- */
- size = flash_sector_size(info, i);
- erased = 1;
- flash = (volatile unsigned long *) info->start[i];
- size = size >> 2; /* divide by 4 for longword access */
- for (k = 0; k < size; k++) {
- if (*flash++ != 0xffffffff) {
- erased = 0;
- break;
- }
- }
-
/* print empty and read-only info */
printf (" %08lX %c %s ",
info->start[i],
- erased ? 'E' : ' ',
+ sector_erased(info, i) ? 'E' : ' ',
info->protect[i] ? "RO" : " ");
#else /* ! CONFIG_SYS_FLASH_EMPTY_INFO */
printf (" %08lX %s ",
@@ -1477,8 +1484,9 @@ static void cmdset_intel_read_jedec_ids(flash_info_t *info)
udelay(1000); /* some flash are slow to respond */
info->manufacturer_id = flash_read_uchar (info,
FLASH_OFFSET_MANUFACTURER_ID);
- info->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);
flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
}
OpenPOWER on IntegriCloud