aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-omap2/clkt2xxx_apll.c4
-rw-r--r--arch/arm/mach-omap2/clkt2xxx_dpllcore.c11
-rw-r--r--arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c24
-rw-r--r--arch/arm/mach-omap2/cm2xxx.c67
-rw-r--r--arch/arm/mach-omap2/cm2xxx.h8
-rw-r--r--arch/arm/mach-omap2/pm24xx.c24
6 files changed, 89 insertions, 49 deletions
diff --git a/arch/arm/mach-omap2/clkt2xxx_apll.c b/arch/arm/mach-omap2/clkt2xxx_apll.c
index 25b1feed480d..c78e893eba7d 100644
--- a/arch/arm/mach-omap2/clkt2xxx_apll.c
+++ b/arch/arm/mach-omap2/clkt2xxx_apll.c
@@ -52,7 +52,7 @@ static bool omap2xxx_clk_apll_locked(struct clk_hw *hw)
52 52
53 apll_mask = EN_APLL_LOCKED << clk->enable_bit; 53 apll_mask = EN_APLL_LOCKED << clk->enable_bit;
54 54
55 r = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKEN); 55 r = omap2xxx_cm_get_pll_status();
56 56
57 return ((r & apll_mask) == apll_mask) ? true : false; 57 return ((r & apll_mask) == apll_mask) ? true : false;
58} 58}
@@ -126,7 +126,7 @@ u32 omap2xxx_get_apll_clkin(void)
126{ 126{
127 u32 aplls, srate = 0; 127 u32 aplls, srate = 0;
128 128
129 aplls = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL1); 129 aplls = omap2xxx_cm_get_pll_config();
130 aplls &= OMAP24XX_APLLS_CLKIN_MASK; 130 aplls &= OMAP24XX_APLLS_CLKIN_MASK;
131 aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT; 131 aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT;
132 132
diff --git a/arch/arm/mach-omap2/clkt2xxx_dpllcore.c b/arch/arm/mach-omap2/clkt2xxx_dpllcore.c
index d8620105c42a..3ff32543493c 100644
--- a/arch/arm/mach-omap2/clkt2xxx_dpllcore.c
+++ b/arch/arm/mach-omap2/clkt2xxx_dpllcore.c
@@ -60,8 +60,7 @@ unsigned long omap2xxx_clk_get_core_rate(void)
60 60
61 core_clk = omap2_get_dpll_rate(dpll_core_ck); 61 core_clk = omap2_get_dpll_rate(dpll_core_ck);
62 62
63 v = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); 63 v = omap2xxx_cm_get_core_clk_src();
64 v &= OMAP24XX_CORE_CLK_SRC_MASK;
65 64
66 if (v == CORE_CLK_SRC_32K) 65 if (v == CORE_CLK_SRC_32K)
67 core_clk = 32768; 66 core_clk = 32768;
@@ -79,8 +78,7 @@ static long omap2_dpllcore_round_rate(unsigned long target_rate)
79{ 78{
80 u32 high, low, core_clk_src; 79 u32 high, low, core_clk_src;
81 80
82 core_clk_src = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); 81 core_clk_src = omap2xxx_cm_get_core_clk_src();
83 core_clk_src &= OMAP24XX_CORE_CLK_SRC_MASK;
84 82
85 if (core_clk_src == CORE_CLK_SRC_DPLL) { /* DPLL clockout */ 83 if (core_clk_src == CORE_CLK_SRC_DPLL) { /* DPLL clockout */
86 high = curr_prcm_set->dpll_speed * 2; 84 high = curr_prcm_set->dpll_speed * 2;
@@ -120,8 +118,7 @@ int omap2_reprogram_dpllcore(struct clk_hw *hw, unsigned long rate,
120 const struct dpll_data *dd; 118 const struct dpll_data *dd;
121 119
122 cur_rate = omap2xxx_clk_get_core_rate(); 120 cur_rate = omap2xxx_clk_get_core_rate();
123 mult = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); 121 mult = omap2xxx_cm_get_core_clk_src();
124 mult &= OMAP24XX_CORE_CLK_SRC_MASK;
125 122
126 if ((rate == (cur_rate / 2)) && (mult == 2)) { 123 if ((rate == (cur_rate / 2)) && (mult == 2)) {
127 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL, 1); 124 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL, 1);
@@ -145,7 +142,7 @@ int omap2_reprogram_dpllcore(struct clk_hw *hw, unsigned long rate,
145 tmpset.cm_clksel1_pll &= ~(dd->mult_mask | 142 tmpset.cm_clksel1_pll &= ~(dd->mult_mask |
146 dd->div1_mask); 143 dd->div1_mask);
147 div = ((curr_prcm_set->xtal_speed / 1000000) - 1); 144 div = ((curr_prcm_set->xtal_speed / 1000000) - 1);
148 tmpset.cm_clksel2_pll = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); 145 tmpset.cm_clksel2_pll = omap2xxx_cm_get_core_pll_config();
149 tmpset.cm_clksel2_pll &= ~OMAP24XX_CORE_CLK_SRC_MASK; 146 tmpset.cm_clksel2_pll &= ~OMAP24XX_CORE_CLK_SRC_MASK;
150 if (rate > low) { 147 if (rate > low) {
151 tmpset.cm_clksel2_pll |= CORE_CLK_SRC_DPLL_X2; 148 tmpset.cm_clksel2_pll |= CORE_CLK_SRC_DPLL_X2;
diff --git a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
index ae2b35e76dc8..b935ed2922d8 100644
--- a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
+++ b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
@@ -98,7 +98,7 @@ long omap2_round_to_table_rate(struct clk_hw *hw, unsigned long rate,
98int omap2_select_table_rate(struct clk_hw *hw, unsigned long rate, 98int omap2_select_table_rate(struct clk_hw *hw, unsigned long rate,
99 unsigned long parent_rate) 99 unsigned long parent_rate)
100{ 100{
101 u32 cur_rate, done_rate, bypass = 0, tmp; 101 u32 cur_rate, done_rate, bypass = 0;
102 const struct prcm_config *prcm; 102 const struct prcm_config *prcm;
103 unsigned long found_speed = 0; 103 unsigned long found_speed = 0;
104 unsigned long flags; 104 unsigned long flags;
@@ -141,23 +141,11 @@ int omap2_select_table_rate(struct clk_hw *hw, unsigned long rate,
141 else 141 else
142 done_rate = CORE_CLK_SRC_DPLL; 142 done_rate = CORE_CLK_SRC_DPLL;
143 143
144 /* MPU divider */ 144 omap2xxx_cm_set_mod_dividers(prcm->cm_clksel_mpu,
145 omap2_cm_write_mod_reg(prcm->cm_clksel_mpu, MPU_MOD, CM_CLKSEL); 145 prcm->cm_clksel_dsp,
146 146 prcm->cm_clksel_gfx,
147 /* dsp + iva1 div(2420), iva2.1(2430) */ 147 prcm->cm_clksel1_core,
148 omap2_cm_write_mod_reg(prcm->cm_clksel_dsp, 148 prcm->cm_clksel_mdm);
149 OMAP24XX_DSP_MOD, CM_CLKSEL);
150
151 omap2_cm_write_mod_reg(prcm->cm_clksel_gfx, GFX_MOD, CM_CLKSEL);
152
153 /* Major subsystem dividers */
154 tmp = omap2_cm_read_mod_reg(CORE_MOD, CM_CLKSEL1) & OMAP24XX_CLKSEL_DSS2_MASK;
155 omap2_cm_write_mod_reg(prcm->cm_clksel1_core | tmp, CORE_MOD,
156 CM_CLKSEL1);
157
158 if (cpu_is_omap2430())
159 omap2_cm_write_mod_reg(prcm->cm_clksel_mdm,
160 OMAP2430_MDM_MOD, CM_CLKSEL);
161 149
162 /* x2 to enter omap2xxx_sdrc_init_params() */ 150 /* x2 to enter omap2xxx_sdrc_init_params() */
163 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL_X2, 1); 151 omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL_X2, 1);
diff --git a/arch/arm/mach-omap2/cm2xxx.c b/arch/arm/mach-omap2/cm2xxx.c
index 6774a53a3874..ce25abbcffae 100644
--- a/arch/arm/mach-omap2/cm2xxx.c
+++ b/arch/arm/mach-omap2/cm2xxx.c
@@ -327,6 +327,73 @@ struct clkdm_ops omap2_clkdm_operations = {
327 .clkdm_clk_disable = omap2xxx_clkdm_clk_disable, 327 .clkdm_clk_disable = omap2xxx_clkdm_clk_disable,
328}; 328};
329 329
330int omap2xxx_cm_fclks_active(void)
331{
332 u32 f1, f2;
333
334 f1 = omap2_cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
335 f2 = omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
336
337 return (f1 | f2) ? 1 : 0;
338}
339
340int omap2xxx_cm_mpu_retention_allowed(void)
341{
342 u32 l;
343
344 /* Check for MMC, UART2, UART1, McSPI2, McSPI1 and DSS1. */
345 l = omap2_cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
346 if (l & (OMAP2420_EN_MMC_MASK | OMAP24XX_EN_UART2_MASK |
347 OMAP24XX_EN_UART1_MASK | OMAP24XX_EN_MCSPI2_MASK |
348 OMAP24XX_EN_MCSPI1_MASK | OMAP24XX_EN_DSS1_MASK))
349 return 0;
350 /* Check for UART3. */
351 l = omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
352 if (l & OMAP24XX_EN_UART3_MASK)
353 return 0;
354
355 return 1;
356}
357
358u32 omap2xxx_cm_get_core_clk_src(void)
359{
360 u32 v;
361
362 v = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2);
363 v &= OMAP24XX_CORE_CLK_SRC_MASK;
364
365 return v;
366}
367
368u32 omap2xxx_cm_get_core_pll_config(void)
369{
370 return omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL2);
371}
372
373u32 omap2xxx_cm_get_pll_config(void)
374{
375 return omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
376}
377
378u32 omap2xxx_cm_get_pll_status(void)
379{
380 return omap2_cm_read_mod_reg(PLL_MOD, CM_CLKEN);
381}
382
383void omap2xxx_cm_set_mod_dividers(u32 mpu, u32 dsp, u32 gfx, u32 core, u32 mdm)
384{
385 u32 tmp;
386
387 omap2_cm_write_mod_reg(mpu, MPU_MOD, CM_CLKSEL);
388 omap2_cm_write_mod_reg(dsp, OMAP24XX_DSP_MOD, CM_CLKSEL);
389 omap2_cm_write_mod_reg(gfx, GFX_MOD, CM_CLKSEL);
390 tmp = omap2_cm_read_mod_reg(CORE_MOD, CM_CLKSEL1) &
391 OMAP24XX_CLKSEL_DSS2_MASK;
392 omap2_cm_write_mod_reg(core | tmp, CORE_MOD, CM_CLKSEL1);
393 if (cpu_is_omap2430())
394 omap2_cm_write_mod_reg(mdm, OMAP2430_MDM_MOD, CM_CLKSEL);
395}
396
330/* 397/*
331 * 398 *
332 */ 399 */
diff --git a/arch/arm/mach-omap2/cm2xxx.h b/arch/arm/mach-omap2/cm2xxx.h
index 4cbb39b051d2..891d81c3c8f4 100644
--- a/arch/arm/mach-omap2/cm2xxx.h
+++ b/arch/arm/mach-omap2/cm2xxx.h
@@ -62,6 +62,14 @@ extern int omap2xxx_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id,
62 u8 idlest_shift); 62 u8 idlest_shift);
63extern int omap2xxx_cm_split_idlest_reg(void __iomem *idlest_reg, 63extern int omap2xxx_cm_split_idlest_reg(void __iomem *idlest_reg,
64 s16 *prcm_inst, u8 *idlest_reg_id); 64 s16 *prcm_inst, u8 *idlest_reg_id);
65extern int omap2xxx_cm_fclks_active(void);
66extern int omap2xxx_cm_mpu_retention_allowed(void);
67extern u32 omap2xxx_cm_get_core_clk_src(void);
68extern u32 omap2xxx_cm_get_core_pll_config(void);
69extern u32 omap2xxx_cm_get_pll_config(void);
70extern u32 omap2xxx_cm_get_pll_status(void);
71extern void omap2xxx_cm_set_mod_dividers(u32 mpu, u32 dsp, u32 gfx, u32 core,
72 u32 mdm);
65 73
66extern int __init omap2xxx_cm_init(void); 74extern int __init omap2xxx_cm_init(void);
67 75
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index ce956b0a7ba4..8c0759496c8d 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -62,16 +62,6 @@ static struct clockdomain *dsp_clkdm, *mpu_clkdm, *wkup_clkdm, *gfx_clkdm;
62 62
63static struct clk *osc_ck, *emul_ck; 63static struct clk *osc_ck, *emul_ck;
64 64
65static int omap2_fclks_active(void)
66{
67 u32 f1, f2;
68
69 f1 = omap2_cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
70 f2 = omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
71
72 return (f1 | f2) ? 1 : 0;
73}
74
75static int omap2_enter_full_retention(void) 65static int omap2_enter_full_retention(void)
76{ 66{
77 u32 l; 67 u32 l;
@@ -142,17 +132,7 @@ static int sti_console_enabled;
142 132
143static int omap2_allow_mpu_retention(void) 133static int omap2_allow_mpu_retention(void)
144{ 134{
145 u32 l; 135 if (!omap2xxx_cm_mpu_retention_allowed())
146
147 /* Check for MMC, UART2, UART1, McSPI2, McSPI1 and DSS1. */
148 l = omap2_cm_read_mod_reg(CORE_MOD, CM_FCLKEN1);
149 if (l & (OMAP2420_EN_MMC_MASK | OMAP24XX_EN_UART2_MASK |
150 OMAP24XX_EN_UART1_MASK | OMAP24XX_EN_MCSPI2_MASK |
151 OMAP24XX_EN_MCSPI1_MASK | OMAP24XX_EN_DSS1_MASK))
152 return 0;
153 /* Check for UART3. */
154 l = omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_FCLKEN2);
155 if (l & OMAP24XX_EN_UART3_MASK)
156 return 0; 136 return 0;
157 if (sti_console_enabled) 137 if (sti_console_enabled)
158 return 0; 138 return 0;
@@ -188,7 +168,7 @@ static void omap2_enter_mpu_retention(void)
188 168
189static int omap2_can_sleep(void) 169static int omap2_can_sleep(void)
190{ 170{
191 if (omap2_fclks_active()) 171 if (omap2xxx_cm_fclks_active())
192 return 0; 172 return 0;
193 if (__clk_is_enabled(osc_ck)) 173 if (__clk_is_enabled(osc_ck))
194 return 0; 174 return 0;