xref: /openbmc/linux/arch/arm/mach-omap2/soc.h (revision 987d13f6d7740a616e8905e6a7b35af28c63b5a4)
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>
116852215aSR Sricharan  * Added DRA7xxx specific defines - Sricharan R<r.sricharan@ti.com>
12e4c060dbSTony Lindgren  *
13e4c060dbSTony Lindgren  * This program is free software; you can redistribute it and/or modify
14e4c060dbSTony Lindgren  * it under the terms of the GNU General Public License as published by
15e4c060dbSTony Lindgren  * the Free Software Foundation; either version 2 of the License, or
16e4c060dbSTony Lindgren  * (at your option) any later version.
17e4c060dbSTony Lindgren  *
18e4c060dbSTony Lindgren  * This program is distributed in the hope that it will be useful,
19e4c060dbSTony Lindgren  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20e4c060dbSTony Lindgren  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21e4c060dbSTony Lindgren  * GNU General Public License for more details.
22e4c060dbSTony Lindgren  *
23e4c060dbSTony Lindgren  * You should have received a copy of the GNU General Public License
24e4c060dbSTony Lindgren  * along with this program; if not, write to the Free Software
25e4c060dbSTony Lindgren  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26e4c060dbSTony Lindgren  *
27e4c060dbSTony Lindgren  */
28e4c060dbSTony Lindgren 
29c49f34bcSTony Lindgren #include "omap24xx.h"
30c49f34bcSTony Lindgren #include "omap34xx.h"
31c49f34bcSTony Lindgren #include "omap44xx.h"
32c49f34bcSTony Lindgren #include "ti81xx.h"
33c49f34bcSTony Lindgren #include "am33xx.h"
34c49f34bcSTony Lindgren #include "omap54xx.h"
35e4c060dbSTony Lindgren 
36e4c060dbSTony Lindgren #ifndef __ASSEMBLY__
37e4c060dbSTony Lindgren 
38e4c060dbSTony Lindgren #include <linux/bitops.h>
396852215aSR Sricharan #include <linux/of.h>
40e4c060dbSTony Lindgren 
41e4c060dbSTony Lindgren /*
42e60ba933SJonas Rabenstein  * OMAP2+ is always defined as ARCH_MULTIPLATFORM in Kconfig
43e4c060dbSTony Lindgren  */
44e4c060dbSTony Lindgren #undef MULTI_OMAP2
45816a65efSTony Lindgren #define MULTI_OMAP2
466852215aSR Sricharan 
47e4c060dbSTony Lindgren /*
48e4c060dbSTony Lindgren  * Omap device type i.e. EMU/HS/TST/GP/BAD
49e4c060dbSTony Lindgren  */
50e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_TEST		0
51e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_EMU		1
52e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_SEC		2
53e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_GP		3
54e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_BAD		4
55e4c060dbSTony Lindgren 
56e4c060dbSTony Lindgren int omap_type(void);
57e4c060dbSTony Lindgren 
58e4c060dbSTony Lindgren /*
59e4c060dbSTony Lindgren  * omap_rev bits:
60d0b50905STony Lindgren  * SoC id bits	(0730, 1510, 1710, 2422...)	[31:16]
61d0b50905STony Lindgren  * SoC revision	(See _REV_ defined in cpu.h)	[15:08]
62d0b50905STony Lindgren  * SoC class bits (15xx, 16xx, 24xx, 34xx...)	[07:00]
63e4c060dbSTony Lindgren  */
64e4c060dbSTony Lindgren unsigned int omap_rev(void);
65e4c060dbSTony Lindgren 
66816a65efSTony Lindgren static inline int soc_is_omap(void)
67816a65efSTony Lindgren {
68816a65efSTony Lindgren 	return omap_rev() != 0;
69816a65efSTony Lindgren }
70816a65efSTony Lindgren 
71e4c060dbSTony Lindgren /*
72d0b50905STony Lindgren  * Get the SoC revision for OMAP devices
73e4c060dbSTony Lindgren  */
74e4c060dbSTony Lindgren #define GET_OMAP_REVISION()	((omap_rev() >> 8) & 0xff)
75e4c060dbSTony Lindgren 
76e4c060dbSTony Lindgren /*
77e4c060dbSTony Lindgren  * Macros to group OMAP into cpu classes.
78e4c060dbSTony Lindgren  * These can be used in most places.
79d0b50905STony Lindgren  * soc_is_omap24xx():	True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
80d0b50905STony Lindgren  * soc_is_omap242x():	True for OMAP2420, OMAP2422, OMAP2423
81d0b50905STony Lindgren  * soc_is_omap243x():	True for OMAP2430
82d0b50905STony Lindgren  * soc_is_omap343x():	True for OMAP3430
83d0b50905STony Lindgren  * soc_is_omap443x():	True for OMAP4430
84d0b50905STony Lindgren  * soc_is_omap446x():	True for OMAP4460
85d0b50905STony Lindgren  * soc_is_omap447x():	True for OMAP4470
86e4c060dbSTony Lindgren  * soc_is_omap543x():	True for OMAP5430, OMAP5432
87e4c060dbSTony Lindgren  */
88e4c060dbSTony Lindgren #define GET_OMAP_CLASS	(omap_rev() & 0xff)
89e4c060dbSTony Lindgren 
90e4c060dbSTony Lindgren #define IS_OMAP_CLASS(class, id)			\
91e4c060dbSTony Lindgren static inline int is_omap ##class (void)		\
92e4c060dbSTony Lindgren {							\
93e4c060dbSTony Lindgren 	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
94e4c060dbSTony Lindgren }
95e4c060dbSTony Lindgren 
96e4c060dbSTony Lindgren #define GET_AM_CLASS	((omap_rev() >> 24) & 0xff)
97e4c060dbSTony Lindgren 
98e4c060dbSTony Lindgren #define IS_AM_CLASS(class, id)				\
99e4c060dbSTony Lindgren static inline int is_am ##class (void)			\
100e4c060dbSTony Lindgren {							\
101e4c060dbSTony Lindgren 	return (GET_AM_CLASS == (id)) ? 1 : 0;		\
102e4c060dbSTony Lindgren }
103e4c060dbSTony Lindgren 
104e4c060dbSTony Lindgren #define GET_TI_CLASS	((omap_rev() >> 24) & 0xff)
105e4c060dbSTony Lindgren 
106e4c060dbSTony Lindgren #define IS_TI_CLASS(class, id)			\
107e4c060dbSTony Lindgren static inline int is_ti ##class (void)		\
108e4c060dbSTony Lindgren {							\
109e4c060dbSTony Lindgren 	return (GET_TI_CLASS == (id)) ? 1 : 0;	\
110e4c060dbSTony Lindgren }
111e4c060dbSTony Lindgren 
11206c2d368SKeerthy #define GET_DRA_CLASS	((omap_rev() >> 24) & 0xff)
11306c2d368SKeerthy 
11406c2d368SKeerthy #define IS_DRA_CLASS(class, id)				\
11506c2d368SKeerthy static inline int is_dra ##class (void)			\
11606c2d368SKeerthy {							\
11706c2d368SKeerthy 	return (GET_DRA_CLASS == (id)) ? 1 : 0;		\
11806c2d368SKeerthy }
11906c2d368SKeerthy 
120e4c060dbSTony Lindgren #define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)
121e4c060dbSTony Lindgren 
122e4c060dbSTony Lindgren #define IS_OMAP_SUBCLASS(subclass, id)			\
123e4c060dbSTony Lindgren static inline int is_omap ##subclass (void)		\
124e4c060dbSTony Lindgren {							\
125e4c060dbSTony Lindgren 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
126e4c060dbSTony Lindgren }
127e4c060dbSTony Lindgren 
128e4c060dbSTony Lindgren #define IS_TI_SUBCLASS(subclass, id)			\
129e4c060dbSTony Lindgren static inline int is_ti ##subclass (void)		\
130e4c060dbSTony Lindgren {							\
131e4c060dbSTony Lindgren 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
132e4c060dbSTony Lindgren }
133e4c060dbSTony Lindgren 
134e4c060dbSTony Lindgren #define IS_AM_SUBCLASS(subclass, id)			\
135e4c060dbSTony Lindgren static inline int is_am ##subclass (void)		\
136e4c060dbSTony Lindgren {							\
137e4c060dbSTony Lindgren 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
138e4c060dbSTony Lindgren }
139e4c060dbSTony Lindgren 
14006c2d368SKeerthy #define IS_DRA_SUBCLASS(subclass, id)			\
14106c2d368SKeerthy static inline int is_dra ##subclass (void)		\
14206c2d368SKeerthy {							\
14306c2d368SKeerthy 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
14406c2d368SKeerthy }
14506c2d368SKeerthy 
146*987d13f6SLokesh Vutla #define GET_DRA_PACKAGE		(omap_rev() & 0xff)
147*987d13f6SLokesh Vutla 
148*987d13f6SLokesh Vutla #define IS_DRA_SUBCLASS_PACKAGE(subclass, package, id)			\
149*987d13f6SLokesh Vutla static inline int is_dra ##subclass ##_ ##package (void)		\
150*987d13f6SLokesh Vutla {									\
151*987d13f6SLokesh Vutla 	return (is_dra ##subclass () && GET_DRA_PACKAGE == id) ? 1 : 0;	\
152*987d13f6SLokesh Vutla }
153*987d13f6SLokesh Vutla 
154e4c060dbSTony Lindgren IS_OMAP_CLASS(24xx, 0x24)
155e4c060dbSTony Lindgren IS_OMAP_CLASS(34xx, 0x34)
156e4c060dbSTony Lindgren IS_OMAP_CLASS(44xx, 0x44)
157e4c060dbSTony Lindgren IS_AM_CLASS(35xx, 0x35)
158e4c060dbSTony Lindgren IS_OMAP_CLASS(54xx, 0x54)
159e4c060dbSTony Lindgren IS_AM_CLASS(33xx, 0x33)
160c664d0a9SAfzal Mohammed IS_AM_CLASS(43xx, 0x43)
161e4c060dbSTony Lindgren 
162e4c060dbSTony Lindgren IS_TI_CLASS(81xx, 0x81)
16306c2d368SKeerthy IS_DRA_CLASS(7xx, 0x7)
164e4c060dbSTony Lindgren 
165e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(242x, 0x242)
166e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(243x, 0x243)
167e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(343x, 0x343)
168e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(363x, 0x363)
169e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(443x, 0x443)
170e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(446x, 0x446)
171e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(447x, 0x447)
172e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(543x, 0x543)
173e4c060dbSTony Lindgren 
174e4c060dbSTony Lindgren IS_TI_SUBCLASS(816x, 0x816)
175e4c060dbSTony Lindgren IS_TI_SUBCLASS(814x, 0x814)
176e4c060dbSTony Lindgren IS_AM_SUBCLASS(335x, 0x335)
177c664d0a9SAfzal Mohammed IS_AM_SUBCLASS(437x, 0x437)
178c15ab996SLokesh Vutla IS_DRA_SUBCLASS(76x, 0x76)
179*987d13f6SLokesh Vutla IS_DRA_SUBCLASS_PACKAGE(76x, abz, 2)
180*987d13f6SLokesh Vutla IS_DRA_SUBCLASS_PACKAGE(76x, acd, 3)
18106c2d368SKeerthy IS_DRA_SUBCLASS(75x, 0x75)
18206c2d368SKeerthy IS_DRA_SUBCLASS(72x, 0x72)
183e4c060dbSTony Lindgren 
184d0b50905STony Lindgren #define soc_is_ti81xx()			0
185d0b50905STony Lindgren #define soc_is_ti816x()			0
186d0b50905STony Lindgren #define soc_is_ti814x()			0
187e4c060dbSTony Lindgren #define soc_is_am35xx()			0
188e4c060dbSTony Lindgren #define soc_is_am33xx()			0
189e4c060dbSTony Lindgren #define soc_is_am335x()			0
190c664d0a9SAfzal Mohammed #define soc_is_am43xx()			0
191c664d0a9SAfzal Mohammed #define soc_is_am437x()			0
192d0b50905STony Lindgren #define soc_is_omap44xx()		0
193d0b50905STony Lindgren #define soc_is_omap443x()		0
194d0b50905STony Lindgren #define soc_is_omap446x()		0
195d0b50905STony Lindgren #define soc_is_omap447x()		0
196e4c060dbSTony Lindgren #define soc_is_omap54xx()		0
197e4c060dbSTony Lindgren #define soc_is_omap543x()		0
1986852215aSR Sricharan #define soc_is_dra7xx()			0
199c15ab996SLokesh Vutla #define soc_is_dra76x()			0
200af438fecSRajendra Nayak #define soc_is_dra74x()			0
201af438fecSRajendra Nayak #define soc_is_dra72x()			0
202e4c060dbSTony Lindgren 
203e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP2)
204d0b50905STony Lindgren # define soc_is_omap24xx()		is_omap24xx()
205e60ba933SJonas Rabenstein #else
206e60ba933SJonas Rabenstein # define soc_is_omap24xx()		0
207e4c060dbSTony Lindgren #endif
208e4c060dbSTony Lindgren #if defined(CONFIG_SOC_OMAP2420)
209d0b50905STony Lindgren # define soc_is_omap242x()		is_omap242x()
210e60ba933SJonas Rabenstein #else
211e60ba933SJonas Rabenstein # define soc_is_omap242x()		0
212e4c060dbSTony Lindgren #endif
213e4c060dbSTony Lindgren #if defined(CONFIG_SOC_OMAP2430)
214d0b50905STony Lindgren # define soc_is_omap243x()		is_omap243x()
215e60ba933SJonas Rabenstein #else
216e60ba933SJonas Rabenstein # define soc_is_omap243x()		0
217e4c060dbSTony Lindgren #endif
218e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP3)
219d0b50905STony Lindgren # define soc_is_omap34xx()		is_omap34xx()
220d0b50905STony Lindgren # define soc_is_omap343x()		is_omap343x()
221e4c060dbSTony Lindgren #else
222e60ba933SJonas Rabenstein # define soc_is_omap34xx()		0
223e60ba933SJonas Rabenstein # define soc_is_omap343x()		0
224e4c060dbSTony Lindgren #endif
225e4c060dbSTony Lindgren 
226e4c060dbSTony Lindgren /*
227e4c060dbSTony Lindgren  * Macros to detect individual cpu types.
228e4c060dbSTony Lindgren  * These are only rarely needed.
229d0b50905STony Lindgren  * soc_is_omap2420():	True for OMAP2420
230d0b50905STony Lindgren  * soc_is_omap2422():	True for OMAP2422
231d0b50905STony Lindgren  * soc_is_omap2423():	True for OMAP2423
232d0b50905STony Lindgren  * soc_is_omap2430():	True for OMAP2430
233d0b50905STony Lindgren  * soc_is_omap3430():	True for OMAP3430
234e4c060dbSTony Lindgren  */
235e4c060dbSTony Lindgren #define GET_OMAP_TYPE	((omap_rev() >> 16) & 0xffff)
236e4c060dbSTony Lindgren 
237e4c060dbSTony Lindgren #define IS_OMAP_TYPE(type, id)				\
238e4c060dbSTony Lindgren static inline int is_omap ##type (void)			\
239e4c060dbSTony Lindgren {							\
240e4c060dbSTony Lindgren 	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
241e4c060dbSTony Lindgren }
242e4c060dbSTony Lindgren 
243e4c060dbSTony Lindgren IS_OMAP_TYPE(2420, 0x2420)
244e4c060dbSTony Lindgren IS_OMAP_TYPE(2422, 0x2422)
245e4c060dbSTony Lindgren IS_OMAP_TYPE(2423, 0x2423)
246e4c060dbSTony Lindgren IS_OMAP_TYPE(2430, 0x2430)
247e4c060dbSTony Lindgren IS_OMAP_TYPE(3430, 0x3430)
248e4c060dbSTony Lindgren 
249d0b50905STony Lindgren #define soc_is_omap2420()		0
250d0b50905STony Lindgren #define soc_is_omap2422()		0
251d0b50905STony Lindgren #define soc_is_omap2423()		0
252d0b50905STony Lindgren #define soc_is_omap2430()		0
253d0b50905STony Lindgren #define soc_is_omap3430()		0
254d0b50905STony Lindgren #define soc_is_omap3630()		0
255e4c060dbSTony Lindgren #define soc_is_omap5430()		0
256e4c060dbSTony Lindgren 
257e4c060dbSTony Lindgren /* These are needed for the common code */
258d0b50905STony Lindgren #define soc_is_omap7xx()		0
259d0b50905STony Lindgren #define soc_is_omap15xx()		0
260d0b50905STony Lindgren #define soc_is_omap16xx()		0
261d0b50905STony Lindgren #define soc_is_omap1510()		0
262d0b50905STony Lindgren #define soc_is_omap1610()		0
263d0b50905STony Lindgren #define soc_is_omap1611()		0
264d0b50905STony Lindgren #define soc_is_omap1621()		0
265d0b50905STony Lindgren #define soc_is_omap1710()		0
266e4c060dbSTony Lindgren #define cpu_class_is_omap1()		0
267e4c060dbSTony Lindgren #define cpu_class_is_omap2()		1
268e4c060dbSTony Lindgren 
269e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP2)
270d0b50905STony Lindgren # undef  soc_is_omap2420
271d0b50905STony Lindgren # undef  soc_is_omap2422
272d0b50905STony Lindgren # undef  soc_is_omap2423
273d0b50905STony Lindgren # undef  soc_is_omap2430
274d0b50905STony Lindgren # define soc_is_omap2420()		is_omap2420()
275d0b50905STony Lindgren # define soc_is_omap2422()		is_omap2422()
276d0b50905STony Lindgren # define soc_is_omap2423()		is_omap2423()
277d0b50905STony Lindgren # define soc_is_omap2430()		is_omap2430()
278e4c060dbSTony Lindgren #endif
279e4c060dbSTony Lindgren 
280e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP3)
281d0b50905STony Lindgren # undef soc_is_omap3430
282d0b50905STony Lindgren # undef soc_is_ti81xx
283d0b50905STony Lindgren # undef soc_is_ti816x
284d0b50905STony Lindgren # undef soc_is_ti814x
285e4c060dbSTony Lindgren # undef soc_is_am35xx
286d0b50905STony Lindgren # define soc_is_omap3430()		is_omap3430()
287d0b50905STony Lindgren # undef soc_is_omap3630
288d0b50905STony Lindgren # define soc_is_omap3630()		is_omap363x()
289d0b50905STony Lindgren # define soc_is_ti81xx()		is_ti81xx()
290d0b50905STony Lindgren # define soc_is_ti816x()		is_ti816x()
291d0b50905STony Lindgren # define soc_is_ti814x()		is_ti814x()
292e4c060dbSTony Lindgren # define soc_is_am35xx()		is_am35xx()
293e4c060dbSTony Lindgren #endif
294e4c060dbSTony Lindgren 
295e4c060dbSTony Lindgren # if defined(CONFIG_SOC_AM33XX)
296e4c060dbSTony Lindgren # undef soc_is_am33xx
297e4c060dbSTony Lindgren # undef soc_is_am335x
298e4c060dbSTony Lindgren # define soc_is_am33xx()		is_am33xx()
299e4c060dbSTony Lindgren # define soc_is_am335x()		is_am335x()
300e4c060dbSTony Lindgren #endif
301e4c060dbSTony Lindgren 
302c664d0a9SAfzal Mohammed #ifdef	CONFIG_SOC_AM43XX
303c664d0a9SAfzal Mohammed # undef soc_is_am43xx
304c664d0a9SAfzal Mohammed # undef soc_is_am437x
305c664d0a9SAfzal Mohammed # define soc_is_am43xx()		is_am43xx()
306c664d0a9SAfzal Mohammed # define soc_is_am437x()		is_am437x()
307c664d0a9SAfzal Mohammed #endif
308c664d0a9SAfzal Mohammed 
309e4c060dbSTony Lindgren # if defined(CONFIG_ARCH_OMAP4)
310d0b50905STony Lindgren # undef soc_is_omap44xx
311d0b50905STony Lindgren # undef soc_is_omap443x
312d0b50905STony Lindgren # undef soc_is_omap446x
313d0b50905STony Lindgren # undef soc_is_omap447x
314d0b50905STony Lindgren # define soc_is_omap44xx()		is_omap44xx()
315d0b50905STony Lindgren # define soc_is_omap443x()		is_omap443x()
316d0b50905STony Lindgren # define soc_is_omap446x()		is_omap446x()
317d0b50905STony Lindgren # define soc_is_omap447x()		is_omap447x()
318e4c060dbSTony Lindgren # endif
319e4c060dbSTony Lindgren 
320e4c060dbSTony Lindgren # if defined(CONFIG_SOC_OMAP5)
321e4c060dbSTony Lindgren # undef soc_is_omap54xx
322e4c060dbSTony Lindgren # undef soc_is_omap543x
323e4c060dbSTony Lindgren # define soc_is_omap54xx()		is_omap54xx()
324e4c060dbSTony Lindgren # define soc_is_omap543x()		is_omap543x()
325e4c060dbSTony Lindgren #endif
326e4c060dbSTony Lindgren 
3276852215aSR Sricharan #if defined(CONFIG_SOC_DRA7XX)
3286852215aSR Sricharan #undef soc_is_dra7xx
329c15ab996SLokesh Vutla #undef soc_is_dra76x
330*987d13f6SLokesh Vutla #undef soc_is_dra76x_abz
331*987d13f6SLokesh Vutla #undef soc_is_dra76x_acd
332af438fecSRajendra Nayak #undef soc_is_dra74x
333af438fecSRajendra Nayak #undef soc_is_dra72x
33406c2d368SKeerthy #define soc_is_dra7xx()	is_dra7xx()
335c15ab996SLokesh Vutla #define soc_is_dra76x()	is_dra76x()
336*987d13f6SLokesh Vutla #define soc_is_dra76x_abz()	is_dra76x_abz()
337*987d13f6SLokesh Vutla #define soc_is_dra76x_acd()	is_dra76x_acd()
33806c2d368SKeerthy #define soc_is_dra74x()	is_dra75x()
33906c2d368SKeerthy #define soc_is_dra72x()	is_dra72x()
3406852215aSR Sricharan #endif
3416852215aSR Sricharan 
342e4c060dbSTony Lindgren /* Various silicon revisions for omap2 */
343e4c060dbSTony Lindgren #define OMAP242X_CLASS		0x24200024
344e4c060dbSTony Lindgren #define OMAP2420_REV_ES1_0	OMAP242X_CLASS
345e4c060dbSTony Lindgren #define OMAP2420_REV_ES2_0	(OMAP242X_CLASS | (0x1 << 8))
346e4c060dbSTony Lindgren 
347e4c060dbSTony Lindgren #define OMAP243X_CLASS		0x24300024
348e4c060dbSTony Lindgren #define OMAP2430_REV_ES1_0	OMAP243X_CLASS
349e4c060dbSTony Lindgren 
350e4c060dbSTony Lindgren #define OMAP343X_CLASS		0x34300034
351e4c060dbSTony Lindgren #define OMAP3430_REV_ES1_0	OMAP343X_CLASS
352e4c060dbSTony Lindgren #define OMAP3430_REV_ES2_0	(OMAP343X_CLASS | (0x1 << 8))
353e4c060dbSTony Lindgren #define OMAP3430_REV_ES2_1	(OMAP343X_CLASS | (0x2 << 8))
354e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_0	(OMAP343X_CLASS | (0x3 << 8))
355e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_1	(OMAP343X_CLASS | (0x4 << 8))
356e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_1_2	(OMAP343X_CLASS | (0x5 << 8))
357e4c060dbSTony Lindgren 
358e4c060dbSTony Lindgren #define OMAP363X_CLASS		0x36300034
359e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_0	OMAP363X_CLASS
360e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_1	(OMAP363X_CLASS | (0x1 << 8))
361e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_2	(OMAP363X_CLASS | (0x2 << 8))
362e4c060dbSTony Lindgren 
363c27964b5STony Lindgren #define TI816X_CLASS		0x81600081
364e4c060dbSTony Lindgren #define TI8168_REV_ES1_0	TI816X_CLASS
365e4c060dbSTony Lindgren #define TI8168_REV_ES1_1	(TI816X_CLASS | (0x1 << 8))
366a5f93d9dSAida Mynzhasova #define TI8168_REV_ES2_0	(TI816X_CLASS | (0x2 << 8))
367a5f93d9dSAida Mynzhasova #define TI8168_REV_ES2_1	(TI816X_CLASS | (0x3 << 8))
368e4c060dbSTony Lindgren 
369c27964b5STony Lindgren #define TI814X_CLASS		0x81400081
370e4c060dbSTony Lindgren #define TI8148_REV_ES1_0	TI814X_CLASS
371e4c060dbSTony Lindgren #define TI8148_REV_ES2_0	(TI814X_CLASS | (0x1 << 8))
372e4c060dbSTony Lindgren #define TI8148_REV_ES2_1	(TI814X_CLASS | (0x2 << 8))
373e4c060dbSTony Lindgren 
374e4c060dbSTony Lindgren #define AM35XX_CLASS		0x35170034
375e4c060dbSTony Lindgren #define AM35XX_REV_ES1_0	AM35XX_CLASS
376e4c060dbSTony Lindgren #define AM35XX_REV_ES1_1	(AM35XX_CLASS | (0x1 << 8))
377e4c060dbSTony Lindgren 
378e4c060dbSTony Lindgren #define AM335X_CLASS		0x33500033
379e4c060dbSTony Lindgren #define AM335X_REV_ES1_0	AM335X_CLASS
3805af044f4SAnilKumar Ch #define AM335X_REV_ES2_0	(AM335X_CLASS | (0x1 << 8))
381d240ef30SVaibhav Hiremath #define AM335X_REV_ES2_1	(AM335X_CLASS | (0x2 << 8))
382e4c060dbSTony Lindgren 
383c664d0a9SAfzal Mohammed #define AM437X_CLASS		0x43700000
3844a2ed4c0SLokesh Vutla #define AM437X_REV_ES1_0	(AM437X_CLASS | (0x10 << 8))
3854a2ed4c0SLokesh Vutla #define AM437X_REV_ES1_1	(AM437X_CLASS | (0x11 << 8))
3864fdd54f0SLokesh Vutla #define AM437X_REV_ES1_2	(AM437X_CLASS | (0x12 << 8))
387c664d0a9SAfzal Mohammed 
388e4c060dbSTony Lindgren #define OMAP443X_CLASS		0x44300044
389e4c060dbSTony Lindgren #define OMAP4430_REV_ES1_0	(OMAP443X_CLASS | (0x10 << 8))
390e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_0	(OMAP443X_CLASS | (0x20 << 8))
391e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_1	(OMAP443X_CLASS | (0x21 << 8))
392e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_2	(OMAP443X_CLASS | (0x22 << 8))
393e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_3	(OMAP443X_CLASS | (0x23 << 8))
394e4c060dbSTony Lindgren 
395e4c060dbSTony Lindgren #define OMAP446X_CLASS		0x44600044
396e4c060dbSTony Lindgren #define OMAP4460_REV_ES1_0	(OMAP446X_CLASS | (0x10 << 8))
397e4c060dbSTony Lindgren #define OMAP4460_REV_ES1_1	(OMAP446X_CLASS | (0x11 << 8))
398e4c060dbSTony Lindgren 
399e4c060dbSTony Lindgren #define OMAP447X_CLASS		0x44700044
400e4c060dbSTony Lindgren #define OMAP4470_REV_ES1_0	(OMAP447X_CLASS | (0x10 << 8))
401e4c060dbSTony Lindgren 
402e4c060dbSTony Lindgren #define OMAP54XX_CLASS		0x54000054
4035a898a78SSantosh Shilimkar #define OMAP5430_REV_ES2_0	(OMAP54XX_CLASS | (0x30 << 16) | (0x20 << 8))
4045a898a78SSantosh Shilimkar #define OMAP5432_REV_ES2_0	(OMAP54XX_CLASS | (0x32 << 16) | (0x20 << 8))
405e4c060dbSTony Lindgren 
406733d20eeSNishanth Menon #define DRA7XX_CLASS		0x07000000
407c15ab996SLokesh Vutla #define DRA762_REV_ES1_0	(DRA7XX_CLASS | (0x62 << 16) | (0x10 << 8))
408*987d13f6SLokesh Vutla #define DRA762_ABZ_REV_ES1_0	(DRA762_REV_ES1_0 | (2 << 0))
409*987d13f6SLokesh Vutla #define DRA762_ACD_REV_ES1_0	(DRA762_REV_ES1_0 | (3 << 0))
410733d20eeSNishanth Menon #define DRA752_REV_ES1_0	(DRA7XX_CLASS | (0x52 << 16) | (0x10 << 8))
411733d20eeSNishanth Menon #define DRA752_REV_ES1_1	(DRA7XX_CLASS | (0x52 << 16) | (0x11 << 8))
41281032e34SVishal Mahaveer #define DRA752_REV_ES2_0	(DRA7XX_CLASS | (0x52 << 16) | (0x20 << 8))
41381032e34SVishal Mahaveer #define DRA722_REV_ES1_0	(DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8))
4146b532c4aSVishal Mahaveer #define DRA722_REV_ES2_0	(DRA7XX_CLASS | (0x22 << 16) | (0x20 << 8))
415cf14dd05SVishal Mahaveer #define DRA722_REV_ES2_1	(DRA7XX_CLASS | (0x22 << 16) | (0x21 << 8))
416733d20eeSNishanth Menon 
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);
421733d20eeSNishanth Menon void dra7xxx_check_revision(void);
422e4c060dbSTony Lindgren void omap3xxx_check_features(void);
423e4c060dbSTony Lindgren void ti81xx_check_features(void);
4247bcad170SVaibhav Hiremath void am33xx_check_features(void);
425e4c060dbSTony Lindgren void omap4xxx_check_features(void);
426e4c060dbSTony Lindgren 
427e4c060dbSTony Lindgren /*
428e4c060dbSTony Lindgren  * Runtime detection of OMAP3 features
429e4c060dbSTony Lindgren  *
430e4c060dbSTony Lindgren  * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
431e4c060dbSTony Lindgren  *    family have OS-level control over the I/O chain clock.  This is
432e4c060dbSTony Lindgren  *    to avoid a window during which wakeups could potentially be lost
433e4c060dbSTony Lindgren  *    during powerdomain transitions.  If this bit is set, it
434e4c060dbSTony Lindgren  *    indicates that the chip does support OS-level control of this
435e4c060dbSTony Lindgren  *    feature.
436e4c060dbSTony Lindgren  */
437e4c060dbSTony Lindgren extern u32 omap_features;
438e4c060dbSTony Lindgren 
439e4c060dbSTony Lindgren #define OMAP3_HAS_L2CACHE		BIT(0)
440e4c060dbSTony Lindgren #define OMAP3_HAS_IVA			BIT(1)
441e4c060dbSTony Lindgren #define OMAP3_HAS_SGX			BIT(2)
442e4c060dbSTony Lindgren #define OMAP3_HAS_NEON			BIT(3)
443e4c060dbSTony Lindgren #define OMAP3_HAS_ISP			BIT(4)
444e4c060dbSTony Lindgren #define OMAP3_HAS_192MHZ_CLK		BIT(5)
445e4c060dbSTony Lindgren #define OMAP3_HAS_IO_WAKEUP		BIT(6)
446e4c060dbSTony Lindgren #define OMAP3_HAS_SDRC			BIT(7)
447e4c060dbSTony Lindgren #define OMAP3_HAS_IO_CHAIN_CTRL		BIT(8)
44842a1cc9cSIvan Khoronzhuk #define OMAP4_HAS_PERF_SILICON		BIT(9)
449e4c060dbSTony Lindgren 
450e4c060dbSTony Lindgren 
451e4c060dbSTony Lindgren #define OMAP3_HAS_FEATURE(feat,flag)			\
452e4c060dbSTony Lindgren static inline unsigned int omap3_has_ ##feat(void)	\
453e4c060dbSTony Lindgren {							\
454e4c060dbSTony Lindgren 	return omap_features & OMAP3_HAS_ ##flag;	\
455e4c060dbSTony Lindgren }							\
456e4c060dbSTony Lindgren 
457e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(l2cache, L2CACHE)
458e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(sgx, SGX)
459e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(iva, IVA)
460e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(neon, NEON)
461e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(isp, ISP)
462e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
463e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
464e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(sdrc, SDRC)
465e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
466e4c060dbSTony Lindgren 
467e4c060dbSTony Lindgren /*
468e4c060dbSTony Lindgren  * Runtime detection of OMAP4 features
469e4c060dbSTony Lindgren  */
470e4c060dbSTony Lindgren #define OMAP4_HAS_FEATURE(feat, flag)			\
471e4c060dbSTony Lindgren static inline unsigned int omap4_has_ ##feat(void)	\
472e4c060dbSTony Lindgren {							\
473e4c060dbSTony Lindgren 	return omap_features & OMAP4_HAS_ ##flag;	\
474e4c060dbSTony Lindgren }							\
475e4c060dbSTony Lindgren 
47642a1cc9cSIvan Khoronzhuk OMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
477e4c060dbSTony Lindgren 
478816a65efSTony Lindgren /*
479816a65efSTony Lindgren  * We need to make sure omap initcalls don't run when
480816a65efSTony Lindgren  * multiplatform kernels are booted on other SoCs.
481816a65efSTony Lindgren  */
482816a65efSTony Lindgren #define omap_initcall(level, fn)		\
483816a65efSTony Lindgren static int __init __used __##fn(void)		\
484816a65efSTony Lindgren {						\
485816a65efSTony Lindgren 	if (!soc_is_omap())			\
486816a65efSTony Lindgren 		return 0;			\
487816a65efSTony Lindgren 	return fn();				\
488816a65efSTony Lindgren }						\
489816a65efSTony Lindgren level(__##fn);
490816a65efSTony Lindgren 
491816a65efSTony Lindgren #define omap_early_initcall(fn)		omap_initcall(early_initcall, fn)
492816a65efSTony Lindgren #define omap_core_initcall(fn)		omap_initcall(core_initcall, fn)
493816a65efSTony Lindgren #define omap_postcore_initcall(fn)	omap_initcall(postcore_initcall, fn)
494816a65efSTony Lindgren #define omap_arch_initcall(fn)		omap_initcall(arch_initcall, fn)
495816a65efSTony Lindgren #define omap_subsys_initcall(fn)	omap_initcall(subsys_initcall, fn)
496816a65efSTony Lindgren #define omap_device_initcall(fn)	omap_initcall(device_initcall, fn)
497816a65efSTony Lindgren #define omap_late_initcall(fn)		omap_initcall(late_initcall, fn)
498e7e17c53SKevin Hilman #define omap_late_initcall_sync(fn)	omap_initcall(late_initcall_sync, fn)
499816a65efSTony Lindgren 
500d0b50905STony Lindgren /* Legacy defines, these can be removed when users are removed */
501d0b50905STony Lindgren #define cpu_is_omap2420()	soc_is_omap2420()
502d0b50905STony Lindgren #define cpu_is_omap2422()	soc_is_omap2422()
503d0b50905STony Lindgren #define cpu_is_omap242x()	soc_is_omap242x()
504d0b50905STony Lindgren #define cpu_is_omap2430()	soc_is_omap2430()
505d0b50905STony Lindgren #define cpu_is_omap243x()	soc_is_omap243x()
506d0b50905STony Lindgren #define cpu_is_omap24xx()	soc_is_omap24xx()
507d0b50905STony Lindgren #define cpu_is_omap3430()	soc_is_omap3430()
508d0b50905STony Lindgren #define cpu_is_omap343x()	soc_is_omap343x()
509d0b50905STony Lindgren #define cpu_is_omap34xx()	soc_is_omap34xx()
510d0b50905STony Lindgren #define cpu_is_omap3630()	soc_is_omap3630()
511d0b50905STony Lindgren #define cpu_is_omap443x()	soc_is_omap443x()
512d0b50905STony Lindgren #define cpu_is_omap446x()	soc_is_omap446x()
513d0b50905STony Lindgren #define cpu_is_omap44xx()	soc_is_omap44xx()
514d0b50905STony Lindgren #define cpu_is_ti814x()		soc_is_ti814x()
515d0b50905STony Lindgren #define cpu_is_ti816x()		soc_is_ti816x()
516d0b50905STony Lindgren #define cpu_is_ti81xx()		soc_is_ti81xx()
517e4c060dbSTony Lindgren 
518d0b50905STony Lindgren #endif	/* __ASSEMBLY__ */
519