Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / arch / arm / plat-omap / include / plat / cpu.h
1 /*
2  * arch/arm/plat-omap/include/mach/cpu.h
3  *
4  * OMAP cpu type detection
5  *
6  * Copyright (C) 2004, 2008 Nokia Corporation
7  *
8  * Copyright (C) 2009-11 Texas Instruments.
9  *
10  * Written by Tony Lindgren <tony.lindgren@nokia.com>
11  *
12  * Added OMAP4 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  */
29
30 #ifndef __ASM_ARCH_OMAP_CPU_H
31 #define __ASM_ARCH_OMAP_CPU_H
32
33 #include <linux/bitops.h>
34 #include <plat/multi.h>
35
36 /*
37  * Omap device type i.e. EMU/HS/TST/GP/BAD
38  */
39 #define OMAP2_DEVICE_TYPE_TEST          0
40 #define OMAP2_DEVICE_TYPE_EMU           1
41 #define OMAP2_DEVICE_TYPE_SEC           2
42 #define OMAP2_DEVICE_TYPE_GP            3
43 #define OMAP2_DEVICE_TYPE_BAD           4
44
45 #ifdef CONFIG_MACH_OMAP3_PANDORA
46 #define omap_type() OMAP2_DEVICE_TYPE_GP
47 #else
48 int __pure omap_type(void);
49 #endif
50
51 /*
52  * omap_rev bits:
53  * CPU id bits  (0730, 1510, 1710, 2422...)     [31:16]
54  * CPU revision (See _REV_ defined in cpu.h)    [15:08]
55  * CPU class bits (15xx, 16xx, 24xx, 34xx...)   [07:00]
56  */
57 unsigned int __pure omap_rev(void);
58
59 /*
60  * Get the CPU revision for OMAP devices
61  */
62 #define GET_OMAP_REVISION()     ((omap_rev() >> 8) & 0xff)
63
64 /*
65  * Macros to group OMAP into cpu classes.
66  * These can be used in most places.
67  * cpu_is_omap7xx():    True for OMAP730, OMAP850
68  * cpu_is_omap15xx():   True for OMAP1510, OMAP5910 and OMAP310
69  * cpu_is_omap16xx():   True for OMAP1610, OMAP5912 and OMAP1710
70  * cpu_is_omap24xx():   True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
71  * cpu_is_omap242x():   True for OMAP2420, OMAP2422, OMAP2423
72  * cpu_is_omap243x():   True for OMAP2430
73  * cpu_is_omap343x():   True for OMAP3430
74  * cpu_is_omap443x():   True for OMAP4430
75  * cpu_is_omap446x():   True for OMAP4460
76  */
77 #define GET_OMAP_CLASS  (omap_rev() & 0xff)
78
79 #define IS_OMAP_CLASS(class, id)                        \
80 static inline int is_omap ##class (void)                \
81 {                                                       \
82         return (GET_OMAP_CLASS == (id)) ? 1 : 0;        \
83 }
84
85 #define GET_OMAP_SUBCLASS       ((omap_rev() >> 20) & 0x0fff)
86
87 #define IS_OMAP_SUBCLASS(subclass, id)                  \
88 static inline int is_omap ##subclass (void)             \
89 {                                                       \
90         return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;     \
91 }
92
93 #define IS_TI_SUBCLASS(subclass, id)                    \
94 static inline int is_ti ##subclass (void)               \
95 {                                                       \
96         return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;     \
97 }
98
99 IS_OMAP_CLASS(7xx, 0x07)
100 IS_OMAP_CLASS(15xx, 0x15)
101 IS_OMAP_CLASS(16xx, 0x16)
102 IS_OMAP_CLASS(24xx, 0x24)
103 IS_OMAP_CLASS(34xx, 0x34)
104 IS_OMAP_CLASS(44xx, 0x44)
105
106 IS_OMAP_SUBCLASS(242x, 0x242)
107 IS_OMAP_SUBCLASS(243x, 0x243)
108 IS_OMAP_SUBCLASS(343x, 0x343)
109 IS_OMAP_SUBCLASS(363x, 0x363)
110 IS_OMAP_SUBCLASS(443x, 0x443)
111 IS_OMAP_SUBCLASS(446x, 0x446)
112
113 IS_TI_SUBCLASS(816x, 0x816)
114
115 #define cpu_is_omap7xx()                0
116 #define cpu_is_omap15xx()               0
117 #define cpu_is_omap16xx()               0
118 #define cpu_is_omap24xx()               0
119 #define cpu_is_omap242x()               0
120 #define cpu_is_omap243x()               0
121 #define cpu_is_omap34xx()               0
122 #define cpu_is_omap343x()               0
123 #define cpu_is_ti816x()                 0
124 #define cpu_is_omap44xx()               0
125 #define cpu_is_omap443x()               0
126 #define cpu_is_omap446x()               0
127
128 #if defined(MULTI_OMAP1)
129 # if defined(CONFIG_ARCH_OMAP730)
130 #  undef  cpu_is_omap7xx
131 #  define cpu_is_omap7xx()              is_omap7xx()
132 # endif
133 # if defined(CONFIG_ARCH_OMAP850)
134 #  undef  cpu_is_omap7xx
135 #  define cpu_is_omap7xx()              is_omap7xx()
136 # endif
137 # if defined(CONFIG_ARCH_OMAP15XX)
138 #  undef  cpu_is_omap15xx
139 #  define cpu_is_omap15xx()             is_omap15xx()
140 # endif
141 # if defined(CONFIG_ARCH_OMAP16XX)
142 #  undef  cpu_is_omap16xx
143 #  define cpu_is_omap16xx()             is_omap16xx()
144 # endif
145 #else
146 # if defined(CONFIG_ARCH_OMAP730)
147 #  undef  cpu_is_omap7xx
148 #  define cpu_is_omap7xx()              1
149 # endif
150 # if defined(CONFIG_ARCH_OMAP850)
151 #  undef  cpu_is_omap7xx
152 #  define cpu_is_omap7xx()              1
153 # endif
154 # if defined(CONFIG_ARCH_OMAP15XX)
155 #  undef  cpu_is_omap15xx
156 #  define cpu_is_omap15xx()             1
157 # endif
158 # if defined(CONFIG_ARCH_OMAP16XX)
159 #  undef  cpu_is_omap16xx
160 #  define cpu_is_omap16xx()             1
161 # endif
162 #endif
163
164 #if defined(MULTI_OMAP2)
165 # if defined(CONFIG_ARCH_OMAP2)
166 #  undef  cpu_is_omap24xx
167 #  define cpu_is_omap24xx()             is_omap24xx()
168 # endif
169 # if defined (CONFIG_SOC_OMAP2420)
170 #  undef  cpu_is_omap242x
171 #  define cpu_is_omap242x()             is_omap242x()
172 # endif
173 # if defined (CONFIG_SOC_OMAP2430)
174 #  undef  cpu_is_omap243x
175 #  define cpu_is_omap243x()             is_omap243x()
176 # endif
177 # if defined(CONFIG_ARCH_OMAP3)
178 #  undef  cpu_is_omap34xx
179 #  undef  cpu_is_omap343x
180 #  define cpu_is_omap34xx()             is_omap34xx()
181 #  define cpu_is_omap343x()             is_omap343x()
182 # endif
183 #else
184 # if defined(CONFIG_ARCH_OMAP2)
185 #  undef  cpu_is_omap24xx
186 #  define cpu_is_omap24xx()             1
187 # endif
188 # if defined(CONFIG_SOC_OMAP2420)
189 #  undef  cpu_is_omap242x
190 #  define cpu_is_omap242x()             1
191 # endif
192 # if defined(CONFIG_SOC_OMAP2430)
193 #  undef  cpu_is_omap243x
194 #  define cpu_is_omap243x()             1
195 # endif
196 # if defined(CONFIG_ARCH_OMAP3)
197 #  undef  cpu_is_omap34xx
198 #  define cpu_is_omap34xx()             1
199 # endif
200 # if defined(CONFIG_SOC_OMAP3430)
201 #  undef  cpu_is_omap343x
202 #  define cpu_is_omap343x()             1
203 # endif
204 #endif
205
206 /*
207  * Macros to detect individual cpu types.
208  * These are only rarely needed.
209  * cpu_is_omap330():    True for OMAP330
210  * cpu_is_omap730():    True for OMAP730
211  * cpu_is_omap850():    True for OMAP850
212  * cpu_is_omap1510():   True for OMAP1510
213  * cpu_is_omap1610():   True for OMAP1610
214  * cpu_is_omap1611():   True for OMAP1611
215  * cpu_is_omap5912():   True for OMAP5912
216  * cpu_is_omap1621():   True for OMAP1621
217  * cpu_is_omap1710():   True for OMAP1710
218  * cpu_is_omap2420():   True for OMAP2420
219  * cpu_is_omap2422():   True for OMAP2422
220  * cpu_is_omap2423():   True for OMAP2423
221  * cpu_is_omap2430():   True for OMAP2430
222  * cpu_is_omap3430():   True for OMAP3430
223  * cpu_is_omap4430():   True for OMAP4430
224  * cpu_is_omap3505():   True for OMAP3505
225  * cpu_is_omap3517():   True for OMAP3517
226  */
227 #define GET_OMAP_TYPE   ((omap_rev() >> 16) & 0xffff)
228
229 #define IS_OMAP_TYPE(type, id)                          \
230 static inline int is_omap ##type (void)                 \
231 {                                                       \
232         return (GET_OMAP_TYPE == (id)) ? 1 : 0;         \
233 }
234
235 IS_OMAP_TYPE(310, 0x0310)
236 IS_OMAP_TYPE(730, 0x0730)
237 IS_OMAP_TYPE(850, 0x0850)
238 IS_OMAP_TYPE(1510, 0x1510)
239 IS_OMAP_TYPE(1610, 0x1610)
240 IS_OMAP_TYPE(1611, 0x1611)
241 IS_OMAP_TYPE(5912, 0x1611)
242 IS_OMAP_TYPE(1621, 0x1621)
243 IS_OMAP_TYPE(1710, 0x1710)
244 IS_OMAP_TYPE(2420, 0x2420)
245 IS_OMAP_TYPE(2422, 0x2422)
246 IS_OMAP_TYPE(2423, 0x2423)
247 IS_OMAP_TYPE(2430, 0x2430)
248 IS_OMAP_TYPE(3430, 0x3430)
249 IS_OMAP_TYPE(3505, 0x3517)
250 IS_OMAP_TYPE(3517, 0x3517)
251
252 #define cpu_is_omap310()                0
253 #define cpu_is_omap730()                0
254 #define cpu_is_omap850()                0
255 #define cpu_is_omap1510()               0
256 #define cpu_is_omap1610()               0
257 #define cpu_is_omap5912()               0
258 #define cpu_is_omap1611()               0
259 #define cpu_is_omap1621()               0
260 #define cpu_is_omap1710()               0
261 #define cpu_is_omap2420()               0
262 #define cpu_is_omap2422()               0
263 #define cpu_is_omap2423()               0
264 #define cpu_is_omap2430()               0
265 #define cpu_is_omap3503()               0
266 #define cpu_is_omap3515()               0
267 #define cpu_is_omap3525()               0
268 #define cpu_is_omap3530()               0
269 #define cpu_is_omap3505()               0
270 #define cpu_is_omap3517()               0
271 #define cpu_is_omap3430()               0
272 #define cpu_is_omap4430()               0
273 #define cpu_is_omap3630()               0
274
275 /*
276  * Whether we have MULTI_OMAP1 or not, we still need to distinguish
277  * between 730 vs 850, 330 vs. 1510 and 1611B/5912 vs. 1710.
278  */
279
280 #if defined(CONFIG_ARCH_OMAP730)
281 # undef  cpu_is_omap730
282 # define cpu_is_omap730()               is_omap730()
283 #endif
284
285 #if defined(CONFIG_ARCH_OMAP850)
286 # undef  cpu_is_omap850
287 # define cpu_is_omap850()               is_omap850()
288 #endif
289
290 #if defined(CONFIG_ARCH_OMAP15XX)
291 # undef  cpu_is_omap310
292 # undef  cpu_is_omap1510
293 # define cpu_is_omap310()               is_omap310()
294 # define cpu_is_omap1510()              is_omap1510()
295 #endif
296
297 #if defined(CONFIG_ARCH_OMAP16XX)
298 # undef  cpu_is_omap1610
299 # undef  cpu_is_omap1611
300 # undef  cpu_is_omap5912
301 # undef  cpu_is_omap1621
302 # undef  cpu_is_omap1710
303 # define cpu_is_omap1610()              is_omap1610()
304 # define cpu_is_omap1611()              is_omap1611()
305 # define cpu_is_omap5912()              is_omap5912()
306 # define cpu_is_omap1621()              is_omap1621()
307 # define cpu_is_omap1710()              is_omap1710()
308 #endif
309
310 #if defined(CONFIG_ARCH_OMAP2)
311 # undef  cpu_is_omap2420
312 # undef  cpu_is_omap2422
313 # undef  cpu_is_omap2423
314 # undef  cpu_is_omap2430
315 # define cpu_is_omap2420()              is_omap2420()
316 # define cpu_is_omap2422()              is_omap2422()
317 # define cpu_is_omap2423()              is_omap2423()
318 # define cpu_is_omap2430()              is_omap2430()
319 #endif
320
321 #if defined(CONFIG_ARCH_OMAP3)
322 # undef cpu_is_omap3430
323 # undef cpu_is_omap3503
324 # undef cpu_is_omap3515
325 # undef cpu_is_omap3525
326 # undef cpu_is_omap3530
327 # undef cpu_is_omap3505
328 # undef cpu_is_omap3517
329 # undef cpu_is_ti816x
330 # define cpu_is_omap3430()              is_omap3430()
331 # define cpu_is_omap3503()              (cpu_is_omap3430() &&           \
332                                                 (!omap3_has_iva()) &&   \
333                                                 (!omap3_has_sgx()))
334 # define cpu_is_omap3515()              (cpu_is_omap3430() &&           \
335                                                 (!omap3_has_iva()) &&   \
336                                                 (omap3_has_sgx()))
337 # define cpu_is_omap3525()              (cpu_is_omap3430() &&           \
338                                                 (!omap3_has_sgx()) &&   \
339                                                 (omap3_has_iva()))
340 # define cpu_is_omap3530()              (cpu_is_omap3430())
341 # define cpu_is_omap3517()              is_omap3517()
342 # define cpu_is_omap3505()              (cpu_is_omap3517() &&           \
343                                                 !omap3_has_sgx())
344 # undef cpu_is_omap3630
345 # define cpu_is_omap3630()              is_omap363x()
346 # define cpu_is_ti816x()                is_ti816x()
347 #endif
348
349 # if defined(CONFIG_ARCH_OMAP4)
350 # undef cpu_is_omap44xx
351 # undef cpu_is_omap443x
352 # undef cpu_is_omap446x
353 # define cpu_is_omap44xx()              is_omap44xx()
354 # define cpu_is_omap443x()              is_omap443x()
355 # define cpu_is_omap446x()              is_omap446x()
356 # endif
357
358 /* Macros to detect if we have OMAP1 or OMAP2 */
359 #define cpu_class_is_omap1()    (cpu_is_omap7xx() || cpu_is_omap15xx() || \
360                                 cpu_is_omap16xx())
361 #define cpu_class_is_omap2()    (cpu_is_omap24xx() || cpu_is_omap34xx() || \
362                                 cpu_is_omap44xx())
363
364 /* Various silicon revisions for omap2 */
365 #define OMAP242X_CLASS          0x24200024
366 #define OMAP2420_REV_ES1_0      OMAP242X_CLASS
367 #define OMAP2420_REV_ES2_0      (OMAP242X_CLASS | (0x1 << 8))
368
369 #define OMAP243X_CLASS          0x24300024
370 #define OMAP2430_REV_ES1_0      OMAP243X_CLASS
371
372 #define OMAP343X_CLASS          0x34300034
373 #define OMAP3430_REV_ES1_0      OMAP343X_CLASS
374 #define OMAP3430_REV_ES2_0      (OMAP343X_CLASS | (0x1 << 8))
375 #define OMAP3430_REV_ES2_1      (OMAP343X_CLASS | (0x2 << 8))
376 #define OMAP3430_REV_ES3_0      (OMAP343X_CLASS | (0x3 << 8))
377 #define OMAP3430_REV_ES3_1      (OMAP343X_CLASS | (0x4 << 8))
378 #define OMAP3430_REV_ES3_1_2    (OMAP343X_CLASS | (0x5 << 8))
379
380 #define OMAP363X_CLASS          0x36300034
381 #define OMAP3630_REV_ES1_0      OMAP363X_CLASS
382 #define OMAP3630_REV_ES1_1      (OMAP363X_CLASS | (0x1 << 8))
383 #define OMAP3630_REV_ES1_2      (OMAP363X_CLASS | (0x2 << 8))
384
385 #define OMAP3517_CLASS          0x35170034
386 #define OMAP3517_REV_ES1_0      OMAP3517_CLASS
387 #define OMAP3517_REV_ES1_1      (OMAP3517_CLASS | (0x1 << 8))
388
389 #define TI816X_CLASS            0x81600034
390 #define TI8168_REV_ES1_0        TI816X_CLASS
391 #define TI8168_REV_ES1_1        (TI816X_CLASS | (0x1 << 8))
392
393 #define OMAP443X_CLASS          0x44300044
394 #define OMAP4430_REV_ES1_0      (OMAP443X_CLASS | (0x10 << 8))
395 #define OMAP4430_REV_ES2_0      (OMAP443X_CLASS | (0x20 << 8))
396 #define OMAP4430_REV_ES2_1      (OMAP443X_CLASS | (0x21 << 8))
397 #define OMAP4430_REV_ES2_2      (OMAP443X_CLASS | (0x22 << 8))
398
399 #define OMAP446X_CLASS          0x44600044
400 #define OMAP4460_REV_ES1_0      (OMAP446X_CLASS | (0x10 << 8))
401
402 #define OMAP447X_CLASS          0x44700044
403 #define OMAP4470_REV_ES1_0      (OMAP447X_CLASS | (0x10 << 8))
404
405 void omap2xxx_check_revision(void);
406 void omap3xxx_check_revision(void);
407 void omap4xxx_check_revision(void);
408 void omap3xxx_check_features(void);
409 void ti81xx_check_features(void);
410 void omap4xxx_check_features(void);
411
412 /*
413  * Runtime detection of OMAP3 features
414  *
415  * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
416  *    family have OS-level control over the I/O chain clock.  This is
417  *    to avoid a window during which wakeups could potentially be lost
418  *    during powerdomain transitions.  If this bit is set, it
419  *    indicates that the chip does support OS-level control of this
420  *    feature.
421  */
422 extern u32 omap_features;
423
424 #define OMAP3_HAS_L2CACHE               BIT(0)
425 #define OMAP3_HAS_IVA                   BIT(1)
426 #define OMAP3_HAS_SGX                   BIT(2)
427 #define OMAP3_HAS_NEON                  BIT(3)
428 #define OMAP3_HAS_ISP                   BIT(4)
429 #define OMAP3_HAS_192MHZ_CLK            BIT(5)
430 #define OMAP3_HAS_IO_WAKEUP             BIT(6)
431 #define OMAP3_HAS_SDRC                  BIT(7)
432 #define OMAP3_HAS_IO_CHAIN_CTRL         BIT(8)
433 #define OMAP4_HAS_MPU_1GHZ              BIT(9)
434 #define OMAP4_HAS_MPU_1_2GHZ            BIT(10)
435 #define OMAP4_HAS_MPU_1_5GHZ            BIT(11)
436
437
438 #define OMAP3_HAS_FEATURE(feat,flag)                    \
439 static inline unsigned int omap3_has_ ##feat(void)      \
440 {                                                       \
441         return omap_features & OMAP3_HAS_ ##flag;       \
442 }                                                       \
443
444 OMAP3_HAS_FEATURE(l2cache, L2CACHE)
445 OMAP3_HAS_FEATURE(sgx, SGX)
446 OMAP3_HAS_FEATURE(iva, IVA)
447 OMAP3_HAS_FEATURE(neon, NEON)
448 OMAP3_HAS_FEATURE(isp, ISP)
449 OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
450 OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
451 OMAP3_HAS_FEATURE(sdrc, SDRC)
452 OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
453
454 /*
455  * Runtime detection of OMAP4 features
456  */
457 #define OMAP4_HAS_FEATURE(feat, flag)                   \
458 static inline unsigned int omap4_has_ ##feat(void)      \
459 {                                                       \
460         return omap_features & OMAP4_HAS_ ##flag;       \
461 }                                                       \
462
463 OMAP4_HAS_FEATURE(mpu_1ghz, MPU_1GHZ)
464 OMAP4_HAS_FEATURE(mpu_1_2ghz, MPU_1_2GHZ)
465 OMAP4_HAS_FEATURE(mpu_1_5ghz, MPU_1_5GHZ)
466
467 #endif