diff options
author | roy zang <tie-fei.zang@freescale.com> | 2007-01-04 11:10:05 +0800 |
---|---|---|
committer | Zang Tiefei <roy@bus.ap.freescale.net> | 2007-01-04 11:10:05 +0800 |
commit | a41969e09b9d886091a804c2ba5f1ab84b084dd3 (patch) | |
tree | 96d4b03713537e6c0a696e4770c23f9d39792666 /drivers | |
parent | d3bb5ec198edad4869ac5276a5899881b7bf5433 (diff) | |
parent | 92eb729bad876725aeea908d2addba0800620840 (diff) |
Merge branch 'master' into hpc2
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/cfi_flash.c | 37 | ||||
-rw-r--r-- | drivers/nand/nand.c | 17 |
2 files changed, 32 insertions, 22 deletions
diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c index 8f959e72a27..a834cb4cf08 100644 --- a/drivers/cfi_flash.c +++ b/drivers/cfi_flash.c @@ -111,6 +111,7 @@ #define FLASH_OFFSET_DEVICE_ID2 0x0E #define FLASH_OFFSET_DEVICE_ID3 0x0F #define FLASH_OFFSET_CFI 0x55 +#define FLASH_OFFSET_CFI_ALT 0x555 #define FLASH_OFFSET_CFI_RESP 0x10 #define FLASH_OFFSET_PRIMARY_VENDOR 0x13 #define FLASH_OFFSET_EXT_QUERY_T_P_ADDR 0x15 /* extended query table primary addr */ @@ -161,6 +162,8 @@ typedef union { #define NUM_ERASE_REGIONS 4 /* max. number of erase regions */ +static uint flash_offset_cfi[2]={FLASH_OFFSET_CFI,FLASH_OFFSET_CFI_ALT}; + /* use CFG_MAX_FLASH_BANKS_DETECT if defined */ #ifdef CFG_MAX_FLASH_BANKS_DETECT static ulong bank_base[CFG_MAX_FLASH_BANKS_DETECT] = CFG_FLASH_BANKS_LIST; @@ -350,7 +353,7 @@ unsigned long flash_init (void) if (flash_info[i].flash_id == FLASH_UNKNOWN) { #ifndef CFG_FLASH_QUIET_TEST printf ("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n", - i, flash_info[i].size, flash_info[i].size << 20); + i+1, flash_info[i].size, flash_info[i].size << 20); #endif /* CFG_FLASH_QUIET_TEST */ } #ifdef CFG_FLASH_PROTECTION @@ -1153,6 +1156,7 @@ static void flash_read_jedec_ids (flash_info_t * info) */ static int flash_detect_cfi (flash_info_t * info) { + int cfi_offset; debug ("flash detect cfi\n"); for (info->portwidth = CFG_FLASH_CFI_WIDTH; @@ -1161,19 +1165,22 @@ static int flash_detect_cfi (flash_info_t * info) info->chipwidth <= info->portwidth; info->chipwidth <<= 1) { flash_write_cmd (info, 0, 0, info->cmd_reset); - flash_write_cmd (info, 0, FLASH_OFFSET_CFI, 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')) { - info->interface = flash_read_ushort (info, 0, FLASH_OFFSET_INTERFACE); - debug ("device interface is %d\n", - info->interface); - debug ("found port %d chip %d ", - info->portwidth, info->chipwidth); - debug ("port %d bits chip %d bits\n", - info->portwidth << CFI_FLASH_SHIFT_WIDTH, - info->chipwidth << CFI_FLASH_SHIFT_WIDTH); - return 1; + for (cfi_offset=0; cfi_offset < sizeof(flash_offset_cfi)/sizeof(uint); 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')) { + info->interface = flash_read_ushort (info, 0, FLASH_OFFSET_INTERFACE); + info->cfi_offset=flash_offset_cfi[cfi_offset]; + debug ("device interface is %d\n", + info->interface); + debug ("found port %d chip %d ", + info->portwidth, info->chipwidth); + debug ("port %d bits chip %d bits\n", + info->portwidth << CFI_FLASH_SHIFT_WIDTH, + info->chipwidth << CFI_FLASH_SHIFT_WIDTH); + return 1; + } } } } @@ -1210,7 +1217,7 @@ ulong flash_get_size (ulong base, int banknum) info->vendor = flash_read_ushort (info, 0, FLASH_OFFSET_PRIMARY_VENDOR); flash_read_jedec_ids (info); - flash_write_cmd (info, 0, FLASH_OFFSET_CFI, FLASH_CMD_CFI); + flash_write_cmd (info, 0, info->cfi_offset, FLASH_CMD_CFI); num_erase_regions = flash_read_uchar (info, FLASH_OFFSET_NUM_ERASE_REGIONS); info->ext_addr = flash_read_ushort (info, 0, diff --git a/drivers/nand/nand.c b/drivers/nand/nand.c index 3899045a72c..9fef71d6293 100644 --- a/drivers/nand/nand.c +++ b/drivers/nand/nand.c @@ -39,7 +39,7 @@ static ulong base_address[CFG_MAX_NAND_DEVICE] = CFG_NAND_BASE_LIST; static const char default_nand_name[] = "nand"; -extern void board_nand_init(struct nand_chip *nand); +extern int board_nand_init(struct nand_chip *nand); static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand, ulong base_addr) @@ -47,13 +47,16 @@ static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand, mtd->priv = nand; nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr; - board_nand_init(nand); - - if (nand_scan(mtd, 1) == 0) { - if (!mtd->name) - mtd->name = (char *)default_nand_name; - } else + if (board_nand_init(nand) == 0) { + if (nand_scan(mtd, 1) == 0) { + if (!mtd->name) + mtd->name = (char *)default_nand_name; + } else + mtd->name = NULL; + } else { mtd->name = NULL; + mtd->size = 0; + } } |