1*1a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2e4c060dbSTony Lindgren /*
3e4c060dbSTony Lindgren * OMAP cpu type detection
4e4c060dbSTony Lindgren *
5e4c060dbSTony Lindgren * Copyright (C) 2004, 2008 Nokia Corporation
6e4c060dbSTony Lindgren *
7e4c060dbSTony Lindgren * Copyright (C) 2009-11 Texas Instruments.
8e4c060dbSTony Lindgren *
9e4c060dbSTony Lindgren * Written by Tony Lindgren <tony.lindgren@nokia.com>
10e4c060dbSTony Lindgren *
11e4c060dbSTony Lindgren * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
126852215aSR Sricharan * Added DRA7xxx specific defines - Sricharan R<r.sricharan@ti.com>
13e4c060dbSTony Lindgren */
14e4c060dbSTony Lindgren
15c49f34bcSTony Lindgren #include "omap24xx.h"
16c49f34bcSTony Lindgren #include "omap34xx.h"
17c49f34bcSTony Lindgren #include "omap44xx.h"
18c49f34bcSTony Lindgren #include "ti81xx.h"
19c49f34bcSTony Lindgren #include "am33xx.h"
20c49f34bcSTony Lindgren #include "omap54xx.h"
21e4c060dbSTony Lindgren
22e4c060dbSTony Lindgren #ifndef __ASSEMBLY__
23e4c060dbSTony Lindgren
24e4c060dbSTony Lindgren #include <linux/bitops.h>
256852215aSR Sricharan #include <linux/of.h>
26e4c060dbSTony Lindgren
27e4c060dbSTony Lindgren /*
28e60ba933SJonas Rabenstein * OMAP2+ is always defined as ARCH_MULTIPLATFORM in Kconfig
29e4c060dbSTony Lindgren */
30e4c060dbSTony Lindgren #undef MULTI_OMAP2
31816a65efSTony Lindgren #define MULTI_OMAP2
326852215aSR Sricharan
33e4c060dbSTony Lindgren /*
34e4c060dbSTony Lindgren * Omap device type i.e. EMU/HS/TST/GP/BAD
35e4c060dbSTony Lindgren */
36e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_TEST 0
37e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_EMU 1
38e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_SEC 2
39e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_GP 3
40e4c060dbSTony Lindgren #define OMAP2_DEVICE_TYPE_BAD 4
41e4c060dbSTony Lindgren
42e4c060dbSTony Lindgren int omap_type(void);
43e4c060dbSTony Lindgren
44e4c060dbSTony Lindgren /*
45e4c060dbSTony Lindgren * omap_rev bits:
46d0b50905STony Lindgren * SoC id bits (0730, 1510, 1710, 2422...) [31:16]
47d0b50905STony Lindgren * SoC revision (See _REV_ defined in cpu.h) [15:08]
48d0b50905STony Lindgren * SoC class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
49e4c060dbSTony Lindgren */
50e4c060dbSTony Lindgren unsigned int omap_rev(void);
51e4c060dbSTony Lindgren
soc_is_omap(void)52816a65efSTony Lindgren static inline int soc_is_omap(void)
53816a65efSTony Lindgren {
54816a65efSTony Lindgren return omap_rev() != 0;
55816a65efSTony Lindgren }
56816a65efSTony Lindgren
57e4c060dbSTony Lindgren /*
58d0b50905STony Lindgren * Get the SoC revision for OMAP devices
59e4c060dbSTony Lindgren */
60e4c060dbSTony Lindgren #define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
61e4c060dbSTony Lindgren
62e4c060dbSTony Lindgren /*
63e4c060dbSTony Lindgren * Macros to group OMAP into cpu classes.
64e4c060dbSTony Lindgren * These can be used in most places.
65d0b50905STony Lindgren * soc_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
66d0b50905STony Lindgren * soc_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
67d0b50905STony Lindgren * soc_is_omap243x(): True for OMAP2430
68d0b50905STony Lindgren * soc_is_omap343x(): True for OMAP3430
69d0b50905STony Lindgren * soc_is_omap443x(): True for OMAP4430
70d0b50905STony Lindgren * soc_is_omap446x(): True for OMAP4460
71d0b50905STony Lindgren * soc_is_omap447x(): True for OMAP4470
72e4c060dbSTony Lindgren * soc_is_omap543x(): True for OMAP5430, OMAP5432
73e4c060dbSTony Lindgren */
74e4c060dbSTony Lindgren #define GET_OMAP_CLASS (omap_rev() & 0xff)
75e4c060dbSTony Lindgren
76e4c060dbSTony Lindgren #define IS_OMAP_CLASS(class, id) \
77e4c060dbSTony Lindgren static inline int is_omap ##class (void) \
78e4c060dbSTony Lindgren { \
79e4c060dbSTony Lindgren return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
80e4c060dbSTony Lindgren }
81e4c060dbSTony Lindgren
82e4c060dbSTony Lindgren #define GET_AM_CLASS ((omap_rev() >> 24) & 0xff)
83e4c060dbSTony Lindgren
84e4c060dbSTony Lindgren #define IS_AM_CLASS(class, id) \
85e4c060dbSTony Lindgren static inline int is_am ##class (void) \
86e4c060dbSTony Lindgren { \
87e4c060dbSTony Lindgren return (GET_AM_CLASS == (id)) ? 1 : 0; \
88e4c060dbSTony Lindgren }
89e4c060dbSTony Lindgren
90e4c060dbSTony Lindgren #define GET_TI_CLASS ((omap_rev() >> 24) & 0xff)
91e4c060dbSTony Lindgren
92e4c060dbSTony Lindgren #define IS_TI_CLASS(class, id) \
93e4c060dbSTony Lindgren static inline int is_ti ##class (void) \
94e4c060dbSTony Lindgren { \
95e4c060dbSTony Lindgren return (GET_TI_CLASS == (id)) ? 1 : 0; \
96e4c060dbSTony Lindgren }
97e4c060dbSTony Lindgren
9806c2d368SKeerthy #define GET_DRA_CLASS ((omap_rev() >> 24) & 0xff)
9906c2d368SKeerthy
10006c2d368SKeerthy #define IS_DRA_CLASS(class, id) \
10106c2d368SKeerthy static inline int is_dra ##class (void) \
10206c2d368SKeerthy { \
10306c2d368SKeerthy return (GET_DRA_CLASS == (id)) ? 1 : 0; \
10406c2d368SKeerthy }
10506c2d368SKeerthy
106e4c060dbSTony Lindgren #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
107e4c060dbSTony Lindgren
108e4c060dbSTony Lindgren #define IS_OMAP_SUBCLASS(subclass, id) \
109e4c060dbSTony Lindgren static inline int is_omap ##subclass (void) \
110e4c060dbSTony Lindgren { \
111e4c060dbSTony Lindgren return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
112e4c060dbSTony Lindgren }
113e4c060dbSTony Lindgren
114e4c060dbSTony Lindgren #define IS_TI_SUBCLASS(subclass, id) \
115e4c060dbSTony Lindgren static inline int is_ti ##subclass (void) \
116e4c060dbSTony Lindgren { \
117e4c060dbSTony Lindgren return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
118e4c060dbSTony Lindgren }
119e4c060dbSTony Lindgren
120e4c060dbSTony Lindgren #define IS_AM_SUBCLASS(subclass, id) \
121e4c060dbSTony Lindgren static inline int is_am ##subclass (void) \
122e4c060dbSTony Lindgren { \
123e4c060dbSTony Lindgren return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
124e4c060dbSTony Lindgren }
125e4c060dbSTony Lindgren
12606c2d368SKeerthy #define IS_DRA_SUBCLASS(subclass, id) \
12706c2d368SKeerthy static inline int is_dra ##subclass (void) \
12806c2d368SKeerthy { \
12906c2d368SKeerthy return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
13006c2d368SKeerthy }
13106c2d368SKeerthy
132987d13f6SLokesh Vutla #define GET_DRA_PACKAGE (omap_rev() & 0xff)
133987d13f6SLokesh Vutla
134987d13f6SLokesh Vutla #define IS_DRA_SUBCLASS_PACKAGE(subclass, package, id) \
135987d13f6SLokesh Vutla static inline int is_dra ##subclass ##_ ##package (void) \
136987d13f6SLokesh Vutla { \
137987d13f6SLokesh Vutla return (is_dra ##subclass () && GET_DRA_PACKAGE == id) ? 1 : 0; \
138987d13f6SLokesh Vutla }
139987d13f6SLokesh Vutla
140e4c060dbSTony Lindgren IS_OMAP_CLASS(24xx, 0x24)
141e4c060dbSTony Lindgren IS_OMAP_CLASS(34xx, 0x34)
142e4c060dbSTony Lindgren IS_OMAP_CLASS(44xx, 0x44)
143e4c060dbSTony Lindgren IS_AM_CLASS(35xx, 0x35)
144e4c060dbSTony Lindgren IS_OMAP_CLASS(54xx, 0x54)
145e4c060dbSTony Lindgren IS_AM_CLASS(33xx, 0x33)
146c664d0a9SAfzal Mohammed IS_AM_CLASS(43xx, 0x43)
147e4c060dbSTony Lindgren
148e4c060dbSTony Lindgren IS_TI_CLASS(81xx, 0x81)
14906c2d368SKeerthy IS_DRA_CLASS(7xx, 0x7)
150e4c060dbSTony Lindgren
151e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(242x, 0x242)
152e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(243x, 0x243)
153e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(343x, 0x343)
154e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(363x, 0x363)
155e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(443x, 0x443)
156e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(446x, 0x446)
157e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(447x, 0x447)
158e4c060dbSTony Lindgren IS_OMAP_SUBCLASS(543x, 0x543)
159e4c060dbSTony Lindgren
160e4c060dbSTony Lindgren IS_TI_SUBCLASS(816x, 0x816)
161e4c060dbSTony Lindgren IS_TI_SUBCLASS(814x, 0x814)
162e4c060dbSTony Lindgren IS_AM_SUBCLASS(335x, 0x335)
163c664d0a9SAfzal Mohammed IS_AM_SUBCLASS(437x, 0x437)
164c15ab996SLokesh Vutla IS_DRA_SUBCLASS(76x, 0x76)
165987d13f6SLokesh Vutla IS_DRA_SUBCLASS_PACKAGE(76x, abz, 2)
166987d13f6SLokesh Vutla IS_DRA_SUBCLASS_PACKAGE(76x, acd, 3)
16706c2d368SKeerthy IS_DRA_SUBCLASS(75x, 0x75)
16806c2d368SKeerthy IS_DRA_SUBCLASS(72x, 0x72)
169e4c060dbSTony Lindgren
170d0b50905STony Lindgren #define soc_is_ti81xx() 0
171d0b50905STony Lindgren #define soc_is_ti816x() 0
172d0b50905STony Lindgren #define soc_is_ti814x() 0
173e4c060dbSTony Lindgren #define soc_is_am35xx() 0
174e4c060dbSTony Lindgren #define soc_is_am33xx() 0
175e4c060dbSTony Lindgren #define soc_is_am335x() 0
176c664d0a9SAfzal Mohammed #define soc_is_am43xx() 0
177c664d0a9SAfzal Mohammed #define soc_is_am437x() 0
178d0b50905STony Lindgren #define soc_is_omap44xx() 0
179d0b50905STony Lindgren #define soc_is_omap443x() 0
180d0b50905STony Lindgren #define soc_is_omap446x() 0
181d0b50905STony Lindgren #define soc_is_omap447x() 0
182e4c060dbSTony Lindgren #define soc_is_omap54xx() 0
183e4c060dbSTony Lindgren #define soc_is_omap543x() 0
1846852215aSR Sricharan #define soc_is_dra7xx() 0
185c15ab996SLokesh Vutla #define soc_is_dra76x() 0
186af438fecSRajendra Nayak #define soc_is_dra74x() 0
187af438fecSRajendra Nayak #define soc_is_dra72x() 0
188e4c060dbSTony Lindgren
189e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP2)
190d0b50905STony Lindgren # define soc_is_omap24xx() is_omap24xx()
191e60ba933SJonas Rabenstein #else
192e60ba933SJonas Rabenstein # define soc_is_omap24xx() 0
193e4c060dbSTony Lindgren #endif
194e4c060dbSTony Lindgren #if defined(CONFIG_SOC_OMAP2420)
195d0b50905STony Lindgren # define soc_is_omap242x() is_omap242x()
196e60ba933SJonas Rabenstein #else
197e60ba933SJonas Rabenstein # define soc_is_omap242x() 0
198e4c060dbSTony Lindgren #endif
199e4c060dbSTony Lindgren #if defined(CONFIG_SOC_OMAP2430)
200d0b50905STony Lindgren # define soc_is_omap243x() is_omap243x()
201e60ba933SJonas Rabenstein #else
202e60ba933SJonas Rabenstein # define soc_is_omap243x() 0
203e4c060dbSTony Lindgren #endif
204e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP3)
205d0b50905STony Lindgren # define soc_is_omap34xx() is_omap34xx()
206d0b50905STony Lindgren # define soc_is_omap343x() is_omap343x()
207e4c060dbSTony Lindgren #else
208e60ba933SJonas Rabenstein # define soc_is_omap34xx() 0
209e60ba933SJonas Rabenstein # define soc_is_omap343x() 0
210e4c060dbSTony Lindgren #endif
211e4c060dbSTony Lindgren
212e4c060dbSTony Lindgren /*
213e4c060dbSTony Lindgren * Macros to detect individual cpu types.
214e4c060dbSTony Lindgren * These are only rarely needed.
215d0b50905STony Lindgren * soc_is_omap2420(): True for OMAP2420
216d0b50905STony Lindgren * soc_is_omap2422(): True for OMAP2422
217d0b50905STony Lindgren * soc_is_omap2423(): True for OMAP2423
218d0b50905STony Lindgren * soc_is_omap2430(): True for OMAP2430
219d0b50905STony Lindgren * soc_is_omap3430(): True for OMAP3430
220e4c060dbSTony Lindgren */
221e4c060dbSTony Lindgren #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
222e4c060dbSTony Lindgren
223e4c060dbSTony Lindgren #define IS_OMAP_TYPE(type, id) \
224e4c060dbSTony Lindgren static inline int is_omap ##type (void) \
225e4c060dbSTony Lindgren { \
226e4c060dbSTony Lindgren return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
227e4c060dbSTony Lindgren }
228e4c060dbSTony Lindgren
229e4c060dbSTony Lindgren IS_OMAP_TYPE(2420, 0x2420)
230e4c060dbSTony Lindgren IS_OMAP_TYPE(2422, 0x2422)
231e4c060dbSTony Lindgren IS_OMAP_TYPE(2423, 0x2423)
232e4c060dbSTony Lindgren IS_OMAP_TYPE(2430, 0x2430)
233e4c060dbSTony Lindgren IS_OMAP_TYPE(3430, 0x3430)
234e4c060dbSTony Lindgren
235d0b50905STony Lindgren #define soc_is_omap2420() 0
236d0b50905STony Lindgren #define soc_is_omap2422() 0
237d0b50905STony Lindgren #define soc_is_omap2423() 0
238d0b50905STony Lindgren #define soc_is_omap2430() 0
239d0b50905STony Lindgren #define soc_is_omap3430() 0
240d0b50905STony Lindgren #define soc_is_omap3630() 0
241e4c060dbSTony Lindgren #define soc_is_omap5430() 0
242e4c060dbSTony Lindgren
243e4c060dbSTony Lindgren /* These are needed for the common code */
244d0b50905STony Lindgren #define soc_is_omap7xx() 0
245d0b50905STony Lindgren #define soc_is_omap15xx() 0
246d0b50905STony Lindgren #define soc_is_omap16xx() 0
247d0b50905STony Lindgren #define soc_is_omap1510() 0
248d0b50905STony Lindgren #define soc_is_omap1610() 0
249d0b50905STony Lindgren #define soc_is_omap1611() 0
250d0b50905STony Lindgren #define soc_is_omap1621() 0
251d0b50905STony Lindgren #define soc_is_omap1710() 0
252e4c060dbSTony Lindgren #define cpu_class_is_omap1() 0
253e4c060dbSTony Lindgren #define cpu_class_is_omap2() 1
254e4c060dbSTony Lindgren
255e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP2)
256d0b50905STony Lindgren # undef soc_is_omap2420
257d0b50905STony Lindgren # undef soc_is_omap2422
258d0b50905STony Lindgren # undef soc_is_omap2423
259d0b50905STony Lindgren # undef soc_is_omap2430
260d0b50905STony Lindgren # define soc_is_omap2420() is_omap2420()
261d0b50905STony Lindgren # define soc_is_omap2422() is_omap2422()
262d0b50905STony Lindgren # define soc_is_omap2423() is_omap2423()
263d0b50905STony Lindgren # define soc_is_omap2430() is_omap2430()
264e4c060dbSTony Lindgren #endif
265e4c060dbSTony Lindgren
266e4c060dbSTony Lindgren #if defined(CONFIG_ARCH_OMAP3)
267d0b50905STony Lindgren # undef soc_is_omap3430
268d0b50905STony Lindgren # undef soc_is_ti81xx
269d0b50905STony Lindgren # undef soc_is_ti816x
270d0b50905STony Lindgren # undef soc_is_ti814x
271e4c060dbSTony Lindgren # undef soc_is_am35xx
272d0b50905STony Lindgren # define soc_is_omap3430() is_omap3430()
273d0b50905STony Lindgren # undef soc_is_omap3630
274d0b50905STony Lindgren # define soc_is_omap3630() is_omap363x()
275d0b50905STony Lindgren # define soc_is_ti81xx() is_ti81xx()
276d0b50905STony Lindgren # define soc_is_ti816x() is_ti816x()
277d0b50905STony Lindgren # define soc_is_ti814x() is_ti814x()
278e4c060dbSTony Lindgren # define soc_is_am35xx() is_am35xx()
279e4c060dbSTony Lindgren #endif
280e4c060dbSTony Lindgren
281e4c060dbSTony Lindgren # if defined(CONFIG_SOC_AM33XX)
282e4c060dbSTony Lindgren # undef soc_is_am33xx
283e4c060dbSTony Lindgren # undef soc_is_am335x
284e4c060dbSTony Lindgren # define soc_is_am33xx() is_am33xx()
285e4c060dbSTony Lindgren # define soc_is_am335x() is_am335x()
286e4c060dbSTony Lindgren #endif
287e4c060dbSTony Lindgren
288c664d0a9SAfzal Mohammed #ifdef CONFIG_SOC_AM43XX
289c664d0a9SAfzal Mohammed # undef soc_is_am43xx
290c664d0a9SAfzal Mohammed # undef soc_is_am437x
291c664d0a9SAfzal Mohammed # define soc_is_am43xx() is_am43xx()
292c664d0a9SAfzal Mohammed # define soc_is_am437x() is_am437x()
293c664d0a9SAfzal Mohammed #endif
294c664d0a9SAfzal Mohammed
295e4c060dbSTony Lindgren # if defined(CONFIG_ARCH_OMAP4)
296d0b50905STony Lindgren # undef soc_is_omap44xx
297d0b50905STony Lindgren # undef soc_is_omap443x
298d0b50905STony Lindgren # undef soc_is_omap446x
299d0b50905STony Lindgren # undef soc_is_omap447x
300d0b50905STony Lindgren # define soc_is_omap44xx() is_omap44xx()
301d0b50905STony Lindgren # define soc_is_omap443x() is_omap443x()
302d0b50905STony Lindgren # define soc_is_omap446x() is_omap446x()
303d0b50905STony Lindgren # define soc_is_omap447x() is_omap447x()
304e4c060dbSTony Lindgren # endif
305e4c060dbSTony Lindgren
306e4c060dbSTony Lindgren # if defined(CONFIG_SOC_OMAP5)
307e4c060dbSTony Lindgren # undef soc_is_omap54xx
308e4c060dbSTony Lindgren # undef soc_is_omap543x
309e4c060dbSTony Lindgren # define soc_is_omap54xx() is_omap54xx()
310e4c060dbSTony Lindgren # define soc_is_omap543x() is_omap543x()
311e4c060dbSTony Lindgren #endif
312e4c060dbSTony Lindgren
3136852215aSR Sricharan #if defined(CONFIG_SOC_DRA7XX)
3146852215aSR Sricharan #undef soc_is_dra7xx
315c15ab996SLokesh Vutla #undef soc_is_dra76x
316987d13f6SLokesh Vutla #undef soc_is_dra76x_abz
317987d13f6SLokesh Vutla #undef soc_is_dra76x_acd
318af438fecSRajendra Nayak #undef soc_is_dra74x
319af438fecSRajendra Nayak #undef soc_is_dra72x
32006c2d368SKeerthy #define soc_is_dra7xx() is_dra7xx()
321c15ab996SLokesh Vutla #define soc_is_dra76x() is_dra76x()
322987d13f6SLokesh Vutla #define soc_is_dra76x_abz() is_dra76x_abz()
323987d13f6SLokesh Vutla #define soc_is_dra76x_acd() is_dra76x_acd()
32406c2d368SKeerthy #define soc_is_dra74x() is_dra75x()
32506c2d368SKeerthy #define soc_is_dra72x() is_dra72x()
3266852215aSR Sricharan #endif
3276852215aSR Sricharan
328e4c060dbSTony Lindgren /* Various silicon revisions for omap2 */
329e4c060dbSTony Lindgren #define OMAP242X_CLASS 0x24200024
330e4c060dbSTony Lindgren #define OMAP2420_REV_ES1_0 OMAP242X_CLASS
331e4c060dbSTony Lindgren #define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (0x1 << 8))
332e4c060dbSTony Lindgren
333e4c060dbSTony Lindgren #define OMAP243X_CLASS 0x24300024
334e4c060dbSTony Lindgren #define OMAP2430_REV_ES1_0 OMAP243X_CLASS
335e4c060dbSTony Lindgren
336e4c060dbSTony Lindgren #define OMAP343X_CLASS 0x34300034
337e4c060dbSTony Lindgren #define OMAP3430_REV_ES1_0 OMAP343X_CLASS
338e4c060dbSTony Lindgren #define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (0x1 << 8))
339e4c060dbSTony Lindgren #define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (0x2 << 8))
340e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (0x3 << 8))
341e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (0x4 << 8))
342e4c060dbSTony Lindgren #define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (0x5 << 8))
343e4c060dbSTony Lindgren
344e4c060dbSTony Lindgren #define OMAP363X_CLASS 0x36300034
345e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_0 OMAP363X_CLASS
346e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (0x1 << 8))
347e4c060dbSTony Lindgren #define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (0x2 << 8))
348e4c060dbSTony Lindgren
349c27964b5STony Lindgren #define TI816X_CLASS 0x81600081
350e4c060dbSTony Lindgren #define TI8168_REV_ES1_0 TI816X_CLASS
351e4c060dbSTony Lindgren #define TI8168_REV_ES1_1 (TI816X_CLASS | (0x1 << 8))
352a5f93d9dSAida Mynzhasova #define TI8168_REV_ES2_0 (TI816X_CLASS | (0x2 << 8))
353a5f93d9dSAida Mynzhasova #define TI8168_REV_ES2_1 (TI816X_CLASS | (0x3 << 8))
354e4c060dbSTony Lindgren
355c27964b5STony Lindgren #define TI814X_CLASS 0x81400081
356e4c060dbSTony Lindgren #define TI8148_REV_ES1_0 TI814X_CLASS
357e4c060dbSTony Lindgren #define TI8148_REV_ES2_0 (TI814X_CLASS | (0x1 << 8))
358e4c060dbSTony Lindgren #define TI8148_REV_ES2_1 (TI814X_CLASS | (0x2 << 8))
359e4c060dbSTony Lindgren
360e4c060dbSTony Lindgren #define AM35XX_CLASS 0x35170034
361e4c060dbSTony Lindgren #define AM35XX_REV_ES1_0 AM35XX_CLASS
362e4c060dbSTony Lindgren #define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8))
363e4c060dbSTony Lindgren
364e4c060dbSTony Lindgren #define AM335X_CLASS 0x33500033
365e4c060dbSTony Lindgren #define AM335X_REV_ES1_0 AM335X_CLASS
3665af044f4SAnilKumar Ch #define AM335X_REV_ES2_0 (AM335X_CLASS | (0x1 << 8))
367d240ef30SVaibhav Hiremath #define AM335X_REV_ES2_1 (AM335X_CLASS | (0x2 << 8))
368e4c060dbSTony Lindgren
369c664d0a9SAfzal Mohammed #define AM437X_CLASS 0x43700000
3704a2ed4c0SLokesh Vutla #define AM437X_REV_ES1_0 (AM437X_CLASS | (0x10 << 8))
3714a2ed4c0SLokesh Vutla #define AM437X_REV_ES1_1 (AM437X_CLASS | (0x11 << 8))
3724fdd54f0SLokesh Vutla #define AM437X_REV_ES1_2 (AM437X_CLASS | (0x12 << 8))
373c664d0a9SAfzal Mohammed
374e4c060dbSTony Lindgren #define OMAP443X_CLASS 0x44300044
375e4c060dbSTony Lindgren #define OMAP4430_REV_ES1_0 (OMAP443X_CLASS | (0x10 << 8))
376e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_0 (OMAP443X_CLASS | (0x20 << 8))
377e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_1 (OMAP443X_CLASS | (0x21 << 8))
378e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_2 (OMAP443X_CLASS | (0x22 << 8))
379e4c060dbSTony Lindgren #define OMAP4430_REV_ES2_3 (OMAP443X_CLASS | (0x23 << 8))
380e4c060dbSTony Lindgren
381e4c060dbSTony Lindgren #define OMAP446X_CLASS 0x44600044
382e4c060dbSTony Lindgren #define OMAP4460_REV_ES1_0 (OMAP446X_CLASS | (0x10 << 8))
383e4c060dbSTony Lindgren #define OMAP4460_REV_ES1_1 (OMAP446X_CLASS | (0x11 << 8))
384e4c060dbSTony Lindgren
385e4c060dbSTony Lindgren #define OMAP447X_CLASS 0x44700044
386e4c060dbSTony Lindgren #define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
387e4c060dbSTony Lindgren
388e4c060dbSTony Lindgren #define OMAP54XX_CLASS 0x54000054
3895a898a78SSantosh Shilimkar #define OMAP5430_REV_ES2_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x20 << 8))
3905a898a78SSantosh Shilimkar #define OMAP5432_REV_ES2_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x20 << 8))
391e4c060dbSTony Lindgren
392733d20eeSNishanth Menon #define DRA7XX_CLASS 0x07000000
393c15ab996SLokesh Vutla #define DRA762_REV_ES1_0 (DRA7XX_CLASS | (0x62 << 16) | (0x10 << 8))
394987d13f6SLokesh Vutla #define DRA762_ABZ_REV_ES1_0 (DRA762_REV_ES1_0 | (2 << 0))
395987d13f6SLokesh Vutla #define DRA762_ACD_REV_ES1_0 (DRA762_REV_ES1_0 | (3 << 0))
396733d20eeSNishanth Menon #define DRA752_REV_ES1_0 (DRA7XX_CLASS | (0x52 << 16) | (0x10 << 8))
397733d20eeSNishanth Menon #define DRA752_REV_ES1_1 (DRA7XX_CLASS | (0x52 << 16) | (0x11 << 8))
39881032e34SVishal Mahaveer #define DRA752_REV_ES2_0 (DRA7XX_CLASS | (0x52 << 16) | (0x20 << 8))
39981032e34SVishal Mahaveer #define DRA722_REV_ES1_0 (DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8))
4006b532c4aSVishal Mahaveer #define DRA722_REV_ES2_0 (DRA7XX_CLASS | (0x22 << 16) | (0x20 << 8))
401cf14dd05SVishal Mahaveer #define DRA722_REV_ES2_1 (DRA7XX_CLASS | (0x22 << 16) | (0x21 << 8))
402733d20eeSNishanth Menon
403e4c060dbSTony Lindgren void omap2xxx_check_revision(void);
404e4c060dbSTony Lindgren void omap3xxx_check_revision(void);
405e4c060dbSTony Lindgren void omap4xxx_check_revision(void);
406e4c060dbSTony Lindgren void omap5xxx_check_revision(void);
407733d20eeSNishanth Menon void dra7xxx_check_revision(void);
408e4c060dbSTony Lindgren void omap3xxx_check_features(void);
409e4c060dbSTony Lindgren void ti81xx_check_features(void);
4107bcad170SVaibhav Hiremath void am33xx_check_features(void);
411e4c060dbSTony Lindgren void omap4xxx_check_features(void);
412e4c060dbSTony Lindgren
413e4c060dbSTony Lindgren /*
414e4c060dbSTony Lindgren * Runtime detection of OMAP3 features
415e4c060dbSTony Lindgren *
416e4c060dbSTony Lindgren * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
417e4c060dbSTony Lindgren * family have OS-level control over the I/O chain clock. This is
418e4c060dbSTony Lindgren * to avoid a window during which wakeups could potentially be lost
419e4c060dbSTony Lindgren * during powerdomain transitions. If this bit is set, it
420e4c060dbSTony Lindgren * indicates that the chip does support OS-level control of this
421e4c060dbSTony Lindgren * feature.
422e4c060dbSTony Lindgren */
423e4c060dbSTony Lindgren extern u32 omap_features;
424e4c060dbSTony Lindgren
425e4c060dbSTony Lindgren #define OMAP3_HAS_L2CACHE BIT(0)
426e4c060dbSTony Lindgren #define OMAP3_HAS_IVA BIT(1)
427e4c060dbSTony Lindgren #define OMAP3_HAS_SGX BIT(2)
428e4c060dbSTony Lindgren #define OMAP3_HAS_NEON BIT(3)
429e4c060dbSTony Lindgren #define OMAP3_HAS_ISP BIT(4)
430e4c060dbSTony Lindgren #define OMAP3_HAS_192MHZ_CLK BIT(5)
431e4c060dbSTony Lindgren #define OMAP3_HAS_IO_WAKEUP BIT(6)
432e4c060dbSTony Lindgren #define OMAP3_HAS_SDRC BIT(7)
433e4c060dbSTony Lindgren #define OMAP3_HAS_IO_CHAIN_CTRL BIT(8)
43442a1cc9cSIvan Khoronzhuk #define OMAP4_HAS_PERF_SILICON BIT(9)
435e4c060dbSTony Lindgren
436e4c060dbSTony Lindgren
437e4c060dbSTony Lindgren #define OMAP3_HAS_FEATURE(feat,flag) \
438e4c060dbSTony Lindgren static inline unsigned int omap3_has_ ##feat(void) \
439e4c060dbSTony Lindgren { \
440e4c060dbSTony Lindgren return omap_features & OMAP3_HAS_ ##flag; \
441e4c060dbSTony Lindgren } \
442e4c060dbSTony Lindgren
443e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(l2cache, L2CACHE)
444e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(sgx, SGX)
445e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(iva, IVA)
446e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(neon, NEON)
447e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(isp, ISP)
448e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
449e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
450e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(sdrc, SDRC)
451e4c060dbSTony Lindgren OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
452e4c060dbSTony Lindgren
453e4c060dbSTony Lindgren /*
454e4c060dbSTony Lindgren * Runtime detection of OMAP4 features
455e4c060dbSTony Lindgren */
456e4c060dbSTony Lindgren #define OMAP4_HAS_FEATURE(feat, flag) \
457e4c060dbSTony Lindgren static inline unsigned int omap4_has_ ##feat(void) \
458e4c060dbSTony Lindgren { \
459e4c060dbSTony Lindgren return omap_features & OMAP4_HAS_ ##flag; \
460e4c060dbSTony Lindgren } \
461e4c060dbSTony Lindgren
46242a1cc9cSIvan Khoronzhuk OMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
463e4c060dbSTony Lindgren
464816a65efSTony Lindgren /*
465816a65efSTony Lindgren * We need to make sure omap initcalls don't run when
466816a65efSTony Lindgren * multiplatform kernels are booted on other SoCs.
467816a65efSTony Lindgren */
468816a65efSTony Lindgren #define omap_initcall(level, fn) \
469816a65efSTony Lindgren static int __init __used __##fn(void) \
470816a65efSTony Lindgren { \
471816a65efSTony Lindgren if (!soc_is_omap()) \
472816a65efSTony Lindgren return 0; \
473816a65efSTony Lindgren return fn(); \
474816a65efSTony Lindgren } \
475816a65efSTony Lindgren level(__##fn);
476816a65efSTony Lindgren
477816a65efSTony Lindgren #define omap_early_initcall(fn) omap_initcall(early_initcall, fn)
478816a65efSTony Lindgren #define omap_core_initcall(fn) omap_initcall(core_initcall, fn)
479816a65efSTony Lindgren #define omap_postcore_initcall(fn) omap_initcall(postcore_initcall, fn)
480816a65efSTony Lindgren #define omap_arch_initcall(fn) omap_initcall(arch_initcall, fn)
481816a65efSTony Lindgren #define omap_subsys_initcall(fn) omap_initcall(subsys_initcall, fn)
482816a65efSTony Lindgren #define omap_device_initcall(fn) omap_initcall(device_initcall, fn)
483816a65efSTony Lindgren #define omap_late_initcall(fn) omap_initcall(late_initcall, fn)
484e7e17c53SKevin Hilman #define omap_late_initcall_sync(fn) omap_initcall(late_initcall_sync, fn)
485816a65efSTony Lindgren
486d0b50905STony Lindgren /* Legacy defines, these can be removed when users are removed */
487d0b50905STony Lindgren #define cpu_is_omap2420() soc_is_omap2420()
488d0b50905STony Lindgren #define cpu_is_omap2422() soc_is_omap2422()
489d0b50905STony Lindgren #define cpu_is_omap242x() soc_is_omap242x()
490d0b50905STony Lindgren #define cpu_is_omap2430() soc_is_omap2430()
491d0b50905STony Lindgren #define cpu_is_omap243x() soc_is_omap243x()
492d0b50905STony Lindgren #define cpu_is_omap24xx() soc_is_omap24xx()
493d0b50905STony Lindgren #define cpu_is_omap3430() soc_is_omap3430()
494d0b50905STony Lindgren #define cpu_is_omap343x() soc_is_omap343x()
495d0b50905STony Lindgren #define cpu_is_omap34xx() soc_is_omap34xx()
496d0b50905STony Lindgren #define cpu_is_omap3630() soc_is_omap3630()
497d0b50905STony Lindgren #define cpu_is_omap443x() soc_is_omap443x()
498d0b50905STony Lindgren #define cpu_is_omap446x() soc_is_omap446x()
499d0b50905STony Lindgren #define cpu_is_omap44xx() soc_is_omap44xx()
500d0b50905STony Lindgren #define cpu_is_ti814x() soc_is_ti814x()
501d0b50905STony Lindgren #define cpu_is_ti816x() soc_is_ti816x()
502d0b50905STony Lindgren #define cpu_is_ti81xx() soc_is_ti81xx()
503e4c060dbSTony Lindgren
504d0b50905STony Lindgren #endif /* __ASSEMBLY__ */
505