协议[I2C]_I2C子系统之I2C总线时钟频率设置
时钟相关基本知识可先参考这篇http://www.linuxidc.com/Linux/2012-02/54968.htm下面直接从总线时钟初始化函数开始分析:void __init s3c244x_init_clocks(int xtal) { /* initialise the clocks here, to allow other things like the
·
时钟相关基本知识可先参考这篇http://www.linuxidc.com/Linux/2012-02/54968.htm
下面直接从总线时钟初始化函数开始分析:
- 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)来初始化前面注册的各个时钟。
- void __init_or_cpufreq s3c24xx_setup_clocks(unsigned long fclk,
- unsigned long hclk,
- unsigned long pclk)
- {
- clk_upll.rate = s3c24xx_get_pll(__raw_readl(S3C2410_UPLLCON),
- clk_xtal.rate);
- clk_mpll.rate = fclk;
- clk_h.rate = hclk;
- clk_p.rate = pclk;
- clk_f.rate = fclk;
- }
更多推荐
已为社区贡献1条内容
所有评论(0)