Last active
August 27, 2016 20:20
-
-
Save eggman/b2f269e8e3f6040a534ce5952b0deb01 to your computer and use it in GitHub Desktop.
startup.c for ameba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* startup.c for ameba */ | |
#include "rtl8195a.h" | |
extern u32 ConfigDebugWarn; | |
extern u32 ConfigDebugInfo; | |
extern u32 ConfigDebugErr; | |
extern void SystemCoreClockUpdate(void); | |
extern void En32KCalibration(void); | |
extern void SpicDisableRtl8195A(void); | |
extern void _AppStart(void); | |
extern void HalCpuClkConfig(u32); | |
extern void RtlConsolRom(u32); | |
extern int32_t SdrControllerInit(void); | |
extern void RtlConsolRom(u32); | |
extern const void * __bss_start__; | |
extern const void * __bss_end__; | |
extern const void * __image2_entry_func__; | |
extern const void * __image1_bss_start__; | |
extern const void * __image1_bss_end__; | |
void InfraStart(void) __attribute__((section(".infra.ram.start"))); | |
void StartupHalInitPlatformLogUart(void) __attribute__((section(".hal.ram.text"))); | |
void SYSCpuClkConfig(uint32_t) __attribute__((section(".hal.ram.text"))); | |
void PreProcessForVendor(void) __attribute__((section(".hal.ram.text"))); | |
void SYSPlatformInit(void) __attribute__((section(".text.SYSPlatformInit"))); | |
void InfraStart(void) | |
{ | |
if( ((int32_t )ConfigDebugErr << 1) < 0) | |
{ | |
DiagPrintf("\r===== Enter Image 2 ====\n"); | |
} | |
/* clear BSS */ | |
_memset( &__bss_start__, 0x0, (size_t) (&__bss_end__ - &__bss_start__)); | |
SystemCoreClockUpdate(); | |
/* REG_SYS_EFUSE_SYSCFG0 */ | |
*(uint32_t *) 0x40000020 = (*(uint32_t *) 0x40000020 & ~0xf000000) | 0x6000000; | |
/* REG_SYS_SWR_CTRL1 */ | |
*(uint32_t *) 0x4000004c = (*(uint32_t *) 0x4000004c & ~0x0000f00); | |
/* REG_SYS_XTAL_CTRL1 */ | |
*(uint32_t *) 0x40000064 = (*(uint32_t *) 0x40000064 & ~0x0000018) | 0x0000008; | |
En32KCalibration(); | |
SpicDisableRtl8195A(); | |
_AppStart(); | |
return; | |
} | |
void StartupHalInitPlatformLogUart(void) | |
{ | |
u32 clk; | |
//todo | |
clk = (HalGetCpuClk()>>2); | |
//todo | |
return; | |
} | |
void SYSCpuClkConfig(uint32_t config) | |
{ | |
//e4 | |
if( ( (int32_t) ConfigDebugInfo << 19 ) < 0) | |
{ | |
//10c | |
DiagPrintf("\r[SPIF Inf]%s(0x%x)\n", "SYSCpuClkConfig", config); | |
} | |
//f0 | |
HalCpuClkConfig(config); | |
HalDelayUs(1000); | |
StartupHalInitPlatformLogUart(); | |
SpicOneBitCalibrationRtl8195A(config); | |
return; | |
} | |
void PreProcessForVendor(void) | |
{ | |
HalPinCtrlRtl8195A(func, pinlocation, Operation); | |
HalDelayUs(2000); | |
SYSCpuClkConfig(); | |
StartupHalInitPlatformLogUart(); | |
SpicFlashInitRtl8195A(); | |
RtlConsolRom(); | |
SdrControllerInit(); | |
return; | |
} | |
void SYSPlatformInit(void) | |
{ | |
/* REG_SYS_EFUSE_SYSCFG0 */ | |
*(uint32_t *) 0x40000020 &= ~0xf000000; | |
*(uint32_t *) 0x40000020 |= 0x6000000; | |
/* REG_SYS_SWR_CTRL1 */ | |
*(uint32_t *) 0x4000004c &= ~0x0000f00; | |
/* REG_SYS_XTAL_CTRL1 */ | |
*(uint32_t *) 0x40000064 &= ~0x0000018; | |
*(uint32_t *) 0x40000064 |= 0x0000008; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment