Message ID | 201101311856.48465.Aaron.Williams@caviumnetworks.com |
---|---|
State | Superseded |
Headers | show |
On Mon, Jan 31, 2011 at 06:56:48PM -0800, Aaron Williams wrote: > Trying again submitting the patch. > > Adds support for NAND flash chips that are 4GiB and larger. > > Signed-off-by: Aaron Williams <aaron.williams@caviumnetworks.com> > > diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c > index 5481c88..26d24b0 100644 > --- a/common/cmd_mtdparts.c > +++ b/common/cmd_mtdparts.c > @@ -21,6 +21,11 @@ > * $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $ > * Copyright 2002 SYSGO Real-Time Solutions GmbH > * > + * (C) Copyright 2011 > + * Aaron Williams, Cavium Networks, Inc. <aaron.williams@caviumnetworks.com> > + * > + * Added support for partitions and flash greater than or equal to 4GiB. > + * > * See file CREDITS for list of people who contributed to this > * project. > * Changelogs go in git, not at the top of the file. > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c > index dd394a8..105eb3f 100644 > --- a/drivers/mtd/cfi_flash.c > +++ b/drivers/mtd/cfi_flash.c > @@ -1162,10 +1162,10 @@ void flash_print_info (flash_info_t * info) > info->name, > (info->portwidth << 3), (info->chipwidth << 3)); > if (info->size < 1024*1024) > - printf (" Size: %ld kB in %d Sectors\n", > + printf (" Size: %ld KiB in %d Sectors\n", > info->size >> 10, info->sector_count); > else > - printf (" Size: %ld MB in %d Sectors\n", > + printf (" Size: %ld MiB in %d Sectors\n", > info->size >> 20, info->sector_count); > printf (" "); > switch (info->vendor) { > @@ -1924,6 +1924,7 @@ ulong flash_get_size (phys_addr_t base, int banknum) > > /* Do manufacturer-specific fixups */ > switch (info->manufacturer_id) { > + case 0x0000: > case 0x0001: > flash_fixup_amd(info, &qry); > break; This seems unrelated. Otherwise, the patch looks good. Whose tree should it go through? It's not really a NAND patch, though NAND is the reason for it. -Scott
On Mon, Feb 7, 2011 at 16:58, Scott Wood <scottwood@freescale.com> wrote: > On Mon, Jan 31, 2011 at 06:56:48PM -0800, Aaron Williams wrote: >> Trying again submitting the patch. >> >> /* Do manufacturer-specific fixups */ >> switch (info->manufacturer_id) { >> + case 0x0000: >> case 0x0001: >> flash_fixup_amd(info, &qry); >> break; > > This seems unrelated. > > Otherwise, the patch looks good. Whose tree should it go through? > It's not really a NAND patch, though NAND is the reason for it. NAK This is not only unrelated (which the OP was told to fix on the previous post of this patch), but wrong. The S29GL series chips don't return 0x0000 for the manufacturer ID. AMD (later Spansion) have always had mfg. ID 0x0001. I have various boards with S29GL064, S29GL128N, and S29GL256P, and they all return the correct value (0x0001) for the mfg. ID. I looked up the latest datasheet and they have not changed that section.
On Tuesday, February 08, 2011 07:38:44 am Andrew Dyer wrote: > On Mon, Feb 7, 2011 at 16:58, Scott Wood <scottwood@freescale.com> wrote: > > On Mon, Jan 31, 2011 at 06:56:48PM -0800, Aaron Williams wrote: > >> Trying again submitting the patch. > >> > >> /* Do manufacturer-specific fixups */ > >> switch (info->manufacturer_id) { > >> + case 0x0000: > >> case 0x0001: > >> flash_fixup_amd(info, &qry); > >> break; > > > > This seems unrelated. > > > > Otherwise, the patch looks good. Whose tree should it go through? > > It's not really a NAND patch, though NAND is the reason for it. > > NAK > > This is not only unrelated (which the OP was told to fix on the > previous post of this patch), but wrong. The S29GL series chips don't > return 0x0000 for the manufacturer ID. AMD (later Spansion) have > always had mfg. ID 0x0001. > > I have various boards with S29GL064, S29GL128N, and S29GL256P, and > they all return the correct value (0x0001) for the mfg. ID. I looked > up the latest datasheet and they have not changed that section. I always get 0x0000 for the mfg ID and cannot explain it. The full part number is S29GL064N90TF103 010FF058. That is why it was added. Without it, the proper fixup doesn't happen with this chip. -Aaron
On Tuesday, February 08, 2011 03:11:54 pm Aaron Williams wrote: > On Tuesday, February 08, 2011 07:38:44 am Andrew Dyer wrote: > > On Mon, Feb 7, 2011 at 16:58, Scott Wood <scottwood@freescale.com> wrote: > > > On Mon, Jan 31, 2011 at 06:56:48PM -0800, Aaron Williams wrote: > > >> Trying again submitting the patch. > > >> > > >> /* Do manufacturer-specific fixups */ > > >> switch (info->manufacturer_id) { > > >> > > >> + case 0x0000: > > >> case 0x0001: > > >> flash_fixup_amd(info, &qry); > > >> break; > > > > > > This seems unrelated. > > > > > > Otherwise, the patch looks good. Whose tree should it go through? > > > It's not really a NAND patch, though NAND is the reason for it. > > > > NAK > > > > This is not only unrelated (which the OP was told to fix on the > > previous post of this patch), but wrong. The S29GL series chips don't > > return 0x0000 for the manufacturer ID. AMD (later Spansion) have > > always had mfg. ID 0x0001. > > > > I have various boards with S29GL064, S29GL128N, and S29GL256P, and > > they all return the correct value (0x0001) for the mfg. ID. I looked > > up the latest datasheet and they have not changed that section. > > I always get 0x0000 for the mfg ID and cannot explain it. The full part > number is S29GL064N90TF103 010FF058. That is why it was added. Without it, > the proper fixup doesn't happen with this chip. > > -Aaron Note that in our case the port width is 16-bits and the chip width is 8 bits. I added some printf statements for all read accesses to help. Here's the output when I enable debugging: flash detect cfi fwc addr 1f400000 cmd f0 f0f0 16bit x 8 bit fwc addr 1f400000 cmd ff ffff 16bit x 8 bit fwc addr 1f4000aa cmd 98 9898 16bit x 8 bit is= cmd 51(Q) addr 1f400020 flash_read16: address 1f400020, value 0x5151 is= 5151 5151 flash_read16: address 1f400020, value 0x5151 is= cmd 52(R) addr 1f400022 flash_read16: address 1f400022, value 0x5252 is= 5252 5252 flash_read16: address 1f400022, value 0x5252 is= cmd 59(Y) addr 1f400024 flash_read16: address 1f400024, value 0x5959 is= 5959 5959 flash_read16: address 1f400024, value 0x5959 flash_read8: address 1f400021, value 0x51 flash_read8: address 1f400023, value 0x52 flash_read8: address 1f400025, value 0x59 flash_read8: address 1f400027, value 0x2 flash_read8: address 1f400029, value 0x0 flash_read8: address 1f40002b, value 0x40 flash_read8: address 1f40002d, value 0x0 flash_read8: address 1f40002f, value 0x0 flash_read8: address 1f400031, value 0x0 flash_read8: address 1f400033, value 0x0 flash_read8: address 1f400035, value 0x0 flash_read8: address 1f400037, value 0x27 flash_read8: address 1f400039, value 0x36 flash_read8: address 1f40003b, value 0x0 flash_read8: address 1f40003d, value 0x0 flash_read8: address 1f40003f, value 0x7 flash_read8: address 1f400041, value 0x7 flash_read8: address 1f400043, value 0xa flash_read8: address 1f400045, value 0x0 flash_read8: address 1f400047, value 0x3 flash_read8: address 1f400049, value 0x5 flash_read8: address 1f40004b, value 0x4 flash_read8: address 1f40004d, value 0x0 flash_read8: address 1f40004f, value 0x17 flash_read8: address 1f400051, value 0x2 flash_read8: address 1f400053, value 0x0 flash_read8: address 1f400055, value 0x5 flash_read8: address 1f400057, value 0x0 flash_read8: address 1f400059, value 0x2 flash_read8: address 1f40005b, value 0x7 flash_read8: address 1f40005d, value 0x0 flash_read8: address 1f40005f, value 0x20 flash_read8: address 1f400061, value 0x0 flash_read8: address 1f400063, value 0x7e flash_read8: address 1f400065, value 0x0 flash_read8: address 1f400067, value 0x0 flash_read8: address 1f400069, value 0x1 flash_read8: address 1f40006b, value 0x0 flash_read8: address 1f40006d, value 0x0 flash_read8: address 1f40006f, value 0x0 flash_read8: address 1f400071, value 0x0 flash_read8: address 1f400073, value 0x0 flash_read8: address 1f400075, value 0x0 flash_read8: address 1f400077, value 0x0 flash_read8: address 1f400079, value 0x0 device interface is 2 found port 2 chip 1 port 16 bits chip 8 bits flash_read8: address 1f400087, value 0x31 flash_read8: address 1f400089, value 0x33 00 : 51 52 59 02 00 40 00 00 00 00 00 27 36 00 00 07 QRY..@.....'6... 10 : 07 0a 00 03 05 04 00 17 02 00 05 00 02 07 00 20 ............... 20 : 00 7e 00 00 01 00 00 00 00 00 00 00 00 00 00 10 .~.............. fwc addr 1f400000 cmd f0 f0f0 16bit x 8 bit fwc addr 1f401554 cmd aa aaaa 16bit x 8 bit fwc addr 1f400aaa cmd 55 5555 16bit x 8 bit fwc addr 1f401554 cmd 90 9090 16bit x 8 bit flash_read8: address 1f400001, value 0x0 flash_read8: address 1f400003, value 0x3f fwc addr 1f400000 cmd f0 f0f0 16bit x 8 bit fwc addr 1f4000aa cmd 98 9898 16bit x 8 bit flash_read8: address 1f40009f, value 0x3 manufacturer is 2 manufacturer id is 0x0 device id is 0x3f device id2 is 0x0 cfi version is 0x3133 size_ratio 1 port 16 bits chip 8 bits found 2 erase regions erase region 0: 0x0100007e erase_region_count = 127 erase_region_size = 65536 erase region 1: 0x00200007 erase_region_count = 8 erase_region_size = 8192 fwc addr 1f400000 cmd f0 f0 8bit x 8 bit fwc addr 1fbfe000 cmd 70 70 8bit x 8 bit flash_read8: address 1fbfe000, value 0xe5 flash_read8: address 1fbfe000, value 0xe5 flash_is_busy: 0 Flash: 8 MiB
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c index 5481c88..26d24b0 100644 --- a/common/cmd_mtdparts.c +++ b/common/cmd_mtdparts.c @@ -21,6 +21,11 @@ * $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $ * Copyright 2002 SYSGO Real-Time Solutions GmbH * + * (C) Copyright 2011 + * Aaron Williams, Cavium Networks, Inc. <aaron.williams@caviumnetworks.com> + * + * Added support for partitions and flash greater than or equal to 4GiB. + * * See file CREDITS for list of people who contributed to this * project. * @@ -174,7 +179,7 @@ static int device_del(struct mtd_device *dev); * @param retptr output pointer to next char after parse completes (output) * @return resulting unsigned int */ -static unsigned long memsize_parse (const char *const ptr, const char **retptr) +static u64 memsize_parse (const char *const ptr, const char **retptr) { unsigned long ret = simple_strtoul(ptr, (char **)retptr, 0); @@ -207,20 +212,20 @@ static unsigned long memsize_parse (const char *const ptr, const char **retptr) * @param buf output buffer * @param size size to be converted to string */ -static void memsize_format(char *buf, u32 size) +static void memsize_format(char *buf, u64 size) { #define SIZE_GB ((u32)1024*1024*1024) #define SIZE_MB ((u32)1024*1024) #define SIZE_KB ((u32)1024) if ((size % SIZE_GB) == 0) - sprintf(buf, "%ug", size/SIZE_GB); + sprintf(buf, "%llug", size/SIZE_GB); else if ((size % SIZE_MB) == 0) - sprintf(buf, "%um", size/SIZE_MB); + sprintf(buf, "%llum", size/SIZE_MB); else if (size % SIZE_KB == 0) - sprintf(buf, "%uk", size/SIZE_KB); + sprintf(buf, "%lluk", size/SIZE_KB); else - sprintf(buf, "%u", size); + sprintf(buf, "%llu", size); } /** @@ -325,7 +330,7 @@ static int part_validate_eraseblock(struct mtdids *id, struct part_info *part) { struct mtd_info *mtd = NULL; int i, j; - ulong start; + u64 start; if (get_mtd_info(id->type, id->num, &mtd)) return 1; @@ -337,7 +342,7 @@ static int part_validate_eraseblock(struct mtdids *id, struct part_info *part) * Only one eraseregion (NAND, OneNAND or uniform NOR), * checking for alignment is easy here */ - if ((unsigned long)part->offset % mtd->erasesize) { + if ((u64)part->offset % mtd->erasesize) { printf("%s%d: partition (%s) start offset" "alignment incorrect\n", MTD_DEV_TYPE(id->type), id->num, part->name); @@ -412,7 +417,7 @@ static int part_validate(struct mtdids *id, struct part_info *part) part->size = id->size - part->offset; if (part->offset > id->size) { - printf("%s: offset %08x beyond flash size %08x\n", + printf("%s: offset %08llx beyond flash size %08llx\n", id->mtd_id, part->offset, id->size); return 1; } @@ -595,8 +600,8 @@ static int part_add(struct mtd_device *dev, struct part_info *part) static int part_parse(const char *const partdef, const char **ret, struct part_info **retpart) { struct part_info *part; - unsigned long size; - unsigned long offset; + u64 size; + u64 offset; const char *name; int name_len; unsigned int mask_flags; @@ -615,7 +620,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i } else { size = memsize_parse(p, &p); if (size < MIN_PART_SIZE) { - printf("partition size too small (%lx)\n", size); + printf("partition size too small (%llx)\n", size); return 1; } } @@ -687,14 +692,14 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i part->auto_name = 0; } else { /* auto generated name in form of size@offset */ - sprintf(part->name, "0x%08lx@0x%08lx", size, offset); + sprintf(part->name, "0x%08llx@0x%08llx", size, offset); part->auto_name = 1; } part->name[name_len - 1] = '\0'; INIT_LIST_HEAD(&part->link); - debug("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n", + debug("+ partition: name %-22s size 0x%08llx offset 0x%08llx mask flags %d\n", part->name, part->size, part->offset, part->mask_flags); @@ -710,7 +715,7 @@ static int part_parse(const char *const partdef, const char **ret, struct part_i * @param size a pointer to the size of the mtd device (output) * @return 0 if device is valid, 1 otherwise */ -int mtd_device_validate(u8 type, u8 num, u32 *size) +int mtd_device_validate(u8 type, u8 num, u64 *size) { struct mtd_info *mtd = NULL; @@ -842,7 +847,7 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_ LIST_HEAD(tmp_list); struct list_head *entry, *n; u16 num_parts; - u32 offset; + u64 offset; int err = 1; debug("===device_parse===\n"); @@ -1077,15 +1082,16 @@ int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num) * @param buflen buffer size * @return 0 on success, 1 otherwise */ -static int generate_mtdparts(char *buf, u32 buflen) +static int generate_mtdparts(char *buf, size_t buflen) { struct list_head *pentry, *dentry; struct mtd_device *dev; struct part_info *part, *prev_part; char *p = buf; char tmpbuf[32]; - u32 size, offset, len, part_cnt; - u32 maxlen = buflen - 1; + u64 size, offset, len; + u32 part_cnt; + size_t maxlen = buflen - 1; debug("--- generate_mtdparts ---\n"); @@ -1204,7 +1210,7 @@ cleanup: * @param buflen buffer size * @return 0 on success, 1 otherwise */ -static int generate_mtdparts_save(char *buf, u32 buflen) +static int generate_mtdparts_save(char *buf, size_t buflen) { int ret; @@ -1265,13 +1271,13 @@ static void print_partition_table(void) printf(" #: name\t\tsize\t\tnet size\toffset\t\tmask_flags\n"); list_for_each(pentry, &dev->parts) { - u32 net_size; + u64 net_size; char *size_note; part = list_entry(pentry, struct part_info, link); net_size = net_part_size(mtd, part); size_note = part->size == net_size ? " " : " (!)"; - printf("%2d: %-20s0x%08x\t0x%08x%s\t0x%08x\t%d\n", + printf("%2d: %-20s0x%08llx\t0x%08llx%s\t0x%08llx\t%d\n", part_num, part->name, part->size, net_size, size_note, part->offset, part->mask_flags); @@ -1283,7 +1289,7 @@ static void print_partition_table(void) list_for_each(pentry, &dev->parts) { part = list_entry(pentry, struct part_info, link); - printf("%2d: %-20s0x%08x\t0x%08x\t%d\n", + printf("%2d: %-20s0x%08llx\t0x%08llx\t%d\n", part_num, part->name, part->size, part->offset, part->mask_flags); #endif /* defined(CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES) */ @@ -1310,7 +1316,7 @@ static void list_partitions(void) if (current_mtd_dev) { part = mtd_part_info(current_mtd_dev, current_mtd_partnum); if (part) { - printf("\nactive partition: %s%d,%d - (%s) 0x%08x @ 0x%08x\n", + printf("\nactive partition: %s%d,%d - (%s) 0x%08llx @ 0x%08llx\n", MTD_DEV_TYPE(current_mtd_dev->id->type), current_mtd_dev->id->num, current_mtd_partnum, part->name, part->size, part->offset); @@ -1410,7 +1416,7 @@ static int delete_partition(const char *id) if (find_dev_and_part(id, &dev, &pnum, &part) == 0) { - debug("delete_partition: device = %s%d, partition %d = (%s) 0x%08x@0x%08x\n", + debug("delete_partition: device = %s%d, partition %d = (%s) 0x%08llx@0x%08llx\n", MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum, part->name, part->size, part->offset); @@ -1499,7 +1505,7 @@ static int spread_partitions(void) part = list_entry(pentry, struct part_info, link); debug("spread_partitions: device = %s%d, partition %d =" - " (%s) 0x%08x@0x%08x\n", + " (%s) 0x%08llx@0x%08llx\n", MTD_DEV_TYPE(dev->id->type), dev->id->num, part_num, part->name, part->size, part->offset); @@ -1596,7 +1602,7 @@ static int parse_mtdids(const char *const ids) struct list_head *entry, *n; struct mtdids *id_tmp; u8 type, num; - u32 size; + u64 size; int ret = 1; debug("\n---parse_mtdids---\nmtdids = %s\n\n", ids); @@ -1670,7 +1676,7 @@ static int parse_mtdids(const char *const ids) id->mtd_id[mtd_id_len - 1] = '\0'; INIT_LIST_HEAD(&id->link); - debug("+ id %s%d\t%16d bytes\t%s\n", + debug("+ id %s%d\t%16llu bytes\t%s\n", MTD_DEV_TYPE(id->type), id->num, id->size, id->mtd_id); @@ -1999,7 +2005,7 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!strcmp(&argv[1][3], ".spread")) { spread_partition(mtd, p, &next_offset); - debug("increased %s to %d bytes\n", p->name, p->size); + debug("increased %s to %llu bytes\n", p->name, p->size); } #endif diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index dd394a8..105eb3f 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -1162,10 +1162,10 @@ void flash_print_info (flash_info_t * info) info->name, (info->portwidth << 3), (info->chipwidth << 3)); if (info->size < 1024*1024) - printf (" Size: %ld kB in %d Sectors\n", + printf (" Size: %ld KiB in %d Sectors\n", info->size >> 10, info->sector_count); else - printf (" Size: %ld MB in %d Sectors\n", + printf (" Size: %ld MiB in %d Sectors\n", info->size >> 20, info->sector_count); printf (" "); switch (info->vendor) { @@ -1924,6 +1924,7 @@ ulong flash_get_size (phys_addr_t base, int banknum) /* Do manufacturer-specific fixups */ switch (info->manufacturer_id) { + case 0x0000: case 0x0001: flash_fixup_amd(info, &qry); break; diff --git a/include/jffs2/load_kernel.h b/include/jffs2/load_kernel.h index 906eb3d..dda096d 100644 --- a/include/jffs2/load_kernel.h +++ b/include/jffs2/load_kernel.h @@ -46,8 +46,8 @@ struct part_info { struct list_head link; char *name; /* partition name */ u8 auto_name; /* set to 1 for generated name */ - u32 size; /* total size of the partition */ - u32 offset; /* offset within device */ + u64 size; /* total size of the partition */ + u64 offset; /* offset within device */ void *jffs2_priv; /* used internaly by jffs2 */ u32 mask_flags; /* kernel MTD mask flags */ u32 sector_size; /* size of sector */ @@ -58,7 +58,7 @@ struct mtdids { struct list_head link; u8 type; /* device type */ u8 num; /* device number */ - u32 size; /* device size */ + u64 size; /* device size */ char *mtd_id; /* linux kernel device id */ };
Trying again submitting the patch. Adds support for NAND flash chips that are 4GiB and larger. Signed-off-by: Aaron Williams <aaron.williams@caviumnetworks.com>