make uboot work on arcaydian board
[openwrt/svn-archive/archive.git] / package / uboot-ifxmips / files / board / ifx / danube / flash.c
index f8a543dbe6756f741ccb7641e2cc1519cf6ffceb..bc919c1c1c9b0f41d050018dc7167520a15cff28 100644 (file)
@@ -83,21 +83,25 @@ unsigned long flash_init (void)
        unsigned long size = 0;
        int i;
 
+       printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
        /* Init: no FLASHes known */
        for (i=0; i < CFG_MAX_FLASH_BANKS; ++i) {         // 1 bank 
                ulong flashbase = (i == 0) ? PHYS_FLASH_1 : PHYS_FLASH_2;      // 0xb0000000,  0xb4000000
 
-       volatile ulong * buscon = (ulong *)
+       printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+          volatile ulong * buscon = (ulong *)
                        ((i == 0) ? DANUBE_EBU_BUSCON0 : DANUBE_EBU_BUSCON1);
 
                /* Disable write protection */
 //             *buscon &= ~AMAZON_EBU_BUSCON0_WRDIS;
                /* Enable write protection */
                *buscon |= DANUBE_EBU_BUSCON0_WRDIS;
+printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
 
 #if 1
                memset(&flash_info[i], 0, sizeof(flash_info_t));
 #endif
+printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
 
                flash_info[i].size = 
                        flash_get_size((FPW *)flashbase, &flash_info[i]);
@@ -227,6 +231,22 @@ static void flash_get_offsets (ulong base, flash_info_t *info)
                bootsect_size = 0x00002000 * (sizeof(FPW)/2);
                sect_size =     0x00010000 * (sizeof(FPW)/2);
 
+               /* set sector offsets for bottom boot block type        */
+               for (i = 0; i < 8; ++i) {
+                       info->start[i] = base + (i * bootsect_size);
+               }
+               for (i = 8; i < info->sector_count; i++) {
+                       info->start[i] = base + ((i - 7) * sect_size);
+               }
+       }       
+       else if(((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_AMD)
+               && ((info->flash_id & FLASH_TYPEMASK)==FLASH_29LV320B)){
+               int bootsect_size;      /* number of bytes/boot sector  */
+               int sect_size;          /* number of bytes/regular sector */
+
+               bootsect_size = 0x00002000 * (sizeof(FPW)/2);
+               sect_size =     0x00010000 * (sizeof(FPW)/2);
+
                /* set sector offsets for bottom boot block type        */
                for (i = 0; i < 8; ++i) {
                        info->start[i] = base + (i * bootsect_size);
@@ -378,6 +398,7 @@ void flash_print_info (flash_info_t *info)
        case FLASH_29LV640BB:           //liupeng for MXIC FLASH_29LV640BB
                fmt = "29LV640BB (64 Mbit, boot sector SA0~SA126 size 64k bytes,other sectors SA127~SA135 size 8k bytes)\n";
                break;  
+       case FLASH_29LV320B:            //joelin for MXIC FLASH_29LV320AB
        case FLASH_29LV320AB:           //joelin for MXIC FLASH_29LV320AB
                fmt = "29LV320AB (32 Mbit, boot sector SA0~SA7 size 8K bytes,other sectors SA8~SA70 size 64K bytes)\n";
                break;  
@@ -437,24 +458,28 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
         * This works for any bus width and any FLASH device width.
         */
  
-//     printf("\n type is %08lx", addr[1] & 0xff);     //joelin 10/06/2004 flash type
-//     printf("\n type is %08lx", addr[0] & 0xff);     //joelin 10/06/2004 flash type
+       printf("\n type is %08lx", addr[1] & 0xff);     //joelin 10/06/2004 flash type
+       printf("\n type is %08lx", addr[0] & 0xff);     //joelin 10/06/2004 flash type
 //             asm("SYNC");     
        switch (addr[1] & 0xff) {
        case (uchar)AMD_MANUFACT:
+               printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
                info->flash_id = FLASH_MAN_AMD;
                break;
 
        case (uchar)INTEL_MANUFACT:                     // 0x0089
+               printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
                info->flash_id = FLASH_MAN_INTEL; //0x00300000
                break;
                
 //joelin for MXIC              
        case (uchar)MX_MANUFACT:                // 0x00c2
+               printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
                info->flash_id = FLASH_MAN_MX ;//0x00030000
                break;
                
        default:
+               printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
                info->flash_id = FLASH_UNKNOWN;
                info->sector_count = 0;
                info->size = 0;
@@ -464,8 +489,15 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
                break;*/
        }
 
+       printf("%s:%s[%d] %08lx\n", __FILE__, __func__, __LINE__, addr[0]);
        /* Check 16 bits or 32 bits of ID so work on 32 or 16 bit bus. */
        if (info->flash_id != FLASH_UNKNOWN) switch (addr[0]) {
+       case (FPW)EON_ID_EN29LV320B:
+               printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+               info->flash_id += FLASH_29LV320B;
+               info->sector_count = 71;
+               info->size = 0x00400000 * (sizeof(FPW)/2);
+               break;
        case (FPW)AMD_ID_LV640U:        /* 29LV640 and 29LV641 have same ID */
                info->flash_id += FLASH_AM640U;
                info->sector_count = 128;
@@ -606,6 +638,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
        case FLASH_28F320J3A:
        case FLASH_AM640U:
        case FLASH_29LV640BB:   //liupeng for MXIC MX29LV640BB
+       case FLASH_29LV320B:
        case FLASH_29LV320AB:   //joelin for MXIC MX29LV320AB
        case FLASH_29LV160BB:   //joelin for MXIC MX29LV160BB
                break;