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