]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/asm-arm/arch-omap/cpu.h
0f1cf783aab926fbb489af24158bc17faef5df28
[linux-2.6-omap-h63xx.git] / include / asm-arm / arch-omap / cpu.h
1 /*
2  * linux/include/asm-arm/arch-omap/cpu.h
3  *
4  * OMAP cpu type detection
5  *
6  * Copyright (C) 2004, 2008 Nokia Corporation
7  *
8  * Written by Tony Lindgren <tony.lindgren@nokia.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25
26 #ifndef __ASM_ARCH_OMAP_CPU_H
27 #define __ASM_ARCH_OMAP_CPU_H
28
29 #include <linux/init.h>
30
31 struct omap_chip_id {
32         u8 oc;
33 };
34
35 #define OMAP_CHIP_INIT(x)       { .oc = x }
36
37 extern unsigned int system_rev;
38
39 #define omap2_cpu_rev()         ((system_rev >> 12) & 0x0f)
40
41 /*
42  * Test if multicore OMAP support is needed
43  */
44 #undef MULTI_OMAP1
45 #undef MULTI_OMAP2
46 #undef OMAP_NAME
47
48 #ifdef CONFIG_ARCH_OMAP730
49 # ifdef OMAP_NAME
50 #  undef  MULTI_OMAP1
51 #  define MULTI_OMAP1
52 # else
53 #  define OMAP_NAME omap730
54 # endif
55 #endif
56 #ifdef CONFIG_ARCH_OMAP15XX
57 # ifdef OMAP_NAME
58 #  undef  MULTI_OMAP1
59 #  define MULTI_OMAP1
60 # else
61 #  define OMAP_NAME omap1510
62 # endif
63 #endif
64 #ifdef CONFIG_ARCH_OMAP16XX
65 # ifdef OMAP_NAME
66 #  undef  MULTI_OMAP1
67 #  define MULTI_OMAP1
68 # else
69 #  define OMAP_NAME omap16xx
70 # endif
71 #endif
72 #if (defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX))
73 # if (defined(OMAP_NAME) || defined(MULTI_OMAP1))
74 #  error "OMAP1 and OMAP2 can't be selected at the same time"
75 # endif
76 #endif
77 #ifdef CONFIG_ARCH_OMAP2420
78 # ifdef OMAP_NAME
79 #  undef  MULTI_OMAP2
80 #  define MULTI_OMAP2
81 # else
82 #  define OMAP_NAME omap2420
83 # endif
84 #endif
85 #ifdef CONFIG_ARCH_OMAP2430
86 # ifdef OMAP_NAME
87 #  undef  MULTI_OMAP2
88 #  define MULTI_OMAP2
89 # else
90 #  define OMAP_NAME omap2430
91 # endif
92 #endif
93 #ifdef CONFIG_ARCH_OMAP3430
94 # ifdef OMAP_NAME
95 #  undef  MULTI_OMAP2
96 #  define MULTI_OMAP2
97 # else
98 #  define OMAP_NAME omap3430
99 # endif
100 #endif
101
102 /*
103  * Macros to group OMAP into cpu classes.
104  * These can be used in most places.
105  * cpu_is_omap7xx():    True for OMAP730
106  * cpu_is_omap15xx():   True for OMAP1510, OMAP5910 and OMAP310
107  * cpu_is_omap16xx():   True for OMAP1610, OMAP5912 and OMAP1710
108  * cpu_is_omap24xx():   True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
109  * cpu_is_omap242x():   True for OMAP2420, OMAP2422, OMAP2423
110  * cpu_is_omap243x():   True for OMAP2430
111  * cpu_is_omap343x():   True for OMAP3430
112  */
113 #define GET_OMAP_CLASS  ((system_rev >> 24) & 0xff)
114
115 #define IS_OMAP_CLASS(class, id)                        \
116 static inline int is_omap ##class (void)                \
117 {                                                       \
118         return (GET_OMAP_CLASS == (id)) ? 1 : 0;        \
119 }
120
121 #define GET_OMAP_SUBCLASS       ((system_rev >> 20) & 0x0fff)
122
123 #define IS_OMAP_SUBCLASS(subclass, id)                  \
124 static inline int is_omap ##subclass (void)             \
125 {                                                       \
126         return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;     \
127 }
128
129 IS_OMAP_CLASS(7xx, 0x07)
130 IS_OMAP_CLASS(15xx, 0x15)
131 IS_OMAP_CLASS(16xx, 0x16)
132 IS_OMAP_CLASS(24xx, 0x24)
133 IS_OMAP_CLASS(34xx, 0x34)
134
135 IS_OMAP_SUBCLASS(242x, 0x242)
136 IS_OMAP_SUBCLASS(243x, 0x243)
137 IS_OMAP_SUBCLASS(343x, 0x343)
138
139 #define cpu_is_omap7xx()                0
140 #define cpu_is_omap15xx()               0
141 #define cpu_is_omap16xx()               0
142 #define cpu_is_omap24xx()               0
143 #define cpu_is_omap242x()               0
144 #define cpu_is_omap243x()               0
145 #define cpu_is_omap34xx()               0
146 #define cpu_is_omap343x()               0
147
148 #if defined(MULTI_OMAP1)
149 # if defined(CONFIG_ARCH_OMAP730)
150 #  undef  cpu_is_omap7xx
151 #  define cpu_is_omap7xx()              is_omap7xx()
152 # endif
153 # if defined(CONFIG_ARCH_OMAP15XX)
154 #  undef  cpu_is_omap15xx
155 #  define cpu_is_omap15xx()             is_omap15xx()
156 # endif
157 # if defined(CONFIG_ARCH_OMAP16XX)
158 #  undef  cpu_is_omap16xx
159 #  define cpu_is_omap16xx()             is_omap16xx()
160 # endif
161 #else
162 # if defined(CONFIG_ARCH_OMAP730)
163 #  undef  cpu_is_omap7xx
164 #  define cpu_is_omap7xx()              1
165 # endif
166 # if defined(CONFIG_ARCH_OMAP15XX)
167 #  undef  cpu_is_omap15xx
168 #  define cpu_is_omap15xx()             1
169 # endif
170 # if defined(CONFIG_ARCH_OMAP16XX)
171 #  undef  cpu_is_omap16xx
172 #  define cpu_is_omap16xx()             1
173 # endif
174 #endif
175
176 #if defined(MULTI_OMAP2)
177 # if defined(CONFIG_ARCH_OMAP24XX)
178 #  undef  cpu_is_omap24xx
179 #  undef  cpu_is_omap242x
180 #  undef  cpu_is_omap243x
181 #  define cpu_is_omap24xx()             is_omap24xx()
182 #  define cpu_is_omap242x()             is_omap242x()
183 #  define cpu_is_omap243x()             is_omap243x()
184 # endif
185 # if defined(CONFIG_ARCH_OMAP34XX)
186 #  undef  cpu_is_omap34xx
187 #  undef  cpu_is_omap343x
188 #  define cpu_is_omap34xx()             is_omap34xx()
189 #  define cpu_is_omap343x()             is_omap343x()
190 # endif
191 #else
192 # if defined(CONFIG_ARCH_OMAP24XX)
193 #  undef  cpu_is_omap24xx
194 #  define cpu_is_omap24xx()             1
195 # endif
196 # if defined(CONFIG_ARCH_OMAP2420)
197 #  undef  cpu_is_omap242x
198 #  define cpu_is_omap242x()             1
199 # endif
200 # if defined(CONFIG_ARCH_OMAP2430)
201 #  undef  cpu_is_omap243x
202 #  define cpu_is_omap243x()             1
203 # endif
204 # if defined(CONFIG_ARCH_OMAP34XX)
205 #  undef  cpu_is_omap34xx
206 #  define cpu_is_omap34xx()             1
207 # endif
208 # if defined(CONFIG_ARCH_OMAP3430)
209 #  undef  cpu_is_omap343x
210 #  define cpu_is_omap343x()             1
211 # endif
212 #endif
213
214 /*
215  * Macros to detect individual cpu types.
216  * These are only rarely needed.
217  * cpu_is_omap330():    True for OMAP330
218  * cpu_is_omap730():    True for OMAP730
219  * cpu_is_omap1510():   True for OMAP1510
220  * cpu_is_omap1610():   True for OMAP1610
221  * cpu_is_omap1611():   True for OMAP1611
222  * cpu_is_omap5912():   True for OMAP5912
223  * cpu_is_omap1621():   True for OMAP1621
224  * cpu_is_omap1710():   True for OMAP1710
225  * cpu_is_omap2420():   True for OMAP2420
226  * cpu_is_omap2422():   True for OMAP2422
227  * cpu_is_omap2423():   True for OMAP2423
228  * cpu_is_omap2430():   True for OMAP2430
229  * cpu_is_omap3430():   True for OMAP3430
230  */
231 #define GET_OMAP_TYPE   ((system_rev >> 16) & 0xffff)
232
233 #define IS_OMAP_TYPE(type, id)                          \
234 static inline int is_omap ##type (void)                 \
235 {                                                       \
236         return (GET_OMAP_TYPE == (id)) ? 1 : 0;         \
237 }
238
239 IS_OMAP_TYPE(310, 0x0310)
240 IS_OMAP_TYPE(730, 0x0730)
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
253 #define cpu_is_omap310()                0
254 #define cpu_is_omap730()                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_omap3430()               0
266
267 #if defined(MULTI_OMAP1)
268 # if defined(CONFIG_ARCH_OMAP730)
269 #  undef  cpu_is_omap730
270 #  define cpu_is_omap730()              is_omap730()
271 # endif
272 #else
273 # if defined(CONFIG_ARCH_OMAP730)
274 #  undef  cpu_is_omap730
275 #  define cpu_is_omap730()              1
276 # endif
277 #endif
278
279 /*
280  * Whether we have MULTI_OMAP1 or not, we still need to distinguish
281  * between 330 vs. 1510 and 1611B/5912 vs. 1710.
282  */
283 #if defined(CONFIG_ARCH_OMAP15XX)
284 # undef  cpu_is_omap310
285 # undef  cpu_is_omap1510
286 # define cpu_is_omap310()               is_omap310()
287 # define cpu_is_omap1510()              is_omap1510()
288 #endif
289
290 #if defined(CONFIG_ARCH_OMAP16XX)
291 # undef  cpu_is_omap1610
292 # undef  cpu_is_omap1611
293 # undef  cpu_is_omap5912
294 # undef  cpu_is_omap1621
295 # undef  cpu_is_omap1710
296 # define cpu_is_omap1610()              is_omap1610()
297 # define cpu_is_omap1611()              is_omap1611()
298 # define cpu_is_omap5912()              is_omap5912()
299 # define cpu_is_omap1621()              is_omap1621()
300 # define cpu_is_omap1710()              is_omap1710()
301 #endif
302
303 #if defined(CONFIG_ARCH_OMAP24XX)
304 # undef  cpu_is_omap2420
305 # undef  cpu_is_omap2422
306 # undef  cpu_is_omap2423
307 # undef  cpu_is_omap2430
308 # define cpu_is_omap2420()              is_omap2420()
309 # define cpu_is_omap2422()              is_omap2422()
310 # define cpu_is_omap2423()              is_omap2423()
311 # define cpu_is_omap2430()              is_omap2430()
312 #endif
313
314 #if defined(CONFIG_ARCH_OMAP34XX)
315 # undef cpu_is_omap3430
316 # define cpu_is_omap3430()              is_omap3430()
317 #endif
318
319 /* Macros to detect if we have OMAP1 or OMAP2 */
320 #define cpu_class_is_omap1()    (cpu_is_omap730() || cpu_is_omap15xx() || \
321                                 cpu_is_omap16xx())
322 #define cpu_class_is_omap2()    (cpu_is_omap24xx() || cpu_is_omap34xx())
323
324 #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
325 /*
326  * Macros to detect silicon revision of OMAP2/3 processors.
327  * is_sil_rev_greater_than:     true if passed cpu type & its rev is greater.
328  * is_sil_rev_lesser_than:      true if passed cpu type & its rev is lesser.
329  * is_sil_rev_equal_to:         true if passed cpu type & its rev is equal.
330  * get_sil_rev:                 return the silicon rev value.
331  */
332 #define get_sil_omap_type(rev)  ((rev & 0xffff0000) >> 16)
333 #define get_sil_revision(rev)   ((rev & 0x0000f000) >> 12)
334
335 #define is_sil_rev_greater_than(rev) \
336                 ((get_sil_omap_type(system_rev) == get_sil_omap_type(rev)) && \
337                 (get_sil_revision(system_rev) > get_sil_revision(rev)))
338
339 #define is_sil_rev_less_than(rev) \
340                 ((get_sil_omap_type(system_rev) == get_sil_omap_type(rev)) && \
341                 (get_sil_revision(system_rev) < get_sil_revision(rev)))
342
343 #define is_sil_rev_equal_to(rev) \
344                 ((get_sil_omap_type(system_rev) == get_sil_omap_type(rev)) && \
345                 (get_sil_revision(system_rev) == get_sil_revision(rev)))
346
347 #define get_sil_rev() \
348                 get_sil_revision(system_rev)
349
350 /* Various silicon macros defined here */
351 #define OMAP2420_REV_ES1_0      0x24200000
352 #define OMAP2420_REV_ES2_0      0x24201000
353 #define OMAP2430_REV_ES1_0      0x24300000
354 #define OMAP3430_REV_ES1_0      0x34300000
355 #define OMAP3430_REV_ES2_0      0x34301000
356 #define OMAP3430_REV_ES2_1      0x34302000
357 #define OMAP3430_REV_ES2_2      0x34303000
358
359 /*
360  * omap_chip bits
361  *
362  * CHIP_IS_OMAP{2420,2430,3430} indicate that a particular structure is
363  * valid on all chips of that type.  CHIP_IS_OMAP3430ES{1,2} indicates
364  * something that is only valid on that particular ES revision.
365  *
366  * These bits may be ORed together to indicate structures that are
367  * available on multiple chip types.
368  *
369  * To test whether a particular structure matches the current OMAP chip type,
370  * use omap_chip_is().
371  *
372  */
373 #define CHIP_IS_OMAP2420       (1 << 0)
374 #define CHIP_IS_OMAP2430       (1 << 1)
375 #define CHIP_IS_OMAP3430       (1 << 2)
376 #define CHIP_IS_OMAP3430ES1    (1 << 3)
377 #define CHIP_IS_OMAP3430ES2    (1 << 4)
378
379 #define CHIP_IS_OMAP24XX       (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
380
381 int omap_chip_is(struct omap_chip_id oci);
382
383
384 /*
385  * Macro to detect device type i.e. EMU/HS/TST/GP/BAD
386  */
387 #define DEVICE_TYPE_TEST        0
388 #define DEVICE_TYPE_EMU         1
389 #define DEVICE_TYPE_SEC         2
390 #define DEVICE_TYPE_GP          3
391 #define DEVICE_TYPE_BAD         4
392
393 #define get_device_type()       ((system_rev & 0x700) >> 8)
394 #define is_device_type_test()   (get_device_type() == DEVICE_TYPE_TEST)
395 #define is_device_type_emu()    (get_device_type() == DEVICE_TYPE_EMU)
396 #define is_device_type_sec()    (get_device_type() == DEVICE_TYPE_SEC)
397 #define is_device_type_gp()     (get_device_type() == DEVICE_TYPE_GP)
398 #define is_device_type_bad()    (get_device_type() == DEVICE_TYPE_BAD)
399
400 void __init omap2_check_revision(void);
401
402 #endif    /* defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) */
403
404 #endif