summaryrefslogtreecommitdiff
path: root/board/innokom/flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/innokom/flash.c')
-rw-r--r--board/innokom/flash.c109
1 files changed, 52 insertions, 57 deletions
diff --git a/board/innokom/flash.c b/board/innokom/flash.c
index 5505bb5..b56707d 100644
--- a/board/innokom/flash.c
+++ b/board/innokom/flash.c
@@ -86,81 +86,79 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
*/
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 = &current_part;
+ part.jffs2_priv = jffs2_priv_saved;
return ∂
}
@@ -174,75 +172,72 @@ struct part_info* jffs2_part_info(int part_num) {
#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 = &current_part;
+ part.jffs2_priv = jffs2_priv_saved;
return ∂
}
@@ -336,13 +331,13 @@ void flash_print_info (flash_info_t *info)
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 +366,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
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 +416,13 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
goto outahere;
}
}
-
+
PRINTK("clearing status register\n");
- *addr = 0x0050;
+ *addr = 0x0050;
PRINTK("resetting to read mode");
- *addr = 0x00FF;
+ *addr = 0x00FF;
}
-
+
printf("ok.\n");
}