diff options
Diffstat (limited to 'c/src/lib/libbsp/arm/lpc24xx/startup')
-rw-r--r-- | c/src/lib/libbsp/arm/lpc24xx/startup/bspstart.c | 30 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c | 76 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/lpc24xx/startup/linkcmds.lpc2362 | 12 |
3 files changed, 101 insertions, 17 deletions
diff --git a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstart.c b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstart.c index 76e1aa79aa..097b66c513 100644 --- a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstart.c +++ b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstart.c @@ -30,6 +30,36 @@ #include <bsp/stackalloc.h> #include <bsp/system-clocks.h> +#ifdef LPC24XX_HEAP_EXTEND + LINKER_SYMBOL(lpc24xx_region_heap_0_begin); + LINKER_SYMBOL(lpc24xx_region_heap_0_size); + LINKER_SYMBOL(lpc24xx_region_heap_0_end); + + LINKER_SYMBOL(lpc24xx_region_heap_1_begin); + LINKER_SYMBOL(lpc24xx_region_heap_1_size); + LINKER_SYMBOL(lpc24xx_region_heap_1_end); + + extern Heap_Control *RTEMS_Malloc_Heap; +#endif + +void bsp_pretasking_hook(void) +{ + #ifdef LPC24XX_HEAP_EXTEND + _Heap_Extend( + RTEMS_Malloc_Heap, + lpc24xx_region_heap_0_begin, + (uintptr_t) lpc24xx_region_heap_0_size, + NULL + ); + _Heap_Extend( + RTEMS_Malloc_Heap, + lpc24xx_region_heap_1_begin, + (uintptr_t) lpc24xx_region_heap_1_size, + NULL + ); + #endif +} + void bsp_start(void) { /* Initialize Timer 1 */ diff --git a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c index 732d30ddf5..9d56df2c7a 100644 --- a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c +++ b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c @@ -28,6 +28,10 @@ #define BSP_START_SECTION __attribute__((section(".bsp_start"))) +#if defined(LPC24XX_EMC_MICRON) || defined(LPC24XX_EMC_NUMONYX) + #define LPC24XX_EMC_INIT +#endif + #ifdef LPC24XX_EMC_MICRON static void BSP_START_SECTION lpc24xx_ram_test_32(void) { @@ -114,15 +118,17 @@ static void BSP_START_SECTION lpc24xx_init_emc_0(void) numonyx.waitrun = 0xf; #endif - /* Set pin functions for EMC */ - PINSEL5 = (PINSEL5 & 0xf000f000) | 0x05550555; - PINSEL6 = 0x55555555; - PINSEL8 = 0x55555555; - PINSEL9 = (PINSEL9 & 0x0f000000) | 0x50555555; + #ifdef LPC24XX_EMC_INIT + /* Set pin functions for EMC */ + PINSEL5 = (PINSEL5 & 0xf000f000) | 0x05550555; + PINSEL6 = 0x55555555; + PINSEL8 = 0x55555555; + PINSEL9 = (PINSEL9 & 0x0f000000) | 0x50555555; + #endif #ifdef LPC24XX_EMC_NUMONYX /* Static Memory 1 settings */ - bsp_start_memcpy_arm( + bsp_start_memcpy( (int *) EMC_STA_BASE_1, (const int *) &numonyx, sizeof(numonyx) @@ -135,8 +141,10 @@ static void BSP_START_SECTION lpc24xx_init_emc_0(void) */ static void BSP_START_SECTION lpc24xx_init_emc_1(void) { - /* Use normal memory map */ - EMC_CTRL = CLEAR_FLAG(EMC_CTRL, 0x2); + #ifdef LPC24XX_EMC_INIT + /* Use normal memory map */ + EMC_CTRL = CLEAR_FLAG(EMC_CTRL, 0x2); + #endif #ifdef LPC24XX_EMC_MICRON /* Check if we need to initialize it */ @@ -326,7 +334,13 @@ static void BSP_START_SECTION lpc24xx_init_pll(void) } /* Set PLL */ - lpc24xx_set_pll(1, 0, 11, 3); + #if LPC24XX_OSCILLATOR_MAIN == 12000000U + lpc24xx_set_pll(1, 0, 11, 3); + #elif LPC24XX_OSCILLATOR_MAIN == 3686400U + lpc24xx_set_pll(1, 0, 47, 5); + #else + #error "unexpected main oscillator frequency" + #endif } static void BSP_START_SECTION lpc24xx_clear_bss(void) @@ -355,9 +369,18 @@ void BSP_START_SECTION bsp_start_hook_1(void) /* Re-map interrupt vectors to internal RAM */ MEMMAP = SET_MEMMAP_MAP(MEMMAP, 2); - /* Set memory accelerator module (MAM) */ + /* Fully enable memory accelerator module functions (MAM) */ MAMCR = 0; - MAMTIM = 4; + #if LPC24XX_CCLK <= 20000000U + MAMTIM = 0x1; + #elif LPC24XX_CCLK <= 40000000U + MAMTIM = 0x2; + #elif LPC24XX_CCLK <= 60000000U + MAMTIM = 0x3; + #else + MAMTIM = 0x4; + #endif + MAMCR = 0x2; /* Enable fast IO for ports 0 and 1 */ SCS = SET_FLAG(SCS, 0x1); @@ -377,29 +400,52 @@ void BSP_START_SECTION bsp_start_hook_1(void) /* Initialize EMC hook 1 */ lpc24xx_init_emc_1(); + #ifdef LPC24XX_STOP_GPDMA + if ((PCONP & PCONP_GPDMA) != 0) { + GPDMA_CONFIG = 0; + PCONP &= ~PCONP_GPDMA; + } + #endif + + #ifdef LPC24XX_STOP_ETHERNET + if ((PCONP & PCONP_ETHERNET) != 0) { + MAC_COMMAND = 0x38; + MAC_MAC1 = 0xcf00; + MAC_MAC1 = 0; + PCONP &= ~PCONP_ETHERNET; + } + #endif + + #ifdef LPC24XX_STOP_USB + if ((PCONP & PCONP_USB) != 0) { + OTG_CLK_CTRL = 0; + PCONP &= ~PCONP_USB; + } + #endif + /* Copy .text section */ - bsp_start_memcpy_arm( + bsp_start_memcpy( (int *) bsp_section_text_begin, (const int *) bsp_section_text_load_begin, (size_t) bsp_section_text_size ); /* Copy .rodata section */ - bsp_start_memcpy_arm( + bsp_start_memcpy( (int *) bsp_section_rodata_begin, (const int *) bsp_section_rodata_load_begin, (size_t) bsp_section_rodata_size ); /* Copy .data section */ - bsp_start_memcpy_arm( + bsp_start_memcpy( (int *) bsp_section_data_begin, (const int *) bsp_section_data_load_begin, (size_t) bsp_section_data_size ); /* Copy .fast section */ - bsp_start_memcpy_arm( + bsp_start_memcpy( (int *) bsp_section_fast_begin, (const int *) bsp_section_fast_load_begin, (size_t) bsp_section_fast_size diff --git a/c/src/lib/libbsp/arm/lpc24xx/startup/linkcmds.lpc2362 b/c/src/lib/libbsp/arm/lpc24xx/startup/linkcmds.lpc2362 index 76e2358f2f..3446994f8b 100644 --- a/c/src/lib/libbsp/arm/lpc24xx/startup/linkcmds.lpc2362 +++ b/c/src/lib/libbsp/arm/lpc24xx/startup/linkcmds.lpc2362 @@ -48,12 +48,20 @@ REGION_ALIAS ("REGION_TEXT", ROM_INT); REGION_ALIAS ("REGION_TEXT_LOAD", ROM_INT); REGION_ALIAS ("REGION_RODATA", ROM_INT); REGION_ALIAS ("REGION_RODATA_LOAD", ROM_INT); -REGION_ALIAS ("REGION_DATA", RAM_ETH); +REGION_ALIAS ("REGION_DATA", RAM_INT); REGION_ALIAS ("REGION_DATA_LOAD", ROM_INT); REGION_ALIAS ("REGION_FAST", RAM_INT); REGION_ALIAS ("REGION_FAST_LOAD", ROM_INT); -REGION_ALIAS ("REGION_BSS", RAM_ETH); +REGION_ALIAS ("REGION_BSS", RAM_INT); REGION_ALIAS ("REGION_WORK", RAM_INT); REGION_ALIAS ("REGION_STACK", RAM_INT); +lpc24xx_region_heap_0_begin = ORIGIN (RAM_ETH); +lpc24xx_region_heap_0_size = LENGTH (RAM_ETH); +lpc24xx_region_heap_0_end = lpc24xx_region_heap_0_begin + lpc24xx_region_heap_0_size; + +lpc24xx_region_heap_1_begin = ORIGIN (RAM_USB); +lpc24xx_region_heap_1_size = LENGTH (RAM_USB); +lpc24xx_region_heap_1_end = lpc24xx_region_heap_1_begin + lpc24xx_region_heap_1_size; + INCLUDE linkcmds.base |