ARM-linux s3c2440 之时钟分析

来源:互联网 发布:淘宝psp3000 编辑:程序博客网 时间:2024/05/22 02:21

S3c2440 时钟 & 电源管理时钟由三部分组成:  Clock control ,USB control, 和 Power control 

Clock control 部分可以产生时钟FCLK,提供ARM内核,HCLK 提供 AHB 总线外设,还有 PLCK APB 总线外设。 s3c2440 有两个内置的PLLS 锁相环,一个提供给 FCLK,HCLK,和PCLK,另一个提供给USB时钟(48MHZ)。Clock control 可以不使用PLL,而降低的时钟,通过软件设置,时能各中种外设,从而可以降低功耗。

Power control部分,用于电能管理,有四种工作模式:Normal mode, Slow mode, Idle mode, Sleep mode.

linux 中 s3c2440 时钟的初始化:

MACHINE_START(S3C2440, "SMDK2440")/* Maintainer: Ben Dooks <ben@fluff.org> */.phys_io = S3C2410_PA_UART,.io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,.boot_params = S3C2410_SDRAM_PA + 0x100,.init_irq = s3c24xx_init_irq,.map_io = smdk2440_map_io,.init_machine = smdk2440_machine_init,.timer = &s3c24xx_timer,MACHINE_END

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

 smdk_2440_map_io()  --> s3c24xx_init_io() -->  s3c_init_cpu() -> s3c244x_init_clocks()

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);       //向系统注册基本时钟: FCLK,HCLK, PCLKs3c244x_setup_clocks();                       //设置基本时钟的参数s3c2410_baseclk_add();                      //添加其他外设的时钟}

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

struct clk {struct list_head      list;struct module        *owner;struct clk           *parent;const char           *name;int      id;int      usage;unsigned long         rate;unsigned long         ctrlbit;int    (*enable)(struct clk *, int enable);int    (*set_rate)(struct clk *c, unsigned long rate);unsigned long    (*get_rate)(struct clk *c);unsigned long    (*round_rate)(struct clk *c, unsigned long rate);int    (*set_parent)(struct clk *c, struct clk *parent);};

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

struct clk init_clocks[];   struct clk init_clocks_disable[];

最后一一注册

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

/* initialise the clock system */int s3c24xx_register_clock(struct clk *clk){if (clk->enable == NULL)clk->enable = clk_null_enable;/* add to the list of available clocks *//* Quick check to see if this clock has already been registered. */BUG_ON(clk->list.prev != clk->list.next);spin_lock(&clocks_lock);list_add(&clk->list, &clocks);spin_unlock(&clocks_lock);return 0;}

原创粉丝点击