cpu.h 11 KB

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