#include <config.h> //这几个头文件在mkconfig中创建软连接。
#include <version.h>
#include <regs.h>
_TEXT_BASE:
.word TEXT_BASE //在链接脚本中定义
.globl lowlevel_init
lowlevel_init:
mov r1, #0
str r1, [r0]
/* Disable main and sub interrupts */
ldr r0, =ELFIN_INTERRUPT_BASE
mvn r1, #0x0
str r1, [r0, #INTMSK_OFFSET]
str r1, [r0, #INTSUBMSK_OFFSET]
/* Set all interrupts as IRQ */
mov r1, #0x0
str r1, [r0, #INTMOD_OFFSET]
/* init system clock */
bl system_clock_init
/* for UART */
bl uart_asm_init
/* simple init for NAND */
/*
* system_clock_init: Initialize core clock and bus clock.
* void system_clock_init(void)
*/
system_clock_init:
ldr r0, =ELFIN_CLOCK_POWER_BASE
ldr r1, [r0, #CLKDIV0CON_OFFSET]
bic r1, r1, #0x37 /* clear HCLKDIV, PREDIV, PCLKDIV */
bic r1, r1, #(0xf<<9) /* clear ARMCLKDIV */
ldr r2, =CLK_DIV_VAL
orr r1, r1, r2
str r1, [r0, #CLKDIV0CON_OFFSET]
/*Set MPLL Locktime*/
ldr r1, =0xe10
str r1, [r0, #LOCKCON0_OFFSET]
ldr r1, =MPLL_VAL
str r1, [r0, #MPLLCON_OFFSET]
#if 1
ldr r1, =0x1780
str r1, [r0, #LOCKCON1_OFFSET]
ldr r1, =EPLL_VAL /*Set EPLL*/
str r1, [r0, #EPLLCON_OFFSET]
ldr r1, [r0, #CLKSRCCON_OFFSET]
orr r1, r1, #0x40
str r1, [r0, #CLKSRCCON_OFFSET]
#endif
/* set CLKSRC to fit MPLL and USB */
ldr r1, [r0, #CLKSRCCON_OFFSET]
orr r1, r1, #0x10
str r1, [r0, #CLKSRCCON_OFFSET]
#if 0
/* wait at least 200us to stablize all clock */
mov r2, #0x10000
1: subs r1, r1, #1
bne 1b
#endif
mrc p15, 0, r0, c1, c0, 0
orr r0, r0, #0xc0000000 /* clock setting in MMU */
mcr p15, 0, r0, c1, c0, 0
mov pc, lr
/*
* uart_asm_init: Initialize UART in asm mode, 115200bps fixed.
* void uart_asm_init(void)
*/
uart_asm_init:
/* set GPIO to enable UART */
ldr r0, =ELFIN_GPIO_BASE
ldr r1, =0x0000aaaa
str r1, [r0, #GPHCON_OFFSET] @GPIO
ldr r0, =ELFIN_UART_BASE
mov r1, #0x0
str r1, [r0, #UFCON_OFFSET]
str r1, [r0, #UMCON_OFFSET]
mov r1, #0x3 @was 0.
str r1, [r0, #ULCON_OFFSET]
ldr r1, =0x245
str r1, [r0, #UCON_OFFSET]
ldr r1, =0x3
ldr r1, =0x23 /* PCLK Is Fixed to 66Mhz */
str r1, [r0, #UBRDIV_OFFSET]
ldr r1, =0x0888
str r1, [r0, #UDIVSLOT_OFFSET]
ldr r1, =0x4f4f4f4f
str r1, [r0, #UTXH_OFFSET]
mov pc, lr
/*
* Nand Interface Init for smdk2416
*/
nand_asm_init:
ldr r0, =ELFIN_GPIO_BASE
ldr r1, [r0]
orr r1, r1, #(0x3f<<17)
str r1, [r0]
/* EVT1 has modification in NAND */
#if 1
ldr r1, =0x1aa8a
str r1, [r0, #GPADAT_OFFSET]
#endif
ldr r0, =ELFIN_NAND_BASE
ldr r1, [r0, #NFCONF_OFFSET]
orr r1, r1, #0x70
orr r1, r1, #0x7700
str r1, [r0, #NFCONF_OFFSET]
ldr r1, [r0, #NFCONT_OFFSET]
orr r1, r1, #0x03
str r1, [r0, #NFCONT_OFFSET]
mov pc, lr
.ltorg
/*
* struct sdram_val {
* ulong bankcfg_val; r5, val of bankcfg
* ulong bankcon1_val; r6, val of bankcon1
* ulong bankcon2_val; r7, val of bankcon2
* ulong bankcon3_val; r8, val of bankcon3
* ulong refresh_val; r9, val of refresh
* }
*/
sdram_bank_set_val:
.word CFG_BANK_CFG_VAL
.word CFG_BANK_CON1_VAL
.word CFG_BANK_CON2_VAL
.word CFG_BANK_CON3_VAL
.word CFG_BANK_REFRESH_VAL
sdram_bank_sel_val_alt:
.word CFG_BANK_CFG_VAL_ALT
.word CFG_BANK_CON1_VAL_ALT
#ifdef CONFIG_ENABLE_MMU
/*
* MMU Table for SMDK2416,采用GNU语法
*/
/* form a first-level section entry */
.macro FL_SECTION_ENTRY base,ap,d,c,b
.word (\base << 20) | (\ap << 10) | \
(\d << 5) | (1<<4) | (\c << 3) | (\b << 2) | (1<<1)
.align 14
/* the following alignment creates the mmu table at address 0x4000. */
.globl mmu_table
mmu_table:
.set __base,0 //__base = 0
/* 1:1 mapping for debugging */
.rept 0x600 //循环 次数
FL_SECTION_ENTRY __base,3,0,0,0
.set __base,__base+1
.endr
.word 0x00000000
.endr
/* 64MB for SDRAM 0xC0000000 -> 0x30000000 */
.set __base, 0x300
.rept 0xC40 - 0xC00
FL_SECTION_ENTRY __base,3,0,1,1
.set __base,__base+1
.endr
/* access is not allowed. */
.rept 0x1000 - 0xc40
.word 0x00000000
.endr
#endif
#include <version.h>
#include <regs.h>
_TEXT_BASE:
.word TEXT_BASE //在链接脚本中定义
.globl lowlevel_init
lowlevel_init:
mov r12, lr
/* Disable Watchdog */
ldr r0, =ELFIN_WATCHDOG_BASEmov r1, #0
str r1, [r0]
/* Disable main and sub interrupts */
ldr r0, =ELFIN_INTERRUPT_BASE
mvn r1, #0x0
str r1, [r0, #INTMSK_OFFSET]
str r1, [r0, #INTSUBMSK_OFFSET]
/* Set all interrupts as IRQ */
mov r1, #0x0
str r1, [r0, #INTMOD_OFFSET]
/* init system clock */
bl system_clock_init
/* for UART */
bl uart_asm_init
/* simple init for NAND */
bl nand_asm_init
mov lr, r12
mov pc, lr/*
* system_clock_init: Initialize core clock and bus clock.
* void system_clock_init(void)
*/
system_clock_init:
ldr r0, =ELFIN_CLOCK_POWER_BASE
ldr r1, [r0, #CLKDIV0CON_OFFSET]
bic r1, r1, #0x37 /* clear HCLKDIV, PREDIV, PCLKDIV */
bic r1, r1, #(0xf<<9) /* clear ARMCLKDIV */
ldr r2, =CLK_DIV_VAL
orr r1, r1, r2
str r1, [r0, #CLKDIV0CON_OFFSET]
/*Set MPLL Locktime*/
ldr r1, =0xe10
str r1, [r0, #LOCKCON0_OFFSET]
ldr r1, =MPLL_VAL
str r1, [r0, #MPLLCON_OFFSET]
#if 1
ldr r1, =0x1780
str r1, [r0, #LOCKCON1_OFFSET]
ldr r1, =EPLL_VAL /*Set EPLL*/
str r1, [r0, #EPLLCON_OFFSET]
ldr r1, [r0, #CLKSRCCON_OFFSET]
orr r1, r1, #0x40
str r1, [r0, #CLKSRCCON_OFFSET]
#endif
/* set CLKSRC to fit MPLL and USB */
ldr r1, [r0, #CLKSRCCON_OFFSET]
orr r1, r1, #0x10
str r1, [r0, #CLKSRCCON_OFFSET]
#if 0
/* wait at least 200us to stablize all clock */
mov r2, #0x10000
1: subs r1, r1, #1
bne 1b
#endif
mrc p15, 0, r0, c1, c0, 0
orr r0, r0, #0xc0000000 /* clock setting in MMU */
mcr p15, 0, r0, c1, c0, 0
mov pc, lr
/*
* uart_asm_init: Initialize UART in asm mode, 115200bps fixed.
* void uart_asm_init(void)
*/
uart_asm_init:
/* set GPIO to enable UART */
ldr r0, =ELFIN_GPIO_BASE
ldr r1, =0x0000aaaa
str r1, [r0, #GPHCON_OFFSET] @GPIO
ldr r0, =ELFIN_UART_BASE
mov r1, #0x0
str r1, [r0, #UFCON_OFFSET]
str r1, [r0, #UMCON_OFFSET]
mov r1, #0x3 @was 0.
str r1, [r0, #ULCON_OFFSET]
ldr r1, =0x245
str r1, [r0, #UCON_OFFSET]
ldr r1, =0x3
ldr r1, =0x23 /* PCLK Is Fixed to 66Mhz */
str r1, [r0, #UBRDIV_OFFSET]
ldr r1, =0x0888
str r1, [r0, #UDIVSLOT_OFFSET]
ldr r1, =0x4f4f4f4f
str r1, [r0, #UTXH_OFFSET]
mov pc, lr
/*
* Nand Interface Init for smdk2416
*/
nand_asm_init:
ldr r0, =ELFIN_GPIO_BASE
ldr r1, [r0]
orr r1, r1, #(0x3f<<17)
str r1, [r0]
/* EVT1 has modification in NAND */
#if 1
ldr r1, =0x1aa8a
str r1, [r0, #GPADAT_OFFSET]
#endif
ldr r0, =ELFIN_NAND_BASE
ldr r1, [r0, #NFCONF_OFFSET]
orr r1, r1, #0x70
orr r1, r1, #0x7700
str r1, [r0, #NFCONF_OFFSET]
ldr r1, [r0, #NFCONT_OFFSET]
orr r1, r1, #0x03
str r1, [r0, #NFCONT_OFFSET]
mov pc, lr
.ltorg
/*
* struct sdram_val {
* ulong bankcfg_val; r5, val of bankcfg
* ulong bankcon1_val; r6, val of bankcon1
* ulong bankcon2_val; r7, val of bankcon2
* ulong bankcon3_val; r8, val of bankcon3
* ulong refresh_val; r9, val of refresh
* }
*/
sdram_bank_set_val:
.word CFG_BANK_CFG_VAL
.word CFG_BANK_CON1_VAL
.word CFG_BANK_CON2_VAL
.word CFG_BANK_CON3_VAL
.word CFG_BANK_REFRESH_VAL
sdram_bank_sel_val_alt:
.word CFG_BANK_CFG_VAL_ALT
.word CFG_BANK_CON1_VAL_ALT
#ifdef CONFIG_ENABLE_MMU
/*
* MMU Table for SMDK2416,采用GNU语法
*/
/* form a first-level section entry */
.macro FL_SECTION_ENTRY base,ap,d,c,b
.word (\base << 20) | (\ap << 10) | \
(\d << 5) | (1<<4) | (\c << 3) | (\b << 2) | (1<<1)
.endm
//汇编宏定义 .macro 标识符 参数 宏体 .endm
.align 14
/* the following alignment creates the mmu table at address 0x4000. */
.globl mmu_table
mmu_table:
.set __base,0 //__base = 0
/* 1:1 mapping for debugging */
.rept 0x600 //循环 次数
FL_SECTION_ENTRY __base,3,0,0,0
.set __base,__base+1
.endr
/*循环格式
*.rept xxx xxxx .endr
*/
/* access is not allowed. */
.rept0xC00 - 0x600.word 0x00000000
.endr
/* 64MB for SDRAM 0xC0000000 -> 0x30000000 */
.set __base, 0x300
.rept 0xC40 - 0xC00
FL_SECTION_ENTRY __base,3,0,1,1
.set __base,__base+1
.endr
/* access is not allowed. */
.rept 0x1000 - 0xc40
.word 0x00000000
.endr
#endif