]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/arm/plat-omap/include/plat/cpu.h
omap3: Replace ARCH_OMAP34XX with ARCH_OMAP3
[net-next-2.6.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 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
35 /*
36  * Omap device type i.e. EMU/HS/TST/GP/BAD
37  */
38 #define OMAP2_DEVICE_TYPE_TEST          0
39 #define OMAP2_DEVICE_TYPE_EMU           1
40 #define OMAP2_DEVICE_TYPE_SEC           2
41 #define OMAP2_DEVICE_TYPE_GP            3
42 #define OMAP2_DEVICE_TYPE_BAD           4
43
44 int omap_type(void);
45
46 struct omap_chip_id {
47         u16 oc;
48         u8 type;
49 };
50
51 #define OMAP_CHIP_INIT(x)       { .oc = x }
52
53 /*
54  * omap_rev bits:
55  * CPU id bits  (0730, 1510, 1710, 2422...)     [31:16]
56  * CPU revision (See _REV_ defined in cpu.h)    [15:08]
57  * CPU class bits (15xx, 16xx, 24xx, 34xx...)   [07:00]
58  */
59 unsigned int omap_rev(void);
60
61 /*
62  * Define CPU revision bits
63  *
64  * Verbose meaning of the revision bits may be different for a silicon
65  * family. This difference can be handled separately.
66  */
67 #define OMAP_REVBITS_00         0x00
68 #define OMAP_REVBITS_10         0x10
69 #define OMAP_REVBITS_20         0x20
70 #define OMAP_REVBITS_30         0x30
71 #define OMAP_REVBITS_40         0x40
72
73 /*
74  * Get the CPU revision for OMAP devices
75  */
76 #define GET_OMAP_REVISION()     ((omap_rev() >> 8) & 0xff)
77
78 /*
79  * Test if multicore OMAP support is needed
80  */
81 #undef MULTI_OMAP1
82 #undef MULTI_OMAP2
83 #undef OMAP_NAME
84
85 #ifdef CONFIG_ARCH_OMAP730
86 # ifdef OMAP_NAME
87 #  undef  MULTI_OMAP1
88 #  define MULTI_OMAP1
89 # else
90 #  define OMAP_NAME omap730
91 # endif
92 #endif
93 #ifdef CONFIG_ARCH_OMAP850
94 # ifdef OMAP_NAME
95 #  undef  MULTI_OMAP1
96 #  define MULTI_OMAP1
97 # else
98 #  define OMAP_NAME omap850
99 # endif
100 #endif
101 #ifdef CONFIG_ARCH_OMAP15XX
102 # ifdef OMAP_NAME
103 #  undef  MULTI_OMAP1
104 #  define MULTI_OMAP1
105 # else
106 #  define OMAP_NAME omap1510
107 # endif
108 #endif
109 #ifdef CONFIG_ARCH_OMAP16XX
110 # ifdef OMAP_NAME
111 #  undef  MULTI_OMAP1
112 #  define MULTI_OMAP1
113 # else
114 #  define OMAP_NAME omap16xx
115 # endif
116 #endif
117 #if (defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3))
118 # if (defined(OMAP_NAME) || defined(MULTI_OMAP1))
119 #  error "OMAP1 and OMAP2 can't be selected at the same time"
120 # endif
121 #endif
122 #ifdef CONFIG_ARCH_OMAP2420
123 # ifdef OMAP_NAME
124 #  undef  MULTI_OMAP2
125 #  define MULTI_OMAP2
126 # else
127 #  define OMAP_NAME omap2420
128 # endif
129 #endif
130 #ifdef CONFIG_ARCH_OMAP2430
131 # ifdef OMAP_NAME
132 #  undef  MULTI_OMAP2
133 #  define MULTI_OMAP2
134 # else
135 #  define OMAP_NAME omap2430
136 # endif
137 #endif
138 #ifdef CONFIG_ARCH_OMAP3430
139 # ifdef OMAP_NAME
140 #  undef  MULTI_OMAP2
141 #  define MULTI_OMAP2
142 # else
143 #  define OMAP_NAME omap3430
144 # endif
145 #endif
146
147 /*
148  * Macros to group OMAP into cpu classes.
149  * These can be used in most places.
150  * cpu_is_omap7xx():    True for OMAP730, OMAP850
151  * cpu_is_omap15xx():   True for OMAP1510, OMAP5910 and OMAP310
152  * cpu_is_omap16xx():   True for OMAP1610, OMAP5912 and OMAP1710
153  * cpu_is_omap24xx():   True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
154  * cpu_is_omap242x():   True for OMAP2420, OMAP2422, OMAP2423
155  * cpu_is_omap243x():   True for OMAP2430
156  * cpu_is_omap343x():   True for OMAP3430
157  * cpu_is_omap443x():   True for OMAP4430
158  */
159 #define GET_OMAP_CLASS  (omap_rev() & 0xff)
160
161 #define IS_OMAP_CLASS(class, id)                        \
162 static inline int is_omap ##class (void)                \
163 {                                                       \
164         return (GET_OMAP_CLASS == (id)) ? 1 : 0;        \
165 }
166
167 #define GET_OMAP_SUBCLASS       ((omap_rev() >> 20) & 0x0fff)
168
169 #define IS_OMAP_SUBCLASS(subclass, id)                  \
170 static inline int is_omap ##subclass (void)             \
171 {                                                       \
172         return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;     \
173 }
174
175 IS_OMAP_CLASS(7xx, 0x07)
176 IS_OMAP_CLASS(15xx, 0x15)
177 IS_OMAP_CLASS(16xx, 0x16)
178 IS_OMAP_CLASS(24xx, 0x24)
179 IS_OMAP_CLASS(34xx, 0x34)
180 IS_OMAP_CLASS(44xx, 0x44)
181
182 IS_OMAP_SUBCLASS(242x, 0x242)
183 IS_OMAP_SUBCLASS(243x, 0x243)
184 IS_OMAP_SUBCLASS(343x, 0x343)
185 IS_OMAP_SUBCLASS(363x, 0x363)
186 IS_OMAP_SUBCLASS(443x, 0x443)
187
188 #define cpu_is_omap7xx()                0
189 #define cpu_is_omap15xx()               0
190 #define cpu_is_omap16xx()               0
191 #define cpu_is_omap24xx()               0
192 #define cpu_is_omap242x()               0
193 #define cpu_is_omap243x()               0
194 #define cpu_is_omap34xx()               0
195 #define cpu_is_omap343x()               0
196 #define cpu_is_omap44xx()               0
197 #define cpu_is_omap443x()               0
198
199 #if defined(MULTI_OMAP1)
200 # if defined(CONFIG_ARCH_OMAP730)
201 #  undef  cpu_is_omap7xx
202 #  define cpu_is_omap7xx()              is_omap7xx()
203 # endif
204 # if defined(CONFIG_ARCH_OMAP850)
205 #  undef  cpu_is_omap7xx
206 #  define cpu_is_omap7xx()              is_omap7xx()
207 # endif
208 # if defined(CONFIG_ARCH_OMAP15XX)
209 #  undef  cpu_is_omap15xx
210 #  define cpu_is_omap15xx()             is_omap15xx()
211 # endif
212 # if defined(CONFIG_ARCH_OMAP16XX)
213 #  undef  cpu_is_omap16xx
214 #  define cpu_is_omap16xx()             is_omap16xx()
215 # endif
216 #else
217 # if defined(CONFIG_ARCH_OMAP730)
218 #  undef  cpu_is_omap7xx
219 #  define cpu_is_omap7xx()              1
220 # endif
221 # if defined(CONFIG_ARCH_OMAP850)
222 #  undef  cpu_is_omap7xx
223 #  define cpu_is_omap7xx()              1
224 # endif
225 # if defined(CONFIG_ARCH_OMAP15XX)
226 #  undef  cpu_is_omap15xx
227 #  define cpu_is_omap15xx()             1
228 # endif
229 # if defined(CONFIG_ARCH_OMAP16XX)
230 #  undef  cpu_is_omap16xx
231 #  define cpu_is_omap16xx()             1
232 # endif
233 #endif
234
235 #if defined(MULTI_OMAP2)
236 # if defined(CONFIG_ARCH_OMAP2)
237 #  undef  cpu_is_omap24xx
238 #  undef  cpu_is_omap242x
239 #  undef  cpu_is_omap243x
240 #  define cpu_is_omap24xx()             is_omap24xx()
241 #  define cpu_is_omap242x()             is_omap242x()
242 #  define cpu_is_omap243x()             is_omap243x()
243 # endif
244 # if defined(CONFIG_ARCH_OMAP3)
245 #  undef  cpu_is_omap34xx
246 #  undef  cpu_is_omap343x
247 #  define cpu_is_omap34xx()             is_omap34xx()
248 #  define cpu_is_omap343x()             is_omap343x()
249 # endif
250 #else
251 # if defined(CONFIG_ARCH_OMAP2)
252 #  undef  cpu_is_omap24xx
253 #  define cpu_is_omap24xx()             1
254 # endif
255 # if defined(CONFIG_ARCH_OMAP2420)
256 #  undef  cpu_is_omap242x
257 #  define cpu_is_omap242x()             1
258 # endif
259 # if defined(CONFIG_ARCH_OMAP2430)
260 #  undef  cpu_is_omap243x
261 #  define cpu_is_omap243x()             1
262 # endif
263 # if defined(CONFIG_ARCH_OMAP3)
264 #  undef  cpu_is_omap34xx
265 #  define cpu_is_omap34xx()             1
266 # endif
267 # if defined(CONFIG_ARCH_OMAP3430)
268 #  undef  cpu_is_omap343x
269 #  define cpu_is_omap343x()             1
270 # endif
271 #endif
272
273 /*
274  * Macros to detect individual cpu types.
275  * These are only rarely needed.
276  * cpu_is_omap330():    True for OMAP330
277  * cpu_is_omap730():    True for OMAP730
278  * cpu_is_omap850():    True for OMAP850
279  * cpu_is_omap1510():   True for OMAP1510
280  * cpu_is_omap1610():   True for OMAP1610
281  * cpu_is_omap1611():   True for OMAP1611
282  * cpu_is_omap5912():   True for OMAP5912
283  * cpu_is_omap1621():   True for OMAP1621
284  * cpu_is_omap1710():   True for OMAP1710
285  * cpu_is_omap2420():   True for OMAP2420
286  * cpu_is_omap2422():   True for OMAP2422
287  * cpu_is_omap2423():   True for OMAP2423
288  * cpu_is_omap2430():   True for OMAP2430
289  * cpu_is_omap3430():   True for OMAP3430
290  * cpu_is_omap4430():   True for OMAP4430
291  * cpu_is_omap3505():   True for OMAP3505
292  * cpu_is_omap3517():   True for OMAP3517
293  */
294 #define GET_OMAP_TYPE   ((omap_rev() >> 16) & 0xffff)
295
296 #define IS_OMAP_TYPE(type, id)                          \
297 static inline int is_omap ##type (void)                 \
298 {                                                       \
299         return (GET_OMAP_TYPE == (id)) ? 1 : 0;         \
300 }
301
302 IS_OMAP_TYPE(310, 0x0310)
303 IS_OMAP_TYPE(730, 0x0730)
304 IS_OMAP_TYPE(850, 0x0850)
305 IS_OMAP_TYPE(1510, 0x1510)
306 IS_OMAP_TYPE(1610, 0x1610)
307 IS_OMAP_TYPE(1611, 0x1611)
308 IS_OMAP_TYPE(5912, 0x1611)
309 IS_OMAP_TYPE(1621, 0x1621)
310 IS_OMAP_TYPE(1710, 0x1710)
311 IS_OMAP_TYPE(2420, 0x2420)
312 IS_OMAP_TYPE(2422, 0x2422)
313 IS_OMAP_TYPE(2423, 0x2423)
314 IS_OMAP_TYPE(2430, 0x2430)
315 IS_OMAP_TYPE(3430, 0x3430)
316 IS_OMAP_TYPE(3505, 0x3505)
317 IS_OMAP_TYPE(3517, 0x3517)
318
319 #define cpu_is_omap310()                0
320 #define cpu_is_omap730()                0
321 #define cpu_is_omap850()                0
322 #define cpu_is_omap1510()               0
323 #define cpu_is_omap1610()               0
324 #define cpu_is_omap5912()               0
325 #define cpu_is_omap1611()               0
326 #define cpu_is_omap1621()               0
327 #define cpu_is_omap1710()               0
328 #define cpu_is_omap2420()               0
329 #define cpu_is_omap2422()               0
330 #define cpu_is_omap2423()               0
331 #define cpu_is_omap2430()               0
332 #define cpu_is_omap3503()               0
333 #define cpu_is_omap3515()               0
334 #define cpu_is_omap3525()               0
335 #define cpu_is_omap3530()               0
336 #define cpu_is_omap3505()               0
337 #define cpu_is_omap3517()               0
338 #define cpu_is_omap3430()               0
339 #define cpu_is_omap4430()               0
340 #define cpu_is_omap3630()               0
341
342 /*
343  * Whether we have MULTI_OMAP1 or not, we still need to distinguish
344  * between 730 vs 850, 330 vs. 1510 and 1611B/5912 vs. 1710.
345  */
346
347 #if defined(CONFIG_ARCH_OMAP730)
348 # undef  cpu_is_omap730
349 # define cpu_is_omap730()               is_omap730()
350 #endif
351
352 #if defined(CONFIG_ARCH_OMAP850)
353 # undef  cpu_is_omap850
354 # define cpu_is_omap850()               is_omap850()
355 #endif
356
357 #if defined(CONFIG_ARCH_OMAP15XX)
358 # undef  cpu_is_omap310
359 # undef  cpu_is_omap1510
360 # define cpu_is_omap310()               is_omap310()
361 # define cpu_is_omap1510()              is_omap1510()
362 #endif
363
364 #if defined(CONFIG_ARCH_OMAP16XX)
365 # undef  cpu_is_omap1610
366 # undef  cpu_is_omap1611
367 # undef  cpu_is_omap5912
368 # undef  cpu_is_omap1621
369 # undef  cpu_is_omap1710
370 # define cpu_is_omap1610()              is_omap1610()
371 # define cpu_is_omap1611()              is_omap1611()
372 # define cpu_is_omap5912()              is_omap5912()
373 # define cpu_is_omap1621()              is_omap1621()
374 # define cpu_is_omap1710()              is_omap1710()
375 #endif
376
377 #if defined(CONFIG_ARCH_OMAP2)
378 # undef  cpu_is_omap2420
379 # undef  cpu_is_omap2422
380 # undef  cpu_is_omap2423
381 # undef  cpu_is_omap2430
382 # define cpu_is_omap2420()              is_omap2420()
383 # define cpu_is_omap2422()              is_omap2422()
384 # define cpu_is_omap2423()              is_omap2423()
385 # define cpu_is_omap2430()              is_omap2430()
386 #endif
387
388 #if defined(CONFIG_ARCH_OMAP3)
389 # undef cpu_is_omap3430
390 # undef cpu_is_omap3503
391 # undef cpu_is_omap3515
392 # undef cpu_is_omap3525
393 # undef cpu_is_omap3530
394 # undef cpu_is_omap3505
395 # undef cpu_is_omap3517
396 # define cpu_is_omap3430()              is_omap3430()
397 # define cpu_is_omap3503()              (cpu_is_omap3430() &&           \
398                                                 (!omap3_has_iva()) &&   \
399                                                 (!omap3_has_sgx()))
400 # define cpu_is_omap3515()              (cpu_is_omap3430() &&           \
401                                                 (!omap3_has_iva()) &&   \
402                                                 (omap3_has_sgx()))
403 # define cpu_is_omap3525()              (cpu_is_omap3430() &&           \
404                                                 (!omap3_has_sgx()) &&   \
405                                                 (omap3_has_iva()))
406 # define cpu_is_omap3530()              (cpu_is_omap3430())
407 # define cpu_is_omap3505()              is_omap3505()
408 # define cpu_is_omap3517()              is_omap3517()
409 # undef cpu_is_omap3630
410 # define cpu_is_omap3630()              is_omap363x()
411 #endif
412
413 # if defined(CONFIG_ARCH_OMAP4)
414 # undef cpu_is_omap44xx
415 # undef cpu_is_omap443x
416 # define cpu_is_omap44xx()              is_omap44xx()
417 # define cpu_is_omap443x()              is_omap443x()
418 # endif
419
420 /* Macros to detect if we have OMAP1 or OMAP2 */
421 #define cpu_class_is_omap1()    (cpu_is_omap7xx() || cpu_is_omap15xx() || \
422                                 cpu_is_omap16xx())
423 #define cpu_class_is_omap2()    (cpu_is_omap24xx() || cpu_is_omap34xx() || \
424                                 cpu_is_omap44xx())
425
426 /* Various silicon revisions for omap2 */
427 #define OMAP242X_CLASS          0x24200024
428 #define OMAP2420_REV_ES1_0      0x24200024
429 #define OMAP2420_REV_ES2_0      0x24201024
430
431 #define OMAP243X_CLASS          0x24300024
432 #define OMAP2430_REV_ES1_0      0x24300024
433
434 #define OMAP343X_CLASS          0x34300034
435 #define OMAP3430_REV_ES1_0      0x34300034
436 #define OMAP3430_REV_ES2_0      0x34301034
437 #define OMAP3430_REV_ES2_1      0x34302034
438 #define OMAP3430_REV_ES3_0      0x34303034
439 #define OMAP3430_REV_ES3_1      0x34304034
440 #define OMAP3430_REV_ES3_1_2    0x34305034
441
442 #define OMAP3630_REV_ES1_0      0x36300034
443
444 #define OMAP35XX_CLASS          0x35000034
445 #define OMAP3503_REV(v)         (OMAP35XX_CLASS | (0x3503 << 16) | (v << 8))
446 #define OMAP3515_REV(v)         (OMAP35XX_CLASS | (0x3515 << 16) | (v << 8))
447 #define OMAP3525_REV(v)         (OMAP35XX_CLASS | (0x3525 << 16) | (v << 8))
448 #define OMAP3530_REV(v)         (OMAP35XX_CLASS | (0x3530 << 16) | (v << 8))
449 #define OMAP3505_REV(v)         (OMAP35XX_CLASS | (0x3505 << 16) | (v << 8))
450 #define OMAP3517_REV(v)         (OMAP35XX_CLASS | (0x3517 << 16) | (v << 8))
451
452 #define OMAP443X_CLASS          0x44300044
453 #define OMAP4430_REV_ES1_0      0x44300044
454
455 /*
456  * omap_chip bits
457  *
458  * CHIP_IS_OMAP{2420,2430,3430} indicate that a particular structure is
459  * valid on all chips of that type.  CHIP_IS_OMAP3430ES{1,2} indicates
460  * something that is only valid on that particular ES revision.
461  *
462  * These bits may be ORed together to indicate structures that are
463  * available on multiple chip types.
464  *
465  * To test whether a particular structure matches the current OMAP chip type,
466  * use omap_chip_is().
467  *
468  */
469 #define CHIP_IS_OMAP2420                (1 << 0)
470 #define CHIP_IS_OMAP2430                (1 << 1)
471 #define CHIP_IS_OMAP3430                (1 << 2)
472 #define CHIP_IS_OMAP3430ES1             (1 << 3)
473 #define CHIP_IS_OMAP3430ES2             (1 << 4)
474 #define CHIP_IS_OMAP3430ES3_0           (1 << 5)
475 #define CHIP_IS_OMAP3430ES3_1           (1 << 6)
476 #define CHIP_IS_OMAP3630ES1             (1 << 7)
477 #define CHIP_IS_OMAP4430ES1             (1 << 8)
478
479 #define CHIP_IS_OMAP24XX                (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
480
481 #define CHIP_IS_OMAP4430                (CHIP_IS_OMAP4430ES1)
482
483 /*
484  * "GE" here represents "greater than or equal to" in terms of ES
485  * levels.  So CHIP_GE_OMAP3430ES2 is intended to match all OMAP3430
486  * chips at ES2 and beyond, but not, for example, any OMAP lines after
487  * OMAP3.
488  */
489 #define CHIP_GE_OMAP3430ES2             (CHIP_IS_OMAP3430ES2 | \
490                                          CHIP_IS_OMAP3430ES3_0 | \
491                                          CHIP_IS_OMAP3430ES3_1 | \
492                                          CHIP_IS_OMAP3630ES1)
493 #define CHIP_GE_OMAP3430ES3_1           (CHIP_IS_OMAP3430ES3_1 | \
494                                          CHIP_IS_OMAP3630ES1)
495
496
497 int omap_chip_is(struct omap_chip_id oci);
498 void omap2_check_revision(void);
499
500 /*
501  * Runtime detection of OMAP3 features
502  */
503 extern u32 omap3_features;
504
505 #define OMAP3_HAS_L2CACHE               BIT(0)
506 #define OMAP3_HAS_IVA                   BIT(1)
507 #define OMAP3_HAS_SGX                   BIT(2)
508 #define OMAP3_HAS_NEON                  BIT(3)
509 #define OMAP3_HAS_ISP                   BIT(4)
510
511 #define OMAP3_HAS_FEATURE(feat,flag)                    \
512 static inline unsigned int omap3_has_ ##feat(void)      \
513 {                                                       \
514         return (omap3_features & OMAP3_HAS_ ##flag);    \
515 }                                                       \
516
517 OMAP3_HAS_FEATURE(l2cache, L2CACHE)
518 OMAP3_HAS_FEATURE(sgx, SGX)
519 OMAP3_HAS_FEATURE(iva, IVA)
520 OMAP3_HAS_FEATURE(neon, NEON)
521 OMAP3_HAS_FEATURE(isp, ISP)
522
523 #endif