u-boot整个过程时钟部分解析
2013-03-18 17:05
351 查看
可能不同2440平台时钟频率有所不同,设置方式却是类似的,以下是我的u-boot时钟设置部分整个过程解析:
这是第一处时钟设置代码:
/* Initialize System Clock, FCLK:HCLK:PCLK = 1:2:4,default FCLK is 120MHz */ ldr r0, =S3C24X0_CLOCK_POWER_BASE mov r1, #3 str r1, [r0, #CLKDIVN_OFFSET]
MPLLCON_OFFSET = 0x14
可见0x4C000014:CLKDIVN被设置为0x03,它的意思是
HDIVN [1] 0: HCLK has the clock same as the FCLK. 1: HCLK has the clock same as the FCLK/2. PDIVN [0] 0: PCLK has the clock same as the HCLK. 1: PCLK has the clock same as the HCLK/2.
即FCLK:HCLK:PCLK = 1:2:4
第二处时钟设置代码:
mov r2, #MDIV_405 add r2, r2, #PSDIV_405 str r2, [r0,#MPLLCON_OFFSET]
其中
#define MDIV_405 0x7f << 12 #define PSDIV_405 0x21 MPLLCON_OFFSET = 0x04
可见0x4c000004:MPLLCON被设置为0x007f021,它的意思是:
PLLCON Bit Description Initial State MDIV [19:12] Main divider control 0x5C / 0x28 PDIV [9:4] Pre-divider control 0x08 / 0x08 SDIV [1:0] Post divider control 0x0 / 0x0
即:SDIV = 0x1, PDIV = 0x2, MDIV = 0x7f
Input Frequency Output Frequency MDIV PDIV SDIVN
12.0000MHz 405.00 MHz 127(0x7f) 2 1
由此可以算出FCLK = 405MHz, HCLK = 202.5MHz, PCLK = 101.25MHz
下面有个注意事项很有必要认真记住:
NOTES:
1. Although the MPLL starts just after a reset, the MPLL output (Mpll) is not used as the system clock until the software
writes valid settings to the MPLLCON register. Before this valid setting, the clock from external crystal or EXTCLKsource
will be used as the system clock directly. Even if the user does not want to change the default value of MPLLCON
register, the user should write the same value into MPLLCON register.
第三处时钟设置代码:
第三处是在C函数armboot_start里调用int board_init (void)初始化化的,来看代码:
int board_init (void) { struct s3c24x0_clock_power * const clk_power = s3c24x0_get_base_clock_power(); struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio(); /* to reduce PLL lock time, adjust the LOCKTIME register */ clk_power->LOCKTIME = 0xFFFFFF; /* configure MPLL */ clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV); /* some delay between MPLL and UPLL */ delay (4000); /* configure UPLL */ clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV); /* some delay between MPLL and UPLL */ delay (8000);
这里clk_power = (s3c24x0_clock_power *)0x4c000000,也就是所有有关时钟寄存器的结构,
clk_power->LOCKTIME = 0xFFFFFF;
上面这句简单的说就是在设置MPLL时,FCLK真正稳定要的一个间隔,这样吧这样我直接上图:
所以delay(4000)应该没有必要加影响性能
/* configure MPLL */ clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
其中
#define M_MDIV 0x7f #define M_PDIV 0x2 #define M_SDIV 0x1
上面的结果和第二次设置相同,应该也没有必要。
/* configure UPLL */ clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
其中
#if defined(CONFIG_S3C2440) #define U_M_MDIV 0x38 #define U_M_PDIV 0x2 #endif
#define U_M_SDIV 0x2
对照下面这个可以知道UPLL被设置成了48M,这应该是USB的漂亮
Input Frequency Output Frequency MDIV PDIV SDIV 12.0000MHz 48.00 MHz (Note) 56(0x38) 2 2 12.0000MHz 96.00 MHz (Note) 56(0x38) 2 1
NOTE: The 48.00MHz and 96MHz output is used for UPLLCON register.
好了u-boot设置时钟的全过程就这些,个人觉得这些设置的地方有些冗余部分:-)
还可以看看这个
http://wenku.baidu.com/view/6d765ec42cc58bd63186bd24.html###
http://hi.baidu.com/kkernel/item/9b5d64c1378fbf42a9ba9497
相关文章推荐
- 详细解析浏览器加载网页的整个过程
- (基于Java)编写编译器和解释器-第11章:解析程序、过程和函数-第二部分
- (基于Java)编写编译器和解释器-第11章:解析程序、过程和函数-第一部分
- spring mvc框架整个执行过程,从输入http url,到action映射,再到action处理,返回jsp文件,解析jsp文件,然后渲染, 到返回给浏览器展示结果
- sphinx索引部分源码续——过程:连接到CSphSource对应的sql数据源,通过fetch row取其中一行,然后解析出field,分词,获得wordhit,最后再加入到CSphSource的Hits里
- Linux中关于 -- Bootloader , Uboot的作用,和整个linux系统的启动过程分析
- S5PV210之UBOOT-2011.06启动过程解析-基于u-boot for tiny210 ver3.1 (by liukun321咕唧咕唧)
- Linux 系统启动过程(initrd部分) --- Linux boot process (initrd part)
- 【转】解析u-boot基于I.MX51_BBG的编译过程(一)
- 一条UPDATE从生到死的整个过程的深入解析
- 一条UPDATE从生到死的整个过程的深入解析
- U-Boot 编译过程解析
- (五) u-boot 命令执行过程解析与添加自定义命令
- u-boot烧写Linux及系统整个启动过程
- 一条UPDATE从生到死的整个过程的深入解析
- 关于在u-boot汇编中设置与初始化时钟频率的解析
- Oracle SQL 的硬解析和软解析 以及 SQL的整个在Oracle中的执行过程。
- Linux 系统启动过程(initrd部分) --- Linux boot process (initrd part)
- S5PV210 -- UBOOT启动过程解析(TINY210)
- STM32因为BOOT和时钟造成的异常的调试过程