手机版
你好,游客 登录 注册
背景:
阅读新闻

ARM Linux S3C2440 之时钟分析

[日期:2012-02-22] 来源:Linux社区  作者:yyplc [字体:大 中 小]

linux 入口时,在start_kernel()中调用 setup_arch(), 会进行平台体系相关初始化:

[cpp]
  1. smdk_2440_map_io()  --> s3c24xx_init_io() -->  s3c_init_cpu() -> s3c244x_init_clocks()  

[cpp]
  1. void __init s3c244x_init_clocks(int xtal)  
  2. {  
  3. /* initialise the clocks here, to allow other things like the 
  4. * console to use them, and to add new ones after the initialisation 
  5. */  
  6. s3c24xx_register_baseclocks(xtal);       //向系统注册基本时钟: FCLK,HCLK, PCLK   
  7. s3c244x_setup_clocks();                       //设置基本时钟的参数   
  8. s3c2410_baseclk_add();                      //添加其他外设的时钟   
  9. }  

系统将所有外设的时钟通过一个叫做struct clk的结构体来进行描述:

[cpp]
  1. struct clk {  
  2. struct list_head      list;  
  3. struct module        *owner;  
  4. struct clk           *parent;  
  5. const char           *name;  
  6. int      id;  
  7. int      usage;  
  8. unsigned long         rate;  
  9. unsigned long         ctrlbit;  
  10.   
  11. int    (*enable)(struct clk *, int enable);  
  12. int    (*set_rate)(struct clk *c, unsigned long rate);  
  13. unsigned long    (*get_rate)(struct clk *c);  
  14. unsigned long    (*round_rate)(struct clk *c, unsigned long rate);  
  15. int    (*set_parent)(struct clk *c, struct clk *parent);  
  16. };  

将所有时钟分成两类,一类是开启,一类关闭; 分别至于 两个数组中

[cpp]
  1. struct clk init_clocks[];   struct clk init_clocks_disable[];  

最后一一注册

注册时钟是通过这个函数注册的 

[cpp]
  1. /* initialise the clock system */  
  2.   
  3. int s3c24xx_register_clock(struct clk *clk)  
  4. {  
  5.     if (clk->enable == NULL)  
  6.         clk->enable = clk_null_enable;  
  7.   
  8.     /* add to the list of available clocks */  
  9.   
  10.     /* Quick check to see if this clock has already been registered. */  
  11.     BUG_ON(clk->list.prev != clk->list.next);  
  12.   
  13.     spin_lock(&clocks_lock);  
  14.     list_add(&clk->list, &clocks);  
  15.     spin_unlock(&clocks_lock);  
  16.   
  17.     return 0;  
  18. }  
linux
相关资讯       arm  S3C2440 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款