]> git.karo-electronics.de Git - karo-tx-redboot.git/blobdiff - packages/devs/flash/arm/mxc/v2_0/src/mxc_mmc.c
TX51 pre-release
[karo-tx-redboot.git] / packages / devs / flash / arm / mxc / v2_0 / src / mxc_mmc.c
index 9ecd22ee8d1bd97d153f1c663328dce61672a150..118f6f92e37f3bf9284af458993ac329e3bdc431 100644 (file)
@@ -55,6 +55,7 @@
 //==========================================================================
 
 #include <pkgconf/hal.h>
+#include <cyg/infra/diag.h>
 #include <cyg/hal/hal_arch.h>
 #include <cyg/hal/hal_cache.h>
 #ifdef CYGPKG_REDBOOT_HAL_OPTIONS
@@ -80,36 +81,36 @@ int flash_hwr_init(void)
 int mmcflash_hwr_init(void)
 #endif
 {
-    cyg_uint32 status = FAIL;
-    cyg_uint32 capacity = 0;
-    int i = 5;
-    while (status != SUCCESS && i--) {
-        hal_delay_us(100000);
-        status = mxcmci_init(1, ESDHC1_REG_BASE);
-    }
-
-    if (FAIL == status) {
-        diag_printf("Error: Card initialization failed!\n");
-        return status;
-    }
-    diag_printf("Card initialization successful!\n");
-    //set flash_info structure
-    externC struct flash_info flash_info;
-    flash_dprintf(FLASH_DEBUG_MAX,"%s: status=%d\n", __FUNCTION__, status);
-    capacity = card_get_capacity_size(); // in unit of KB
-    diag_printf("Actual capacity of the card is %dKB\n", capacity);
-    //if the capacity size is larger than 2G or equals zero, force to be 2G
-    if (capacity > 0x200000 || capacity == 0) {
-        capacity = 0x200000;
-    }
-    diag_printf("Redboot uses %dKB\n", capacity);
-
-    flash_info.block_size = 0x20000; // =  128KB
-    flash_info.blocks = capacity / 128;
-    flash_info.start = (void *)MXC_MMC_BASE_DUMMY;
-    flash_info.end = (void *)(MXC_MMC_BASE_DUMMY + flash_info.block_size * flash_info.blocks);
-
-    return status;
+       cyg_uint32 status = FAIL;
+       cyg_uint32 capacity = 0;
+       int i = 5;
+       while (status != SUCCESS && i--) {
+               hal_delay_us(100000);
+               status = mxcmci_init(1, ESDHC1_REG_BASE);
+       }
+
+       if (FAIL == status) {
+               diag_printf("Error: Card initialization failed!\n");
+               return status;
+       }
+       diag_printf("Card initialization successful!\n");
+       //set flash_info structure
+       externC struct flash_info flash_info;
+       flash_dprintf(FLASH_DEBUG_MAX,"%s: status=%d\n", __FUNCTION__, status);
+       capacity = card_get_capacity_size(); // in unit of KB
+       diag_printf("Actual capacity of the card is %dKB\n", capacity);
+       //if the capacity size is larger than 2G or equals zero, force to be 2G
+       if (capacity > 0x200000 || capacity == 0) {
+               capacity = 0x200000;
+       }
+       diag_printf("Redboot uses %dKB\n", capacity);
+
+       flash_info.block_size = 0x20000; // =  128KB
+       flash_info.blocks = capacity / 128;
+       flash_info.start = (void *)MXC_MMC_BASE_DUMMY;
+       flash_info.end = (void *)(MXC_MMC_BASE_DUMMY + flash_info.block_size * flash_info.blocks);
+
+       return status;
 }
 
 
@@ -132,7 +133,7 @@ void flash_query(void* data)
 void mmcflash_query(void* data)
 #endif
 {
-    return card_flash_query(data);
+       card_flash_query(data);
 }
 
 #ifndef MXCFLASH_SELECT_MULTI
@@ -141,7 +142,7 @@ int flash_hwr_map_error(int e)
 int mmcflash_hwr_map_error(int e)
 #endif
 {
-    return e;
+       return e;
 }
 
 #ifndef MXCFLASH_SELECT_MULTI
@@ -150,14 +151,14 @@ bool flash_code_overlaps(void *start, void *end)
 bool mmcflash_code_overlaps(void *start, void *end)
 #endif
 {
-    extern char _stext[], _etext[];
-
-    bool ret = ((((unsigned long)&_stext >= (unsigned long)start) &&
-                 ((unsigned long)&_stext < (unsigned long)end)) ||
-                (((unsigned long)&_etext >= (unsigned long)start) &&
-                 ((unsigned long)&_etext < (unsigned long)end)));
-    flash_dprintf(FLASH_DEBUG_MAX,"%s: flash code overlap::%d\n", __FUNCTION__, ret);
-    return ret;
+       extern char _stext[], _etext[];
+
+       bool ret = ((((unsigned long)&_stext >= (unsigned long)start) &&
+                                                       ((unsigned long)&_stext < (unsigned long)end)) ||
+                               (((unsigned long)&_etext >= (unsigned long)start) &&
+                                       ((unsigned long)&_etext < (unsigned long)end)));
+       flash_dprintf(FLASH_DEBUG_MAX,"%s: flash code overlap::%d\n", __FUNCTION__, ret);
+       return ret;
 }
 
 #ifndef MXCFLASH_SELECT_MULTI
@@ -166,8 +167,8 @@ int flash_erase_block(void* block, unsigned int size)
 int mmcflash_erase_block(void* block, unsigned int size)
 #endif
 {
-    flash_dprintf(FLASH_DEBUG_MAX,"%s:Debug:1:block=0x%X, size=%d\n", __FUNCTION__, (cyg_uint32)block, size);
-    return mmc_data_erase((cyg_uint32)block, size);
+       flash_dprintf(FLASH_DEBUG_MAX,"%s:Debug:1:block=0x%X, size=%d\n", __FUNCTION__, (cyg_uint32)block, size);
+       return mmc_data_erase((cyg_uint32)block, size);
 }
 
 #ifndef MXCFLASH_SELECT_MULTI