]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/innokom/flash.c
rename CFG_ macros to CONFIG_SYS
[karo-tx-uboot.git] / board / innokom / flash.c
index 5505bb549bb54fdd565954d535f7156f3a805110..8c95341b644ad6da51e305051222fe683e6bf2ec 100644 (file)
@@ -9,6 +9,10 @@
  * (C) Copyright 2002
  * Robert Schwebel, Pengutronix, <r.schwebel@pengutronix.de>
  *
+ * (C) Copyright 2002
+ * Auerswald GmbH & Co KG, Germany
+ * Kai-Uwe Bloem <kai-uwe.bloem@auerswald.de>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
 #include <common.h>
 #include <asm/arch/pxa-regs.h>
 
-#if defined CFG_JFFS_CUSTOM_PART
-#include <jffs2/jffs2.h>
-#endif
-
 /* Debugging macros ------------------------------------------------------  */
 
 #undef FLASH_DEBUG
-//#define FLASH_DEBUG 1
 
 /* Some debug macros */
 #if (FLASH_DEBUG > 2 )
 #define MAIN_SECT_SIZE  0x00020000     /* 128k per sector                  */
 #endif
 
-flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];
-
-
-#if defined CFG_JFFS_CUSTOM_PART
-
-/**
- * jffs2_part_info - get information about a JFFS2 partition
- *
- * @part_num: number of the partition you want to get info about
- * @return:   struct part_info* in case of success, 0 if failure
- */
-
-static struct part_info part;
-
-#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) {
-
-       PRINTK2("jffs2_part_info: part_num=%i\n",part_num);
-
-       /* u-boot partition                                                 */
-       if(part_num==0){
-               if(part.usr_priv==(void*)1) return &part;
-
-               memset(&part, 0, sizeof(part));
-
-               part.offset=(char*)0x00000000;
-               part.size=256*1024;
-
-               /* Mark the struct as ready */
-               part.usr_priv=(void*)1;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-               return &part;
-       }
-
-       /* primary OS+firmware partition                                    */
-       if(part_num==1){
-               if(part.usr_priv==(void*)1) return &part;
-
-               memset(&part, 0, sizeof(part));
-
-               part.offset=(char*)0x00040000;
-               part.size=768*1024;
-
-               /* Mark the struct as ready */
-               part.usr_priv=(void*)1;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-               return &part;
-       }
-
-       /* secondary OS+firmware partition                                  */
-       if(part_num==2){
-               if(part.usr_priv==(void*)1) return &part;
-
-               memset(&part, 0, sizeof(part));
-
-               part.offset=(char*)0x00100000;
-               part.size=8*1024*1024;
-
-               /* Mark the struct as ready */
-               part.usr_priv=(void*)1;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-               return &part;
-       }
-
-       /* data partition */
-       if(part_num==3){
-               if(part.usr_priv==(void*)1) return &part;
-
-               memset(&part, 0, sizeof(part));
-
-               part.offset=(char*)0x00900000;
-               part.size=7*1024*1024;
-
-               /* Mark the struct as ready */
-               part.usr_priv=(void*)1;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-
-               return &part;
-       }
-
-       PRINTK("jffs2_part_info: end of partition table\n");
-       return 0;
-}
-#endif /* CONFIG_MTD_INNOKOM_16MB */
-
-#ifdef CONFIG_MTD_INNOKOM_64MB
-#ifdef CONFIG_MTD_INNOKOM_16MB
-#error Please define only one CONFIG_MTD_INNOKOM_XXMB option.
-#endif
-struct part_info* jffs2_part_info(int part_num) {
-
-       PRINTK2("jffs2_part_info: part_num=%i\n",part_num);
-
-       /* u-boot partition                                                 */
-       if(part_num==0){
-               if(part.usr_priv==(void*)1) return &part;
-
-               memset(&part, 0, sizeof(part));
-
-               part.offset=(char*)0x00000000;
-               part.size=256*1024;
-
-               /* Mark the struct as ready */
-               part.usr_priv=(void*)1;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-               return &part;
-       }
-
-       /* primary OS+firmware partition                                    */
-       if(part_num==1){
-               if(part.usr_priv==(void*)1) return &part;
-
-               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;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-               return &part;
-       }
-
-       /* secondary OS+firmware partition                                  */
-       if(part_num==2){
-               if(part.usr_priv==(void*)1) return &part;
-
-               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;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-               return &part;
-       }
-
-       /* data partition */
-       if(part_num==3){
-               if(part.usr_priv==(void*)1) return &part;
-
-               memset(&part, 0, sizeof(part));
-
-               part.offset=(char*)0x02000000;
-               part.size=32*1024*1024;
-
-               /* Mark the struct as ready */
-               part.usr_priv=(void*)1;
-
-               PRINTK("part.offset = 0x%08x\n",(unsigned int)part.offset);
-               PRINTK("part.size   = 0x%08x\n",(unsigned int)part.size);
-
-               return &part;
-       }
-
-       PRINTK("jffs2_part_info: end of partition table\n");
-       return 0;
-}
-#endif /* CONFIG_MTD_INNOKOM_64MB */
-#endif /* defined CFG_JFFS_CUSTOM_PART */
-
+flash_info_t    flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
 
 /**
  * flash_init: - initialize data structures for flash chips
@@ -264,21 +85,21 @@ ulong flash_init(void)
        int i, j;
        ulong size = 0;
 
-       for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
+       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
                ulong flashbase = 0;
                flash_info[i].flash_id =
-                       (INTEL_MANUFACT & FLASH_VENDMASK) |
-                       (INTEL_ID_28F128J3 & FLASH_TYPEMASK);
+                       (INTEL_MANUFACT & FLASH_VENDMASK) |
+                       (INTEL_ID_28F128J3 & FLASH_TYPEMASK);
                flash_info[i].size = FLASH_BANK_SIZE;
-               flash_info[i].sector_count = CFG_MAX_FLASH_SECT;
-               memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
+               flash_info[i].sector_count = CONFIG_SYS_MAX_FLASH_SECT;
+               memset(flash_info[i].protect, 0, CONFIG_SYS_MAX_FLASH_SECT);
 
                switch (i) {
                        case 0:
                                flashbase = PHYS_FLASH_1;
                                break;
                        default:
-                               panic("configured to many flash banks!\n");
+                               panic("configured too many flash banks!\n");
                                break;
                }
                for (j = 0; j < flash_info[i].sector_count; j++) {
@@ -289,14 +110,14 @@ ulong flash_init(void)
 
        /* Protect u-boot sectors */
        flash_protect(FLAG_PROTECT_SET,
-                       CFG_FLASH_BASE,
-                       CFG_FLASH_BASE + (256*1024) - 1,
+                       CONFIG_SYS_FLASH_BASE,
+                       CONFIG_SYS_FLASH_BASE + (256*1024) - 1,
                        &flash_info[0]);
 
