Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck...
[pandora-kernel.git] / arch / arm / plat-omap / include / plat / cpu.h
1 /*
2  * arch/arm/plat-omap/include/mach/cpu.h
3  *
4  * OMAP cpu type detection
5  *
6  * Copyright (C) 2004, 2008 Nokia Corporation
7  *
8  * Copyright (C) 2009-11 Texas Instruments.
9  *
10  * Written by Tony Lindgren <tony.lindgren@nokia.com>
11  *
12  * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  */
29
30 #ifndef __ASM_ARCH_OMAP_CPU_H
31 #define __ASM_ARCH_OMAP_CPU_H
32
33 #include <linux/bitops.h>
34 #include <plat/multi.h>
35
36 /*
37  * Omap device type i.e. EMU/HS/TST/GP/BAD
38  */
39 #define OMAP2_DEVICE_TYPE_TEST          0
40 #define OMAP2_DEVICE_TYPE_EMU           1
41 #define OMAP2_DEVICE_TYPE_SEC           2
42 #define OMAP2_DEVICE_TYPE_GP            3
43 #define OMAP2_DEVICE_TYPE_BAD           4
44
45 int omap_type(void);
46
47 /*
48  * omap_rev bits:
49  * CPU id bits  (0730, 1510, 1710, 2422...)     [31:16]
50  * CPU revision (See _REV_ defined in cpu.h)    [15:08]
51  * CPU class bits (15xx, 16xx, 24xx, 34xx...)   [07:00]
52  */
53 unsigned int omap_rev(void);
54
55 /*
56  * Get the CPU revision for OMAP devices
57  */
58 #define GET_OMAP_REVISION()     ((omap_rev() >> 8) & 0xff)
59
60 /*
61  * Macros to group OMAP into cpu classes.
62  * These can be used in most places.
63  * cpu_is_omap7xx():    True for OMAP730, OMAP850
64  * cpu_is_omap15xx():   True for OMAP1510, OMAP5910 and OMAP310
65  * cpu_is_omap16xx():   True for OMAP1610, OMAP5912 and OMAP1710
66  * cpu_is_omap24xx():   True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
67  * cpu_is_omap242x():   True for OMAP2420, OMAP2422, OMAP2423
68  * cpu_is_omap243x():   True for OMAP2430
69  * cpu_is_omap343x():   True for OMAP3430
70  * cpu_is_omap443x():   True for OMAP4430
71  * cpu_is_omap446x():   True for OMAP4460
72  * cpu_is_omap447x():   True for OMAP4470
73  * soc_is_omap543x():   True for OMAP5430, OMAP5432
74  */
75 #define GET_OMAP_CLASS  (omap_rev() & 0xff)
76
77 #define IS_OMAP_CLASS(class, id)                        \
78 static inline int is_omap ##class (void)                \
79 {                                                       \
80         return (GET_OMAP_CLASS == (id)) ? 1 : 0;        \
81 }
82
83 #define GET_AM_CLASS    ((omap_rev() >> 24) & 0xff)
84
85 #define IS_AM_CLASS(class, id)                          \
86 static inline int is_am ##class (void)                  \
87 {                                                       \
88         return (GET_AM_CLASS == (id)) ? 1 : 0;          \
89 }
90
91 #define GET_TI_CLASS    ((omap_rev() >> 24) & 0xff)
92
93 #define IS_TI_CLASS(class, id)                  \
94 static inline int is_ti ##class (void)          \
95 {                                                       \
96         return (GET_TI_CLASS == (id)) ? 1 : 0;  \
97 }
98
99 #define GET_OMAP_SUBCLASS       ((omap_rev() >> 20) & 0x0fff)
100
101 #define IS_OMAP_SUBCLASS(subclass, id)                  \
102 static inline int is_omap ##subclass (void)             \
103 {                                                       \
104         return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;     \
105 }
106
107 #define IS_TI_SUBCLASS(subclass, id)                    \
108 static inline int is_ti ##subclass (void)               \
109 {                                                       \
110         return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;     \
111 }
112
113 #define IS_AM_SUBCLASS(subclass, id)                    \
114 static inline int is_am ##subclass (void)               \
115 {                                                       \
116         return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;     \
117 }
118
119 IS_OMAP_CLASS(7xx, 0x07)
120 IS_OMAP_CLASS(15xx, 0x15)
121 IS_OMAP_CLASS(16xx, 0x16)
122 IS_OMAP_CLASS(24xx, 0x24)
123 IS_OMAP_CLASS(34xx, 0x34)
124 IS_OMAP_CLASS(44xx, 0x44)
125 IS_AM_CLASS(35xx, 0x35)
126 IS_OMAP_CLASS(54xx, 0x54)
127 IS_AM_CLASS(33xx, 0x33)
128
129 IS_TI_CLASS(81xx, 0x81)
130
131 IS_OMAP_SUBCLASS(242x, 0x242)
132 IS_OMAP_SUBCLASS(243x, 0x243)
133 IS_OMAP_SUBCLASS(343x, 0x343)
134 IS_OMAP_SUBCLASS(363x, 0x363)
135 IS_OMAP_SUBCLASS(443x, 0x443)
136 IS_OMAP_SUBCLASS(446x, 0x446)
137 IS_OMAP_SUBCLASS(447x, 0x447)
138 IS_OMAP_SUBCLASS(543x, 0x543)
139
140 IS_TI_SUBCLASS(816x, 0x816)
141 IS_TI_SUBCLASS(814x, 0x814)
142 IS_AM_SUBCLASS(335x, 0x335)
143
144 #define cpu_is_omap7xx()                0
145 #define cpu_is_omap15xx()               0
146 #define cpu_is_omap16xx()               0
147 #define cpu_is_omap24xx()               0
148 #define cpu_is_omap242x()               0
149 #define cpu_is_omap243x()               0
150 #define cpu_is_omap34xx()               0
151 #define cpu_is_omap343x()               0
152 #define cpu_is_ti81xx()                 0
153 #define cpu_is_ti816x()                 0
154 #define cpu_is_ti814x()                 0
155 #define soc_is_am35xx()                 0
156 #define soc_is_am33xx()                 0
157 #define soc_is_am335x()                 0
158 #define cpu_is_omap44xx()               0
159 #define cpu_is_omap443x()               0
160 #define cpu_is_omap446x()               0
161 #define cpu_is_omap447x()               0
162 #define soc_is_omap54xx()               0
163 #define soc_is_omap543x()               0
164
165 #if defined(MULTI_OMAP1)
166 # if defined(CONFIG_ARCH_OMAP730)
167 #  undef  cpu_is_omap7xx
168 #  define cpu_is_omap7xx()              is_omap7xx()
169 # endif
170 # if defined(CONFIG_ARCH_OMAP850)
171 #  undef  cpu_is_omap7xx
172 #  define cpu_is_omap7xx()              is_omap7xx()
173 # endif
174 # if defined(CONFIG_ARCH_OMAP15XX)
175 #  undef  cpu_is_omap15xx
176 #  define cpu_is_omap15xx()             is_omap15xx()
177 # endif
178 # if defined(CONFIG_ARCH_OMAP16XX)
179 #  undef  cpu_is_omap16xx
180 #  define cpu_is_omap16xx()             is_omap16xx()
181 # endif
182 #else
183 # if defined(CONFIG_ARCH_OMAP730)
184 #  undef  cpu_is_omap7xx
185 #  define cpu_is_omap7xx()              1
186 # endif
187 # if defined(CONFIG_ARCH_OMAP850)
188 #  undef  cpu_is_omap7xx
189 #  define cpu_is_omap7xx()              1
190 # endif
191 # if defined(CONFIG_ARCH_OMAP15XX)
192 #  undef  cpu_is_omap15xx
193 #  define cpu_is_omap15xx()             1
194 # endif
195 # if defined(CONFIG_ARCH_OMAP16XX)
196 #  undef  cpu_is_omap16xx
197 #  define cpu_is_omap16xx()             1
198 # endif
199 #endif
200
201 #if defined(MULTI_OMAP2)
202 # if defined(CONFIG_ARCH_OMAP2)
203 #  undef  cpu_is_omap24xx
204 #  define cpu_is_omap24xx()             is_omap24xx()
205 # endif
206 # if defined (CONFIG_SOC_OMAP2420)
207 #  undef  cpu_is_omap242x
208 #  define cpu_is_omap242x()             is_omap242x()
209 # endif
210 # if defined (CONFIG_SOC_OMAP2430)
211 #  undef  cpu_is_omap243x
212 #  define cpu_is_omap243x()             is_omap243x()
213 # endif
214 # if defined(CONFIG_ARCH_OMAP3)
215 #  undef  cpu_is_omap34xx
216 #  undef  cpu_is_omap343x
217 #  define cpu_is_omap34xx()             is_omap34xx()
218 #  define cpu_is_omap343x()             is_omap343x()
219 # endif
220 #else
221 # if defined(CONFIG_ARCH_OMAP2)
222 #  undef  cpu_is_omap24xx
223 #  define cpu_is_omap24xx()             1
224 # endif
225 # if defined(CONFIG_SOC_OMAP2420)
226 #  undef  cpu_is_omap242x
227 #  define cpu_is_omap242x()             1
228 # endif
229 # if defined(CONFIG_SOC_OMAP2430)
230 #  undef  cpu_is_omap243x
231 #  define cpu_is_omap243x()             1
232 # endif
233 # if defined(CONFIG_ARCH_OMAP3)
234 #  undef  cpu_is_omap34xx
235 #  define cpu_is_omap34xx()             1
236 # endif
237 # if defined(CONFIG_SOC_OMAP3430)
238 #  undef  cpu_is_omap343x
239 #  define cpu_is_omap343x()             1
240 # endif
241 #endif
242
243 /*
244  * Macros to detect individual cpu types.
245  * These are only rarely needed.
246  * cpu_is_omap310():    True for OMAP310
247  * cpu_is_omap1510():   True for OMAP1510
248  * cpu_is_omap1610():   True for OMAP1610
249  * cpu_is_omap1611():   True for OMAP1611
250  * cpu_is_omap5912():   True for OMAP5912
251  * cpu_is_omap1621():   True for OMAP1621
252  * cpu_is_omap1710():   True for OMAP1710
253  * cpu_is_omap2420():   True for OMAP2420
254  * cpu_is_omap2422():   True for OMAP2422
255  * cpu_is_omap2423():   True for OMAP2423
256  * cpu_is_omap2430():   True for OMAP2430
257  * cpu_is_omap3430():   True for OMAP3430
258  */
259 #define GET_OMAP_TYPE   ((omap_rev() >> 16) & 0xffff)
260
261 #define IS_OMAP_TYPE(type, id)                          \
262 static inline int is_omap ##type (void)                 \
263 {                                                       \
264         return (GET_OMAP_TYPE == (id)) ? 1 : 0;         \
265 }
266
267 IS_OMAP_TYPE(310, 0x0310)
268 IS_OMAP_TYPE(1510, 0x1510)
269 IS_OMAP_TYPE(1610, 0x1610)
270 IS_OMAP_TYPE(1611, 0x1611)
271 IS_OMAP_TYPE(5912, 0x1611)
272 IS_OMAP_TYPE(1621, 0x1621)
273 IS_OMAP_TYPE(1710, 0x1710)
274 IS_OMAP_TYPE(2420, 0x2420)
275 IS_OMAP_TYPE(2422, 0x2422)
276 IS_OMAP_TYPE(2423, 0x2423)
277 IS_OMAP_TYPE(2430, 0x2430)
278 IS_OMAP_TYPE(3430, 0x3430)
279
280 #define cpu_is_omap310()                0
281 #define cpu_is_omap1510()               0
282 #define cpu_is_omap1610()               0
283 #define cpu_is_omap5912()               0
284 #define cpu_is_omap1611()               0
285 #define cpu_is_omap1621()               0
286 #define cpu_is_omap1710()               0
287 #define cpu_is_omap2420()               0
288 #define cpu_is_omap2422()               0
289 #define cpu_is_omap2423()               0
290 #define cpu_is_omap2430()               0
291 #define cpu_is_omap3430()               0
292 #define cpu_is_omap3630()               0
293 #define soc_is_omap5430()               0
294
295 /*
296  * Whether we have MULTI_OMAP1 or not, we still need to distinguish
297  * between 310 vs. 1510 and 1611B/5912 vs. 1710.
298  */
299
300 #if defined(CONFIG_ARCH_OMAP15XX)
301 # undef  cpu_is_omap310
302 # undef  cpu_is_omap1510
303 # define cpu_is_omap310()               is_omap310()
304 # define cpu_is_omap1510()              is_omap1510()
305 #endif
306
307 #if defined(CONFIG_ARCH_OMAP16XX)
308 # undef  cpu_is_omap1610
309 # undef  cpu_is_omap1611
310 # undef  cpu_is_omap5912
311 # undef  cpu_is_omap1621
312 # undef  cpu_is_omap1710
313 # define cpu_is_omap1610()              is_omap1610()
314 # define cpu_is_omap1611()              is_omap1611()
315 # define cpu_is_omap5912()              is_omap5912()
316 # define cpu_is_omap1621()              is_omap1621()
317 # define cpu_is_omap1710()              is_omap1710()
318 #endif
319
320 #if defined(CONFIG_ARCH_OMAP2)
321 # undef  cpu_is_omap2420
322 # undef  cpu_is_omap2422
323 # undef  cpu_is_omap2423
324 # undef  cpu_is_omap2430
325 # define cpu_is_omap2420()              is_omap2420()
326 # define cpu_is_omap2422()              is_omap2422()
327 # define cpu_is_omap2423()              is_omap2423()
328 # define cpu_is_omap2430()              is_omap2430()
329 #endif
330
331 #if defined(CONFIG_ARCH_OMAP3)
332 # undef cpu_is_omap3430
333 # undef cpu_is_ti81xx
334 # undef cpu_is_ti816x
335 # undef cpu_is_ti814x
336 # undef soc_is_am35xx
337 # define cpu_is_omap3430()              is_omap3430()
338 # undef cpu_is_omap3630
339 # define cpu_is_omap3630()              is_omap363x()
340 # define cpu_is_ti81xx()                is_ti81xx()
341 # define cpu_is_ti816x()                is_ti816x()
342 # define cpu_is_ti814x()                is_ti814x()
343 # define soc_is_am35xx()                is_am35xx()
344 #endif
345
346 # if defined(CONFIG_SOC_AM33XX)
347 # undef soc_is_am33xx
348 # undef soc_is_am335x
349 # define soc_is_am33xx()                is_am33xx()
350 # define soc_is_am335x()                is_am335x()
351 #endif
352
353 # if defined(CONFIG_ARCH_OMAP4)
354 # undef cpu_is_omap44xx
355 # undef cpu_is_omap443x
356 # undef cpu_is_omap446x
357 # undef cpu_is_omap447x
358 # define cpu_is_omap44xx()              is_omap44xx()
359 # define cpu_is_omap443x()              is_omap443x()
360 # define cpu_is_omap446x()              is_omap446x()
361 # define cpu_is_omap447x()              is_omap447x()
362 # endif
363
364 # if defined(CONFIG_SOC_OMAP5)
365 # undef soc_is_omap54xx
366 # undef soc_is_omap543x
367 # define soc_is_omap54xx()              is_omap54xx()
368 # define soc_is_omap543x()              is_omap543x()
369 #endif
370
371 /* Macros to detect if we have OMAP1 or OMAP2 */
372 #define cpu_class_is_omap1()    (cpu_is_omap7xx() || cpu_is_omap15xx() || \
373                                 cpu_is_omap16xx())
374 #define cpu_class_is_omap2()    (cpu_is_omap24xx() || cpu_is_omap34xx() || \
375                                 cpu_is_omap44xx() || soc_is_omap54xx())
376
377 /* Various silicon revisions for omap2 */
378 #define OMAP242X_CLASS          0x24200024
379 #define OMAP2420_REV_ES1_0      OMAP242X_CLASS
380 #define OMAP2420_REV_ES2_0      (OMAP242X_CLASS | (0x1 << 8))
381
382 #define OMAP243X_CLASS          0x24300024
383 #define OMAP2430_REV_ES1_0      OMAP243X_CLASS
384
385 #define OMAP343X_CLASS          0x34300034
386 #define OMAP3430_REV_ES1_0      OMAP343X_CLASS
387 #define OMAP3430_REV_ES2_0      (OMAP343X_CLASS | (0x1 << 8))
388 #define OMAP3430_REV_ES2_1      (OMAP343X_CLASS | (0x2 << 8))
389 #define OMAP3430_REV_ES3_0      (OMAP343X_CLASS | (0x3 << 8))
390 #define OMAP3430_REV_ES3_1      (OMAP343X_CLASS | (0x4 << 8))
391 #define OMAP3430_REV_ES3_1_2    (OMAP343X_CLASS | (0x5 << 8))
392
393 #define OMAP363X_CLASS          0x36300034
394 #define OMAP3630_REV_ES1_0      OMAP363X_CLASS
395 #define OMAP3630_REV_ES1_1      (OMAP363X_CLASS | (0x1 << 8))
396 #define OMAP3630_REV_ES1_2      (OMAP363X_CLASS | (0x2 << 8))
397
398 #define TI816X_CLASS            0x81600034
399 #define TI8168_REV_ES1_0        TI816X_CLASS
400 #define TI8168_REV_ES1_1        (TI816X_CLASS | (0x1 << 8))
401
402 #define TI814X_CLASS            0x81400034
403 #define TI8148_REV_ES1_0        TI814X_CLASS
404 #define TI8148_REV_ES2_0        (TI814X_CLASS | (0x1 << 8))
405 #define TI8148_REV_ES2_1        (TI814X_CLASS | (0x2 << 8))
406
407 #define AM35XX_CLASS            0x35170034
408 #define AM35XX_REV_ES1_0        AM35XX_CLASS
409 #define AM35XX_REV_ES1_1        (AM35XX_CLASS | (0x1 << 8))
410
411 #define AM335X_CLASS            0x33500033
412 #define AM335X_REV_ES1_0        AM335X_CLASS
413
414 #define OMAP443X_CLASS          0x44300044
415 #define OMAP4430_REV_ES1_0      (OMAP443X_CLASS | (0x10 << 8))
416 #define OMAP4430_REV_ES2_0      (OMAP443X_CLASS | (0x20 << 8))
417 #define OMAP4430_REV_ES2_1      (OMAP443X_CLASS | (0x21 << 8))
418 #define OMAP4430_REV_ES2_2      (OMAP443X_CLASS | (0x22 << 8))
419 #define OMAP4430_REV_ES2_3      (OMAP443X_CLASS | (0x23 << 8))
420
421 #define OMAP446X_CLASS          0x44600044
422 #define OMAP4460_REV_ES1_0      (OMAP446X_CLASS | (0x10 << 8))
423 #define OMAP4460_REV_ES1_1      (OMAP446X_CLASS | (0x11 << 8))
424
425 #define OMAP447X_CLASS          0x44700044
426 #define OMAP4470_REV_ES1_0      (OMAP447X_CLASS | (0x10 << 8))
427
428 #define OMAP54XX_CLASS          0x54000054
429 #define OMAP5430_REV_ES1_0      (OMAP54XX_CLASS | (0x30 << 16) | (0x10 << 8))
430 #define OMAP5432_REV_ES1_0      (OMAP54XX_CLASS | (0x32 << 16) | (0x10 << 8))
431
432 void omap2xxx_check_revision(void);
433 void omap3xxx_check_revision(void);
434 void omap4xxx_check_revision(void);
435 void omap5xxx_check_revision(void);
436 void omap3xxx_check_features(void);
437 void ti81xx_check_features(void);
438 void omap4xxx_check_features(void);
439
440 /*
441  * Runtime detection of OMAP3 features
442  *
443  * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
444  *    family have OS-level control over the I/O chain clock.  This is
445  *    to avoid a window during which wakeups could potentially be lost
446  *    during powerdomain transitions.  If this bit is set, it
447  *    indicates that the chip does support OS-level control of this
448  *    feature.
449  */
450 extern u32 omap_features;
451
452 #define OMAP3_HAS_L2CACHE               BIT(0)
453 #define OMAP3_HAS_IVA                   BIT(1)
454 #define OMAP3_HAS_SGX                   BIT(2)
455 #define OMAP3_HAS_NEON                  BIT(3)
456 #define OMAP3_HAS_ISP                   BIT(4)
457 #define OMAP3_HAS_192MHZ_CLK            BIT(5)
458 #define OMAP3_HAS_IO_WAKEUP             BIT(6)
459 #define OMAP3_HAS_SDRC                  BIT(7)
460 #define OMAP3_HAS_IO_CHAIN_CTRL         BIT(8)
461 #define OMAP4_HAS_MPU_1GHZ              BIT(9)
462 #define OMAP4_HAS_MPU_1_2GHZ            BIT(10)
463 #define OMAP4_HAS_MPU_1_5GHZ            BIT(11)
464
465
466 #define OMAP3_HAS_FEATURE(feat,flag)                    \
467 static inline unsigned int omap3_has_ ##feat(void)      \
468 {                                                       \
469         return omap_features & OMAP3_HAS_ ##flag;       \
470 }                                                       \
471
472 OMAP3_HAS_FEATURE(l2cache, L2CACHE)
473 OMAP3_HAS_FEATURE(sgx, SGX)
474 OMAP3_HAS_FEATURE(iva, IVA)
475 OMAP3_HAS_FEATURE(neon, NEON)
476 OMAP3_HAS_FEATURE(isp, ISP)
477 OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
478 OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
479 OMAP3_HAS_FEATURE(sdrc, SDRC)
480 OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
481
482 /*
483  * Runtime detection of OMAP4 features
484  */
485 #define OMAP4_HAS_FEATURE(feat, flag)                   \
486 static inline unsigned int omap4_has_ ##feat(void)      \
487 {                                                       \
488         return omap_features & OMAP4_HAS_ ##flag;       \
489 }                                                       \
490
491 OMAP4_HAS_FEATURE(mpu_1ghz, MPU_1GHZ)
492 OMAP4_HAS_FEATURE(mpu_1_2ghz, MPU_1_2GHZ)
493 OMAP4_HAS_FEATURE(mpu_1_5ghz, MPU_1_5GHZ)
494
495 #endif