aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-10-21 03:01:11 -0400
committerPaul Walmsley <paul@pwsan.com>2012-10-21 03:01:11 -0400
commitff4ae5d9319b86f940e410e92659c50f9879ff46 (patch)
treec522f8b1c8981a51ed7fc0280be7a9d345074ad8 /arch
parent498153995b9ff41279be54fc56facb92f5cad793 (diff)
ARM: OMAP2+: CM/hwmod: split CM functions into OMAP2, OMAP3-specific files
Move OMAP3xxx-specific CM functions & macros into cm3xxx.[ch] and OMAP2xxx-specific macros into cm2xxx.[ch]. Move basic CM register access functions into static inline functions in cm2xxx_3xxx.h, leaving only OMAP2/3 hardreset functions in cm2xxx_3xxx.c. As part of this, split the CM and hwmod code that waits for devices to become ready into SoC-specific functions. This is in preparation for the upcoming move of this code to drivers/. Signed-off-by: Paul Walmsley <paul@pwsan.com> Reviewed-by: Russ Dill <Russ.Dill@ti.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/Makefile6
-rw-r--r--arch/arm/mach-omap2/clkt2xxx_apll.c2
-rw-r--r--arch/arm/mach-omap2/clkt2xxx_dpll.c2
-rw-r--r--arch/arm/mach-omap2/clock.c3
-rw-r--r--arch/arm/mach-omap2/clock2420_data.c2
-rw-r--r--arch/arm/mach-omap2/clock2430.c2
-rw-r--r--arch/arm/mach-omap2/clock2430_data.c2
-rw-r--r--arch/arm/mach-omap2/clock34xx.c2
-rw-r--r--arch/arm/mach-omap2/clock3517.c2
-rw-r--r--arch/arm/mach-omap2/clock3xxx_data.c2
-rw-r--r--arch/arm/mach-omap2/clockdomain2xxx_3xxx.c27
-rw-r--r--arch/arm/mach-omap2/cm2xxx.c168
-rw-r--r--arch/arm/mach-omap2/cm2xxx.h66
-rw-r--r--arch/arm/mach-omap2/cm2xxx_3xxx.h113
-rw-r--r--arch/arm/mach-omap2/cm3xxx.c (renamed from arch/arm/mach-omap2/cm2xxx_3xxx.c)161
-rw-r--r--arch/arm/mach-omap2/cm3xxx.h86
-rw-r--r--arch/arm/mach-omap2/control.c2
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c49
-rw-r--r--arch/arm/mach-omap2/pm24xx.c2
-rw-r--r--arch/arm/mach-omap2/pm34xx.c3
-rw-r--r--arch/arm/mach-omap2/sleep34xx.S2
-rw-r--r--arch/arm/mach-omap2/sram242x.S2
-rw-r--r--arch/arm/mach-omap2/sram243x.S2
-rw-r--r--arch/arm/mach-omap2/sram34xx.S2
24 files changed, 440 insertions, 270 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 7404e3d48cea..56a33869c8b2 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -94,10 +94,8 @@ endif
94 94
95# PRCM 95# PRCM
96obj-y += prcm.o prm_common.o 96obj-y += prcm.o prm_common.o
97obj-$(CONFIG_ARCH_OMAP2) += cm2xxx_3xxx.o prm2xxx_3xxx.o 97obj-$(CONFIG_ARCH_OMAP2) += prm2xxx_3xxx.o prm2xxx.o cm2xxx.o
98obj-$(CONFIG_ARCH_OMAP2) += prm2xxx.o 98obj-$(CONFIG_ARCH_OMAP3) += prm2xxx_3xxx.o prm3xxx.o cm3xxx.o
99obj-$(CONFIG_ARCH_OMAP3) += cm2xxx_3xxx.o prm2xxx_3xxx.o
100obj-$(CONFIG_ARCH_OMAP3) += prm3xxx.o
101obj-$(CONFIG_ARCH_OMAP3) += vc3xxx_data.o vp3xxx_data.o 99obj-$(CONFIG_ARCH_OMAP3) += vc3xxx_data.o vp3xxx_data.o
102obj-$(CONFIG_SOC_AM33XX) += prm33xx.o cm33xx.o 100obj-$(CONFIG_SOC_AM33XX) += prm33xx.o cm33xx.o
103omap-prcm-4-5-common = cminst44xx.o cm44xx.o prm44xx.o \ 101omap-prcm-4-5-common = cminst44xx.o cm44xx.o prm44xx.o \
diff --git a/arch/arm/mach-omap2/clkt2xxx_apll.c b/arch/arm/mach-omap2/clkt2xxx_apll.c
index c2d15212d64d..3d2f67ea9b10 100644
--- a/arch/arm/mach-omap2/clkt2xxx_apll.c
+++ b/arch/arm/mach-omap2/clkt2xxx_apll.c
@@ -26,7 +26,7 @@
26 26
27#include "clock.h" 27#include "clock.h"
28#include "clock2xxx.h" 28#include "clock2xxx.h"
29#include "cm2xxx_3xxx.h" 29#include "cm2xxx.h"
30#include "cm-regbits-24xx.h" 30#include "cm-regbits-24xx.h"
31 31
32/* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */ 32/* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */
diff --git a/arch/arm/mach-omap2/clkt2xxx_dpll.c b/arch/arm/mach-omap2/clkt2xxx_dpll.c
index 1502a7bc20bb..0f587794f007 100644
--- a/arch/arm/mach-omap2/clkt2xxx_dpll.c
+++ b/arch/arm/mach-omap2/clkt2xxx_dpll.c
@@ -17,7 +17,7 @@
17#include <plat/clock.h> 17#include <plat/clock.h>
18 18
19#include "clock.h" 19#include "clock.h"
20#include "cm2xxx_3xxx.h" 20#include "cm2xxx.h"
21#include "cm-regbits-24xx.h" 21#include "cm-regbits-24xx.h"
22 22
23/* Private functions */ 23/* Private functions */
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 961ac8f7e13d..d0c6d9b066da 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -33,7 +33,8 @@
33#include "soc.h" 33#include "soc.h"
34#include "clockdomain.h" 34#include "clockdomain.h"
35#include "clock.h" 35#include "clock.h"
36#include "cm2xxx_3xxx.h" 36#include "cm2xxx.h"
37#include "cm3xxx.h"
37#include "cm-regbits-24xx.h" 38#include "cm-regbits-24xx.h"
38#include "cm-regbits-34xx.h" 39#include "cm-regbits-34xx.h"
39 40
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index c3cde1a2b6de..969bc5805f92 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -25,7 +25,7 @@
25#include "clock.h" 25#include "clock.h"
26#include "clock2xxx.h" 26#include "clock2xxx.h"
27#include "opp2xxx.h" 27#include "opp2xxx.h"
28#include "cm2xxx_3xxx.h" 28#include "cm2xxx.h"
29#include "prm2xxx_3xxx.h" 29#include "prm2xxx_3xxx.h"
30#include "prm-regbits-24xx.h" 30#include "prm-regbits-24xx.h"
31#include "cm-regbits-24xx.h" 31#include "cm-regbits-24xx.h"
diff --git a/arch/arm/mach-omap2/clock2430.c b/arch/arm/mach-omap2/clock2430.c
index a8e326177466..e786733e78bc 100644
--- a/arch/arm/mach-omap2/clock2430.c
+++ b/arch/arm/mach-omap2/clock2430.c
@@ -27,7 +27,7 @@
27#include "iomap.h" 27#include "iomap.h"
28#include "clock.h" 28#include "clock.h"
29#include "clock2xxx.h" 29#include "clock2xxx.h"
30#include "cm2xxx_3xxx.h" 30#include "cm2xxx.h"
31#include "cm-regbits-24xx.h" 31#include "cm-regbits-24xx.h"
32 32
33/** 33/**
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
index 22404fe435e7..186f06a97fb1 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -24,7 +24,7 @@
24#include "clock.h" 24#include "clock.h"
25#include "clock2xxx.h" 25#include "clock2xxx.h"
26#include "opp2xxx.h" 26#include "opp2xxx.h"
27#include "cm2xxx_3xxx.h" 27#include "cm2xxx.h"
28#include "prm2xxx_3xxx.h" 28#include "prm2xxx_3xxx.h"
29#include "prm-regbits-24xx.h" 29#include "prm-regbits-24xx.h"
30#include "cm-regbits-24xx.h" 30#include "cm-regbits-24xx.h"
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 1fc96b9ee330..150f42bd22b7 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -25,7 +25,7 @@
25 25
26#include "clock.h" 26#include "clock.h"
27#include "clock34xx.h" 27#include "clock34xx.h"
28#include "cm2xxx_3xxx.h" 28#include "cm3xxx.h"
29#include "cm-regbits-34xx.h" 29#include "cm-regbits-34xx.h"
30 30
31/** 31/**
diff --git a/arch/arm/mach-omap2/clock3517.c b/arch/arm/mach-omap2/clock3517.c
index 2e97d08f0e56..3e610c81bf8e 100644
--- a/arch/arm/mach-omap2/clock3517.c
+++ b/arch/arm/mach-omap2/clock3517.c
@@ -25,7 +25,7 @@
25 25
26#include "clock.h" 26#include "clock.h"
27#include "clock3517.h" 27#include "clock3517.h"
28#include "cm2xxx_3xxx.h" 28#include "cm3xxx.h"
29#include "cm-regbits-34xx.h" 29#include "cm-regbits-34xx.h"
30 30
31/* 31/*
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 1f42c9d5ecf3..7879c84d2472 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -30,7 +30,7 @@
30#include "clock34xx.h" 30#include "clock34xx.h"
31#include "clock36xx.h" 31#include "clock36xx.h"
32#include "clock3517.h" 32#include "clock3517.h"
33#include "cm2xxx_3xxx.h" 33#include "cm3xxx.h"
34#include "cm-regbits-34xx.h" 34#include "cm-regbits-34xx.h"
35#include "prm2xxx_3xxx.h" 35#include "prm2xxx_3xxx.h"
36#include "prm-regbits-34xx.h" 36#include "prm-regbits-34xx.h"
diff --git a/arch/arm/mach-omap2/clockdomain2xxx_3xxx.c b/arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
index 70294f54e35a..658487c34cb2 100644
--- a/arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/clockdomain2xxx_3xxx.c
@@ -17,7 +17,8 @@
17#include "prm.h" 17#include "prm.h"
18#include "prm2xxx_3xxx.h" 18#include "prm2xxx_3xxx.h"
19#include "cm.h" 19#include "cm.h"
20#include "cm2xxx_3xxx.h" 20#include "cm2xxx.h"
21#include "cm3xxx.h"
21#include "cm-regbits-24xx.h" 22#include "cm-regbits-24xx.h"
22#include "cm-regbits-34xx.h" 23#include "cm-regbits-34xx.h"
23#include "prm-regbits-24xx.h" 24#include "prm-regbits-24xx.h"
@@ -176,15 +177,15 @@ static int omap3_clkdm_wakeup(struct clockdomain *clkdm)
176 return 0; 177 return 0;
177} 178}
178 179
179static int omap2_clkdm_clk_enable(struct clockdomain *clkdm) 180static int omap2xxx_clkdm_clk_enable(struct clockdomain *clkdm)
180{ 181{
181 bool hwsup = false; 182 bool hwsup = false;
182 183
183 if (!clkdm->clktrctrl_mask) 184 if (!clkdm->clktrctrl_mask)
184 return 0; 185 return 0;
185 186
186 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs, 187 hwsup = omap3xxx_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
187 clkdm->clktrctrl_mask); 188 clkdm->clktrctrl_mask);
188 189
189 if (hwsup) { 190 if (hwsup) {
190 /* Disable HW transitions when we are changing deps */ 191 /* Disable HW transitions when we are changing deps */
@@ -199,15 +200,15 @@ static int omap2_clkdm_clk_enable(struct clockdomain *clkdm)
199 return 0; 200 return 0;
200} 201}
201 202
202static int omap2_clkdm_clk_disable(struct clockdomain *clkdm) 203static int omap2xxx_clkdm_clk_disable(struct clockdomain *clkdm)
203{ 204{
204 bool hwsup = false; 205 bool hwsup = false;
205 206
206 if (!clkdm->clktrctrl_mask) 207 if (!clkdm->clktrctrl_mask)
207 return 0; 208 return 0;
208 209
209 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs, 210 hwsup = omap3xxx_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
210 clkdm->clktrctrl_mask); 211 clkdm->clktrctrl_mask);
211 212
212 if (hwsup) { 213 if (hwsup) {
213 /* Disable HW transitions when we are changing deps */ 214 /* Disable HW transitions when we are changing deps */
@@ -258,8 +259,8 @@ static int omap3xxx_clkdm_clk_enable(struct clockdomain *clkdm)
258 return 0; 259 return 0;
259 } 260 }
260 261
261 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs, 262 hwsup = omap2xxx_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
262 clkdm->clktrctrl_mask); 263 clkdm->clktrctrl_mask);
263 264
264 if (hwsup) { 265 if (hwsup) {
265 /* Disable HW transitions when we are changing deps */ 266 /* Disable HW transitions when we are changing deps */
@@ -292,8 +293,8 @@ static int omap3xxx_clkdm_clk_disable(struct clockdomain *clkdm)
292 return 0; 293 return 0;
293 } 294 }
294 295
295 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs, 296 hwsup = omap2xxx_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
296 clkdm->clktrctrl_mask); 297 clkdm->clktrctrl_mask);
297 298
298 if (hwsup) { 299 if (hwsup) {
299 /* Disable HW transitions when we are changing deps */ 300 /* Disable HW transitions when we are changing deps */
@@ -317,8 +318,8 @@ struct clkdm_ops omap2_clkdm_operations = {
317 .clkdm_wakeup = omap2_clkdm_wakeup, 318 .clkdm_wakeup = omap2_clkdm_wakeup,
318 .clkdm_allow_idle = omap2_clkdm_allow_idle, 319 .clkdm_allow_idle = omap2_clkdm_allow_idle,
319 .clkdm_deny_idle = omap2_clkdm_deny_idle, 320 .clkdm_deny_idle = omap2_clkdm_deny_idle,
320 .clkdm_clk_enable = omap2_clkdm_clk_enable, 321 .clkdm_clk_enable = omap2xxx_clkdm_clk_enable,
321 .clkdm_clk_disable = omap2_clkdm_clk_disable, 322 .clkdm_clk_disable = omap2xxx_clkdm_clk_disable,
322}; 323};
323 324
324struct clkdm_ops omap3_clkdm_operations = { 325struct clkdm_ops omap3_clkdm_operations = {
diff --git a/arch/arm/mach-omap2/cm2xxx.c b/arch/arm/mach-omap2/cm2xxx.c
new file mode 100644
index 000000000000..051349370711
--- /dev/null
+++ b/arch/arm/mach-omap2/cm2xxx.c
@@ -0,0 +1,168 @@
1/*
2 * OMAP2xxx CM module functions
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Copyright (C) 2012 Texas Instruments, Inc.
6 * Paul Walmsley
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/delay.h>
16#include <linux/errno.h>
17#include <linux/err.h>
18#include <linux/io.h>
19
20#include "soc.h"
21#include "iomap.h"
22#include "common.h"
23#include "cm.h"
24#include "cm2xxx.h"
25#include "cm-regbits-24xx.h"
26
27/* CM_AUTOIDLE_PLL.AUTO_* bit values for DPLLs */
28#define DPLL_AUTOIDLE_DISABLE 0x0
29#define OMAP2XXX_DPLL_AUTOIDLE_LOW_POWER_STOP 0x3
30
31/* CM_AUTOIDLE_PLL.AUTO_* bit values for APLLs (OMAP2xxx only) */
32#define OMAP2XXX_APLL_AUTOIDLE_DISABLE 0x0
33#define OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP 0x3
34
35static const u8 omap2xxx_cm_idlest_offs[] = {
36 CM_IDLEST1, CM_IDLEST2, OMAP2430_CM_IDLEST3, OMAP24XX_CM_IDLEST4
37};
38
39/*
40 *
41 */
42
43static void _write_clktrctrl(u8 c, s16 module, u32 mask)
44{
45 u32 v;
46
47 v = omap2_cm_read_mod_reg(module, OMAP2_CM_CLKSTCTRL);
48 v &= ~mask;
49 v |= c << __ffs(mask);
50 omap2_cm_write_mod_reg(v, module, OMAP2_CM_CLKSTCTRL);
51}
52
53bool omap2xxx_cm_is_clkdm_in_hwsup(s16 module, u32 mask)
54{
55 u32 v;
56
57 v = omap2_cm_read_mod_reg(module, OMAP2_CM_CLKSTCTRL);
58 v &= mask;
59 v >>= __ffs(mask);
60
61 return (v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO) ? 1 : 0;
62}
63
64void omap2xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask)
65{
66 _write_clktrctrl(OMAP24XX_CLKSTCTRL_ENABLE_AUTO, module, mask);
67}
68
69void omap2xxx_cm_clkdm_disable_hwsup(s16 module, u32 mask)
70{
71 _write_clktrctrl(OMAP24XX_CLKSTCTRL_DISABLE_AUTO, module, mask);
72}
73
74/*
75 * DPLL autoidle control
76 */
77
78static void _omap2xxx_set_dpll_autoidle(u8 m)
79{
80 u32 v;
81
82 v = omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE);
83 v &= ~OMAP24XX_AUTO_DPLL_MASK;
84 v |= m << OMAP24XX_AUTO_DPLL_SHIFT;
85 omap2_cm_write_mod_reg(v, PLL_MOD, CM_AUTOIDLE);
86}
87
88void omap2xxx_cm_set_dpll_disable_autoidle(void)
89{
90 _omap2xxx_set_dpll_autoidle(OMAP2XXX_DPLL_AUTOIDLE_LOW_POWER_STOP);
91}
92
93void omap2xxx_cm_set_dpll_auto_low_power_stop(void)
94{
95 _omap2xxx_set_dpll_autoidle(DPLL_AUTOIDLE_DISABLE);
96}
97
98/*
99 * APLL autoidle control
100 */
101
102static void _omap2xxx_set_apll_autoidle(u8 m, u32 mask)
103{
104 u32 v;
105
106 v = omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE);
107 v &= ~mask;
108 v |= m << __ffs(mask);
109 omap2_cm_write_mod_reg(v, PLL_MOD, CM_AUTOIDLE);
110}
111
112void omap2xxx_cm_set_apll54_disable_autoidle(void)
113{
114 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP,
115 OMAP24XX_AUTO_54M_MASK);
116}
117
118void omap2xxx_cm_set_apll54_auto_low_power_stop(void)
119{
120 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_DISABLE,
121 OMAP24XX_AUTO_54M_MASK);
122}
123
124void omap2xxx_cm_set_apll96_disable_autoidle(void)
125{
126 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP,
127 OMAP24XX_AUTO_96M_MASK);
128}
129
130void omap2xxx_cm_set_apll96_auto_low_power_stop(void)
131{
132 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_DISABLE,
133 OMAP24XX_AUTO_96M_MASK);
134}
135
136/*
137 *
138 */
139
140/**
141 * omap2xxx_cm_wait_module_ready - wait for a module to leave idle or standby
142 * @prcm_mod: PRCM module offset
143 * @idlest_id: CM_IDLESTx register ID (i.e., x = 1, 2, 3)
144 * @idlest_shift: shift of the bit in the CM_IDLEST* register to check
145 *
146 * Wait for the PRCM to indicate that the module identified by
147 * (@prcm_mod, @idlest_id, @idlest_shift) is clocked. Return 0 upon
148 * success or -EBUSY if the module doesn't enable in time.
149 */
150int omap2xxx_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, u8 idlest_shift)
151{
152 int ena = 0, i = 0;
153 u8 cm_idlest_reg;
154 u32 mask;
155
156 if (!idlest_id || (idlest_id > ARRAY_SIZE(omap2xxx_cm_idlest_offs)))
157 return -EINVAL;
158
159 cm_idlest_reg = omap2xxx_cm_idlest_offs[idlest_id - 1];
160
161 mask = 1 << idlest_shift;
162 ena = mask;
163
164 omap_test_timeout(((omap2_cm_read_mod_reg(prcm_mod, cm_idlest_reg) &
165 mask) == ena), MAX_MODULE_READY_TIME, i);
166
167 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
168}
diff --git a/arch/arm/mach-omap2/cm2xxx.h b/arch/arm/mach-omap2/cm2xxx.h
new file mode 100644
index 000000000000..bce3c4be6d1f
--- /dev/null
+++ b/arch/arm/mach-omap2/cm2xxx.h
@@ -0,0 +1,66 @@
1/*
2 * OMAP2xxx Clock Management (CM) register definitions
3 *
4 * Copyright (C) 2007-2009, 2012 Texas Instruments, Inc.
5 * Copyright (C) 2007-2010 Nokia Corporation
6 * Paul Walmsley
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * The CM hardware modules on the OMAP2/3 are quite similar to each
13 * other. The CM modules/instances on OMAP4 are quite different, so
14 * they are handled in a separate file.
15 */
16#ifndef __ARCH_ASM_MACH_OMAP2_CM2XXX_H
17#define __ARCH_ASM_MACH_OMAP2_CM2XXX_H
18
19#include "prcm-common.h"
20#include "cm2xxx_3xxx.h"
21
22#define OMAP2420_CM_REGADDR(module, reg) \
23 OMAP2_L4_IO_ADDRESS(OMAP2420_CM_BASE + (module) + (reg))
24#define OMAP2430_CM_REGADDR(module, reg) \
25 OMAP2_L4_IO_ADDRESS(OMAP2430_CM_BASE + (module) + (reg))
26
27/*
28 * Module specific CM register offsets from CM_BASE + domain offset
29 * Use cm_{read,write}_mod_reg() with these registers.
30 * These register offsets generally appear in more than one PRCM submodule.
31 */
32
33/* OMAP2-specific register offsets */
34
35#define OMAP24XX_CM_FCLKEN2 0x0004
36#define OMAP24XX_CM_ICLKEN4 0x001c
37#define OMAP24XX_CM_AUTOIDLE4 0x003c
38#define OMAP24XX_CM_IDLEST4 0x002c
39
40/* CM_IDLEST bit field values to indicate deasserted IdleReq */
41
42#define OMAP24XX_CM_IDLEST_VAL 0
43
44
45/* Clock management domain register get/set */
46
47#ifndef __ASSEMBLER__
48
49extern void omap2xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask);
50extern void omap2xxx_cm_clkdm_disable_hwsup(s16 module, u32 mask);
51
52extern void omap2xxx_cm_set_dpll_disable_autoidle(void);
53extern void omap2xxx_cm_set_dpll_auto_low_power_stop(void);
54
55extern void omap2xxx_cm_set_apll54_disable_autoidle(void);
56extern void omap2xxx_cm_set_apll54_auto_low_power_stop(void);
57extern void omap2xxx_cm_set_apll96_disable_autoidle(void);
58extern void omap2xxx_cm_set_apll96_auto_low_power_stop(void);
59
60extern bool omap2xxx_cm_is_clkdm_in_hwsup(s16 module, u32 mask);
61extern int omap2xxx_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id,
62 u8 idlest_shift);
63
64#endif
65
66#endif
diff --git a/arch/arm/mach-omap2/cm2xxx_3xxx.h b/arch/arm/mach-omap2/cm2xxx_3xxx.h
index 57b2f3c2fbf3..865d332f6fb1 100644
--- a/arch/arm/mach-omap2/cm2xxx_3xxx.h
+++ b/arch/arm/mach-omap2/cm2xxx_3xxx.h
@@ -18,27 +18,6 @@
18 18
19#include "prcm-common.h" 19#include "prcm-common.h"
20 20
21#define OMAP2420_CM_REGADDR(module, reg) \
22 OMAP2_L4_IO_ADDRESS(OMAP2420_CM_BASE + (module) + (reg))
23#define OMAP2430_CM_REGADDR(module, reg) \
24 OMAP2_L4_IO_ADDRESS(OMAP2430_CM_BASE + (module) + (reg))
25#define OMAP34XX_CM_REGADDR(module, reg) \
26 OMAP2_L4_IO_ADDRESS(OMAP3430_CM_BASE + (module) + (reg))
27
28
29/*
30 * OMAP3-specific global CM registers
31 * Use cm_{read,write}_reg() with these registers.
32 * These registers appear once per CM module.
33 */
34
35#define OMAP3430_CM_REVISION OMAP34XX_CM_REGADDR(OCP_MOD, 0x0000)
36#define OMAP3430_CM_SYSCONFIG OMAP34XX_CM_REGADDR(OCP_MOD, 0x0010)
37#define OMAP3430_CM_POLCTRL OMAP34XX_CM_REGADDR(OCP_MOD, 0x009c)
38
39#define OMAP3_CM_CLKOUT_CTRL_OFFSET 0x0070
40#define OMAP3430_CM_CLKOUT_CTRL OMAP_CM_REGADDR(OMAP3430_CCR_MOD, 0x0070)
41
42/* 21/*
43 * Module specific CM register offsets from CM_BASE + domain offset 22 * Module specific CM register offsets from CM_BASE + domain offset
44 * Use cm_{read,write}_mod_reg() with these registers. 23 * Use cm_{read,write}_mod_reg() with these registers.
@@ -57,6 +36,7 @@
57#define CM_IDLEST 0x0020 36#define CM_IDLEST 0x0020
58#define CM_IDLEST1 CM_IDLEST 37#define CM_IDLEST1 CM_IDLEST
59#define CM_IDLEST2 0x0024 38#define CM_IDLEST2 0x0024
39#define OMAP2430_CM_IDLEST3 0x0028
60#define CM_AUTOIDLE 0x0030 40#define CM_AUTOIDLE 0x0030
61#define CM_AUTOIDLE1 CM_AUTOIDLE 41#define CM_AUTOIDLE1 CM_AUTOIDLE
62#define CM_AUTOIDLE2 0x0034 42#define CM_AUTOIDLE2 0x0034
@@ -66,70 +46,43 @@
66#define CM_CLKSEL2 0x0044 46#define CM_CLKSEL2 0x0044
67#define OMAP2_CM_CLKSTCTRL 0x0048 47#define OMAP2_CM_CLKSTCTRL 0x0048
68 48
69/* OMAP2-specific register offsets */ 49#ifndef __ASSEMBLER__
70
71#define OMAP24XX_CM_FCLKEN2 0x0004
72#define OMAP24XX_CM_ICLKEN4 0x001c
73#define OMAP24XX_CM_AUTOIDLE4 0x003c
74#define OMAP24XX_CM_IDLEST4 0x002c
75
76#define OMAP2430_CM_IDLEST3 0x0028
77
78/* OMAP3-specific register offsets */
79
80#define OMAP3430_CM_CLKEN_PLL 0x0004
81#define OMAP3430ES2_CM_CLKEN2 0x0004
82#define OMAP3430ES2_CM_FCLKEN3 0x0008
83#define OMAP3430_CM_IDLEST_PLL CM_IDLEST2
84#define OMAP3430_CM_AUTOIDLE_PLL CM_AUTOIDLE2
85#define OMAP3430ES2_CM_AUTOIDLE2_PLL CM_AUTOIDLE2
86#define OMAP3430_CM_CLKSEL1 CM_CLKSEL
87#define OMAP3430_CM_CLKSEL1_PLL CM_CLKSEL
88#define OMAP3430_CM_CLKSEL2_PLL CM_CLKSEL2
89#define OMAP3430_CM_SLEEPDEP CM_CLKSEL2
90#define OMAP3430_CM_CLKSEL3 OMAP2_CM_CLKSTCTRL
91#define OMAP3430_CM_CLKSTST 0x004c
92#define OMAP3430ES2_CM_CLKSEL4 0x004c
93#define OMAP3430ES2_CM_CLKSEL5 0x0050
94#define OMAP3430_CM_CLKSEL2_EMU 0x0050
95#define OMAP3430_CM_CLKSEL3_EMU 0x0054
96
97
98/* CM_IDLEST bit field values to indicate deasserted IdleReq */
99
100#define OMAP24XX_CM_IDLEST_VAL 0
101#define OMAP34XX_CM_IDLEST_VAL 1
102 50
51#include <linux/io.h>
103 52
104/* Clock management domain register get/set */ 53static inline u32 omap2_cm_read_mod_reg(s16 module, u16 idx)
54{
55 return __raw_readl(cm_base + module + idx);
56}
105 57
106#ifndef __ASSEMBLER__ 58static inline void omap2_cm_write_mod_reg(u32 val, s16 module, u16 idx)
59{
60 __raw_writel(val, cm_base + module + idx);
61}
107 62
108extern u32 omap2_cm_read_mod_reg(s16 module, u16 idx); 63/* Read-modify-write a register in a CM module. Caller must lock */
109extern void omap2_cm_write_mod_reg(u32 val, s16 module, u16 idx); 64static inline u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module,
110extern u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx); 65 s16 idx)
66{
67 u32 v;
111 68
112extern int omap2_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, 69 v = omap2_cm_read_mod_reg(module, idx);
113 u8 idlest_shift); 70 v &= ~mask;
114extern u32 omap2_cm_set_mod_reg_bits(u32 bits, s16 module, s16 idx); 71 v |= bits;
115extern u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx); 72 omap2_cm_write_mod_reg(v, module, idx);
116 73
117extern bool omap2_cm_is_clkdm_in_hwsup(s16 module, u32 mask); 74 return v;
118extern void omap2xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask); 75}
119extern void omap2xxx_cm_clkdm_disable_hwsup(s16 module, u32 mask);
120 76
121extern void omap3xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask); 77static inline u32 omap2_cm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
122extern void omap3xxx_cm_clkdm_disable_hwsup(s16 module, u32 mask); 78{
123extern void omap3xxx_cm_clkdm_force_sleep(s16 module, u32 mask); 79 return omap2_cm_rmw_mod_reg_bits(bits, bits, module, idx);
124extern void omap3xxx_cm_clkdm_force_wakeup(s16 module, u32 mask); 80}
125 81
126extern void omap2xxx_cm_set_dpll_disable_autoidle(void); 82static inline u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
127extern void omap2xxx_cm_set_dpll_auto_low_power_stop(void); 83{
128 84 return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx);
129extern void omap2xxx_cm_set_apll54_disable_autoidle(void); 85}
130extern void omap2xxx_cm_set_apll54_auto_low_power_stop(void);
131extern void omap2xxx_cm_set_apll96_disable_autoidle(void);
132extern void omap2xxx_cm_set_apll96_auto_low_power_stop(void);
133 86
134#endif 87#endif
135 88
@@ -147,10 +100,4 @@ extern void omap2xxx_cm_set_apll96_auto_low_power_stop(void);
147#define OMAP_ST_GFX_MASK (1 << 0) 100#define OMAP_ST_GFX_MASK (1 << 0)
148 101
149 102
150/* Function prototypes */
151# ifndef __ASSEMBLER__
152extern void omap3_cm_save_context(void);
153extern void omap3_cm_restore_context(void);
154# endif
155
156#endif 103#endif
diff --git a/arch/arm/mach-omap2/cm2xxx_3xxx.c b/arch/arm/mach-omap2/cm3xxx.c
index 7f07ab02a5b3..8f92c56e2254 100644
--- a/arch/arm/mach-omap2/cm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/cm3xxx.c
@@ -2,6 +2,7 @@
2 * OMAP2/3 CM module functions 2 * OMAP2/3 CM module functions
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009 Nokia Corporation
5 * Copyright (C) 2012 Texas Instruments, Inc.
5 * Paul Walmsley 6 * Paul Walmsley
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
@@ -12,8 +13,6 @@
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/types.h> 14#include <linux/types.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/spinlock.h>
16#include <linux/list.h>
17#include <linux/errno.h> 16#include <linux/errno.h>
18#include <linux/err.h> 17#include <linux/err.h>
19#include <linux/io.h> 18#include <linux/io.h>
@@ -22,55 +21,13 @@
22#include "iomap.h" 21#include "iomap.h"
23#include "common.h" 22#include "common.h"
24#include "cm.h" 23#include "cm.h"
25#include "cm2xxx_3xxx.h" 24#include "cm3xxx.h"
26#include "cm-regbits-24xx.h"
27#include "cm-regbits-34xx.h" 25#include "cm-regbits-34xx.h"
28 26
29/* CM_AUTOIDLE_PLL.AUTO_* bit values for DPLLs */ 27static const u8 omap3xxx_cm_idlest_offs[] = {
30#define DPLL_AUTOIDLE_DISABLE 0x0 28 CM_IDLEST1, CM_IDLEST2, OMAP2430_CM_IDLEST3
31#define OMAP2XXX_DPLL_AUTOIDLE_LOW_POWER_STOP 0x3
32
33/* CM_AUTOIDLE_PLL.AUTO_* bit values for APLLs (OMAP2xxx only) */
34#define OMAP2XXX_APLL_AUTOIDLE_DISABLE 0x0
35#define OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP 0x3
36
37static const u8 cm_idlest_offs[] = {
38 CM_IDLEST1, CM_IDLEST2, OMAP2430_CM_IDLEST3, OMAP24XX_CM_IDLEST4
39}; 29};
40 30
41u32 omap2_cm_read_mod_reg(s16 module, u16 idx)
42{
43 return __raw_readl(cm_base + module + idx);
44}
45
46void omap2_cm_write_mod_reg(u32 val, s16 module, u16 idx)
47{
48 __raw_writel(val, cm_base + module + idx);
49}
50
51/* Read-modify-write a register in a CM module. Caller must lock */
52u32 omap2_cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
53{
54 u32 v;
55
56 v = omap2_cm_read_mod_reg(module, idx);
57 v &= ~mask;
58 v |= bits;
59 omap2_cm_write_mod_reg(v, module, idx);
60
61 return v;
62}
63
64u32 omap2_cm_set_mod_reg_bits(u32 bits, s16 module, s16 idx)
65{
66 return omap2_cm_rmw_mod_reg_bits(bits, bits, module, idx);
67}
68
69u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
70{
71 return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx);
72}
73
74/* 31/*
75 * 32 *
76 */ 33 */
@@ -85,33 +42,15 @@ static void _write_clktrctrl(u8 c, s16 module, u32 mask)
85 omap2_cm_write_mod_reg(v, module, OMAP2_CM_CLKSTCTRL); 42 omap2_cm_write_mod_reg(v, module, OMAP2_CM_CLKSTCTRL);
86} 43}
87 44
88bool omap2_cm_is_clkdm_in_hwsup(s16 module, u32 mask) 45bool omap3xxx_cm_is_clkdm_in_hwsup(s16 module, u32 mask)
89{ 46{
90 u32 v; 47 u32 v;
91 bool ret = 0;
92
93 BUG_ON(!cpu_is_omap24xx() && !cpu_is_omap34xx());
94 48
95 v = omap2_cm_read_mod_reg(module, OMAP2_CM_CLKSTCTRL); 49 v = omap2_cm_read_mod_reg(module, OMAP2_CM_CLKSTCTRL);
96 v &= mask; 50 v &= mask;
97 v >>= __ffs(mask); 51 v >>= __ffs(mask);
98 52
99 if (cpu_is_omap24xx()) 53 return (v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ? 1 : 0;
100 ret = (v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO) ? 1 : 0;
101 else
102 ret = (v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ? 1 : 0;
103
104 return ret;
105}
106
107void omap2xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask)
108{
109 _write_clktrctrl(OMAP24XX_CLKSTCTRL_ENABLE_AUTO, module, mask);
110}
111
112void omap2xxx_cm_clkdm_disable_hwsup(s16 module, u32 mask)
113{
114 _write_clktrctrl(OMAP24XX_CLKSTCTRL_DISABLE_AUTO, module, mask);
115} 54}
116 55
117void omap3xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask) 56void omap3xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask)
@@ -135,101 +74,35 @@ void omap3xxx_cm_clkdm_force_wakeup(s16 module, u32 mask)
135} 74}
136 75
137/* 76/*
138 * DPLL autoidle control
139 */
140
141static void _omap2xxx_set_dpll_autoidle(u8 m)
142{
143 u32 v;
144
145 v = omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE);
146 v &= ~OMAP24XX_AUTO_DPLL_MASK;
147 v |= m << OMAP24XX_AUTO_DPLL_SHIFT;
148 omap2_cm_write_mod_reg(v, PLL_MOD, CM_AUTOIDLE);
149}
150
151void omap2xxx_cm_set_dpll_disable_autoidle(void)
152{
153 _omap2xxx_set_dpll_autoidle(OMAP2XXX_DPLL_AUTOIDLE_LOW_POWER_STOP);
154}
155
156void omap2xxx_cm_set_dpll_auto_low_power_stop(void)
157{
158 _omap2xxx_set_dpll_autoidle(DPLL_AUTOIDLE_DISABLE);
159}
160
161/*
162 * APLL autoidle control
163 */
164
165static void _omap2xxx_set_apll_autoidle(u8 m, u32 mask)
166{
167 u32 v;
168
169 v = omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE);
170 v &= ~mask;
171 v |= m << __ffs(mask);
172 omap2_cm_write_mod_reg(v, PLL_MOD, CM_AUTOIDLE);
173}
174
175void omap2xxx_cm_set_apll54_disable_autoidle(void)
176{
177 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP,
178 OMAP24XX_AUTO_54M_MASK);
179}
180
181void omap2xxx_cm_set_apll54_auto_low_power_stop(void)
182{
183 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_DISABLE,
184 OMAP24XX_AUTO_54M_MASK);
185}
186
187void omap2xxx_cm_set_apll96_disable_autoidle(void)
188{
189 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP,
190 OMAP24XX_AUTO_96M_MASK);
191}
192
193void omap2xxx_cm_set_apll96_auto_low_power_stop(void)
194{
195 _omap2xxx_set_apll_autoidle(OMAP2XXX_APLL_AUTOIDLE_DISABLE,
196 OMAP24XX_AUTO_96M_MASK);
197}
198
199/*
200 * 77 *
201 */ 78 */
202 79
203/** 80/**
204 * omap2_cm_wait_idlest_ready - wait for a module to leave idle or standby 81 * omap3xxx_cm_wait_module_ready - wait for a module to leave idle or standby
205 * @prcm_mod: PRCM module offset 82 * @prcm_mod: PRCM module offset
206 * @idlest_id: CM_IDLESTx register ID (i.e., x = 1, 2, 3) 83 * @idlest_id: CM_IDLESTx register ID (i.e., x = 1, 2, 3)
207 * @idlest_shift: shift of the bit in the CM_IDLEST* register to check 84 * @idlest_shift: shift of the bit in the CM_IDLEST* register to check
208 * 85 *
209 * XXX document 86 * Wait for the PRCM to indicate that the module identified by
87 * (@prcm_mod, @idlest_id, @idlest_shift) is clocked. Return 0 upon
88 * success or -EBUSY if the module doesn't enable in time.
210 */ 89 */
211int omap2_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, u8 idlest_shift) 90int omap3xxx_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, u8 idlest_shift)
212{ 91{
213 int ena = 0, i = 0; 92 int ena = 0, i = 0;
214 u8 cm_idlest_reg; 93 u8 cm_idlest_reg;
215 u32 mask; 94 u32 mask;
216 95
217 if (!idlest_id || (idlest_id > ARRAY_SIZE(cm_idlest_offs))) 96 if (!idlest_id || (idlest_id > ARRAY_SIZE(omap3xxx_cm_idlest_offs)))
218 return -EINVAL; 97 return -EINVAL;
219 98
220 cm_idlest_reg = cm_idlest_offs[idlest_id - 1]; 99 cm_idlest_reg = omap3xxx_cm_idlest_offs[idlest_id - 1];
221 100
222 mask = 1 << idlest_shift; 101 mask = 1 << idlest_shift;
102 ena = 0;
223 103
224 if (cpu_is_omap24xx()) 104 omap_test_timeout(((omap2_cm_read_mod_reg(prcm_mod, cm_idlest_reg) &
225 ena = mask; 105 mask) == ena), MAX_MODULE_READY_TIME, i);
226 else if (cpu_is_omap34xx())
227 ena = 0;
228 else
229 BUG();
230
231 omap_test_timeout(((omap2_cm_read_mod_reg(prcm_mod, cm_idlest_reg) & mask) == ena),
232 MAX_MODULE_READY_TIME, i);
233 106
234 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY; 107 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
235} 108}
@@ -237,7 +110,6 @@ int omap2_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, u8 idlest_shift)
237/* 110/*
238 * Context save/restore code - OMAP3 only 111 * Context save/restore code - OMAP3 only
239 */ 112 */
240#ifdef CONFIG_ARCH_OMAP3
241struct omap3_cm_regs { 113struct omap3_cm_regs {
242 u32 iva2_cm_clksel1; 114 u32 iva2_cm_clksel1;
243 u32 iva2_cm_clksel2; 115 u32 iva2_cm_clksel2;
@@ -555,4 +427,3 @@ void omap3_cm_restore_context(void)
555 omap2_cm_write_mod_reg(cm_context.cm_clkout_ctrl, OMAP3430_CCR_MOD, 427 omap2_cm_write_mod_reg(cm_context.cm_clkout_ctrl, OMAP3430_CCR_MOD,
556 OMAP3_CM_CLKOUT_CTRL_OFFSET); 428 OMAP3_CM_CLKOUT_CTRL_OFFSET);
557} 429}
558#endif
diff --git a/arch/arm/mach-omap2/cm3xxx.h b/arch/arm/mach-omap2/cm3xxx.h
new file mode 100644
index 000000000000..4a6ac812edf4
--- /dev/null
+++ b/arch/arm/mach-omap2/cm3xxx.h
@@ -0,0 +1,86 @@
1/*
2 * OMAP2/3 Clock Management (CM) register definitions
3 *
4 * Copyright (C) 2007-2009 Texas Instruments, Inc.
5 * Copyright (C) 2007-2010 Nokia Corporation
6 * Paul Walmsley
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * The CM hardware modules on the OMAP2/3 are quite similar to each
13 * other. The CM modules/instances on OMAP4 are quite different, so
14 * they are handled in a separate file.
15 */
16#ifndef __ARCH_ASM_MACH_OMAP2_CM3XXX_H
17#define __ARCH_ASM_MACH_OMAP2_CM3XXX_H
18
19#include "prcm-common.h"
20#include "cm2xxx_3xxx.h"
21
22#define OMAP34XX_CM_REGADDR(module, reg) \
23 OMAP2_L4_IO_ADDRESS(OMAP3430_CM_BASE + (module) + (reg))
24
25
26/*
27 * OMAP3-specific global CM registers
28 * Use cm_{read,write}_reg() with these registers.
29 * These registers appear once per CM module.
30 */
31
32#define OMAP3430_CM_REVISION OMAP34XX_CM_REGADDR(OCP_MOD, 0x0000)
33#define OMAP3430_CM_SYSCONFIG OMAP34XX_CM_REGADDR(OCP_MOD, 0x0010)
34#define OMAP3430_CM_POLCTRL OMAP34XX_CM_REGADDR(OCP_MOD, 0x009c)
35
36#define OMAP3_CM_CLKOUT_CTRL_OFFSET 0x0070
37#define OMAP3430_CM_CLKOUT_CTRL OMAP_CM_REGADDR(OMAP3430_CCR_MOD, 0x0070)
38
39/*
40 * Module specific CM register offsets from CM_BASE + domain offset
41 * Use cm_{read,write}_mod_reg() with these registers.
42 * These register offsets generally appear in more than one PRCM submodule.
43 */
44
45/* OMAP3-specific register offsets */
46
47#define OMAP3430_CM_CLKEN_PLL 0x0004
48#define OMAP3430ES2_CM_CLKEN2 0x0004
49#define OMAP3430ES2_CM_FCLKEN3 0x0008
50#define OMAP3430_CM_IDLEST_PLL CM_IDLEST2
51#define OMAP3430_CM_AUTOIDLE_PLL CM_AUTOIDLE2
52#define OMAP3430ES2_CM_AUTOIDLE2_PLL CM_AUTOIDLE2
53#define OMAP3430_CM_CLKSEL1 CM_CLKSEL
54#define OMAP3430_CM_CLKSEL1_PLL CM_CLKSEL
55#define OMAP3430_CM_CLKSEL2_PLL CM_CLKSEL2
56#define OMAP3430_CM_SLEEPDEP CM_CLKSEL2
57#define OMAP3430_CM_CLKSEL3 OMAP2_CM_CLKSTCTRL
58#define OMAP3430_CM_CLKSTST 0x004c
59#define OMAP3430ES2_CM_CLKSEL4 0x004c
60#define OMAP3430ES2_CM_CLKSEL5 0x0050
61#define OMAP3430_CM_CLKSEL2_EMU 0x0050
62#define OMAP3430_CM_CLKSEL3_EMU 0x0054
63
64
65/* CM_IDLEST bit field values to indicate deasserted IdleReq */
66
67#define OMAP34XX_CM_IDLEST_VAL 1
68
69
70#ifndef __ASSEMBLER__
71
72extern void omap3xxx_cm_clkdm_enable_hwsup(s16 module, u32 mask);
73extern void omap3xxx_cm_clkdm_disable_hwsup(s16 module, u32 mask);
74extern void omap3xxx_cm_clkdm_force_sleep(s16 module, u32 mask);
75extern void omap3xxx_cm_clkdm_force_wakeup(s16 module, u32 mask);
76
77extern bool omap3xxx_cm_is_clkdm_in_hwsup(s16 module, u32 mask);
78extern int omap3xxx_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id,
79 u8 idlest_shift);
80
81extern void omap3_cm_save_context(void);
82extern void omap3_cm_restore_context(void);
83
84#endif
85
86#endif
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index 1220e0ef0b86..a7d1eb8fb57c 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -23,7 +23,7 @@
23#include "cm-regbits-34xx.h" 23#include "cm-regbits-34xx.h"
24#include "prm-regbits-34xx.h" 24#include "prm-regbits-34xx.h"
25#include "prm3xxx.h" 25#include "prm3xxx.h"
26#include "cm2xxx_3xxx.h" 26#include "cm3xxx.h"
27#include "sdrc.h" 27#include "sdrc.h"
28#include "pm.h" 28#include "pm.h"
29#include "control.h" 29#include "control.h"
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 525c58d25730..504e0e0ecbbd 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -147,7 +147,8 @@
147#include "common.h" 147#include "common.h"
148#include "clockdomain.h" 148#include "clockdomain.h"
149#include "powerdomain.h" 149#include "powerdomain.h"
150#include "cm2xxx_3xxx.h" 150#include "cm2xxx.h"
151#include "cm3xxx.h"
151#include "cminst44xx.h" 152#include "cminst44xx.h"
152#include "cm33xx.h" 153#include "cm33xx.h"
153#include "prm3xxx.h" 154#include "prm3xxx.h"
@@ -2668,7 +2669,7 @@ static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
2668/* Static functions intended only for use in soc_ops field function pointers */ 2669/* Static functions intended only for use in soc_ops field function pointers */
2669 2670
2670/** 2671/**
2671 * _omap2_wait_target_ready - wait for a module to leave slave idle 2672 * _omap2xxx_wait_target_ready - wait for a module to leave slave idle
2672 * @oh: struct omap_hwmod * 2673 * @oh: struct omap_hwmod *
2673 * 2674 *
2674 * Wait for a module @oh to leave slave idle. Returns 0 if the module 2675 * Wait for a module @oh to leave slave idle. Returns 0 if the module
@@ -2676,7 +2677,7 @@ static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
2676 * slave idle; otherwise, pass along the return value of the 2677 * slave idle; otherwise, pass along the return value of the
2677 * appropriate *_cm*_wait_module_ready() function. 2678 * appropriate *_cm*_wait_module_ready() function.
2678 */ 2679 */
2679static int _omap2_wait_target_ready(struct omap_hwmod *oh) 2680static int _omap2xxx_wait_target_ready(struct omap_hwmod *oh)
2680{ 2681{
2681 if (!oh) 2682 if (!oh)
2682 return -EINVAL; 2683 return -EINVAL;
@@ -2689,9 +2690,36 @@ static int _omap2_wait_target_ready(struct omap_hwmod *oh)
2689 2690
2690 /* XXX check module SIDLEMODE, hardreset status, enabled clocks */ 2691 /* XXX check module SIDLEMODE, hardreset status, enabled clocks */
2691 2692
2692 return omap2_cm_wait_module_ready(oh->prcm.omap2.module_offs, 2693 return omap2xxx_cm_wait_module_ready(oh->prcm.omap2.module_offs,
2693 oh->prcm.omap2.idlest_reg_id, 2694 oh->prcm.omap2.idlest_reg_id,
2694 oh->prcm.omap2.idlest_idle_bit); 2695 oh->prcm.omap2.idlest_idle_bit);
2696}
2697
2698/**
2699 * _omap3xxx_wait_target_ready - wait for a module to leave slave idle
2700 * @oh: struct omap_hwmod *
2701 *
2702 * Wait for a module @oh to leave slave idle. Returns 0 if the module
2703 * does not have an IDLEST bit or if the module successfully leaves
2704 * slave idle; otherwise, pass along the return value of the
2705 * appropriate *_cm*_wait_module_ready() function.
2706 */
2707static int _omap3xxx_wait_target_ready(struct omap_hwmod *oh)
2708{
2709 if (!oh)
2710 return -EINVAL;
2711
2712 if (oh->flags & HWMOD_NO_IDLEST)
2713 return 0;
2714
2715 if (!_find_mpu_rt_port(oh))
2716 return 0;
2717
2718 /* XXX check module SIDLEMODE, hardreset status, enabled clocks */
2719
2720 return omap3xxx_cm_wait_module_ready(oh->prcm.omap2.module_offs,
2721 oh->prcm.omap2.idlest_reg_id,
2722 oh->prcm.omap2.idlest_idle_bit);
2695} 2723}
2696 2724
2697/** 2725/**
@@ -3959,8 +3987,13 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx)
3959 */ 3987 */
3960void __init omap_hwmod_init(void) 3988void __init omap_hwmod_init(void)
3961{ 3989{
3962 if (cpu_is_omap24xx() || cpu_is_omap34xx()) { 3990 if (cpu_is_omap24xx()) {
3963 soc_ops.wait_target_ready = _omap2_wait_target_ready; 3991 soc_ops.wait_target_ready = _omap2xxx_wait_target_ready;
3992 soc_ops.assert_hardreset = _omap2_assert_hardreset;
3993 soc_ops.deassert_hardreset = _omap2_deassert_hardreset;
3994 soc_ops.is_hardreset_asserted = _omap2_is_hardreset_asserted;
3995 } else if (cpu_is_omap34xx()) {
3996 soc_ops.wait_target_ready = _omap3xxx_wait_target_ready;
3964 soc_ops.assert_hardreset = _omap2_assert_hardreset; 3997 soc_ops.assert_hardreset = _omap2_assert_hardreset;
3965 soc_ops.deassert_hardreset = _omap2_deassert_hardreset; 3998 soc_ops.deassert_hardreset = _omap2_deassert_hardreset;
3966 soc_ops.is_hardreset_asserted = _omap2_is_hardreset_asserted; 3999 soc_ops.is_hardreset_asserted = _omap2_is_hardreset_asserted;
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 78405a7fb99e..02dca24ec0ab 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -43,7 +43,7 @@
43#include "common.h" 43#include "common.h"
44#include "prm2xxx.h" 44#include "prm2xxx.h"
45#include "prm-regbits-24xx.h" 45#include "prm-regbits-24xx.h"
46#include "cm2xxx_3xxx.h" 46#include "cm2xxx.h"
47#include "cm-regbits-24xx.h" 47#include "cm-regbits-24xx.h"
48#include "sdrc.h" 48#include "sdrc.h"
49#include "pm.h" 49#include "pm.h"
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index c02c9ca9ef05..c0f8a7804bf7 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -44,10 +44,9 @@
44#include <plat/dma.h> 44#include <plat/dma.h>
45 45
46#include "common.h" 46#include "common.h"
47#include "cm2xxx_3xxx.h" 47#include "cm3xxx.h"
48#include "cm-regbits-34xx.h" 48#include "cm-regbits-34xx.h"
49#include "prm-regbits-34xx.h" 49#include "prm-regbits-34xx.h"
50
51#include "prm3xxx.h" 50#include "prm3xxx.h"
52#include "pm.h" 51#include "pm.h"
53#include "sdrc.h" 52#include "sdrc.h"
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index d83b91829335..b5bc4b107565 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -30,7 +30,7 @@
30 30
31#include "omap34xx.h" 31#include "omap34xx.h"
32#include "iomap.h" 32#include "iomap.h"
33#include "cm2xxx_3xxx.h" 33#include "cm3xxx.h"
34#include "prm3xxx.h" 34#include "prm3xxx.h"
35#include "sdrc.h" 35#include "sdrc.h"
36#include "control.h" 36#include "control.h"
diff --git a/arch/arm/mach-omap2/sram242x.S b/arch/arm/mach-omap2/sram242x.S
index c7204439bdab..680a7c56cc3e 100644
--- a/arch/arm/mach-omap2/sram242x.S
+++ b/arch/arm/mach-omap2/sram242x.S
@@ -35,7 +35,7 @@
35#include "soc.h" 35#include "soc.h"
36#include "iomap.h" 36#include "iomap.h"
37#include "prm2xxx.h" 37#include "prm2xxx.h"
38#include "cm2xxx_3xxx.h" 38#include "cm2xxx.h"
39#include "sdrc.h" 39#include "sdrc.h"
40 40
41 .text 41 .text
diff --git a/arch/arm/mach-omap2/sram243x.S b/arch/arm/mach-omap2/sram243x.S
index cfdc0bcfea6d..a1e9edd673f4 100644
--- a/arch/arm/mach-omap2/sram243x.S
+++ b/arch/arm/mach-omap2/sram243x.S
@@ -35,7 +35,7 @@
35#include "soc.h" 35#include "soc.h"
36#include "iomap.h" 36#include "iomap.h"
37#include "prm2xxx.h" 37#include "prm2xxx.h"
38#include "cm2xxx_3xxx.h" 38#include "cm2xxx.h"
39#include "sdrc.h" 39#include "sdrc.h"
40 40
41 .text 41 .text
diff --git a/arch/arm/mach-omap2/sram34xx.S b/arch/arm/mach-omap2/sram34xx.S
index 2d0ceaa23fb8..1446331b576a 100644
--- a/arch/arm/mach-omap2/sram34xx.S
+++ b/arch/arm/mach-omap2/sram34xx.S
@@ -32,7 +32,7 @@
32#include "soc.h" 32#include "soc.h"
33#include "iomap.h" 33#include "iomap.h"
34#include "sdrc.h" 34#include "sdrc.h"
35#include "cm2xxx_3xxx.h" 35#include "cm3xxx.h"
36 36
37/* 37/*
38 * This file needs be built unconditionally as ARM to interoperate correctly 38 * This file needs be built unconditionally as ARM to interoperate correctly