blob: 366f829edb145006776bb8d0c8a418a6e04f983f [file] [log] [blame]
Russell Kinga09e64f2008-08-05 16:14:15 +01001/*
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 * 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
29struct omap_chip_id {
30 u8 oc;
Tony Lindgrena8823142008-12-10 17:36:30 -080031 u8 type;
Russell Kinga09e64f2008-08-05 16:14:15 +010032};
33
34#define OMAP_CHIP_INIT(x) { .oc = x }
35
Tony Lindgrena8823142008-12-10 17:36:30 -080036/*
Lauri Leukkunen84a34342008-12-10 17:36:31 -080037 * omap_rev bits:
Tony Lindgrena8823142008-12-10 17:36:30 -080038 * CPU id bits (0730, 1510, 1710, 2422...) [31:16]
39 * CPU revision (See _REV_ defined in cpu.h) [15:08]
40 * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
41 */
Lauri Leukkunen84a34342008-12-10 17:36:31 -080042unsigned int omap_rev(void);
Russell Kinga09e64f2008-08-05 16:14:15 +010043
Russell Kinga09e64f2008-08-05 16:14:15 +010044/*
45 * Test if multicore OMAP support is needed
46 */
47#undef MULTI_OMAP1
48#undef MULTI_OMAP2
49#undef OMAP_NAME
50
51#ifdef CONFIG_ARCH_OMAP730
52# ifdef OMAP_NAME
53# undef MULTI_OMAP1
54# define MULTI_OMAP1
55# else
56# define OMAP_NAME omap730
57# endif
58#endif
Zebediah C. McClureae302f42009-03-23 18:07:39 -070059#ifdef CONFIG_ARCH_OMAP850
60# ifdef OMAP_NAME
61# undef MULTI_OMAP1
62# define MULTI_OMAP1
63# else
64# define OMAP_NAME omap850
65# endif
66#endif
Russell Kinga09e64f2008-08-05 16:14:15 +010067#ifdef CONFIG_ARCH_OMAP15XX
68# ifdef OMAP_NAME
69# undef MULTI_OMAP1
70# define MULTI_OMAP1
71# else
72# define OMAP_NAME omap1510
73# endif
74#endif
75#ifdef CONFIG_ARCH_OMAP16XX
76# ifdef OMAP_NAME
77# undef MULTI_OMAP1
78# define MULTI_OMAP1
79# else
80# define OMAP_NAME omap16xx
81# endif
82#endif
83#if (defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX))
84# if (defined(OMAP_NAME) || defined(MULTI_OMAP1))
85# error "OMAP1 and OMAP2 can't be selected at the same time"
86# endif
87#endif
88#ifdef CONFIG_ARCH_OMAP2420
89# ifdef OMAP_NAME
90# undef MULTI_OMAP2
91# define MULTI_OMAP2
92# else
93# define OMAP_NAME omap2420
94# endif
95#endif
96#ifdef CONFIG_ARCH_OMAP2430
97# ifdef OMAP_NAME
98# undef MULTI_OMAP2
99# define MULTI_OMAP2
100# else
101# define OMAP_NAME omap2430
102# endif
103#endif
104#ifdef CONFIG_ARCH_OMAP3430
105# ifdef OMAP_NAME
106# undef MULTI_OMAP2
107# define MULTI_OMAP2
108# else
109# define OMAP_NAME omap3430
110# endif
111#endif
112
113/*
114 * Macros to group OMAP into cpu classes.
115 * These can be used in most places.
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700116 * cpu_is_omap7xx(): True for OMAP730, OMAP850
Russell Kinga09e64f2008-08-05 16:14:15 +0100117 * cpu_is_omap15xx(): True for OMAP1510, OMAP5910 and OMAP310
118 * cpu_is_omap16xx(): True for OMAP1610, OMAP5912 and OMAP1710
119 * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
120 * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
121 * cpu_is_omap243x(): True for OMAP2430
122 * cpu_is_omap343x(): True for OMAP3430
123 */
Lauri Leukkunen84a34342008-12-10 17:36:31 -0800124#define GET_OMAP_CLASS (omap_rev() & 0xff)
Russell Kinga09e64f2008-08-05 16:14:15 +0100125
126#define IS_OMAP_CLASS(class, id) \
127static inline int is_omap ##class (void) \
128{ \
129 return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
130}
131
Lauri Leukkunen84a34342008-12-10 17:36:31 -0800132#define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
Russell Kinga09e64f2008-08-05 16:14:15 +0100133
134#define IS_OMAP_SUBCLASS(subclass, id) \
135static inline int is_omap ##subclass (void) \
136{ \
137 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
138}
139
140IS_OMAP_CLASS(7xx, 0x07)
141IS_OMAP_CLASS(15xx, 0x15)
142IS_OMAP_CLASS(16xx, 0x16)
143IS_OMAP_CLASS(24xx, 0x24)
144IS_OMAP_CLASS(34xx, 0x34)
145
146IS_OMAP_SUBCLASS(242x, 0x242)
147IS_OMAP_SUBCLASS(243x, 0x243)
148IS_OMAP_SUBCLASS(343x, 0x343)
149
150#define cpu_is_omap7xx() 0
151#define cpu_is_omap15xx() 0
152#define cpu_is_omap16xx() 0
153#define cpu_is_omap24xx() 0
154#define cpu_is_omap242x() 0
155#define cpu_is_omap243x() 0
156#define cpu_is_omap34xx() 0
157#define cpu_is_omap343x() 0
158
159#if defined(MULTI_OMAP1)
160# if defined(CONFIG_ARCH_OMAP730)
161# undef cpu_is_omap7xx
162# define cpu_is_omap7xx() is_omap7xx()
163# endif
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700164# if defined(CONFIG_ARCH_OMAP850)
165# undef cpu_is_omap7xx
166# define cpu_is_omap7xx() is_omap7xx()
167# endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100168# if defined(CONFIG_ARCH_OMAP15XX)
169# undef cpu_is_omap15xx
170# define cpu_is_omap15xx() is_omap15xx()
171# endif
172# if defined(CONFIG_ARCH_OMAP16XX)
173# undef cpu_is_omap16xx
174# define cpu_is_omap16xx() is_omap16xx()
175# endif
176#else
177# if defined(CONFIG_ARCH_OMAP730)
178# undef cpu_is_omap7xx
179# define cpu_is_omap7xx() 1
180# endif
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700181# if defined(CONFIG_ARCH_OMAP850)
182# undef cpu_is_omap7xx
183# define cpu_is_omap7xx() 1
184# endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100185# if defined(CONFIG_ARCH_OMAP15XX)
186# undef cpu_is_omap15xx
187# define cpu_is_omap15xx() 1
188# endif
189# if defined(CONFIG_ARCH_OMAP16XX)
190# undef cpu_is_omap16xx
191# define cpu_is_omap16xx() 1
192# endif
193#endif
194
195#if defined(MULTI_OMAP2)
196# if defined(CONFIG_ARCH_OMAP24XX)
197# undef cpu_is_omap24xx
198# undef cpu_is_omap242x
199# undef cpu_is_omap243x
200# define cpu_is_omap24xx() is_omap24xx()
201# define cpu_is_omap242x() is_omap242x()
202# define cpu_is_omap243x() is_omap243x()
203# endif
204# if defined(CONFIG_ARCH_OMAP34XX)
205# undef cpu_is_omap34xx
206# undef cpu_is_omap343x
207# define cpu_is_omap34xx() is_omap34xx()
208# define cpu_is_omap343x() is_omap343x()
209# endif
210#else
211# if defined(CONFIG_ARCH_OMAP24XX)
212# undef cpu_is_omap24xx
213# define cpu_is_omap24xx() 1
214# endif
215# if defined(CONFIG_ARCH_OMAP2420)
216# undef cpu_is_omap242x
217# define cpu_is_omap242x() 1
218# endif
219# if defined(CONFIG_ARCH_OMAP2430)
220# undef cpu_is_omap243x
221# define cpu_is_omap243x() 1
222# endif
223# if defined(CONFIG_ARCH_OMAP34XX)
224# undef cpu_is_omap34xx
225# define cpu_is_omap34xx() 1
226# endif
227# if defined(CONFIG_ARCH_OMAP3430)
228# undef cpu_is_omap343x
229# define cpu_is_omap343x() 1
230# endif
231#endif
232
233/*
234 * Macros to detect individual cpu types.
235 * These are only rarely needed.
236 * cpu_is_omap330(): True for OMAP330
237 * cpu_is_omap730(): True for OMAP730
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700238 * cpu_is_omap850(): True for OMAP850
Russell Kinga09e64f2008-08-05 16:14:15 +0100239 * cpu_is_omap1510(): True for OMAP1510
240 * cpu_is_omap1610(): True for OMAP1610
241 * cpu_is_omap1611(): True for OMAP1611
242 * cpu_is_omap5912(): True for OMAP5912
243 * cpu_is_omap1621(): True for OMAP1621
244 * cpu_is_omap1710(): True for OMAP1710
245 * cpu_is_omap2420(): True for OMAP2420
246 * cpu_is_omap2422(): True for OMAP2422
247 * cpu_is_omap2423(): True for OMAP2423
248 * cpu_is_omap2430(): True for OMAP2430
249 * cpu_is_omap3430(): True for OMAP3430
250 */
Lauri Leukkunen84a34342008-12-10 17:36:31 -0800251#define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
Russell Kinga09e64f2008-08-05 16:14:15 +0100252
253#define IS_OMAP_TYPE(type, id) \
254static inline int is_omap ##type (void) \
255{ \
256 return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
257}
258
259IS_OMAP_TYPE(310, 0x0310)
260IS_OMAP_TYPE(730, 0x0730)
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700261IS_OMAP_TYPE(850, 0x0850)
Russell Kinga09e64f2008-08-05 16:14:15 +0100262IS_OMAP_TYPE(1510, 0x1510)
263IS_OMAP_TYPE(1610, 0x1610)
264IS_OMAP_TYPE(1611, 0x1611)
265IS_OMAP_TYPE(5912, 0x1611)
266IS_OMAP_TYPE(1621, 0x1621)
267IS_OMAP_TYPE(1710, 0x1710)
268IS_OMAP_TYPE(2420, 0x2420)
269IS_OMAP_TYPE(2422, 0x2422)
270IS_OMAP_TYPE(2423, 0x2423)
271IS_OMAP_TYPE(2430, 0x2430)
272IS_OMAP_TYPE(3430, 0x3430)
273
274#define cpu_is_omap310() 0
275#define cpu_is_omap730() 0
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700276#define cpu_is_omap850() 0
Russell Kinga09e64f2008-08-05 16:14:15 +0100277#define cpu_is_omap1510() 0
278#define cpu_is_omap1610() 0
279#define cpu_is_omap5912() 0
280#define cpu_is_omap1611() 0
281#define cpu_is_omap1621() 0
282#define cpu_is_omap1710() 0
283#define cpu_is_omap2420() 0
284#define cpu_is_omap2422() 0
285#define cpu_is_omap2423() 0
286#define cpu_is_omap2430() 0
287#define cpu_is_omap3430() 0
288
289#if defined(MULTI_OMAP1)
290# if defined(CONFIG_ARCH_OMAP730)
291# undef cpu_is_omap730
292# define cpu_is_omap730() is_omap730()
293# endif
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700294# if defined(CONFIG_ARCH_OMAP850)
295# undef cpu_is_omap850
296# define cpu_is_omap850() is_omap850()
297# endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100298#else
299# if defined(CONFIG_ARCH_OMAP730)
300# undef cpu_is_omap730
301# define cpu_is_omap730() 1
302# endif
303#endif
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700304#else
305# if defined(CONFIG_ARCH_OMAP850)
306# undef cpu_is_omap850
307# define cpu_is_omap850() 1
308# endif
309#endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100310
311/*
312 * Whether we have MULTI_OMAP1 or not, we still need to distinguish
313 * between 330 vs. 1510 and 1611B/5912 vs. 1710.
314 */
315#if defined(CONFIG_ARCH_OMAP15XX)
316# undef cpu_is_omap310
317# undef cpu_is_omap1510
318# define cpu_is_omap310() is_omap310()
319# define cpu_is_omap1510() is_omap1510()
320#endif
321
322#if defined(CONFIG_ARCH_OMAP16XX)
323# undef cpu_is_omap1610
324# undef cpu_is_omap1611
325# undef cpu_is_omap5912
326# undef cpu_is_omap1621
327# undef cpu_is_omap1710
328# define cpu_is_omap1610() is_omap1610()
329# define cpu_is_omap1611() is_omap1611()
330# define cpu_is_omap5912() is_omap5912()
331# define cpu_is_omap1621() is_omap1621()
332# define cpu_is_omap1710() is_omap1710()
333#endif
334
335#if defined(CONFIG_ARCH_OMAP24XX)
336# undef cpu_is_omap2420
337# undef cpu_is_omap2422
338# undef cpu_is_omap2423
339# undef cpu_is_omap2430
340# define cpu_is_omap2420() is_omap2420()
341# define cpu_is_omap2422() is_omap2422()
342# define cpu_is_omap2423() is_omap2423()
343# define cpu_is_omap2430() is_omap2430()
344#endif
345
346#if defined(CONFIG_ARCH_OMAP34XX)
347# undef cpu_is_omap3430
348# define cpu_is_omap3430() is_omap3430()
349#endif
350
351/* Macros to detect if we have OMAP1 or OMAP2 */
Zebediah C. McClureae302f42009-03-23 18:07:39 -0700352#define cpu_class_is_omap1() (cpu_is_omap7xx() || cpu_is_omap15xx() || \
Russell Kinga09e64f2008-08-05 16:14:15 +0100353 cpu_is_omap16xx())
354#define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx())
355
356#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
Russell Kinga09e64f2008-08-05 16:14:15 +0100357
Tony Lindgrena8823142008-12-10 17:36:30 -0800358/* Various silicon revisions for omap2 */
359#define OMAP242X_CLASS 0x24200024
360#define OMAP2420_REV_ES1_0 0x24200024
361#define OMAP2420_REV_ES2_0 0x24201024
Russell Kinga09e64f2008-08-05 16:14:15 +0100362
Tony Lindgrena8823142008-12-10 17:36:30 -0800363#define OMAP243X_CLASS 0x24300024
364#define OMAP2430_REV_ES1_0 0x24300024
Russell Kinga09e64f2008-08-05 16:14:15 +0100365
Tony Lindgrena8823142008-12-10 17:36:30 -0800366#define OMAP343X_CLASS 0x34300034
367#define OMAP3430_REV_ES1_0 0x34300034
368#define OMAP3430_REV_ES2_0 0x34301034
369#define OMAP3430_REV_ES2_1 0x34302034
370#define OMAP3430_REV_ES3_0 0x34303034
Tony Lindgren187e6882009-01-29 08:57:16 -0800371#define OMAP3430_REV_ES3_1 0x34304034
Russell Kinga09e64f2008-08-05 16:14:15 +0100372
373/*
374 * omap_chip bits
375 *
376 * CHIP_IS_OMAP{2420,2430,3430} indicate that a particular structure is
377 * valid on all chips of that type. CHIP_IS_OMAP3430ES{1,2} indicates
378 * something that is only valid on that particular ES revision.
379 *
380 * These bits may be ORed together to indicate structures that are
381 * available on multiple chip types.
382 *
383 * To test whether a particular structure matches the current OMAP chip type,
384 * use omap_chip_is().
385 *
386 */
387#define CHIP_IS_OMAP2420 (1 << 0)
388#define CHIP_IS_OMAP2430 (1 << 1)
389#define CHIP_IS_OMAP3430 (1 << 2)
390#define CHIP_IS_OMAP3430ES1 (1 << 3)
391#define CHIP_IS_OMAP3430ES2 (1 << 4)
392
393#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
394
395int omap_chip_is(struct omap_chip_id oci);
Tony Lindgrena8823142008-12-10 17:36:30 -0800396int omap_type(void);
Russell Kinga09e64f2008-08-05 16:14:15 +0100397
398/*
399 * Macro to detect device type i.e. EMU/HS/TST/GP/BAD
400 */
Tony Lindgrena8823142008-12-10 17:36:30 -0800401#define OMAP2_DEVICE_TYPE_TEST 0
402#define OMAP2_DEVICE_TYPE_EMU 1
403#define OMAP2_DEVICE_TYPE_SEC 2
404#define OMAP2_DEVICE_TYPE_GP 3
405#define OMAP2_DEVICE_TYPE_BAD 4
Russell Kinga09e64f2008-08-05 16:14:15 +0100406
407void omap2_check_revision(void);
408
409#endif /* defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) */