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;}