From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Schwebel Date: Wed, 12 Mar 2003 08:54:06 +0100 Subject: [U-Boot-Users] [PATCH] innokom flash update Message-ID: <20030312075406.GT4459@pengutronix.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Here's a patch to fix the chpart command on innokom. Please apply. Robert -- Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de Pengutronix - Linux Solutions for Science and Industry Braunschweiger Str. 79, 31134 Hildesheim, Germany Handelsregister: Amtsgericht Hildesheim, HRA 2686 Phone: +49-5121-28619-0 | Fax: +49-5121-28619-4 -------------- next part -------------- diff -urN -x ptx-patches -x CVS u-boot/board/innokom/flash.c u-boot-ptx/board/innokom/flash.c --- u-boot/board/innokom/flash.c 2003-03-06 16:53:37.000000000 +0100 +++ u-boot-ptx/board/innokom/flash.c 2003-03-07 13:58:46.000000000 +0100 @@ -86,81 +89,79 @@ */ static struct part_info part; +static int current_part = -1; #ifdef CONFIG_MTD_INNOKOM_16MB #ifdef CONFIG_MTD_INNOKOM_64MB #error Please define only one CONFIG_MTD_INNOKOM_XXMB option. #endif struct part_info* jffs2_part_info(int part_num) { + void *jffs2_priv_saved = part.jffs2_priv; PRINTK2("jffs2_part_info: part_num=%i\n",part_num); + if (current_part == part_num) + return ∂ + /* u-boot partition */ if(part_num==0){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x00000000; part.size=256*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - return ∂ } /* primary OS+firmware partition */ if(part_num==1){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x00040000; part.size=768*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - return ∂ } - + /* secondary OS+firmware partition */ if(part_num==2){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x00100000; part.size=8*1024*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - return ∂ } /* data partition */ if(part_num==3){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x00900000; part.size=7*1024*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - + } + + if (current_part == part_num) { + part.usr_priv = ¤t_part; + part.jffs2_priv = jffs2_priv_saved; return ∂ } @@ -174,75 +175,72 @@ #error Please define only one CONFIG_MTD_INNOKOM_XXMB option. #endif struct part_info* jffs2_part_info(int part_num) { + void *jffs2_priv_saved = part.jffs2_priv; PRINTK2("jffs2_part_info: part_num=%i\n",part_num); + if (current_part == part_num) + return ∂ + /* u-boot partition */ if(part_num==0){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x00000000; part.size=256*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - return ∂ } /* primary OS+firmware partition */ if(part_num==1){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x00040000; part.size=16*1024*1024-128*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - return ∂ } - + /* secondary OS+firmware partition */ if(part_num==2){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x01020000; part.size=16*1024*1024-128*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - return ∂ } /* data partition */ if(part_num==3){ - if(part.usr_priv==(void*)1) return ∂ - memset(&part, 0, sizeof(part)); - + part.offset=(char*)0x02000000; part.size=32*1024*1024; - + /* Mark the struct as ready */ - part.usr_priv=(void*)1; + current_part = part_num; PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset); PRINTK("part.size = 0x%08x\n",(unsigned int)part.size); - + } + + if (current_part == part_num) { + part.usr_priv = ¤t_part; + part.jffs2_priv = jffs2_priv_saved; return ∂ } @@ -336,13 +334,13 @@ return; } - printf(" Size: %ld MB in %d Sectors\n", + printf(" Size: %ld MB in %d Sectors\n", info->size >> 20, info->sector_count); printf(" Sector Start Addresses:"); for (i = 0; i < info->sector_count; i++) { if ((i % 5) == 0) printf ("\n "); - + printf (" %08lX%s", info->start[i], info->protect[i] ? " (RO)" : " "); } @@ -371,7 +369,7 @@ if ((info->flash_id & FLASH_VENDMASK) != (INTEL_MANUFACT & FLASH_VENDMASK)) return ERR_UNKNOWN_FLASH_VENDOR; - + prot = 0; for (sect=s_first; sect<=s_last; ++sect) { if (info->protect[sect]) prot++; @@ -421,13 +419,13 @@ goto outahere; } } - + PRINTK("clearing status register\n"); - *addr = 0x0050; + *addr = 0x0050; PRINTK("resetting to read mode"); - *addr = 0x00FF; + *addr = 0x00FF; } - + printf("ok.\n"); } diff -urN -x ptx-patches -x CVS u-boot/common/cmd_flash.c u-boot-ptx/common/cmd_flash.c --- u-boot/common/cmd_flash.c 2002-09-18 14:49:44.000000000 +0200 +++ u-boot-ptx/common/cmd_flash.c 2003-01-31 23:03:14.000000000 +0100 @@ -129,7 +129,7 @@ if (strcmp(argv[1], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { - printf ("Erase Flash Bank # %ld ", bank); + printf ("Erase Flash Bank #%ld\n", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); } @@ -141,7 +141,7 @@ printf("Bad sector specification\n"); return 1; } - printf ("Erase Flash Sectors %d-%d in Bank # %d ", + printf ("Erase Flash Sectors %d-%d in Bank #%d\n", sect_first, sect_last, (info-flash_info)+1); rcode = flash_erase(info, sect_first, sect_last); return rcode; @@ -159,7 +159,7 @@ CFG_MAX_FLASH_BANKS); return 1; } - printf ("Erase Flash Bank # %ld ", bank); + printf ("Erase Flash Bank #%ld\n", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); return rcode;