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_OMAP15XX
24  # ifdef OMAP_NAME
25  #  undef  MULTI_OMAP1
26  #  define MULTI_OMAP1
27  # else
28  #  define OMAP_NAME omap1510
29  # endif
30  #endif
31  #ifdef CONFIG_ARCH_OMAP16XX
32  # ifdef OMAP_NAME
33  #  undef  MULTI_OMAP1
34  #  define MULTI_OMAP1
35  # else
36  #  define OMAP_NAME omap16xx
37  # endif
38  #endif
39  
40  /*
41   * omap_rev bits:
42   * CPU id bits	(0730, 1510, 1710, 2422...)	[31:16]
43   * CPU revision	(See _REV_ defined in cpu.h)	[15:08]
44   * CPU class bits (15xx, 16xx, 24xx, 34xx...)	[07:00]
45   */
46  unsigned int omap_rev(void);
47  
48  /*
49   * Get the CPU revision for OMAP devices
50   */
51  #define GET_OMAP_REVISION()	((omap_rev() >> 8) & 0xff)
52  
53  /*
54   * Macros to group OMAP into cpu classes.
55   * These can be used in most places.
56   * cpu_is_omap15xx():	True for OMAP1510, OMAP5910 and OMAP310
57   * cpu_is_omap16xx():	True for OMAP1610, OMAP5912 and OMAP1710
58   */
59  #define GET_OMAP_CLASS	(omap_rev() & 0xff)
60  
61  #define IS_OMAP_CLASS(class, id)			\
62  static inline int is_omap ##class (void)		\
63  {							\
64  	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
65  }
66  
67  #define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)
68  
69  #define IS_OMAP_SUBCLASS(subclass, id)			\
70  static inline int is_omap ##subclass (void)		\
71  {							\
72  	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
73  }
74  
75  IS_OMAP_CLASS(15xx, 0x15)
76  IS_OMAP_CLASS(16xx, 0x16)
77  
78  #define cpu_is_omap15xx()		0
79  #define cpu_is_omap16xx()		0
80  
81  #if defined(MULTI_OMAP1)
82  # if defined(CONFIG_ARCH_OMAP15XX)
83  #  undef  cpu_is_omap15xx
84  #  define cpu_is_omap15xx()		is_omap15xx()
85  # endif
86  # if defined(CONFIG_ARCH_OMAP16XX)
87  #  undef  cpu_is_omap16xx
88  #  define cpu_is_omap16xx()		is_omap16xx()
89  # endif
90  #else
91  # if defined(CONFIG_ARCH_OMAP15XX)
92  #  undef  cpu_is_omap15xx
93  #  define cpu_is_omap15xx()		1
94  # endif
95  # if defined(CONFIG_ARCH_OMAP16XX)
96  #  undef  cpu_is_omap16xx
97  #  define cpu_is_omap16xx()		1
98  # endif
99  #endif
100  
101  /*
102   * Macros to detect individual cpu types.
103   * These are only rarely needed.
104   * cpu_is_omap310():	True for OMAP310
105   * cpu_is_omap1510():	True for OMAP1510
106   * cpu_is_omap1610():	True for OMAP1610
107   * cpu_is_omap1611():	True for OMAP1611
108   * cpu_is_omap5912():	True for OMAP5912
109   * cpu_is_omap1621():	True for OMAP1621
110   * cpu_is_omap1710():	True for OMAP1710
111   */
112  #define GET_OMAP_TYPE	((omap_rev() >> 16) & 0xffff)
113  
114  #define IS_OMAP_TYPE(type, id)				\
115  static inline int is_omap ##type (void)			\
116  {							\
117  	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
118  }
119  
120  IS_OMAP_TYPE(310, 0x0310)
121  IS_OMAP_TYPE(1510, 0x1510)
122  IS_OMAP_TYPE(1610, 0x1610)
123  IS_OMAP_TYPE(1611, 0x1611)
124  IS_OMAP_TYPE(5912, 0x1611)
125  IS_OMAP_TYPE(1621, 0x1621)
126  IS_OMAP_TYPE(1710, 0x1710)
127  
128  #define cpu_is_omap310()		0
129  #define cpu_is_omap1510()		0
130  #define cpu_is_omap1610()		0
131  #define cpu_is_omap5912()		0
132  #define cpu_is_omap1611()		0
133  #define cpu_is_omap1621()		0
134  #define cpu_is_omap1710()		0
135  
136  #define cpu_class_is_omap1()		1
137  
138  /*
139   * Whether we have MULTI_OMAP1 or not, we still need to distinguish
140   * between 310 vs. 1510 and 1611B/5912 vs. 1710.
141   */
142  
143  #if defined(CONFIG_ARCH_OMAP15XX)
144  # undef  cpu_is_omap310
145  # undef  cpu_is_omap1510
146  # define cpu_is_omap310()		is_omap310()
147  # define cpu_is_omap1510()		is_omap1510()
148  #endif
149  
150  #if defined(CONFIG_ARCH_OMAP16XX)
151  # undef  cpu_is_omap1610
152  # undef  cpu_is_omap1611
153  # undef  cpu_is_omap5912
154  # undef  cpu_is_omap1621
155  # undef  cpu_is_omap1710
156  # define cpu_is_omap1610()		is_omap1610()
157  # define cpu_is_omap1611()		is_omap1611()
158  # define cpu_is_omap5912()		is_omap5912()
159  # define cpu_is_omap1621()		is_omap1621()
160  # define cpu_is_omap1710()		is_omap1710()
161  #endif
162  
163  #endif
164