aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mx5/clock-mx51.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-mx5/clock-mx51.c')
-rw-r--r--arch/arm/mach-mx5/clock-mx51.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index f2aae92cf0e..8ac36d88292 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -362,7 +362,7 @@ static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
362 return 0; 362 return 0;
363} 363}
364 364
365static unsigned long clk_arm_get_rate(struct clk *clk) 365static unsigned long clk_cpu_get_rate(struct clk *clk)
366{ 366{
367 u32 cacrr, div; 367 u32 cacrr, div;
368 unsigned long parent_rate; 368 unsigned long parent_rate;
@@ -374,6 +374,22 @@ static unsigned long clk_arm_get_rate(struct clk *clk)
374 return parent_rate / div; 374 return parent_rate / div;
375} 375}
376 376
377static int clk_cpu_set_rate(struct clk *clk, unsigned long rate)
378{
379 u32 reg, cpu_podf;
380 unsigned long parent_rate;
381
382 parent_rate = clk_get_rate(clk->parent);
383 cpu_podf = parent_rate / rate - 1;
384 /* use post divider to change freq */
385 reg = __raw_readl(MXC_CCM_CACRR);
386 reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK;
387 reg |= cpu_podf << MXC_CCM_CACRR_ARM_PODF_OFFSET;
388 __raw_writel(reg, MXC_CCM_CACRR);
389
390 return 0;
391}
392
377static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent) 393static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
378{ 394{
379 u32 reg, mux; 395 u32 reg, mux;
@@ -736,7 +752,8 @@ static struct clk periph_apm_clk = {
736 752
737static struct clk cpu_clk = { 753static struct clk cpu_clk = {
738 .parent = &pll1_sw_clk, 754 .parent = &pll1_sw_clk,
739 .get_rate = clk_arm_get_rate, 755 .get_rate = clk_cpu_get_rate,
756 .set_rate = clk_cpu_set_rate,
740}; 757};
741 758
742static struct clk ahb_clk = { 759static struct clk ahb_clk = {
@@ -1064,6 +1081,7 @@ static struct clk_lookup lookups[] = {
1064 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) 1081 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk)
1065 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) 1082 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
1066 _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) 1083 _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk)
1084 _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk)
1067}; 1085};
1068 1086
1069static void clk_tree_init(void) 1087static void clk_tree_init(void)