-#ifdef CFG_ENV_IS_IN_FLASH
+#ifdef CONFIG_ENV_IS_IN_FLASH
        flash_protect(FLAG_PROTECT_SET,
-                       CFG_ENV_ADDR,
-                       CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
+                       CONFIG_ENV_ADDR,
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
                        &flash_info[0]);
 #endif
 
@@ -314,7 +135,7 @@ void flash_print_info  (flash_info_t *info)
 {
        int i, j;
 
-       for (j=0; j<CFG_MAX_FLASH_BANKS; j++) {
+       for (j=0; j<CONFIG_SYS_MAX_FLASH_BANKS; j++) {
 
                switch (info->flash_id & FLASH_VENDMASK) {
 
@@ -414,7 +235,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 
                        while ((*addr & 0x0080) != 0x0080) {
                                PRINTK(".");
-                               if (get_timer_masked() > CFG_FLASH_ERASE_TOUT) {
+                               if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) {
                                        *addr = 0x00B0; /* suspend erase*/
                                        *addr = 0x00FF; /* read mode    */
                                        rc = ERR_TIMOUT;
@@ -485,7 +306,7 @@ static int write_word (flash_info_t *info, ulong dest, ushort data)
 
        /* wait while polling the status register */
        while(((val = *addr) & 0x80) != 0x80) {
-               if (get_timer_masked() > CFG_FLASH_WRITE_TOUT) {
+               if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) {
                        rc = ERR_TIMOUT;
                        *addr = 0xB0; /* suspend program command */
                        goto outahere;
@@ -529,7 +350,7 @@ static int write_word (flash_info_t *info, ulong dest, ushort data)
  * @param info:
  * @param src: source of copy transaction
  * @param addr:        where to copy to
- * @param cnt:         number of bytes to copy
+ * @param cnt: number of bytes to copy
  *
  * @return     error code
  */
@@ -596,4 +417,3 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 
        return write_word(info, wp, data);
 }
-