1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * OMAP cpu type detection
4  *
5  * Copyright (C) 2004, 2008 Nokia Corporation
6  *
7  * Copyright (C) 2009-11 Texas Instruments.
8  *
9  * Written by Tony Lindgren <tony.lindgren@nokia.com>
10  *
11  * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
12  */
13 
14 #ifndef __ASM_ARCH_OMAP_CPU_H
15 #define __ASM_ARCH_OMAP_CPU_H
16 
17 /*
18  * Test if multicore OMAP support is needed
19  */
20 #undef MULTI_OMAP1
21 #undef OMAP_NAME
22 
23 #ifdef CONFIG_ARCH_OMAP730
24 # ifdef OMAP_NAME
25 #  undef  MULTI_OMAP1
26 #  define MULTI_OMAP1
27 # else
28 #  define OMAP_NAME omap730
29 # endif
30 #endif
31 #ifdef CONFIG_ARCH_OMAP850
32 # ifdef OMAP_NAME
33 #  undef  MULTI_OMAP1
34 #  define MULTI_OMAP1
35 # else
36 #  define OMAP_NAME omap850
37 # endif
38 #endif
39 #ifdef CONFIG_ARCH_OMAP15XX
40 # ifdef OMAP_NAME
41 #  undef  MULTI_OMAP1
42 #  define MULTI_OMAP1
43 # else
44 #  define OMAP_NAME omap1510
45 # endif
46 #endif
47 #ifdef CONFIG_ARCH_OMAP16XX
48 # ifdef OMAP_NAME
49 #  undef  MULTI_OMAP1
50 #  define MULTI_OMAP1
51 # else
52 #  define OMAP_NAME omap16xx
53 # endif
54 #endif
55 
56 /*
57  * omap_rev bits:
58  * CPU id bits	(0730, 1510, 1710, 2422...)	[31:16]
59  * CPU revision	(See _REV_ defined in cpu.h)	[15:08]
60  * CPU class bits (15xx, 16xx, 24xx, 34xx...)	[07:00]
61  */
62 unsigned int omap_rev(void);
63 
64 /*
65  * Get the CPU revision for OMAP devices
66  */
67 #define GET_OMAP_REVISION()	((omap_rev() >> 8) & 0xff)
68 
69 /*
70  * Macros to group OMAP into cpu classes.
71  * These can be used in most places.
72  * cpu_is_omap7xx():	True for OMAP730, OMAP850
73  * cpu_is_omap15xx():	True for OMAP1510, OMAP5910 and OMAP310
74  * cpu_is_omap16xx():	True for OMAP1610, OMAP5912 and OMAP1710
75  */
76 #define GET_OMAP_CLASS	(omap_rev() & 0xff)
77 
78 #define IS_OMAP_CLASS(class, id)			\
79 static inline int is_omap ##class (void)		\
80 {							\
81 	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
82 }
83 
84 #define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)
85 
86 #define IS_OMAP_SUBCLASS(subclass, id)			\
87 static inline int is_omap ##subclass (void)		\
88 {							\
89 	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
90 }
91 
92 IS_OMAP_CLASS(7xx, 0x07)
93 IS_OMAP_CLASS(15xx, 0x15)
94 IS_OMAP_CLASS(16xx, 0x16)
95 
96 #define cpu_is_omap7xx()		0
97 #define cpu_is_omap15xx()		0
98 #define cpu_is_omap16xx()		0
99 
100 #if defined(MULTI_OMAP1)
101 # if defined(CONFIG_ARCH_OMAP730)
102 #  undef  cpu_is_omap7xx
103 #  define cpu_is_omap7xx()		is_omap7xx()
104 # endif
105 # if defined(CONFIG_ARCH_OMAP850)
106 #  undef  cpu_is_omap7xx
107 #  define cpu_is_omap7xx()		is_omap7xx()
108 # endif
109 # if defined(CONFIG_ARCH_OMAP15XX)
110 #  undef  cpu_is_omap15xx
111 #  define cpu_is_omap15xx()		is_omap15xx()
112 # endif
113 # if defined(CONFIG_ARCH_OMAP16XX)
114 #  undef  cpu_is_omap16xx
115 #  define cpu_is_omap16xx()		is_omap16xx()
116 # endif
117 #else
118 # if defined(CONFIG_ARCH_OMAP730)
119 #  undef  cpu_is_omap7xx
120 #  define cpu_is_omap7xx()		1
121 # endif
122 # if defined(CONFIG_ARCH_OMAP850)
123 #  undef  cpu_is_omap7xx
124 #  define cpu_is_omap7xx()		1
125 # endif
126 # if defined(CONFIG_ARCH_OMAP15XX)
127 #  undef  cpu_is_omap15xx
128 #  define cpu_is_omap15xx()		1
129 # endif
130 # if defined(CONFIG_ARCH_OMAP16XX)
131 #  undef  cpu_is_omap16xx
132 #  define cpu_is_omap16xx()		1
133 # endif
134 #endif
135 
136 /*
137  * Macros to detect individual cpu types.
138  * These are only rarely needed.
139  * cpu_is_omap310():	True for OMAP310
140  * cpu_is_omap1510():	True for OMAP1510
141  * cpu_is_omap1610():	True for OMAP1610
142  * cpu_is_omap1611():	True for OMAP1611
143  * cpu_is_omap5912():	True for OMAP5912
144  * cpu_is_omap1621():	True for OMAP1621
145  * cpu_is_omap1710():	True for OMAP1710
146  */
147 #define GET_OMAP_TYPE	((omap_rev() >> 16) & 0xffff)
148 
149 #define IS_OMAP_TYPE(type, id)				\
150 static inline int is_omap ##type (void)			\
151 {							\
152 	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
153 }
154 
155 IS_OMAP_TYPE(310, 0x0310)
156 IS_OMAP_TYPE(1510, 0x1510)
157 IS_OMAP_TYPE(1610, 0x1610)
158 IS_OMAP_TYPE(1611, 0x1611)
159 IS_OMAP_TYPE(5912, 0x1611)
160 IS_OMAP_TYPE(1621, 0x1621)
161 IS_OMAP_TYPE(1710, 0x1710)
162 
163 #define cpu_is_omap310()		0
164 #define cpu_is_omap1510()		0
165 #define cpu_is_omap1610()		0
166 #define cpu_is_omap5912()		0
167 #define cpu_is_omap1611()		0
168 #define cpu_is_omap1621()		0
169 #define cpu_is_omap1710()		0
170 
171 #define cpu_class_is_omap1()		1
172 
173 /*
174  * Whether we have MULTI_OMAP1 or not, we still need to distinguish
175  * between 310 vs. 1510 and 1611B/5912 vs. 1710.
176  */
177 
178 #if defined(CONFIG_ARCH_OMAP15XX)
179 # undef  cpu_is_omap310
180 # undef  cpu_is_omap1510
181 # define cpu_is_omap310()		is_omap310()
182 # define cpu_is_omap1510()		is_omap1510()
183 #endif
184 
185 #if defined(CONFIG_ARCH_OMAP16XX)
186 # undef  cpu_is_omap1610
187 # undef  cpu_is_omap1611
188 # undef  cpu_is_omap5912
189 # undef  cpu_is_omap1621
190 # undef  cpu_is_omap1710
191 # define cpu_is_omap1610()		is_omap1610()
192 # define cpu_is_omap1611()		is_omap1611()
193 # define cpu_is_omap5912()		is_omap5912()
194 # define cpu_is_omap1621()		is_omap1621()
195 # define cpu_is_omap1710()		is_omap1710()
196 #endif
197 
198 #endif
199