下面直接从总线时钟初始化函数开始分析:
void __init s3c244x_init_clocks(int xtal) { /* initialise the clocks here, to allow other things like the * console to use them, and to add new ones after the initialisation */ s3c24xx_register_baseclocks(xtal); s3c244x_setup_clocks(); s3c2410_baseclk_add(); }s3c24xx_init_clocks主要实现两个功能:
1.初始化s3c2440的总线时钟。通过s3c24xx_register_baseclocks(xtal)和s3c244x_setup_clocks实现
2.想系统注册外设时钟。通过s3c2410_baseclk_add()实现
首先分析初始化系统时钟
int __init s3c24xx_register_baseclocks(unsigned long xtal) { printk(KERN_INFO "S3C24XX Clocks, Copyright 2004 Simtec Electronics\n"); clk_xtal.rate = xtal; /* register our clocks */ if (s3c24xx_register_clock(&clk_xtal) < 0) printk(KERN_ERR "failed to register master xtal\n"); if (s3c24xx_register_clock(&clk_mpll) < 0) printk(KERN_ERR "failed to register mpll clock\n"); if (s3c24xx_register_clock(&clk_upll) < 0) printk(KERN_ERR "failed to register upll clock\n"); if (s3c24xx_register_clock(&clk_f) < 0) printk(KERN_ERR "failed to register cpu fclk\n"); if (s3c24xx_register_clock(&clk_h) < 0) printk(KERN_ERR "failed to register cpu hclk\n"); if (s3c24xx_register_clock(&clk_p) < 0) printk(KERN_ERR "failed to register cpu pclk\n"); return 0; }
依次向注册clk_xtal、clk_mpll、clk_upll... ...clk_p等时钟,clk_p等的定义如下:
struct clk clk_p = { .name = "pclk", .id = -1, .rate = 0, .parent = NULL, .ctrlbit = 0, .ops = &clk_ops_def_setrate, };
注册成功后然后通过s3c244x_setup_clocks->s3c24xx_setup_clocks(fclk, hclk, pclk)来初始化前面注册的各个时钟。