//==========================================================================
#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
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;
}
void mmcflash_query(void* data)
#endif
{
- return card_flash_query(data);
+ card_flash_query(data);
}
#ifndef MXCFLASH_SELECT_MULTI
int mmcflash_hwr_map_error(int e)
#endif
{
- return e;
+ return e;
}
#ifndef MXCFLASH_SELECT_MULTI
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
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