summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2010-11-27 00:00:38 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2010-12-03 01:53:12 +0800
commit8b41ca208e108ba49267ceb1b2ff880022f7c1bb (patch)
tree011b8cb24c727504be7d888a0d06cdb17a349a62
parentce35b3c09ad8a6f6c52627e969ea7c0a394300ef (diff)
downloadbarebox-8b41ca208e108ba49267ceb1b2ff880022f7c1bb.tar.gz
barebox-8b41ca208e108ba49267ceb1b2ff880022f7c1bb.tar.xz
cfi_flash: update manufacturer id flash support
several first banks can contain 0x7f instead of actual ID support as done in linux Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
-rw-r--r--drivers/nor/cfi_flash.c18
-rw-r--r--drivers/nor/cfi_flash.h3
-rw-r--r--drivers/nor/cfi_flash_amd.c4
-rw-r--r--drivers/nor/cfi_flash_intel.c4
4 files changed, 25 insertions, 4 deletions
diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
index fb5935e352..a1e0726701 100644
--- a/drivers/nor/cfi_flash.c
+++ b/drivers/nor/cfi_flash.c
@@ -269,6 +269,24 @@ static ulong flash_read_long (struct flash_info *info, flash_sect_t sect, uint o
* http://www.jedec.org/download/search/jesd68.pdf
*
*/
+u32 jedec_read_mfr(struct flash_info *info)
+{
+ int bank = 0;
+ uchar mfr;
+
+ /* According to JEDEC "Standard Manufacturer's Identification Code"
+ * (http://www.jedec.org/download/search/jep106W.pdf)
+ * several first banks can contain 0x7f instead of actual ID
+ */
+ do {
+ mfr = flash_read_uchar (info,
+ (bank << 8) | FLASH_OFFSET_MANUFACTURER_ID);
+ bank++;
+ } while (mfr == FLASH_ID_CONTINUATION);
+
+ return mfr;
+}
+
static int flash_detect_cfi (struct flash_info *info)
{
int cfi_offset;
diff --git a/drivers/nor/cfi_flash.h b/drivers/nor/cfi_flash.h
index 4094b02f21..877822abba 100644
--- a/drivers/nor/cfi_flash.h
+++ b/drivers/nor/cfi_flash.h
@@ -107,6 +107,8 @@ extern struct cfi_cmd_set cfi_cmd_set_amd;
#define FLASH_STATUS_R 0x01
#define FLASH_STATUS_PROTECT 0x01
+#define FLASH_ID_CONTINUATION 0x7F
+
#define AMD_CMD_RESET 0xF0
#define AMD_CMD_WRITE 0xA0
#define AMD_CMD_ERASE_START 0x80
@@ -211,6 +213,7 @@ static inline uchar *flash_make_addr (struct flash_info *info, flash_sect_t sect
}
uchar flash_read_uchar (struct flash_info *info, uint offset);
+u32 jedec_read_mfr(struct flash_info *info);
#ifdef CONFIG_DRIVER_CFI_BANK_WIDTH_1
#define bankwidth_is_1(info) (info->portwidth == 1)
diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index c64377b550..54e764db59 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -42,8 +42,8 @@ static void amd_read_jedec_ids (struct flash_info *info)
flash_unlock_seq(info);
flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
udelay(1000); /* some flash are slow to respond */
- info->manufacturer_id = flash_read_uchar (info,
- FLASH_OFFSET_MANUFACTURER_ID);
+
+ info->manufacturer_id = jedec_read_mfr(info);
info->device_id = flash_read_uchar (info,
FLASH_OFFSET_DEVICE_ID);
if (info->device_id == 0x7E) {
diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/nor/cfi_flash_intel.c
index a71f7c455d..649f83b43f 100644
--- a/drivers/nor/cfi_flash_intel.c
+++ b/drivers/nor/cfi_flash_intel.c
@@ -16,8 +16,8 @@ static void intel_read_jedec_ids (struct flash_info *info)
flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
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_OFFSET_MANUFACTURER_ID);
+
+ info->manufacturer_id = jedec_read_mfr(info);
info->device_id = flash_read_uchar (info,
FLASH_OFFSET_DEVICE_ID);
flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);