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