s5pv210 uboot-2012-10移植(四) 之使系统工作在1000Mhz

s5pv210 uboot-2012-10移植(四) 之使系统工作在1000Mhz 

 

在uboot原来的代码里,有系统时钟的初始化函数,在board/samsung/smdkv210/lowlevel_init.S的system_clock_init函数,我大概看了一下,寄存器不一样,而且是汇编写的,所以我就改成用c语言来实现,在BL1阶段初始化一下,BL2阶段就不用重新初始化了。

 

1.arch/arm/lib/spl.c +43添加

 

//SystemClock
#define APLL_LOCK     (*(volatile unsigned int *)0xE0100000)
#define MPLL_LOCK     (*(volatile unsigned int *)0xE0100008)
#define EPLL_LOCK     (*(volatile unsigned int *)0xE0100010)
#define VPLL_LOCK     (*(volatile unsigned int *)0xE0100020)
#define APLL_CON0     (*(volatile unsigned int *)0xE0100100)
#define APLL_CON1     (*(volatile unsigned int *)0xE0100104)
#define MPLL_CON      (*(volatile unsigned int *)0xE0100108)
#define EPLL_CON0     (*(volatile unsigned int *)0xE0100110)
#define EPLL_CON1     (*(volatile unsigned int *)0xE0100114)
#define VPLL_CON      (*(volatile unsigned int *)0xE0100120)
#define CLK_SRC0      (*(volatile unsigned int *)0xE0100200)
#define CLK_DIV0      (*(volatile unsigned int *)0xE0100300)
#define SETPLL(mdiv, pdiv, sdiv) ((1<<31)|(mdiv<<16)|(pdiv<<8)|(sdiv<<0))
#define APLL_MDIV   250
#define APLL_PDIV   6
#define APLL_SDIV   1
#define APLL_CON0_VAL SETPLL (APLL_MDIV, APLL_PDIV, APLL_SDIV)
#define MPLL_MDIV   667
#define MPLL_PDIV   12
#define MPLL_SDIV   1
#define MPLL_CON_VAL SETPLL (MPLL_MDIV, MPLL_PDIV, MPLL_SDIV)
#define PCLK_PSYS_RATIO   1
#define HCLK_PSYS_RATIO   4
#define PCLK_DSYS_RATIO   1
#define HCLK_DSYS_RATIO   3
#define PCLK_MSYS_RATIO   1
#define HCLK_MSYS_RATIO   4
#define A2M_RATIO         4
#define APLL_RATIO        0
#define CLK_DIV0_VAL ( (APLL_RATIO<<0)|\
(A2M_RATIO<<4)|\
(HCLK_MSYS_RATIO<<8)|\
(PCLK_MSYS_RATIO<<12)|\
(HCLK_DSYS_RATIO<<16)|\
(PCLK_DSYS_RATIO<<20)|\
(HCLK_PSYS_RATIO<<24)|\
(PCLK_PSYS_RATIO<<28) )

 

2. arch/arm/lib/spl.c +135添加 

 

void init_SystemClock (void)
{
int i;
//CLK_DIV0 = 0;
APLL_CON0 = APLL_CON0_VAL;
MPLL_CON  = MPLL_CON_VAL;
CLK_SRC0 = 0x1111;
CLK_DIV0 = CLK_DIV0_VAL;
//for (i=65535; i>=0; i--);
}

 

3. include/configs/smdkv210.h +178 

 

/*#define CONFIG_SYS_PROMPT     "SMDKC100 # "*/
#define CONFIG_SYS_PROMPT       "SMDKV210 # "

 

4. include/configs/smdkv210.h +206

 

/*#define CONFIG_IDENT_STRING       " for SMDKC100"*/
#define CONFIG_IDENT_STRING     " for SMDKV210"

 

5. arch/arm/lib/spl.c +183

 

void __weak board_init_f(ulong dummy)
{
__attribute__((noreturn)) void (*uboot)(void);
#if 0
/* Set the stack pointer. */
asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
/* Clear the BSS. */
memset(__bss_start, 0, __bss_end__ - __bss_start);
/* Set global data pointer. */
gd = &gdata;
board_init_r(NULL, 0);
#endif
/*
// test
#define GPH0CON (*(volatile unsigned int *)0xE0200C00)
#define GPH0DAT (*(volatile unsigned int *)0xE0200C04)
GPH0CON = (1<<0) | (1<<4) | (1<<8) | (1<<12);
GPH0DAT = 10;
*/
init_SystemClock();
uart_init();
copy_uboot_to_ram();
//printf ("jump to u-boot image\r\n");
/* Jump to U-Boot image */
uboot = (void *)CONFIG_SYS_TEXT_BASE;
(*uboot)();
}

 

6. 好了,make一下,使用命令烧写spl/smdkv210-spl.bin和u-boot.bin到SD卡里,启动,就会看到下面这个画面了。  


 

你可能感兴趣的:(C语言,寄存器,Samsung,而且)