xref: /openbmc/linux/arch/arm/mach-omap2/soc.h (revision 816a65ef4ce1848d8083d9e198922ddafbe221f2)
1e4c060dbSTony Lindgren /*
2e4c060dbSTony Lindgren  * OMAP cpu type detection
3e4c060dbSTony Lindgren  *
4e4c060dbSTony Lindgren  * Copyright (C) 2004, 2008 Nokia Corporation
5e4c060dbSTony Lindgren  *
6e4c060dbSTony Lindgren  * Copyright (C) 2009-11 Texas Instruments.
7e4c060dbSTony Lindgren  *
8e4c060dbSTony Lindgren  * Written by Tony Lindgren <tony.lindgren@nokia.com>
9e4c060dbSTony Lindgren  *
10e4c060dbSTony Lindgren  * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
11e4c060dbSTony Lindgren  *
12e4c060dbSTony Lindgren  * This program is free software; you can redistribute it and/or modify
13e4c060dbSTony Lindgren  * it under the terms of the GNU General Public License as published by
14e4c060dbSTony Lindgren  * the Free Software Foundation; either version 2 of the License, or
15e4c060dbSTony Lindgren  * (at your option) any later version.
16e4c060dbSTony Lindgren  *
17e4c060dbSTony Lindgren  * This program is distributed in the hope that it will be useful,
18e4c060dbSTony Lindgren  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19e4c060dbSTony Lindgren  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20e4c060dbSTony Lindgren  * GNU General Public License for more details.
21e4c060dbSTony Lindgren  *
22e4c060dbSTony Lindgren  * You should have received a copy of the GNU General Public License
23e4c060dbSTony Lindgren  * along with this program; if not, write to the Free Software
24e4c060dbSTony Lindgren  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25e4c060dbSTony Lindgren  *
26e4c060dbSTony Lindgren  */
27e4c060dbSTony Lindgren 
28c49f34bcSTony Lindgren #include "omap24xx.h"
29c49f34bcSTony Lindgren #include "omap34xx.h"
30c49f34bcSTony Lindgren #include "omap44xx.h"
31c49f34bcSTony Lindgren #include "ti81xx.h"
32c49f34bcSTony Lindgren #include "am33xx.h"
33c49f34bcSTony Lindgren #include "omap54xx.h"
34e4c060dbSTony Lindgren 
35e4c060dbSTony Lindgren #ifndef __ASSEMBLY__
36e4c060dbSTony Lindgren 
37e4c060dbSTony Lindgren #include <linux/bitops.h>
38e4c060dbSTony Lindgren 
39e4c060dbSTony Lindgren /*
40e4c060dbSTony Lindgren  * Test if multicore OMAP support is needed
41e4c060dbSTony Lindgren  */
42e4c060dbSTony Lindgren #undef MULTI_OMAP2
43e4c060dbSTony Lindgren #undef OMAP_NAME
44e4c060dbSTony Lindgren 
45*816a65efSTony Lindgren #ifdef CONFIG_ARCH_MULTIPLATFORM
46*816a65efSTony Lindgren #define MULTI_OMAP2
47*816a65efSTony Lindgren #endif
48e4c060dbSTony Lindgren #ifdef CONFIG_SOC_OMAP2420
49e4c060dbSTony Lindgren # ifdef OMAP_NAME
50e4c060dbSTony Lindgren #  undef  MULTI_OMAP2
51e4c060dbSTony Lindgren #  define MULTI_OMAP2
52e4c060dbSTony Lindgren # else
53e4c060dbSTony Lindgren #  define OMAP_NAME omap2420
54e4c060dbSTony Lindgren # endif
55e4c060dbSTony Lindgren #endif
56e4c060dbSTony Lindgren #ifdef CONFIG_SOC_OMAP2430
57e4c060dbSTony Lindgren # ifdef OMAP_NAME
58e4c060dbSTony Lindgren #  undef  MULTI_OMAP2
59e4c060dbSTony Lindgren #  define MULTI_OMAP2
60e4c060dbSTony Lindgren # else
61e4c060dbSTony Lindgren #  define OMAP_NAME omap2430
62e4c060dbSTony Lindgren # endif
63e4c060dbSTony Lindgren #endif
64e4c060dbSTony Lindgren #ifdef CONFIG_ARCH_OMAP3
65e4c060dbSTony Lindgren # ifdef OMAP_NAME
66e4c060dbSTony Lindgren #  undef  MULTI_OMAP2
67e4c060dbSTony Lindgren #  define MULTI_OMAP2
68e4c060dbSTony Lindgren # else
69e4c060dbSTony Lindgren #  define OMAP_NAME omap3
70e4c060dbSTony Lindgren # endif
71e4c060dbSTony Lindgren #endif
72e4c060dbSTony Lindgren #ifdef CONFIG_ARCH_OMAP4
73e4c060dbSTony Lindgren # ifdef OMAP_NAME
74e4c060dbSTony Lindgren #  undef  MULTI_OMAP2
75e4c060dbSTony Lindgren #  define MULTI_OMAP2
76e4c060dbSTony Lindgren # else
77e4c060dbSTony Lindgren #  define OMAP_NAME omap4
78e4c060dbSTony Lindgren # endif
79e4c060dbSTony Lindgren #endif
80e4c060dbSTony Lindgren 
81e4c060dbSTony Lindgren #ifdef CONFIG_SOC_OMAP5
82e4c060dbSTony Lindgren # ifdef OMAP_NAME
83e4c060dbSTony Lindgren #  undef  MULTI_OMAP2
84e4c060dbSTony Lindgren #  define MULTI_OMAP2
85e4c060dbSTony Lindgren # else
86e4c060dbSTony Lindgren #  define OMAP_NAME omap5
87e4c060dbSTony Lindgren # endif
88e4c060dbSTony Lindgren #endif
89e4c060dbSTony Lindgren 
90e4c060dbSTony Lindgren #ifdef CONFIG_SOC_AM33XX
91e4c060dbSTony Lindgren # ifdef OMAP_NAME
92e4c060dbSTony Lindgren #  undef  MULTI_OMAP2
93e4c060dbSTony Lindgren #  define MULTI_OMAP2
94e4c060dbSTony Lindgren # else
95e4c060dbSTony Lindgren #  define OMAP_NAME am33xx
96e4c060dbSTony Lindgren # endif
97e4c060dbSTony Lindgren #endif
98e4c060dbSTony Lindgren 
99e4c060dbSTony Lindgren /*
100e4c060dbSTony Lindgren  * Omap device type i.e. EMU/HS/TST/GP/BAD
101e4c060dbSTony Lindgren  */
102e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_TEST		0
103e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_EMU		1
104e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_SEC		2
105e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_GP		3
106e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_BAD		4
107e4c060dbSTony Lindgren 
108e4c060dbSTony Lindgren int omap_type(void);
109e4c060dbSTony Lindgren 
110e4c060dbSTony Lindgren /*
111e4c060dbSTony Lindgren  * omap_rev bits:
112e4c060dbSTony Lindgren  * CPU id bits	(0730, 1510, 1710, 2422...)	[31:16]
113e4c060dbSTony Lindgren  * CPU revision	(See _REV_ defined in cpu.h)	[15:08]
114e4c060dbSTony Lindgren  * CPU class bits (15xx, 16xx, 24xx, 34xx...)	[07:00]
115e4c060dbSTony Lindgren  */
116e4c060dbSTony Lindgren unsigned int omap_rev(void);
117e4c060dbSTony Lindgren 
118*816a65efSTony Lindgren static inline int soc_is_omap(void)
119*816a65efSTony Lindgren {
120*816a65efSTony Lindgren 	return omap_rev() != 0;
121*816a65efSTony Lindgren }
122*816a65efSTony Lindgren 
123e4c060dbSTony Lindgren /*
124e4c060dbSTony Lindgren  * Get the CPU revision for OMAP devices
125e4c060dbSTony Lindgren  */
126e4c060dbSTony Lindgren #define GET_OMAP_REVISION()	((omap_rev() >> 8) & 0xff)
127e4c060dbSTony Lindgren 
128e4c060dbSTony Lindgren /*
129e4c060dbSTony Lindgren  * Macros to group OMAP into cpu classes.
130e4c060dbSTony Lindgren  * These can be used in most places.
131e4c060dbSTony Lindgren  * cpu_is_omap24xx():	True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
132e4c060dbSTony Lindgren  * cpu_is_omap242x():	True for OMAP2420, OMAP2422, OMAP2423
133e4c060dbSTony Lindgren  * cpu_is_omap243x():	True for OMAP2430
134e4c060dbSTony Lindgren  * cpu_is_omap343x():	True for OMAP3430
135e4c060dbSTony Lindgren  * cpu_is_omap443x():	True for OMAP4430
136e4c060dbSTony Lindgren  * cpu_is_omap446x():	True for OMAP4460
137e4c060dbSTony Lindgren  * cpu_is_omap447x():	True for OMAP4470
138e4c060dbSTony Lindgren  * soc_is_omap543x():	True for OMAP5430, OMAP5432
139e4c060dbSTony Lindgren  */
140e4c060dbSTony Lindgren #define GET_OMAP_CLASS	(omap_rev() & 0xff)
141e4c060dbSTony Lindgren 
142e4c060dbSTony Lindgren #define IS_OMAP_CLASS(class, id)			\
143e4c060dbSTony Lindgren static inline int is_omap ##class (void)		\
144e4c060dbSTony Lindgren {							\
145e4c060dbSTony Lindgren 	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
146e4c060dbSTony Lindgren }
147e4c060dbSTony Lindgren 
148e4c060dbSTony Lindgren #define GET_AM_CLASS	((omap_rev() >> 24) & 0xff)
149e4c060dbSTony Lindgren 
150e4c060dbSTony Lindgren #define IS_AM_CLASS(class, id)				\
151e4c060dbSTony Lindgren static inline int is_am ##class (void)			\
152e4c060dbSTony Lindgren {							\
153e4c060dbSTony Lindgren 	return (GET_AM_CLASS == (id)) ? 1 : 0;		\
154e4c060dbSTony Lindgren }
155e4c060dbSTony Lindgren 
156e4c060dbSTony Lindgren #define GET_TI_CLASS	((omap_rev() >> 24) & 0xff)
157e4c060dbSTony Lindgren 
158e4c060dbSTony Lindgren #define IS_TI_CLASS(class, id)			\
159e4c060dbSTony Lindgren static inline int is_ti ##class (void)		\
160e4c060dbSTony Lindgren {							\
161e4c060dbSTony Lindgren 	return (GET_TI_CLASS == (id)) ? 1 : 0;	\
162e4c060dbSTony Lindgren }
163e4c060dbSTony Lindgren 
164e4c060dbSTony Lindgren #define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)
165e4c060dbSTony Lindgren 
166e4c060dbSTony Lindgren #define IS_OMAP_SUBCLASS(subclass, id)			\
167e4c060dbSTony Lindgren static inline int is_omap ##subclass (void)		\
168e4c060dbSTony Lindgren {							\
169e4c060dbSTony Lindgren 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
170e4c060dbSTony Lindgren }
171e4c060dbSTony Lindgren 
172e4c060dbSTony Lindgren #define IS_TI_SUBCLASS(subclass, id)			\
173e4c060dbSTony Lindgren static inline int is_ti ##subclass (void)		\
174e4c060dbSTony Lindgren {							\
175e4c060dbSTony Lindgren 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
176e4c060dbSTony Lindgren }
177e4c060dbSTony Lindgren 
178e4c060dbSTony Lindgren #define IS_AM_SUBCLASS(subclass, id)			\
179e4c060dbSTony Lindgren static inline int is_am ##subclass (void)		\
180e4c060dbSTony Lindgren {							\
181e4c060dbSTony Lindgren 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
182e4c060dbSTony Lindgren }
183e4c060dbSTony Lindgren 
184e4c060dbSTony Lindgren IS_OMAP_CLASS(24xx, 0x24)
185e4c060dbSTony Lindgren IS_OMAP_CLASS(34xx, 0x34)
186e4c060dbSTony Lindgren IS_OMAP_CLASS(44xx, 0x44)
187e4c060dbSTony Lindgren IS_AM_CLASS(35xx, 0x35)
188e4c060dbSTony Lindgren IS_OMAP_CLASS(54xx, 0x54)
189e4c060dbSTony Lindgren IS_AM_CLASS(33xx, 0x33)
190e4c060dbSTony Lindgren 
191e4c060dbSTony Lindgren IS_TI_CLASS(81xx, 0x81)
192e4c060dbSTony Lindgren 
193e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(242x, 0x242)
194e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(243x, 0x243)
195e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(343x, 0x343)
196e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(363x, 0x363)
197e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(443x, 0x443)
198e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(446x, 0x446)
199e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(447x, 0x447)
200e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(543x, 0x543)
201e4c060dbSTony Lindgren 
202e4c060dbSTony Lindgren IS_TI_SUBCLASS(816x, 0x816)
203e4c060dbSTony Lindgren IS_TI_SUBCLASS(814x, 0x814)
204e4c060dbSTony Lindgren IS_AM_SUBCLASS(335x, 0x335)
205e4c060dbSTony Lindgren 
206e4c060dbSTony Lindgren #define cpu_is_omap24xx()		0
207e4c060dbSTony Lindgren #define cpu_is_omap242x()		0
208e4c060dbSTony Lindgren #define cpu_is_omap243x()		0
209e4c060dbSTony Lindgren #define cpu_is_omap34xx()		0
210e4c060dbSTony Lindgren #define cpu_is_omap343x()		0
211e4c060dbSTony Lindgren #define cpu_is_ti81xx()			0
212e4c060dbSTony Lindgren #define cpu_is_ti816x()			0
213e4c060dbSTony Lindgren #define cpu_is_ti814x()			0
214e4c060dbSTony Lindgren #define soc_is_am35xx()			0
215e4c060dbSTony Lindgren #define soc_is_am33xx()			0
216e4c060dbSTony Lindgren #define soc_is_am335x()			0
217e4c060dbSTony Lindgren #define cpu_is_omap44xx()		0
218e4c060dbSTony Lindgren #define cpu_is_omap443x()		0
219e4c060dbSTony Lindgren #define cpu_is_omap446x()		0
220e4c060dbSTony Lindgren #define cpu_is_omap447x()		0
221e4c060dbSTony Lindgren #define soc_is_omap54xx()		0
222e4c060dbSTony Lindgren #define soc_is_omap543x()		0
223e4c060dbSTony Lindgren 
224e4c060dbSTony Lindgren #if defined(MULTI_OMAP2)
225e4c060dbSTony Lindgren # if defined(CONFIG_ARCH_OMAP2)
226e4c060dbSTony Lindgren #  undef  cpu_is_omap24xx
227e4c060dbSTony Lindgren #  define cpu_is_omap24xx()		is_omap24xx()
228e4c060dbSTony Lindgren # endif
229e4c060dbSTony Lindgren # if defined (CONFIG_SOC_OMAP2420)
230e4c060dbSTony Lindgren #  undef  cpu_is_omap242x
231e4c060dbSTony Lindgren #  define cpu_is_omap242x()		is_omap242x()
232e4c060dbSTony Lindgren # endif
233e4c060dbSTony Lindgren # if defined (CONFIG_SOC_OMAP2430)
234e4c060dbSTony Lindgren #  undef  cpu_is_omap243x
235e4c060dbSTony Lindgren #  define cpu_is_omap243x()		is_omap243x()
236e4c060dbSTony Lindgren # endif
237e4c060dbSTony Lindgren # if defined(CONFIG_ARCH_OMAP3)
238e4c060dbSTony Lindgren #  undef  cpu_is_omap34xx
239e4c060dbSTony Lindgren #  undef  cpu_is_omap343x
240e4c060dbSTony Lindgren #  define cpu_is_omap34xx()		is_omap34xx()
241e4c060dbSTony Lindgren #  define cpu_is_omap343x()		is_omap343x()
242e4c060dbSTony Lindgren # endif
243e4c060dbSTony Lindgren #else
244e4c060dbSTony Lindgren # if defined(CONFIG_ARCH_OMAP2)
245e4c060dbSTony Lindgren #  undef  cpu_is_omap24xx
246e4c060dbSTony Lindgren #  define cpu_is_omap24xx()		1
247e4c060dbSTony Lindgren # endif
248e4c060dbSTony Lindgren # if defined(CONFIG_SOC_OMAP2420)
249e4c060dbSTony Lindgren #  undef  cpu_is_omap242x
250e4c060dbSTony Lindgren #  define cpu_is_omap242x()		1
251e4c060dbSTony Lindgren # endif
252e4c060dbSTony Lindgren # if defined(CONFIG_SOC_OMAP2430)
253e4c060dbSTony Lindgren #  undef  cpu_is_omap243x
254e4c060dbSTony Lindgren #  define cpu_is_omap243x()		1
255e4c060dbSTony Lindgren # endif
256e4c060dbSTony Lindgren # if defined(CONFIG_ARCH_OMAP3)
257e4c060dbSTony Lindgren #  undef  cpu_is_omap34xx
258e4c060dbSTony Lindgren #  define cpu_is_omap34xx()		1
259e4c060dbSTony Lindgren # endif
260e4c060dbSTony Lindgren # if defined(CONFIG_SOC_OMAP3430)
261e4c060dbSTony Lindgren #  undef  cpu_is_omap343x
262e4c060dbSTony Lindgren #  define cpu_is_omap343x()		1
263e4c060dbSTony Lindgren # endif
264e4c060dbSTony Lindgren #endif
265e4c060dbSTony Lindgren 
266e4c060dbSTony Lindgren /*
267e4c060dbSTony Lindgren  * Macros to detect individual cpu types.
268e4c060dbSTony Lindgren  * These are only rarely needed.
269e4c060dbSTony Lindgren  * cpu_is_omap2420():	True for OMAP2420
270e4c060dbSTony Lindgren  * cpu_is_omap2422():	True for OMAP2422
271e4c060dbSTony Lindgren  * cpu_is_omap2423():	True for OMAP2423
272e4c060dbSTony Lindgren  * cpu_is_omap2430():	True for OMAP2430
273e4c060dbSTony Lindgren  * cpu_is_omap3430():	True for OMAP3430
274e4c060dbSTony Lindgren  */
275e4c060dbSTony Lindgren #define GET_OMAP_TYPE	((omap_rev() >> 16) & 0xffff)
276e4c060dbSTony Lindgren 
277e4c060dbSTony Lindgren #define IS_OMAP_TYPE(type, id)				\
278e4c060dbSTony Lindgren static inline int is_omap ##type (void)			\
279e4c060dbSTony Lindgren {							\
280e4c060dbSTony Lindgren 	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
281e4c060dbSTony Lindgren }
282e4c060dbSTony Lindgren 
283e4c060dbSTony Lindgren IS_OMAP_TYPE(2420, 0x2420)
284e4c060dbSTony Lindgren IS_OMAP_TYPE(2422, 0x2422)
285e4c060dbSTony Lindgren IS_OMAP_TYPE(2423, 0x2423)
286e4c060dbSTony Lindgren IS_OMAP_TYPE(2430, 0x2430)
287e4c060dbSTony Lindgren IS_OMAP_TYPE(3430, 0x3430)
288e4c060dbSTony Lindgren 
289e4c060dbSTony Lindgren #define cpu_is_omap2420()		0
290e4c060dbSTony Lindgren #define cpu_is_omap2422()		0
291e4c060dbSTony Lindgren #define cpu_is_omap2423()		0
292e4c060dbSTony Lindgren #define cpu_is_omap2430()		0
293e4c060dbSTony Lindgren #define cpu_is_omap3430()		0
294e4c060dbSTony Lindgren #define cpu_is_omap3630()		0
295e4c060dbSTony Lindgren #define soc_is_omap5430()		0
296e4c060dbSTony Lindgren 
297e4c060dbSTony Lindgren /* These are needed for the common code */
298e4c060dbSTony Lindgren #ifdef CONFIG_ARCH_OMAP2PLUS
299e4c060dbSTony Lindgren #define cpu_is_omap7xx()		0
300e4c060dbSTony Lindgren #define cpu_is_omap15xx()		0
301e4c060dbSTony Lindgren #define cpu_is_omap16xx()		0
302e4c060dbSTony Lindgren #define cpu_is_omap1510()		0
303e4c060dbSTony Lindgren #define cpu_is_omap1610()		0
304e4c060dbSTony Lindgren #define cpu_is_omap1611()		0
305e4c060dbSTony Lindgren #define cpu_is_omap1621()		0
306e4c060dbSTony Lindgren #define cpu_is_omap1710()		0
307e4c060dbSTony Lindgren #define cpu_class_is_omap1()		0
308e4c060dbSTony Lindgren #define cpu_class_is_omap2()		1
309e4c060dbSTony Lindgren #endif
310e4c060dbSTony Lindgren 
311e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP2)
312e4c060dbSTony Lindgren # undef  cpu_is_omap2420
313e4c060dbSTony Lindgren # undef  cpu_is_omap2422
314e4c060dbSTony Lindgren # undef  cpu_is_omap2423
315e4c060dbSTony Lindgren # undef  cpu_is_omap2430
316e4c060dbSTony Lindgren # define cpu_is_omap2420()		is_omap2420()
317e4c060dbSTony Lindgren # define cpu_is_omap2422()		is_omap2422()
318e4c060dbSTony Lindgren # define cpu_is_omap2423()		is_omap2423()
319e4c060dbSTony Lindgren # define cpu_is_omap2430()		is_omap2430()
320e4c060dbSTony Lindgren #endif
321e4c060dbSTony Lindgren 
322e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP3)
323e4c060dbSTony Lindgren # undef cpu_is_omap3430
324e4c060dbSTony Lindgren # undef cpu_is_ti81xx
325e4c060dbSTony Lindgren # undef cpu_is_ti816x
326e4c060dbSTony Lindgren # undef cpu_is_ti814x
327e4c060dbSTony Lindgren # undef soc_is_am35xx
328e4c060dbSTony Lindgren # define cpu_is_omap3430()		is_omap3430()
329e4c060dbSTony Lindgren # undef cpu_is_omap3630
330e4c060dbSTony Lindgren # define cpu_is_omap3630()		is_omap363x()
331e4c060dbSTony Lindgren # define cpu_is_ti81xx()		is_ti81xx()
332e4c060dbSTony Lindgren # define cpu_is_ti816x()		is_ti816x()
333e4c060dbSTony Lindgren # define cpu_is_ti814x()		is_ti814x()
334e4c060dbSTony Lindgren # define soc_is_am35xx()		is_am35xx()
335e4c060dbSTony Lindgren #endif
336e4c060dbSTony Lindgren 
337e4c060dbSTony Lindgren # if defined(CONFIG_SOC_AM33XX)
338e4c060dbSTony Lindgren # undef soc_is_am33xx
339e4c060dbSTony Lindgren # undef soc_is_am335x
340e4c060dbSTony Lindgren # define soc_is_am33xx()		is_am33xx()
341e4c060dbSTony Lindgren # define soc_is_am335x()		is_am335x()
342e4c060dbSTony Lindgren #endif
343e4c060dbSTony Lindgren 
344e4c060dbSTony Lindgren # if defined(CONFIG_ARCH_OMAP4)
345e4c060dbSTony Lindgren # undef cpu_is_omap44xx
346e4c060dbSTony Lindgren # undef cpu_is_omap443x
347e4c060dbSTony Lindgren # undef cpu_is_omap446x
348e4c060dbSTony Lindgren # undef cpu_is_omap447x
349e4c060dbSTony Lindgren # define cpu_is_omap44xx()		is_omap44xx()
350e4c060dbSTony Lindgren # define cpu_is_omap443x()		is_omap443x()
351e4c060dbSTony Lindgren # define cpu_is_omap446x()		is_omap446x()
352e4c060dbSTony Lindgren # define cpu_is_omap447x()		is_omap447x()
353e4c060dbSTony Lindgren # endif
354e4c060dbSTony Lindgren 
355e4c060dbSTony Lindgren # if defined(CONFIG_SOC_OMAP5)
356e4c060dbSTony Lindgren # undef soc_is_omap54xx
357e4c060dbSTony Lindgren # undef soc_is_omap543x
358e4c060dbSTony Lindgren # define soc_is_omap54xx()		is_omap54xx()
359e4c060dbSTony Lindgren # define soc_is_omap543x()		is_omap543x()
360e4c060dbSTony Lindgren #endif
361e4c060dbSTony Lindgren 
362e4c060dbSTony Lindgren /* Various silicon revisions for omap2 */
363e4c060dbSTony Lindgren #define OMAP242X_CLASS		0x24200024
364e4c060dbSTony Lindgren #define OMAP2420_REV_ES1_0	OMAP242X_CLASS
365e4c060dbSTony Lindgren #define OMAP2420_REV_ES2_0	(OMAP242X_CLASS | (0x1 << 8))
366e4c060dbSTony Lindgren 
367e4c060dbSTony Lindgren #define OMAP243X_CLASS		0x24300024
368e4c060dbSTony Lindgren #define OMAP2430_REV_ES1_0	OMAP243X_CLASS
369e4c060dbSTony Lindgren 
370e4c060dbSTony Lindgren #define OMAP343X_CLASS		0x34300034
371e4c060dbSTony Lindgren #define OMAP3430_REV_ES1_0	OMAP343X_CLASS
372e4c060dbSTony Lindgren #define OMAP3430_REV_ES2_0	(OMAP343X_CLASS | (0x1 << 8))
373e4c060dbSTony Lindgren #define OMAP3430_REV_ES2_1	(OMAP343X_CLASS | (0x2 << 8))
374e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_0	(OMAP343X_CLASS | (0x3 << 8))
375e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_1	(OMAP343X_CLASS | (0x4 << 8))
376e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_1_2	(OMAP343X_CLASS | (0x5 << 8))
377e4c060dbSTony Lindgren 
378e4c060dbSTony Lindgren #define OMAP363X_CLASS		0x36300034
379e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_0	OMAP363X_CLASS
380e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_1	(OMAP363X_CLASS | (0x1 << 8))
381e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_2	(OMAP363X_CLASS | (0x2 << 8))
382e4c060dbSTony Lindgren 
383e4c060dbSTony Lindgren #define TI816X_CLASS		0x81600034
384e4c060dbSTony Lindgren #define TI8168_REV_ES1_0	TI816X_CLASS
385e4c060dbSTony Lindgren #define TI8168_REV_ES1_1	(TI816X_CLASS | (0x1 << 8))
386e4c060dbSTony Lindgren 
387e4c060dbSTony Lindgren #define TI814X_CLASS		0x81400034
388e4c060dbSTony Lindgren #define TI8148_REV_ES1_0	TI814X_CLASS
389e4c060dbSTony Lindgren #define TI8148_REV_ES2_0	(TI814X_CLASS | (0x1 << 8))
390e4c060dbSTony Lindgren #define TI8148_REV_ES2_1	(TI814X_CLASS | (0x2 << 8))
391e4c060dbSTony Lindgren 
392e4c060dbSTony Lindgren #define AM35XX_CLASS		0x35170034
393e4c060dbSTony Lindgren #define AM35XX_REV_ES1_0	AM35XX_CLASS
394e4c060dbSTony Lindgren #define AM35XX_REV_ES1_1	(AM35XX_CLASS | (0x1 << 8))
395e4c060dbSTony Lindgren 
396e4c060dbSTony Lindgren #define AM335X_CLASS		0x33500033
397e4c060dbSTony Lindgren #define AM335X_REV_ES1_0	AM335X_CLASS
398e4c060dbSTony Lindgren 
399e4c060dbSTony Lindgren #define OMAP443X_CLASS		0x44300044
400e4c060dbSTony Lindgren #define OMAP4430_REV_ES1_0	(OMAP443X_CLASS | (0x10 << 8))
401e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_0	(OMAP443X_CLASS | (0x20 << 8))
402e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_1	(OMAP443X_CLASS | (0x21 << 8))
403e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_2	(OMAP443X_CLASS | (0x22 << 8))
404e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_3	(OMAP443X_CLASS | (0x23 << 8))
405e4c060dbSTony Lindgren 
406e4c060dbSTony Lindgren #define OMAP446X_CLASS		0x44600044
407e4c060dbSTony Lindgren #define OMAP4460_REV_ES1_0	(OMAP446X_CLASS | (0x10 << 8))
408e4c060dbSTony Lindgren #define OMAP4460_REV_ES1_1	(OMAP446X_CLASS | (0x11 << 8))
409e4c060dbSTony Lindgren 
410e4c060dbSTony Lindgren #define OMAP447X_CLASS		0x44700044
411e4c060dbSTony Lindgren #define OMAP4470_REV_ES1_0	(OMAP447X_CLASS | (0x10 << 8))
412e4c060dbSTony Lindgren 
413e4c060dbSTony Lindgren #define OMAP54XX_CLASS		0x54000054
414e4c060dbSTony Lindgren #define OMAP5430_REV_ES1_0	(OMAP54XX_CLASS | (0x30 << 16) | (0x10 << 8))
415e4c060dbSTony Lindgren #define OMAP5432_REV_ES1_0	(OMAP54XX_CLASS | (0x32 << 16) | (0x10 << 8))
416e4c060dbSTony Lindgren 
417e4c060dbSTony Lindgren void omap2xxx_check_revision(void);
418e4c060dbSTony Lindgren void omap3xxx_check_revision(void);
419e4c060dbSTony Lindgren void omap4xxx_check_revision(void);
420e4c060dbSTony Lindgren void omap5xxx_check_revision(void);
421e4c060dbSTony Lindgren void omap3xxx_check_features(void);
422e4c060dbSTony Lindgren void ti81xx_check_features(void);
423e4c060dbSTony Lindgren void omap4xxx_check_features(void);
424e4c060dbSTony Lindgren 
425e4c060dbSTony Lindgren /*
426e4c060dbSTony Lindgren  * Runtime detection of OMAP3 features
427e4c060dbSTony Lindgren  *
428e4c060dbSTony Lindgren  * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
429e4c060dbSTony Lindgren  *    family have OS-level control over the I/O chain clock.  This is
430e4c060dbSTony Lindgren  *    to avoid a window during which wakeups could potentially be lost
431e4c060dbSTony Lindgren  *    during powerdomain transitions.  If this bit is set, it
432e4c060dbSTony Lindgren  *    indicates that the chip does support OS-level control of this
433e4c060dbSTony Lindgren  *    feature.
434e4c060dbSTony Lindgren  */
435e4c060dbSTony Lindgren extern u32 omap_features;
436e4c060dbSTony Lindgren 
437e4c060dbSTony Lindgren #define OMAP3_HAS_L2CACHE		BIT(0)
438e4c060dbSTony Lindgren #define OMAP3_HAS_IVA			BIT(1)
439e4c060dbSTony Lindgren #define OMAP3_HAS_SGX			BIT(2)
440e4c060dbSTony Lindgren #define OMAP3_HAS_NEON			BIT(3)
441e4c060dbSTony Lindgren #define OMAP3_HAS_ISP			BIT(4)
442e4c060dbSTony Lindgren #define OMAP3_HAS_192MHZ_CLK		BIT(5)
443e4c060dbSTony Lindgren #define OMAP3_HAS_IO_WAKEUP		BIT(6)
444e4c060dbSTony Lindgren #define OMAP3_HAS_SDRC			BIT(7)
445e4c060dbSTony Lindgren #define OMAP3_HAS_IO_CHAIN_CTRL		BIT(8)
44642a1cc9cSIvan Khoronzhuk #define OMAP4_HAS_PERF_SILICON		BIT(9)
447e4c060dbSTony Lindgren 
448e4c060dbSTony Lindgren 
449e4c060dbSTony Lindgren #define OMAP3_HAS_FEATURE(feat,flag)			\
450e4c060dbSTony Lindgren static inline unsigned int omap3_has_ ##feat(void)	\
451e4c060dbSTony Lindgren {							\
452e4c060dbSTony Lindgren 	return omap_features & OMAP3_HAS_ ##flag;	\
453e4c060dbSTony Lindgren }							\
454e4c060dbSTony Lindgren 
455e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(l2cache, L2CACHE)
456e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(sgx, SGX)
457e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(iva, IVA)
458e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(neon, NEON)
459e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(isp, ISP)
460e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
461e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
462e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(sdrc, SDRC)
463e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
464e4c060dbSTony Lindgren 
465e4c060dbSTony Lindgren /*
466e4c060dbSTony Lindgren  * Runtime detection of OMAP4 features
467e4c060dbSTony Lindgren  */
468e4c060dbSTony Lindgren #define OMAP4_HAS_FEATURE(feat, flag)			\
469e4c060dbSTony Lindgren static inline unsigned int omap4_has_ ##feat(void)	\
470e4c060dbSTony Lindgren {							\
471e4c060dbSTony Lindgren 	return omap_features & OMAP4_HAS_ ##flag;	\
472e4c060dbSTony Lindgren }							\
473e4c060dbSTony Lindgren 
47442a1cc9cSIvan Khoronzhuk OMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
475e4c060dbSTony Lindgren 
476*816a65efSTony Lindgren /*
477*816a65efSTony Lindgren  * We need to make sure omap initcalls don't run when
478*816a65efSTony Lindgren  * multiplatform kernels are booted on other SoCs.
479*816a65efSTony Lindgren  */
480*816a65efSTony Lindgren #define omap_initcall(level, fn)		\
481*816a65efSTony Lindgren static int __init __used __##fn(void)		\
482*816a65efSTony Lindgren {						\
483*816a65efSTony Lindgren 	if (!soc_is_omap())			\
484*816a65efSTony Lindgren 		return 0;			\
485*816a65efSTony Lindgren 	return fn();				\
486*816a65efSTony Lindgren }						\
487*816a65efSTony Lindgren level(__##fn);
488*816a65efSTony Lindgren 
489*816a65efSTony Lindgren #define omap_early_initcall(fn)		omap_initcall(early_initcall, fn)
490*816a65efSTony Lindgren #define omap_core_initcall(fn)		omap_initcall(core_initcall, fn)
491*816a65efSTony Lindgren #define omap_postcore_initcall(fn)	omap_initcall(postcore_initcall, fn)
492*816a65efSTony Lindgren #define omap_arch_initcall(fn)		omap_initcall(arch_initcall, fn)
493*816a65efSTony Lindgren #define omap_subsys_initcall(fn)	omap_initcall(subsys_initcall, fn)
494*816a65efSTony Lindgren #define omap_device_initcall(fn)	omap_initcall(device_initcall, fn)
495*816a65efSTony Lindgren #define omap_late_initcall(fn)		omap_initcall(late_initcall, fn)
496*816a65efSTony Lindgren 
497e4c060dbSTony Lindgren #endif	/* __ASSEMBLY__ */
498e4c060dbSTony Lindgren 
499