1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include "omap24xx.h"
29#include "omap34xx.h"
30#include "omap44xx.h"
31#include "ti81xx.h"
32#include "am33xx.h"
33#include "omap54xx.h"
34
35#ifndef __ASSEMBLY__
36
37#include <linux/bitops.h>
38
39
40
41
42#undef MULTI_OMAP2
43#undef OMAP_NAME
44
45#ifdef CONFIG_ARCH_MULTIPLATFORM
46#define MULTI_OMAP2
47#endif
48#ifdef CONFIG_SOC_OMAP2420
49# ifdef OMAP_NAME
50# undef MULTI_OMAP2
51# define MULTI_OMAP2
52# else
53# define OMAP_NAME omap2420
54# endif
55#endif
56#ifdef CONFIG_SOC_OMAP2430
57# ifdef OMAP_NAME
58# undef MULTI_OMAP2
59# define MULTI_OMAP2
60# else
61# define OMAP_NAME omap2430
62# endif
63#endif
64#ifdef CONFIG_ARCH_OMAP3
65# ifdef OMAP_NAME
66# undef MULTI_OMAP2
67# define MULTI_OMAP2
68# else
69# define OMAP_NAME omap3
70# endif
71#endif
72#ifdef CONFIG_ARCH_OMAP4
73# ifdef OMAP_NAME
74# undef MULTI_OMAP2
75# define MULTI_OMAP2
76# else
77# define OMAP_NAME omap4
78# endif
79#endif
80
81#ifdef CONFIG_SOC_OMAP5
82# ifdef OMAP_NAME
83# undef MULTI_OMAP2
84# define MULTI_OMAP2
85# else
86# define OMAP_NAME omap5
87# endif
88#endif
89
90#ifdef CONFIG_SOC_AM33XX
91# ifdef OMAP_NAME
92# undef MULTI_OMAP2
93# define MULTI_OMAP2
94# else
95# define OMAP_NAME am33xx
96# endif
97#endif
98
99
100
101
102#define OMAP2_DEVICE_TYPE_TEST 0
103#define OMAP2_DEVICE_TYPE_EMU 1
104#define OMAP2_DEVICE_TYPE_SEC 2
105#define OMAP2_DEVICE_TYPE_GP 3
106#define OMAP2_DEVICE_TYPE_BAD 4
107
108int omap_type(void);
109
110
111
112
113
114
115
116unsigned int omap_rev(void);
117
118static inline int soc_is_omap(void)
119{
120 return omap_rev() != 0;
121}
122
123
124
125
126#define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
127
128
129
130
131
132
133
134
135
136
137
138
139
140#define GET_OMAP_CLASS (omap_rev() & 0xff)
141
142#define IS_OMAP_CLASS(class, id) \
143static inline int is_omap ##class (void) \
144{ \
145 return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
146}
147
148#define GET_AM_CLASS ((omap_rev() >> 24) & 0xff)
149
150#define IS_AM_CLASS(class, id) \
151static inline int is_am ##class (void) \
152{ \
153 return (GET_AM_CLASS == (id)) ? 1 : 0; \
154}
155
156#define GET_TI_CLASS ((omap_rev() >> 24) & 0xff)
157
158#define IS_TI_CLASS(class, id) \
159static inline int is_ti ##class (void) \
160{ \
161 return (GET_TI_CLASS == (id)) ? 1 : 0; \
162}
163
164#define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
165
166#define IS_OMAP_SUBCLASS(subclass, id) \
167static inline int is_omap ##subclass (void) \
168{ \
169 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
170}
171
172#define IS_TI_SUBCLASS(subclass, id) \
173static inline int is_ti ##subclass (void) \
174{ \
175 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
176}
177
178#define IS_AM_SUBCLASS(subclass, id) \
179static inline int is_am ##subclass (void) \
180{ \
181 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
182}
183
184IS_OMAP_CLASS(24xx, 0x24)
185IS_OMAP_CLASS(34xx, 0x34)
186IS_OMAP_CLASS(44xx, 0x44)
187IS_AM_CLASS(35xx, 0x35)
188IS_OMAP_CLASS(54xx, 0x54)
189IS_AM_CLASS(33xx, 0x33)
190
191IS_TI_CLASS(81xx, 0x81)
192
193IS_OMAP_SUBCLASS(242x, 0x242)
194IS_OMAP_SUBCLASS(243x, 0x243)
195IS_OMAP_SUBCLASS(343x, 0x343)
196IS_OMAP_SUBCLASS(363x, 0x363)
197IS_OMAP_SUBCLASS(443x, 0x443)
198IS_OMAP_SUBCLASS(446x, 0x446)
199IS_OMAP_SUBCLASS(447x, 0x447)
200IS_OMAP_SUBCLASS(543x, 0x543)
201
202IS_TI_SUBCLASS(816x, 0x816)
203IS_TI_SUBCLASS(814x, 0x814)
204IS_AM_SUBCLASS(335x, 0x335)
205
206#define cpu_is_omap24xx() 0
207#define cpu_is_omap242x() 0
208#define cpu_is_omap243x() 0
209#define cpu_is_omap34xx() 0
210#define cpu_is_omap343x() 0
211#define cpu_is_ti81xx() 0
212#define cpu_is_ti816x() 0
213#define cpu_is_ti814x() 0
214#define soc_is_am35xx() 0
215#define soc_is_am33xx() 0
216#define soc_is_am335x() 0
217#define cpu_is_omap44xx() 0
218#define cpu_is_omap443x() 0
219#define cpu_is_omap446x() 0
220#define cpu_is_omap447x() 0
221#define soc_is_omap54xx() 0
222#define soc_is_omap543x() 0
223
224#if defined(MULTI_OMAP2)
225# if defined(CONFIG_ARCH_OMAP2)
226# undef cpu_is_omap24xx
227# define cpu_is_omap24xx() is_omap24xx()
228# endif
229# if defined (CONFIG_SOC_OMAP2420)
230# undef cpu_is_omap242x
231# define cpu_is_omap242x() is_omap242x()
232# endif
233# if defined (CONFIG_SOC_OMAP2430)
234# undef cpu_is_omap243x
235# define cpu_is_omap243x() is_omap243x()
236# endif
237# if defined(CONFIG_ARCH_OMAP3)
238# undef cpu_is_omap34xx
239# undef cpu_is_omap343x
240# define cpu_is_omap34xx() is_omap34xx()
241# define cpu_is_omap343x() is_omap343x()
242# endif
243#else
244# if defined(CONFIG_ARCH_OMAP2)
245# undef cpu_is_omap24xx
246# define cpu_is_omap24xx() 1
247# endif
248# if defined(CONFIG_SOC_OMAP2420)
249# undef cpu_is_omap242x
250# define cpu_is_omap242x() 1
251# endif
252# if defined(CONFIG_SOC_OMAP2430)
253# undef cpu_is_omap243x
254# define cpu_is_omap243x() 1
255# endif
256# if defined(CONFIG_ARCH_OMAP3)
257# undef cpu_is_omap34xx
258# define cpu_is_omap34xx() 1
259# endif
260# if defined(CONFIG_SOC_OMAP3430)
261# undef cpu_is_omap343x
262# define cpu_is_omap343x() 1
263# endif
264#endif
265
266
267
268
269
270
271
272
273
274
275#define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
276
277#define IS_OMAP_TYPE(type, id) \
278static inline int is_omap ##type (void) \
279{ \
280 return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
281}
282
283IS_OMAP_TYPE(2420, 0x2420)
284IS_OMAP_TYPE(2422, 0x2422)
285IS_OMAP_TYPE(2423, 0x2423)
286IS_OMAP_TYPE(2430, 0x2430)
287IS_OMAP_TYPE(3430, 0x3430)
288
289#define cpu_is_omap2420() 0
290#define cpu_is_omap2422() 0
291#define cpu_is_omap2423() 0
292#define cpu_is_omap2430() 0
293#define cpu_is_omap3430() 0
294#define cpu_is_omap3630() 0
295#define soc_is_omap5430() 0
296
297
298#ifdef CONFIG_ARCH_OMAP2PLUS
299#define cpu_is_omap7xx() 0
300#define cpu_is_omap15xx() 0
301#define cpu_is_omap16xx() 0
302#define cpu_is_omap1510() 0
303#define cpu_is_omap1610() 0
304#define cpu_is_omap1611() 0
305#define cpu_is_omap1621() 0
306#define cpu_is_omap1710() 0
307#define cpu_class_is_omap1() 0
308#define cpu_class_is_omap2() 1
309#endif
310
311#if defined(CONFIG_ARCH_OMAP2)
312# undef cpu_is_omap2420
313# undef cpu_is_omap2422
314# undef cpu_is_omap2423
315# undef cpu_is_omap2430
316# define cpu_is_omap2420() is_omap2420()
317# define cpu_is_omap2422() is_omap2422()
318# define cpu_is_omap2423() is_omap2423()
319# define cpu_is_omap2430() is_omap2430()
320#endif
321
322#if defined(CONFIG_ARCH_OMAP3)
323# undef cpu_is_omap3430
324# undef cpu_is_ti81xx
325# undef cpu_is_ti816x
326# undef cpu_is_ti814x
327# undef soc_is_am35xx
328# define cpu_is_omap3430() is_omap3430()
329# undef cpu_is_omap3630
330# define cpu_is_omap3630() is_omap363x()
331# define cpu_is_ti81xx() is_ti81xx()
332# define cpu_is_ti816x() is_ti816x()
333# define cpu_is_ti814x() is_ti814x()
334# define soc_is_am35xx() is_am35xx()
335#endif
336
337# if defined(CONFIG_SOC_AM33XX)
338# undef soc_is_am33xx
339# undef soc_is_am335x
340# define soc_is_am33xx() is_am33xx()
341# define soc_is_am335x() is_am335x()
342#endif
343
344# if defined(CONFIG_ARCH_OMAP4)
345# undef cpu_is_omap44xx
346# undef cpu_is_omap443x
347# undef cpu_is_omap446x
348# undef cpu_is_omap447x
349# define cpu_is_omap44xx() is_omap44xx()
350# define cpu_is_omap443x() is_omap443x()
351# define cpu_is_omap446x() is_omap446x()
352# define cpu_is_omap447x() is_omap447x()
353# endif
354
355# if defined(CONFIG_SOC_OMAP5)
356# undef soc_is_omap54xx
357# undef soc_is_omap543x
358# define soc_is_omap54xx() is_omap54xx()
359# define soc_is_omap543x() is_omap543x()
360#endif
361
362
363#define OMAP242X_CLASS 0x24200024
364#define OMAP2420_REV_ES1_0 OMAP242X_CLASS
365#define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (0x1 << 8))
366
367#define OMAP243X_CLASS 0x24300024
368#define OMAP2430_REV_ES1_0 OMAP243X_CLASS
369
370#define OMAP343X_CLASS 0x34300034
371#define OMAP3430_REV_ES1_0 OMAP343X_CLASS
372#define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (0x1 << 8))
373#define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (0x2 << 8))
374#define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (0x3 << 8))
375#define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (0x4 << 8))
376#define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (0x5 << 8))
377
378#define OMAP363X_CLASS 0x36300034
379#define OMAP3630_REV_ES1_0 OMAP363X_CLASS
380#define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (0x1 << 8))
381#define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (0x2 << 8))
382
383#define TI816X_CLASS 0x81600034
384#define TI8168_REV_ES1_0 TI816X_CLASS
385#define TI8168_REV_ES1_1 (TI816X_CLASS | (0x1 << 8))
386
387#define TI814X_CLASS 0x81400034
388#define TI8148_REV_ES1_0 TI814X_CLASS
389#define TI8148_REV_ES2_0 (TI814X_CLASS | (0x1 << 8))
390#define TI8148_REV_ES2_1 (TI814X_CLASS | (0x2 << 8))
391
392#define AM35XX_CLASS 0x35170034
393#define AM35XX_REV_ES1_0 AM35XX_CLASS
394#define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8))
395
396#define AM335X_CLASS 0x33500033
397#define AM335X_REV_ES1_0 AM335X_CLASS
398#define AM335X_REV_ES2_0 (AM335X_CLASS | (0x1 << 8))
399#define AM335X_REV_ES2_1 (AM335X_CLASS | (0x2 << 8))
400
401#define OMAP443X_CLASS 0x44300044
402#define OMAP4430_REV_ES1_0 (OMAP443X_CLASS | (0x10 << 8))
403#define OMAP4430_REV_ES2_0 (OMAP443X_CLASS | (0x20 << 8))
404#define OMAP4430_REV_ES2_1 (OMAP443X_CLASS | (0x21 << 8))
405#define OMAP4430_REV_ES2_2 (OMAP443X_CLASS | (0x22 << 8))
406#define OMAP4430_REV_ES2_3 (OMAP443X_CLASS | (0x23 << 8))
407
408#define OMAP446X_CLASS 0x44600044
409#define OMAP4460_REV_ES1_0 (OMAP446X_CLASS | (0x10 << 8))
410#define OMAP4460_REV_ES1_1 (OMAP446X_CLASS | (0x11 << 8))
411
412#define OMAP447X_CLASS 0x44700044
413#define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
414
415#define OMAP54XX_CLASS 0x54000054
416#define OMAP5430_REV_ES1_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x10 << 8))
417#define OMAP5430_REV_ES2_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x20 << 8))
418#define OMAP5432_REV_ES1_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x10 << 8))
419#define OMAP5432_REV_ES2_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x20 << 8))
420
421void omap2xxx_check_revision(void);
422void omap3xxx_check_revision(void);
423void omap4xxx_check_revision(void);
424void omap5xxx_check_revision(void);
425void omap3xxx_check_features(void);
426void ti81xx_check_features(void);
427void omap4xxx_check_features(void);
428
429
430
431
432
433
434
435
436
437
438
439extern u32 omap_features;
440
441#define OMAP3_HAS_L2CACHE BIT(0)
442#define OMAP3_HAS_IVA BIT(1)
443#define OMAP3_HAS_SGX BIT(2)
444#define OMAP3_HAS_NEON BIT(3)
445#define OMAP3_HAS_ISP BIT(4)
446#define OMAP3_HAS_192MHZ_CLK BIT(5)
447#define OMAP3_HAS_IO_WAKEUP BIT(6)
448#define OMAP3_HAS_SDRC BIT(7)
449#define OMAP3_HAS_IO_CHAIN_CTRL BIT(8)
450#define OMAP4_HAS_PERF_SILICON BIT(9)
451
452
453#define OMAP3_HAS_FEATURE(feat,flag) \
454static inline unsigned int omap3_has_ ##feat(void) \
455{ \
456 return omap_features & OMAP3_HAS_ ##flag; \
457} \
458
459OMAP3_HAS_FEATURE(l2cache, L2CACHE)
460OMAP3_HAS_FEATURE(sgx, SGX)
461OMAP3_HAS_FEATURE(iva, IVA)
462OMAP3_HAS_FEATURE(neon, NEON)
463OMAP3_HAS_FEATURE(isp, ISP)
464OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
465OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
466OMAP3_HAS_FEATURE(sdrc, SDRC)
467OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
468
469
470
471
472#define OMAP4_HAS_FEATURE(feat, flag) \
473static inline unsigned int omap4_has_ ##feat(void) \
474{ \
475 return omap_features & OMAP4_HAS_ ##flag; \
476} \
477
478OMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
479
480
481
482
483
484#define omap_initcall(level, fn) \
485static int __init __used __##fn(void) \
486{ \
487 if (!soc_is_omap()) \
488 return 0; \
489 return fn(); \
490} \
491level(__##fn);
492
493#define omap_early_initcall(fn) omap_initcall(early_initcall, fn)
494#define omap_core_initcall(fn) omap_initcall(core_initcall, fn)
495#define omap_postcore_initcall(fn) omap_initcall(postcore_initcall, fn)
496#define omap_arch_initcall(fn) omap_initcall(arch_initcall, fn)
497#define omap_subsys_initcall(fn) omap_initcall(subsys_initcall, fn)
498#define omap_device_initcall(fn) omap_initcall(device_initcall, fn)
499#define omap_late_initcall(fn) omap_initcall(late_initcall, fn)
500#define omap_late_initcall_sync(fn) omap_initcall(late_initcall_sync, fn)
501
502#endif
503
504