From cd1d937f90250a32988c37b2b4af8364d25de8ed Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Fri, 5 Jan 2007 11:46:05 +0100 Subject: [PATCH] nand: Fix problem with oobsize calculation Here the description from Brian Brelsford : The Hynix part returns a 0x1d in the 4th ID byte. The Samsung part returns a 0x15. In the code fragment below bits [1:0] determine the page size, it is ANDed via "(extid & 0x3)" then shifted out. The next field is also ANDed with 0x3. However this is a one bit field as defined in the Hynix and Samsung parts in the 4th ID byte that determins the oobsize, not a two bit field. It works on Samsung as bits[3:2] are 01. However for the Hynix there is a 11 in these two bits, so the oob size gets messed up. I checked the correct linux code and the suggested fix from Brian is also available in the linux nand mtd driver. Signed-off-by: Stefan Roese --- drivers/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/nand/nand_base.c b/drivers/nand/nand_base.c index 7fdf57b..8495829 100644 --- a/drivers/nand/nand_base.c +++ b/drivers/nand/nand_base.c @@ -2338,7 +2338,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) mtd->oobblock = 1024 << (extid & 0x3); extid >>= 2; /* Calc oobsize */ - mtd->oobsize = (8 << (extid & 0x03)) * (mtd->oobblock / 512); + mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock / 512); extid >>= 2; /* Calc blocksize. Blocksize is multiples of 64KiB */ mtd->erasesize = (64 * 1024) << (extid & 0x03); -- cgit v1.1 From ca43ba18e910206ef8063e4b22d282630bff3fd2 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Thu, 11 Jan 2007 15:44:44 +0100 Subject: Added support for the SOLIDCARD III board from Eurodesign Signed-off-by: Heiko Schocher --- drivers/cfi_flash.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c index 2699cce..8dc4499 100644 --- a/drivers/cfi_flash.c +++ b/drivers/cfi_flash.c @@ -40,6 +40,10 @@ #include #ifdef CFG_FLASH_CFI_DRIVER +#if defined(CONFIG_SOLIDCARD3) +#define __LITTLE_ENDIAN +#endif + /* * This file implements a Common Flash Interface (CFI) driver for U-Boot. * The width of the port and the width of the chips are determined at initialization. @@ -867,7 +871,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) cword->c = c; break; case FLASH_CFI_16BIT: -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) w = c; w <<= 8; cword->w = (cword->w >> 8) | w; @@ -1359,7 +1363,6 @@ static int flash_write_cfiword (flash_info_t * info, ulong dest, ctladdr.cp = flash_make_addr (info, 0, 0); cptr.cp = (uchar *) dest; - /* Check if Flash is (sufficiently) erased */ switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -1531,4 +1534,9 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp, } } #endif /* CFG_FLASH_USE_BUFFER_WRITE */ + +#if defined(CONFIG_SOLIDCARD3) +#undef __LITTLE_ENDIAN +#endif + #endif /* CFG_FLASH_CFI */ -- cgit v1.1 From cb4820725e9fc409c5cbc8e83054a6ed522d2111 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Thu, 18 Jan 2007 11:28:51 +0100 Subject: [PATCH] Fix: Compilerwarnings for SC3 board. The EBC Configuration Register is now by CFG_EBC_CFG definable Added JFFS2 support for the SC3 board. Signed-off-by: Heiko Schocher --- drivers/cfi_flash.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c index 8dc4499..665d8e7 100644 --- a/drivers/cfi_flash.c +++ b/drivers/cfi_flash.c @@ -860,7 +860,7 @@ static int flash_full_status_check (flash_info_t * info, flash_sect_t sector, */ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) { -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) unsigned short w; unsigned int l; unsigned long long ll; @@ -880,7 +880,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) #endif break; case FLASH_CFI_32BIT: -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) l = c; l <<= 24; cword->l = (cword->l >> 8) | l; @@ -889,7 +889,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) #endif break; case FLASH_CFI_64BIT: -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) ll = c; ll <<= 56; cword->ll = (cword->ll >> 8) | ll; -- cgit v1.1 From d0b6e14087ddd8789f224a48e1d33f2a5df4d167 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Fri, 19 Jan 2007 18:05:26 +0100 Subject: [PATCH] CFI: define CFG_WRITE_SWAPPED_DATA for the CFI-Flash driver if you must swap the bytes between reading/writing. (Needed for the SC3 board) Signed-off-by: Heiko Schocher --- drivers/cfi_flash.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c index 665d8e7..696f9a4 100644 --- a/drivers/cfi_flash.c +++ b/drivers/cfi_flash.c @@ -40,10 +40,6 @@ #include #ifdef CFG_FLASH_CFI_DRIVER -#if defined(CONFIG_SOLIDCARD3) -#define __LITTLE_ENDIAN -#endif - /* * This file implements a Common Flash Interface (CFI) driver for U-Boot. * The width of the port and the width of the chips are determined at initialization. @@ -58,6 +54,8 @@ * AMD/Spansion Application Note: Migration from Single-byte to Three-byte * Device IDs, Publication Number 25538 Revision A, November 8, 2001 * + * define CFG_WRITE_SWAPPED_DATA, if you have to swap the Bytes between + * reading and writing ... (yes there is such a Hardware). */ #ifndef CFG_FLASH_BANKS_LIST @@ -260,7 +258,7 @@ inline uchar flash_read_uchar (flash_info_t * info, uint offset) uchar *cp; cp = flash_make_addr (info, 0, offset); -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) return (cp[0]); #else return (cp[info->portwidth - 1]); @@ -287,7 +285,7 @@ ushort flash_read_ushort (flash_info_t * info, flash_sect_t sect, uint offset) debug ("addr[%x] = 0x%x\n", x, addr[x]); } #endif -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) retval = ((addr[(info->portwidth)] << 8) | addr[0]); #else retval = ((addr[(2 * info->portwidth) - 1] << 8) | @@ -319,7 +317,7 @@ ulong flash_read_long (flash_info_t * info, flash_sect_t sect, uint offset) debug ("addr[%x] = 0x%x\n", x, addr[x]); } #endif -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) retval = (addr[0] << 16) | (addr[(info->portwidth)] << 24) | (addr[(2 * info->portwidth)]) | (addr[(3 * info->portwidth)] << 8); #else @@ -860,7 +858,7 @@ static int flash_full_status_check (flash_info_t * info, flash_sect_t sector, */ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) { -#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) +#if defined(__LITTLE_ENDIAN) && !defined(CFG_WRITE_SWAPPED_DATA) unsigned short w; unsigned int l; unsigned long long ll; @@ -871,7 +869,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) cword->c = c; break; case FLASH_CFI_16BIT: -#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) +#if defined(__LITTLE_ENDIAN) && !defined(CFG_WRITE_SWAPPED_DATA) w = c; w <<= 8; cword->w = (cword->w >> 8) | w; @@ -880,7 +878,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) #endif break; case FLASH_CFI_32BIT: -#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) +#if defined(__LITTLE_ENDIAN) && !defined(CFG_WRITE_SWAPPED_DATA) l = c; l <<= 24; cword->l = (cword->l >> 8) | l; @@ -889,7 +887,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c) #endif break; case FLASH_CFI_64BIT: -#if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SOLIDCARD3) +#if defined(__LITTLE_ENDIAN) && !defined(CFG_WRITE_SWAPPED_DATA) ll = c; ll <<= 56; cword->ll = (cword->ll >> 8) | ll; @@ -909,7 +907,7 @@ static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf) int i; uchar *cp = (uchar *) cmdbuf; -#if defined(__LITTLE_ENDIAN) +#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA) for (i = info->portwidth; i > 0; i--) #else for (i = 1; i <= info->portwidth; i++) @@ -1535,8 +1533,4 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp, } #endif /* CFG_FLASH_USE_BUFFER_WRITE */ -#if defined(CONFIG_SOLIDCARD3) -#undef __LITTLE_ENDIAN -#endif - #endif /* CFG_FLASH_CFI */ -- cgit v1.1