Merge tag 'drivers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[linux-2.6.git] / arch / arm / mach-omap2 / soc.h
blob8c616e436bc7bcf0ff1d4ac2ac11eb9497535ce4
1 /*
2 * OMAP cpu type detection
4 * Copyright (C) 2004, 2008 Nokia Corporation
6 * Copyright (C) 2009-11 Texas Instruments.
8 * Written by Tony Lindgren <tony.lindgren@nokia.com>
10 * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "omap24xx.h"
29 #include "omap34xx.h"
30 #include "omap44xx.h"
31 #include "ti81xx.h"
32 #include "am33xx.h"
33 #include "omap54xx.h"
35 #ifndef __ASSEMBLY__
37 #include <linux/bitops.h>
40 * Test if multicore OMAP support is needed
42 #undef MULTI_OMAP2
43 #undef OMAP_NAME
45 #ifdef CONFIG_ARCH_MULTIPLATFORM
46 #define MULTI_OMAP2
47 #endif
48 #ifdef CONFIG_SOC_OMAP2420
49 # ifdef OMAP_NAME
50 # undef MULTI_OMAP2
51 # define MULTI_OMAP2
52 # else
53 # define OMAP_NAME omap2420
54 # endif
55 #endif
56 #ifdef CONFIG_SOC_OMAP2430
57 # ifdef OMAP_NAME
58 # undef MULTI_OMAP2
59 # define MULTI_OMAP2
60 # else
61 # define OMAP_NAME omap2430
62 # endif
63 #endif
64 #ifdef CONFIG_ARCH_OMAP3
65 # ifdef OMAP_NAME
66 # undef MULTI_OMAP2
67 # define MULTI_OMAP2
68 # else
69 # define OMAP_NAME omap3
70 # endif
71 #endif
72 #ifdef CONFIG_ARCH_OMAP4
73 # ifdef OMAP_NAME
74 # undef MULTI_OMAP2
75 # define MULTI_OMAP2
76 # else
77 # define OMAP_NAME omap4
78 # endif
79 #endif
81 #ifdef CONFIG_SOC_OMAP5
82 # ifdef OMAP_NAME
83 # undef MULTI_OMAP2
84 # define MULTI_OMAP2
85 # else
86 # define OMAP_NAME omap5
87 # endif
88 #endif
90 #ifdef CONFIG_SOC_AM33XX
91 # ifdef OMAP_NAME
92 # undef MULTI_OMAP2
93 # define MULTI_OMAP2
94 # else
95 # define OMAP_NAME am33xx
96 # endif
97 #endif
99 #ifdef CONFIG_SOC_AM43XX
100 # ifdef OMAP_NAME
101 # undef MULTI_OMAP2
102 # define MULTI_OMAP2
103 # else
104 # define OMAP_NAME am43xx
105 # endif
106 #endif
109 * Omap device type i.e. EMU/HS/TST/GP/BAD
111 #define OMAP2_DEVICE_TYPE_TEST 0
112 #define OMAP2_DEVICE_TYPE_EMU 1
113 #define OMAP2_DEVICE_TYPE_SEC 2
114 #define OMAP2_DEVICE_TYPE_GP 3
115 #define OMAP2_DEVICE_TYPE_BAD 4
117 int omap_type(void);
120 * omap_rev bits:
121 * CPU id bits (0730, 1510, 1710, 2422...) [31:16]
122 * CPU revision (See _REV_ defined in cpu.h) [15:08]
123 * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
125 unsigned int omap_rev(void);
127 static inline int soc_is_omap(void)
129 return omap_rev() != 0;
133 * Get the CPU revision for OMAP devices
135 #define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
138 * Macros to group OMAP into cpu classes.
139 * These can be used in most places.
140 * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
141 * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
142 * cpu_is_omap243x(): True for OMAP2430
143 * cpu_is_omap343x(): True for OMAP3430
144 * cpu_is_omap443x(): True for OMAP4430
145 * cpu_is_omap446x(): True for OMAP4460
146 * cpu_is_omap447x(): True for OMAP4470
147 * soc_is_omap543x(): True for OMAP5430, OMAP5432
149 #define GET_OMAP_CLASS (omap_rev() & 0xff)
151 #define IS_OMAP_CLASS(class, id) \
152 static inline int is_omap ##class (void) \
154 return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
157 #define GET_AM_CLASS ((omap_rev() >> 24) & 0xff)
159 #define IS_AM_CLASS(class, id) \
160 static inline int is_am ##class (void) \
162 return (GET_AM_CLASS == (id)) ? 1 : 0; \
165 #define GET_TI_CLASS ((omap_rev() >> 24) & 0xff)
167 #define IS_TI_CLASS(class, id) \
168 static inline int is_ti ##class (void) \
170 return (GET_TI_CLASS == (id)) ? 1 : 0; \
173 #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
175 #define IS_OMAP_SUBCLASS(subclass, id) \
176 static inline int is_omap ##subclass (void) \
178 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
181 #define IS_TI_SUBCLASS(subclass, id) \
182 static inline int is_ti ##subclass (void) \
184 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
187 #define IS_AM_SUBCLASS(subclass, id) \
188 static inline int is_am ##subclass (void) \
190 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
193 IS_OMAP_CLASS(24xx, 0x24)
194 IS_OMAP_CLASS(34xx, 0x34)
195 IS_OMAP_CLASS(44xx, 0x44)
196 IS_AM_CLASS(35xx, 0x35)
197 IS_OMAP_CLASS(54xx, 0x54)
198 IS_AM_CLASS(33xx, 0x33)
199 IS_AM_CLASS(43xx, 0x43)
201 IS_TI_CLASS(81xx, 0x81)
203 IS_OMAP_SUBCLASS(242x, 0x242)
204 IS_OMAP_SUBCLASS(243x, 0x243)
205 IS_OMAP_SUBCLASS(343x, 0x343)
206 IS_OMAP_SUBCLASS(363x, 0x363)
207 IS_OMAP_SUBCLASS(443x, 0x443)
208 IS_OMAP_SUBCLASS(446x, 0x446)
209 IS_OMAP_SUBCLASS(447x, 0x447)
210 IS_OMAP_SUBCLASS(543x, 0x543)
212 IS_TI_SUBCLASS(816x, 0x816)
213 IS_TI_SUBCLASS(814x, 0x814)
214 IS_AM_SUBCLASS(335x, 0x335)
215 IS_AM_SUBCLASS(437x, 0x437)
217 #define cpu_is_omap24xx() 0
218 #define cpu_is_omap242x() 0
219 #define cpu_is_omap243x() 0
220 #define cpu_is_omap34xx() 0
221 #define cpu_is_omap343x() 0
222 #define cpu_is_ti81xx() 0
223 #define cpu_is_ti816x() 0
224 #define cpu_is_ti814x() 0
225 #define soc_is_am35xx() 0
226 #define soc_is_am33xx() 0
227 #define soc_is_am335x() 0
228 #define soc_is_am43xx() 0
229 #define soc_is_am437x() 0
230 #define cpu_is_omap44xx() 0
231 #define cpu_is_omap443x() 0
232 #define cpu_is_omap446x() 0
233 #define cpu_is_omap447x() 0
234 #define soc_is_omap54xx() 0
235 #define soc_is_omap543x() 0
237 #if defined(MULTI_OMAP2)
238 # if defined(CONFIG_ARCH_OMAP2)
239 # undef cpu_is_omap24xx
240 # define cpu_is_omap24xx() is_omap24xx()
241 # endif
242 # if defined (CONFIG_SOC_OMAP2420)
243 # undef cpu_is_omap242x
244 # define cpu_is_omap242x() is_omap242x()
245 # endif
246 # if defined (CONFIG_SOC_OMAP2430)
247 # undef cpu_is_omap243x
248 # define cpu_is_omap243x() is_omap243x()
249 # endif
250 # if defined(CONFIG_ARCH_OMAP3)
251 # undef cpu_is_omap34xx
252 # undef cpu_is_omap343x
253 # define cpu_is_omap34xx() is_omap34xx()
254 # define cpu_is_omap343x() is_omap343x()
255 # endif
256 #else
257 # if defined(CONFIG_ARCH_OMAP2)
258 # undef cpu_is_omap24xx
259 # define cpu_is_omap24xx() 1
260 # endif
261 # if defined(CONFIG_SOC_OMAP2420)
262 # undef cpu_is_omap242x
263 # define cpu_is_omap242x() 1
264 # endif
265 # if defined(CONFIG_SOC_OMAP2430)
266 # undef cpu_is_omap243x
267 # define cpu_is_omap243x() 1
268 # endif
269 # if defined(CONFIG_ARCH_OMAP3)
270 # undef cpu_is_omap34xx
271 # define cpu_is_omap34xx() 1
272 # endif
273 # if defined(CONFIG_SOC_OMAP3430)
274 # undef cpu_is_omap343x
275 # define cpu_is_omap343x() 1
276 # endif
277 #endif
280 * Macros to detect individual cpu types.
281 * These are only rarely needed.
282 * cpu_is_omap2420(): True for OMAP2420
283 * cpu_is_omap2422(): True for OMAP2422
284 * cpu_is_omap2423(): True for OMAP2423
285 * cpu_is_omap2430(): True for OMAP2430
286 * cpu_is_omap3430(): True for OMAP3430
288 #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
290 #define IS_OMAP_TYPE(type, id) \
291 static inline int is_omap ##type (void) \
293 return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
296 IS_OMAP_TYPE(2420, 0x2420)
297 IS_OMAP_TYPE(2422, 0x2422)
298 IS_OMAP_TYPE(2423, 0x2423)
299 IS_OMAP_TYPE(2430, 0x2430)
300 IS_OMAP_TYPE(3430, 0x3430)
302 #define cpu_is_omap2420() 0
303 #define cpu_is_omap2422() 0
304 #define cpu_is_omap2423() 0
305 #define cpu_is_omap2430() 0
306 #define cpu_is_omap3430() 0
307 #define cpu_is_omap3630() 0
308 #define soc_is_omap5430() 0
310 /* These are needed for the common code */
311 #ifdef CONFIG_ARCH_OMAP2PLUS
312 #define cpu_is_omap7xx() 0
313 #define cpu_is_omap15xx() 0
314 #define cpu_is_omap16xx() 0
315 #define cpu_is_omap1510() 0
316 #define cpu_is_omap1610() 0
317 #define cpu_is_omap1611() 0
318 #define cpu_is_omap1621() 0
319 #define cpu_is_omap1710() 0
320 #define cpu_class_is_omap1() 0
321 #define cpu_class_is_omap2() 1
322 #endif
324 #if defined(CONFIG_ARCH_OMAP2)
325 # undef cpu_is_omap2420
326 # undef cpu_is_omap2422
327 # undef cpu_is_omap2423
328 # undef cpu_is_omap2430
329 # define cpu_is_omap2420() is_omap2420()
330 # define cpu_is_omap2422() is_omap2422()
331 # define cpu_is_omap2423() is_omap2423()
332 # define cpu_is_omap2430() is_omap2430()
333 #endif
335 #if defined(CONFIG_ARCH_OMAP3)
336 # undef cpu_is_omap3430
337 # undef cpu_is_ti81xx
338 # undef cpu_is_ti816x
339 # undef cpu_is_ti814x
340 # undef soc_is_am35xx
341 # define cpu_is_omap3430() is_omap3430()
342 # undef cpu_is_omap3630
343 # define cpu_is_omap3630() is_omap363x()
344 # define cpu_is_ti81xx() is_ti81xx()
345 # define cpu_is_ti816x() is_ti816x()
346 # define cpu_is_ti814x() is_ti814x()
347 # define soc_is_am35xx() is_am35xx()
348 #endif
350 # if defined(CONFIG_SOC_AM33XX)
351 # undef soc_is_am33xx
352 # undef soc_is_am335x
353 # define soc_is_am33xx() is_am33xx()
354 # define soc_is_am335x() is_am335x()
355 #endif
357 #ifdef CONFIG_SOC_AM43XX
358 # undef soc_is_am43xx
359 # undef soc_is_am437x
360 # define soc_is_am43xx() is_am43xx()
361 # define soc_is_am437x() is_am437x()
362 #endif
364 # if defined(CONFIG_ARCH_OMAP4)
365 # undef cpu_is_omap44xx
366 # undef cpu_is_omap443x
367 # undef cpu_is_omap446x
368 # undef cpu_is_omap447x
369 # define cpu_is_omap44xx() is_omap44xx()
370 # define cpu_is_omap443x() is_omap443x()
371 # define cpu_is_omap446x() is_omap446x()
372 # define cpu_is_omap447x() is_omap447x()
373 # endif
375 # if defined(CONFIG_SOC_OMAP5)
376 # undef soc_is_omap54xx
377 # undef soc_is_omap543x
378 # define soc_is_omap54xx() is_omap54xx()
379 # define soc_is_omap543x() is_omap543x()
380 #endif
382 /* Various silicon revisions for omap2 */
383 #define OMAP242X_CLASS 0x24200024
384 #define OMAP2420_REV_ES1_0 OMAP242X_CLASS
385 #define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (0x1 << 8))
387 #define OMAP243X_CLASS 0x24300024
388 #define OMAP2430_REV_ES1_0 OMAP243X_CLASS
390 #define OMAP343X_CLASS 0x34300034
391 #define OMAP3430_REV_ES1_0 OMAP343X_CLASS
392 #define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (0x1 << 8))
393 #define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (0x2 << 8))
394 #define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (0x3 << 8))
395 #define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (0x4 << 8))
396 #define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (0x5 << 8))
398 #define OMAP363X_CLASS 0x36300034
399 #define OMAP3630_REV_ES1_0 OMAP363X_CLASS
400 #define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (0x1 << 8))
401 #define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (0x2 << 8))
403 #define TI816X_CLASS 0x81600034
404 #define TI8168_REV_ES1_0 TI816X_CLASS
405 #define TI8168_REV_ES1_1 (TI816X_CLASS | (0x1 << 8))
406 #define TI8168_REV_ES2_0 (TI816X_CLASS | (0x2 << 8))
407 #define TI8168_REV_ES2_1 (TI816X_CLASS | (0x3 << 8))
409 #define TI814X_CLASS 0x81400034
410 #define TI8148_REV_ES1_0 TI814X_CLASS
411 #define TI8148_REV_ES2_0 (TI814X_CLASS | (0x1 << 8))
412 #define TI8148_REV_ES2_1 (TI814X_CLASS | (0x2 << 8))
414 #define AM35XX_CLASS 0x35170034
415 #define AM35XX_REV_ES1_0 AM35XX_CLASS
416 #define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8))
418 #define AM335X_CLASS 0x33500033
419 #define AM335X_REV_ES1_0 AM335X_CLASS
420 #define AM335X_REV_ES2_0 (AM335X_CLASS | (0x1 << 8))
421 #define AM335X_REV_ES2_1 (AM335X_CLASS | (0x2 << 8))
423 #define AM437X_CLASS 0x43700000
424 #define AM437X_REV_ES1_0 AM437X_CLASS
426 #define OMAP443X_CLASS 0x44300044
427 #define OMAP4430_REV_ES1_0 (OMAP443X_CLASS | (0x10 << 8))
428 #define OMAP4430_REV_ES2_0 (OMAP443X_CLASS | (0x20 << 8))
429 #define OMAP4430_REV_ES2_1 (OMAP443X_CLASS | (0x21 << 8))
430 #define OMAP4430_REV_ES2_2 (OMAP443X_CLASS | (0x22 << 8))
431 #define OMAP4430_REV_ES2_3 (OMAP443X_CLASS | (0x23 << 8))
433 #define OMAP446X_CLASS 0x44600044
434 #define OMAP4460_REV_ES1_0 (OMAP446X_CLASS | (0x10 << 8))
435 #define OMAP4460_REV_ES1_1 (OMAP446X_CLASS | (0x11 << 8))
437 #define OMAP447X_CLASS 0x44700044
438 #define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
440 #define OMAP54XX_CLASS 0x54000054
441 #define OMAP5430_REV_ES1_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x10 << 8))
442 #define OMAP5430_REV_ES2_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x20 << 8))
443 #define OMAP5432_REV_ES1_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x10 << 8))
444 #define OMAP5432_REV_ES2_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x20 << 8))
446 void omap2xxx_check_revision(void);
447 void omap3xxx_check_revision(void);
448 void omap4xxx_check_revision(void);
449 void omap5xxx_check_revision(void);
450 void omap3xxx_check_features(void);
451 void ti81xx_check_features(void);
452 void am33xx_check_features(void);
453 void omap4xxx_check_features(void);
456 * Runtime detection of OMAP3 features
458 * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
459 * family have OS-level control over the I/O chain clock. This is
460 * to avoid a window during which wakeups could potentially be lost
461 * during powerdomain transitions. If this bit is set, it
462 * indicates that the chip does support OS-level control of this
463 * feature.
465 extern u32 omap_features;
467 #define OMAP3_HAS_L2CACHE BIT(0)
468 #define OMAP3_HAS_IVA BIT(1)
469 #define OMAP3_HAS_SGX BIT(2)
470 #define OMAP3_HAS_NEON BIT(3)
471 #define OMAP3_HAS_ISP BIT(4)
472 #define OMAP3_HAS_192MHZ_CLK BIT(5)
473 #define OMAP3_HAS_IO_WAKEUP BIT(6)
474 #define OMAP3_HAS_SDRC BIT(7)
475 #define OMAP3_HAS_IO_CHAIN_CTRL BIT(8)
476 #define OMAP4_HAS_PERF_SILICON BIT(9)
479 #define OMAP3_HAS_FEATURE(feat,flag) \
480 static inline unsigned int omap3_has_ ##feat(void) \
482 return omap_features & OMAP3_HAS_ ##flag; \
485 OMAP3_HAS_FEATURE(l2cache, L2CACHE)
486 OMAP3_HAS_FEATURE(sgx, SGX)
487 OMAP3_HAS_FEATURE(iva, IVA)
488 OMAP3_HAS_FEATURE(neon, NEON)
489 OMAP3_HAS_FEATURE(isp, ISP)
490 OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
491 OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
492 OMAP3_HAS_FEATURE(sdrc, SDRC)
493 OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
496 * Runtime detection of OMAP4 features
498 #define OMAP4_HAS_FEATURE(feat, flag) \
499 static inline unsigned int omap4_has_ ##feat(void) \
501 return omap_features & OMAP4_HAS_ ##flag; \
504 OMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
507 * We need to make sure omap initcalls don't run when
508 * multiplatform kernels are booted on other SoCs.
510 #define omap_initcall(level, fn) \
511 static int __init __used __##fn(void) \
513 if (!soc_is_omap()) \
514 return 0; \
515 return fn(); \
517 level(__##fn);
519 #define omap_early_initcall(fn) omap_initcall(early_initcall, fn)
520 #define omap_core_initcall(fn) omap_initcall(core_initcall, fn)
521 #define omap_postcore_initcall(fn) omap_initcall(postcore_initcall, fn)
522 #define omap_arch_initcall(fn) omap_initcall(arch_initcall, fn)
523 #define omap_subsys_initcall(fn) omap_initcall(subsys_initcall, fn)
524 #define omap_device_initcall(fn) omap_initcall(device_initcall, fn)
525 #define omap_late_initcall(fn) omap_initcall(late_initcall, fn)
526 #define omap_late_initcall_sync(fn) omap_initcall(late_initcall_sync, fn)
528 #endif /* __ASSEMBLY__ */