cpu.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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 Texas Instruments.
  9. *
  10. * Written by Tony Lindgren <tony.lindgren@nokia.com>
  11. *
  12. * Added OMAP4 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. #ifndef __ASM_ARCH_OMAP_CPU_H
  30. #define __ASM_ARCH_OMAP_CPU_H
  31. #include <linux/bitops.h>
  32. /*
  33. * Omap device type i.e. EMU/HS/TST/GP/BAD
  34. */
  35. #define OMAP2_DEVICE_TYPE_TEST 0
  36. #define OMAP2_DEVICE_TYPE_EMU 1
  37. #define OMAP2_DEVICE_TYPE_SEC 2
  38. #define OMAP2_DEVICE_TYPE_GP 3
  39. #define OMAP2_DEVICE_TYPE_BAD 4
  40. int omap_type(void);
  41. struct omap_chip_id {
  42. u8 oc;
  43. u8 type;
  44. };
  45. #define OMAP_CHIP_INIT(x) { .oc = x }
  46. /*
  47. * omap_rev bits:
  48. * CPU id bits (0730, 1510, 1710, 2422...) [31:16]
  49. * CPU revision (See _REV_ defined in cpu.h) [15:08]
  50. * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
  51. */
  52. unsigned int omap_rev(void);
  53. /*
  54. * Define CPU revision bits
  55. *
  56. * Verbose meaning of the revision bits may be different for a silicon
  57. * family. This difference can be handled separately.
  58. */
  59. #define OMAP_REVBITS_00 0x00
  60. #define OMAP_REVBITS_10 0x10
  61. #define OMAP_REVBITS_20 0x20
  62. #define OMAP_REVBITS_30 0x30
  63. #define OMAP_REVBITS_40 0x40
  64. /*
  65. * Get the CPU revision for OMAP devices
  66. */
  67. #define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
  68. /*
  69. * Test if multicore OMAP support is needed
  70. */
  71. #undef MULTI_OMAP1
  72. #undef MULTI_OMAP2
  73. #undef OMAP_NAME
  74. #ifdef CONFIG_ARCH_OMAP730
  75. # ifdef OMAP_NAME
  76. # undef MULTI_OMAP1
  77. # define MULTI_OMAP1
  78. # else
  79. # define OMAP_NAME omap730
  80. # endif
  81. #endif
  82. #ifdef CONFIG_ARCH_OMAP850
  83. # ifdef OMAP_NAME
  84. # undef MULTI_OMAP1
  85. # define MULTI_OMAP1
  86. # else
  87. # define OMAP_NAME omap850
  88. # endif
  89. #endif
  90. #ifdef CONFIG_ARCH_OMAP15XX
  91. # ifdef OMAP_NAME
  92. # undef MULTI_OMAP1
  93. # define MULTI_OMAP1
  94. # else
  95. # define OMAP_NAME omap1510
  96. # endif
  97. #endif
  98. #ifdef CONFIG_ARCH_OMAP16XX
  99. # ifdef OMAP_NAME
  100. # undef MULTI_OMAP1
  101. # define MULTI_OMAP1
  102. # else
  103. # define OMAP_NAME omap16xx
  104. # endif
  105. #endif
  106. #if (defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX))
  107. # if (defined(OMAP_NAME) || defined(MULTI_OMAP1))
  108. # error "OMAP1 and OMAP2 can't be selected at the same time"
  109. # endif
  110. #endif
  111. #ifdef CONFIG_ARCH_OMAP2420
  112. # ifdef OMAP_NAME
  113. # undef MULTI_OMAP2
  114. # define MULTI_OMAP2
  115. # else
  116. # define OMAP_NAME omap2420
  117. # endif
  118. #endif
  119. #ifdef CONFIG_ARCH_OMAP2430
  120. # ifdef OMAP_NAME
  121. # undef MULTI_OMAP2
  122. # define MULTI_OMAP2
  123. # else
  124. # define OMAP_NAME omap2430
  125. # endif
  126. #endif
  127. #ifdef CONFIG_ARCH_OMAP3430
  128. # ifdef OMAP_NAME
  129. # undef MULTI_OMAP2
  130. # define MULTI_OMAP2
  131. # else
  132. # define OMAP_NAME omap3430
  133. # endif
  134. #endif
  135. /*
  136. * Macros to group OMAP into cpu classes.
  137. * These can be used in most places.
  138. * cpu_is_omap7xx(): True for OMAP730, OMAP850
  139. * cpu_is_omap15xx(): True for OMAP1510, OMAP5910 and OMAP310
  140. * cpu_is_omap16xx(): True for OMAP1610, OMAP5912 and OMAP1710
  141. * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
  142. * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
  143. * cpu_is_omap243x(): True for OMAP2430
  144. * cpu_is_omap343x(): True for OMAP3430
  145. */
  146. #define GET_OMAP_CLASS (omap_rev() & 0xff)
  147. #define IS_OMAP_CLASS(class, id) \
  148. static inline int is_omap ##class (void) \
  149. { \
  150. return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
  151. }
  152. #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
  153. #define IS_OMAP_SUBCLASS(subclass, id) \
  154. static inline int is_omap ##subclass (void) \
  155. { \
  156. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  157. }
  158. IS_OMAP_CLASS(7xx, 0x07)
  159. IS_OMAP_CLASS(15xx, 0x15)
  160. IS_OMAP_CLASS(16xx, 0x16)
  161. IS_OMAP_CLASS(24xx, 0x24)
  162. IS_OMAP_CLASS(34xx, 0x34)
  163. IS_OMAP_SUBCLASS(242x, 0x242)
  164. IS_OMAP_SUBCLASS(243x, 0x243)
  165. IS_OMAP_SUBCLASS(343x, 0x343)
  166. #define cpu_is_omap7xx() 0
  167. #define cpu_is_omap15xx() 0
  168. #define cpu_is_omap16xx() 0
  169. #define cpu_is_omap24xx() 0
  170. #define cpu_is_omap242x() 0
  171. #define cpu_is_omap243x() 0
  172. #define cpu_is_omap34xx() 0
  173. #define cpu_is_omap343x() 0
  174. #define cpu_is_omap44xx() 0
  175. #define cpu_is_omap443x() 0
  176. #if defined(MULTI_OMAP1)
  177. # if defined(CONFIG_ARCH_OMAP730)
  178. # undef cpu_is_omap7xx
  179. # define cpu_is_omap7xx() is_omap7xx()
  180. # endif
  181. # if defined(CONFIG_ARCH_OMAP850)
  182. # undef cpu_is_omap7xx
  183. # define cpu_is_omap7xx() is_omap7xx()
  184. # endif
  185. # if defined(CONFIG_ARCH_OMAP15XX)
  186. # undef cpu_is_omap15xx
  187. # define cpu_is_omap15xx() is_omap15xx()
  188. # endif
  189. # if defined(CONFIG_ARCH_OMAP16XX)
  190. # undef cpu_is_omap16xx
  191. # define cpu_is_omap16xx() is_omap16xx()
  192. # endif
  193. #else
  194. # if defined(CONFIG_ARCH_OMAP730)
  195. # undef cpu_is_omap7xx
  196. # define cpu_is_omap7xx() 1
  197. # endif
  198. # if defined(CONFIG_ARCH_OMAP850)
  199. # undef cpu_is_omap7xx
  200. # define cpu_is_omap7xx() 1
  201. # endif
  202. # if defined(CONFIG_ARCH_OMAP15XX)
  203. # undef cpu_is_omap15xx
  204. # define cpu_is_omap15xx() 1
  205. # endif
  206. # if defined(CONFIG_ARCH_OMAP16XX)
  207. # undef cpu_is_omap16xx
  208. # define cpu_is_omap16xx() 1
  209. # endif
  210. #endif
  211. #if defined(MULTI_OMAP2)
  212. # if defined(CONFIG_ARCH_OMAP24XX)
  213. # undef cpu_is_omap24xx
  214. # undef cpu_is_omap242x
  215. # undef cpu_is_omap243x
  216. # define cpu_is_omap24xx() is_omap24xx()
  217. # define cpu_is_omap242x() is_omap242x()
  218. # define cpu_is_omap243x() is_omap243x()
  219. # endif
  220. # if defined(CONFIG_ARCH_OMAP34XX)
  221. # undef cpu_is_omap34xx
  222. # undef cpu_is_omap343x
  223. # define cpu_is_omap34xx() is_omap34xx()
  224. # define cpu_is_omap343x() is_omap343x()
  225. # endif
  226. #else
  227. # if defined(CONFIG_ARCH_OMAP24XX)
  228. # undef cpu_is_omap24xx
  229. # define cpu_is_omap24xx() 1
  230. # endif
  231. # if defined(CONFIG_ARCH_OMAP2420)
  232. # undef cpu_is_omap242x
  233. # define cpu_is_omap242x() 1
  234. # endif
  235. # if defined(CONFIG_ARCH_OMAP2430)
  236. # undef cpu_is_omap243x
  237. # define cpu_is_omap243x() 1
  238. # endif
  239. # if defined(CONFIG_ARCH_OMAP34XX)
  240. # undef cpu_is_omap34xx
  241. # define cpu_is_omap34xx() 1
  242. # endif
  243. # if defined(CONFIG_ARCH_OMAP3430)
  244. # undef cpu_is_omap343x
  245. # define cpu_is_omap343x() 1
  246. # endif
  247. #endif
  248. /*
  249. * Macros to detect individual cpu types.
  250. * These are only rarely needed.
  251. * cpu_is_omap330(): True for OMAP330
  252. * cpu_is_omap730(): True for OMAP730
  253. * cpu_is_omap850(): True for OMAP850
  254. * cpu_is_omap1510(): True for OMAP1510
  255. * cpu_is_omap1610(): True for OMAP1610
  256. * cpu_is_omap1611(): True for OMAP1611
  257. * cpu_is_omap5912(): True for OMAP5912
  258. * cpu_is_omap1621(): True for OMAP1621
  259. * cpu_is_omap1710(): True for OMAP1710
  260. * cpu_is_omap2420(): True for OMAP2420
  261. * cpu_is_omap2422(): True for OMAP2422
  262. * cpu_is_omap2423(): True for OMAP2423
  263. * cpu_is_omap2430(): True for OMAP2430
  264. * cpu_is_omap3430(): True for OMAP3430
  265. */
  266. #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
  267. #define IS_OMAP_TYPE(type, id) \
  268. static inline int is_omap ##type (void) \
  269. { \
  270. return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
  271. }
  272. IS_OMAP_TYPE(310, 0x0310)
  273. IS_OMAP_TYPE(730, 0x0730)
  274. IS_OMAP_TYPE(850, 0x0850)
  275. IS_OMAP_TYPE(1510, 0x1510)
  276. IS_OMAP_TYPE(1610, 0x1610)
  277. IS_OMAP_TYPE(1611, 0x1611)
  278. IS_OMAP_TYPE(5912, 0x1611)
  279. IS_OMAP_TYPE(1621, 0x1621)
  280. IS_OMAP_TYPE(1710, 0x1710)
  281. IS_OMAP_TYPE(2420, 0x2420)
  282. IS_OMAP_TYPE(2422, 0x2422)
  283. IS_OMAP_TYPE(2423, 0x2423)
  284. IS_OMAP_TYPE(2430, 0x2430)
  285. IS_OMAP_TYPE(3430, 0x3430)
  286. #define cpu_is_omap310() 0
  287. #define cpu_is_omap730() 0
  288. #define cpu_is_omap850() 0
  289. #define cpu_is_omap1510() 0
  290. #define cpu_is_omap1610() 0
  291. #define cpu_is_omap5912() 0
  292. #define cpu_is_omap1611() 0
  293. #define cpu_is_omap1621() 0
  294. #define cpu_is_omap1710() 0
  295. #define cpu_is_omap2420() 0
  296. #define cpu_is_omap2422() 0
  297. #define cpu_is_omap2423() 0
  298. #define cpu_is_omap2430() 0
  299. #define cpu_is_omap3503() 0
  300. #define cpu_is_omap3515() 0
  301. #define cpu_is_omap3525() 0
  302. #define cpu_is_omap3530() 0
  303. #define cpu_is_omap3430() 0
  304. /*
  305. * Whether we have MULTI_OMAP1 or not, we still need to distinguish
  306. * between 730 vs 850, 330 vs. 1510 and 1611B/5912 vs. 1710.
  307. */
  308. #if defined(CONFIG_ARCH_OMAP730)
  309. # undef cpu_is_omap730
  310. # define cpu_is_omap730() is_omap730()
  311. #endif
  312. #if defined(CONFIG_ARCH_OMAP850)
  313. # undef cpu_is_omap850
  314. # define cpu_is_omap850() is_omap850()
  315. #endif
  316. #if defined(CONFIG_ARCH_OMAP15XX)
  317. # undef cpu_is_omap310
  318. # undef cpu_is_omap1510
  319. # define cpu_is_omap310() is_omap310()
  320. # define cpu_is_omap1510() is_omap1510()
  321. #endif
  322. #if defined(CONFIG_ARCH_OMAP16XX)
  323. # undef cpu_is_omap1610
  324. # undef cpu_is_omap1611
  325. # undef cpu_is_omap5912
  326. # undef cpu_is_omap1621
  327. # undef cpu_is_omap1710
  328. # define cpu_is_omap1610() is_omap1610()
  329. # define cpu_is_omap1611() is_omap1611()
  330. # define cpu_is_omap5912() is_omap5912()
  331. # define cpu_is_omap1621() is_omap1621()
  332. # define cpu_is_omap1710() is_omap1710()
  333. #endif
  334. #if defined(CONFIG_ARCH_OMAP24XX)
  335. # undef cpu_is_omap2420
  336. # undef cpu_is_omap2422
  337. # undef cpu_is_omap2423
  338. # undef cpu_is_omap2430
  339. # define cpu_is_omap2420() is_omap2420()
  340. # define cpu_is_omap2422() is_omap2422()
  341. # define cpu_is_omap2423() is_omap2423()
  342. # define cpu_is_omap2430() is_omap2430()
  343. #endif
  344. #if defined(CONFIG_ARCH_OMAP34XX)
  345. # undef cpu_is_omap3430
  346. # undef cpu_is_omap3503
  347. # undef cpu_is_omap3515
  348. # undef cpu_is_omap3525
  349. # undef cpu_is_omap3530
  350. # define cpu_is_omap3430() is_omap3430()
  351. # define cpu_is_omap3503() (cpu_is_omap3430() && \
  352. (!omap3_has_iva()) && \
  353. (!omap3_has_sgx()))
  354. # define cpu_is_omap3515() (cpu_is_omap3430() && \
  355. (omap3_has_iva()) && \
  356. (!omap3_has_sgx()))
  357. # define cpu_is_omap3525() (cpu_is_omap3430() && \
  358. (omap3_has_sgx()) && \
  359. (!omap3_has_iva()))
  360. # define cpu_is_omap3530() (cpu_is_omap3430())
  361. #endif
  362. # if defined(CONFIG_ARCH_OMAP4)
  363. # undef cpu_is_omap44xx
  364. # undef cpu_is_omap443x
  365. # define cpu_is_omap44xx() 1
  366. # define cpu_is_omap443x() 1
  367. # endif
  368. /* Macros to detect if we have OMAP1 or OMAP2 */
  369. #define cpu_class_is_omap1() (cpu_is_omap7xx() || cpu_is_omap15xx() || \
  370. cpu_is_omap16xx())
  371. #define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx() || \
  372. cpu_is_omap44xx())
  373. /* Various silicon revisions for omap2 */
  374. #define OMAP242X_CLASS 0x24200024
  375. #define OMAP2420_REV_ES1_0 0x24200024
  376. #define OMAP2420_REV_ES2_0 0x24201024
  377. #define OMAP243X_CLASS 0x24300024
  378. #define OMAP2430_REV_ES1_0 0x24300024
  379. #define OMAP343X_CLASS 0x34300034
  380. #define OMAP3430_REV_ES1_0 0x34300034
  381. #define OMAP3430_REV_ES2_0 0x34301034
  382. #define OMAP3430_REV_ES2_1 0x34302034
  383. #define OMAP3430_REV_ES3_0 0x34303034
  384. #define OMAP3430_REV_ES3_1 0x34304034
  385. #define OMAP35XX_CLASS 0x35000034
  386. #define OMAP3503_REV(v) (OMAP35XX_CLASS | (0x3503 << 16) | (v << 12))
  387. #define OMAP3515_REV(v) (OMAP35XX_CLASS | (0x3515 << 16) | (v << 12))
  388. #define OMAP3525_REV(v) (OMAP35XX_CLASS | (0x3525 << 16) | (v << 12))
  389. #define OMAP3530_REV(v) (OMAP35XX_CLASS | (0x3530 << 16) | (v << 12))
  390. #define OMAP443X_CLASS 0x44300034
  391. /*
  392. * omap_chip bits
  393. *
  394. * CHIP_IS_OMAP{2420,2430,3430} indicate that a particular structure is
  395. * valid on all chips of that type. CHIP_IS_OMAP3430ES{1,2} indicates
  396. * something that is only valid on that particular ES revision.
  397. *
  398. * These bits may be ORed together to indicate structures that are
  399. * available on multiple chip types.
  400. *
  401. * To test whether a particular structure matches the current OMAP chip type,
  402. * use omap_chip_is().
  403. *
  404. */
  405. #define CHIP_IS_OMAP2420 (1 << 0)
  406. #define CHIP_IS_OMAP2430 (1 << 1)
  407. #define CHIP_IS_OMAP3430 (1 << 2)
  408. #define CHIP_IS_OMAP3430ES1 (1 << 3)
  409. #define CHIP_IS_OMAP3430ES2 (1 << 4)
  410. #define CHIP_IS_OMAP3430ES3_0 (1 << 5)
  411. #define CHIP_IS_OMAP3430ES3_1 (1 << 6)
  412. #define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
  413. /*
  414. * "GE" here represents "greater than or equal to" in terms of ES
  415. * levels. So CHIP_GE_OMAP3430ES2 is intended to match all OMAP3430
  416. * chips at ES2 and beyond, but not, for example, any OMAP lines after
  417. * OMAP3.
  418. */
  419. #define CHIP_GE_OMAP3430ES2 (CHIP_IS_OMAP3430ES2 | \
  420. CHIP_IS_OMAP3430ES3_0 | \
  421. CHIP_IS_OMAP3430ES3_1)
  422. #define CHIP_GE_OMAP3430ES3_1 (CHIP_IS_OMAP3430ES3_1)
  423. int omap_chip_is(struct omap_chip_id oci);
  424. void omap2_check_revision(void);
  425. /*
  426. * Runtime detection of OMAP3 features
  427. */
  428. extern u32 omap3_features;
  429. #define OMAP3_HAS_L2CACHE BIT(0)
  430. #define OMAP3_HAS_IVA BIT(1)
  431. #define OMAP3_HAS_SGX BIT(2)
  432. #define OMAP3_HAS_NEON BIT(3)
  433. #define OMAP3_HAS_ISP BIT(4)
  434. #define OMAP3_HAS_FEATURE(feat,flag) \
  435. static inline unsigned int omap3_has_ ##feat(void) \
  436. { \
  437. return (omap3_features & OMAP3_HAS_ ##flag); \
  438. } \
  439. OMAP3_HAS_FEATURE(l2cache, L2CACHE)
  440. OMAP3_HAS_FEATURE(sgx, SGX)
  441. OMAP3_HAS_FEATURE(iva, IVA)
  442. OMAP3_HAS_FEATURE(neon, NEON)
  443. OMAP3_HAS_FEATURE(isp, ISP)
  444. #endif