1/*
2 * OMAP cpu type detection
3 *
4 * Copyright (C) 2004, 2008 Nokia Corporation
5 *
6 * Copyright (C) 2009-11 Texas Instruments.
7 *
8 * Written by Tony Lindgren <tony.lindgren@nokia.com>
9 *
10 * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28#ifndef __ASM_ARCH_OMAP_CPU_H
29#define __ASM_ARCH_OMAP_CPU_H
30
31#ifndef __ASSEMBLY__
32
33#include <linux/bitops.h>
34
35/*
36 * Test if multicore OMAP support is needed
37 */
38#undef MULTI_OMAP1
39#undef OMAP_NAME
40
41#ifdef CONFIG_ARCH_OMAP730
42# ifdef OMAP_NAME
43#  undef  MULTI_OMAP1
44#  define MULTI_OMAP1
45# else
46#  define OMAP_NAME omap730
47# endif
48#endif
49#ifdef CONFIG_ARCH_OMAP850
50# ifdef OMAP_NAME
51#  undef  MULTI_OMAP1
52#  define MULTI_OMAP1
53# else
54#  define OMAP_NAME omap850
55# endif
56#endif
57#ifdef CONFIG_ARCH_OMAP15XX
58# ifdef OMAP_NAME
59#  undef  MULTI_OMAP1
60#  define MULTI_OMAP1
61# else
62#  define OMAP_NAME omap1510
63# endif
64#endif
65#ifdef CONFIG_ARCH_OMAP16XX
66# ifdef OMAP_NAME
67#  undef  MULTI_OMAP1
68#  define MULTI_OMAP1
69# else
70#  define OMAP_NAME omap16xx
71# endif
72#endif
73
74/*
75 * omap_rev bits:
76 * CPU id bits	(0730, 1510, 1710, 2422...)	[31:16]
77 * CPU revision	(See _REV_ defined in cpu.h)	[15:08]
78 * CPU class bits (15xx, 16xx, 24xx, 34xx...)	[07:00]
79 */
80unsigned int omap_rev(void);
81
82/*
83 * Get the CPU revision for OMAP devices
84 */
85#define GET_OMAP_REVISION()	((omap_rev() >> 8) & 0xff)
86
87/*
88 * Macros to group OMAP into cpu classes.
89 * These can be used in most places.
90 * cpu_is_omap7xx():	True for OMAP730, OMAP850
91 * cpu_is_omap15xx():	True for OMAP1510, OMAP5910 and OMAP310
92 * cpu_is_omap16xx():	True for OMAP1610, OMAP5912 and OMAP1710
93 */
94#define GET_OMAP_CLASS	(omap_rev() & 0xff)
95
96#define IS_OMAP_CLASS(class, id)			\
97static inline int is_omap ##class (void)		\
98{							\
99	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
100}
101
102#define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)
103
104#define IS_OMAP_SUBCLASS(subclass, id)			\
105static inline int is_omap ##subclass (void)		\
106{							\
107	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
108}
109
110IS_OMAP_CLASS(7xx, 0x07)
111IS_OMAP_CLASS(15xx, 0x15)
112IS_OMAP_CLASS(16xx, 0x16)
113
114#define cpu_is_omap7xx()		0
115#define cpu_is_omap15xx()		0
116#define cpu_is_omap16xx()		0
117
118#if defined(MULTI_OMAP1)
119# if defined(CONFIG_ARCH_OMAP730)
120#  undef  cpu_is_omap7xx
121#  define cpu_is_omap7xx()		is_omap7xx()
122# endif
123# if defined(CONFIG_ARCH_OMAP850)
124#  undef  cpu_is_omap7xx
125#  define cpu_is_omap7xx()		is_omap7xx()
126# endif
127# if defined(CONFIG_ARCH_OMAP15XX)
128#  undef  cpu_is_omap15xx
129#  define cpu_is_omap15xx()		is_omap15xx()
130# endif
131# if defined(CONFIG_ARCH_OMAP16XX)
132#  undef  cpu_is_omap16xx
133#  define cpu_is_omap16xx()		is_omap16xx()
134# endif
135#else
136# if defined(CONFIG_ARCH_OMAP730)
137#  undef  cpu_is_omap7xx
138#  define cpu_is_omap7xx()		1
139# endif
140# if defined(CONFIG_ARCH_OMAP850)
141#  undef  cpu_is_omap7xx
142#  define cpu_is_omap7xx()		1
143# endif
144# if defined(CONFIG_ARCH_OMAP15XX)
145#  undef  cpu_is_omap15xx
146#  define cpu_is_omap15xx()		1
147# endif
148# if defined(CONFIG_ARCH_OMAP16XX)
149#  undef  cpu_is_omap16xx
150#  define cpu_is_omap16xx()		1
151# endif
152#endif
153
154/*
155 * Macros to detect individual cpu types.
156 * These are only rarely needed.
157 * cpu_is_omap310():	True for OMAP310
158 * cpu_is_omap1510():	True for OMAP1510
159 * cpu_is_omap1610():	True for OMAP1610
160 * cpu_is_omap1611():	True for OMAP1611
161 * cpu_is_omap5912():	True for OMAP5912
162 * cpu_is_omap1621():	True for OMAP1621
163 * cpu_is_omap1710():	True for OMAP1710
164 */
165#define GET_OMAP_TYPE	((omap_rev() >> 16) & 0xffff)
166
167#define IS_OMAP_TYPE(type, id)				\
168static inline int is_omap ##type (void)			\
169{							\
170	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
171}
172
173IS_OMAP_TYPE(310, 0x0310)
174IS_OMAP_TYPE(1510, 0x1510)
175IS_OMAP_TYPE(1610, 0x1610)
176IS_OMAP_TYPE(1611, 0x1611)
177IS_OMAP_TYPE(5912, 0x1611)
178IS_OMAP_TYPE(1621, 0x1621)
179IS_OMAP_TYPE(1710, 0x1710)
180
181#define cpu_is_omap310()		0
182#define cpu_is_omap1510()		0
183#define cpu_is_omap1610()		0
184#define cpu_is_omap5912()		0
185#define cpu_is_omap1611()		0
186#define cpu_is_omap1621()		0
187#define cpu_is_omap1710()		0
188
189/* These are needed to compile common code */
190#ifdef CONFIG_ARCH_OMAP1
191#define cpu_is_omap242x()		0
192#define cpu_is_omap2430()		0
193#define cpu_is_omap243x()		0
194#define cpu_is_omap24xx()		0
195#define cpu_is_omap34xx()		0
196#define cpu_is_omap44xx()		0
197#define soc_is_omap54xx()		0
198#define soc_is_dra7xx()			0
199#define soc_is_am33xx()			0
200#define cpu_class_is_omap1()		1
201#define cpu_class_is_omap2()		0
202#endif
203
204/*
205 * Whether we have MULTI_OMAP1 or not, we still need to distinguish
206 * between 310 vs. 1510 and 1611B/5912 vs. 1710.
207 */
208
209#if defined(CONFIG_ARCH_OMAP15XX)
210# undef  cpu_is_omap310
211# undef  cpu_is_omap1510
212# define cpu_is_omap310()		is_omap310()
213# define cpu_is_omap1510()		is_omap1510()
214#endif
215
216#if defined(CONFIG_ARCH_OMAP16XX)
217# undef  cpu_is_omap1610
218# undef  cpu_is_omap1611
219# undef  cpu_is_omap5912
220# undef  cpu_is_omap1621
221# undef  cpu_is_omap1710
222# define cpu_is_omap1610()		is_omap1610()
223# define cpu_is_omap1611()		is_omap1611()
224# define cpu_is_omap5912()		is_omap5912()
225# define cpu_is_omap1621()		is_omap1621()
226# define cpu_is_omap1710()		is_omap1710()
227#endif
228
229#endif	/* __ASSEMBLY__ */
230#endif
231