cpu.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. * Written by Tony Lindgren <tony.lindgren@nokia.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. */
  25. #ifndef __ASM_ARCH_OMAP_CPU_H
  26. #define __ASM_ARCH_OMAP_CPU_H
  27. struct omap_chip_id {
  28. u8 oc;
  29. u8 type;
  30. };
  31. #define OMAP_CHIP_INIT(x) { .oc = x }
  32. /*
  33. * omap_rev bits:
  34. * CPU id bits (0730, 1510, 1710, 2422...) [31:16]
  35. * CPU revision (See _REV_ defined in cpu.h) [15:08]
  36. * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
  37. */
  38. unsigned int omap_rev(void);
  39. /*
  40. * Test if multicore OMAP support is needed
  41. */
  42. #undef MULTI_OMAP1
  43. #undef MULTI_OMAP2
  44. #undef OMAP_NAME
  45. #ifdef CONFIG_ARCH_OMAP730
  46. # ifdef OMAP_NAME
  47. # undef MULTI_OMAP1
  48. # define MULTI_OMAP1
  49. # else
  50. # define OMAP_NAME omap730
  51. # endif
  52. #endif
  53. #ifdef CONFIG_ARCH_OMAP850
  54. # ifdef OMAP_NAME
  55. # undef MULTI_OMAP1
  56. # define MULTI_OMAP1
  57. # else
  58. # define OMAP_NAME omap850
  59. # endif
  60. #endif
  61. #ifdef CONFIG_ARCH_OMAP15XX
  62. # ifdef OMAP_NAME
  63. # undef MULTI_OMAP1
  64. # define MULTI_OMAP1
  65. # else
  66. # define OMAP_NAME omap1510
  67. # endif
  68. #endif
  69. #ifdef CONFIG_ARCH_OMAP16XX
  70. # ifdef OMAP_NAME
  71. # undef MULTI_OMAP1
  72. # define MULTI_OMAP1
  73. # else
  74. # define OMAP_NAME omap16xx
  75. # endif
  76. #endif
  77. #if (defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX))
  78. # if (defined(OMAP_NAME) || defined(MULTI_OMAP1))
  79. # error "OMAP1 and OMAP2 can't be selected at the same time"
  80. # endif
  81. #endif
  82. #ifdef CONFIG_ARCH_OMAP2420
  83. # ifdef OMAP_NAME
  84. # undef MULTI_OMAP2
  85. # define MULTI_OMAP2
  86. # else
  87. # define OMAP_NAME omap2420
  88. # endif
  89. #endif
  90. #ifdef CONFIG_ARCH_OMAP2430
  91. # ifdef OMAP_NAME
  92. # undef MULTI_OMAP2
  93. # define MULTI_OMAP2
  94. # else
  95. # define OMAP_NAME omap2430
  96. # endif
  97. #endif
  98. #ifdef CONFIG_ARCH_OMAP3430
  99. # ifdef OMAP_NAME
  100. # undef MULTI_OMAP2
  101. # define MULTI_OMAP2
  102. # else
  103. # define OMAP_NAME omap3430
  104. # endif
  105. #endif
  106. /*
  107. * Macros to group OMAP into cpu classes.
  108. * These can be used in most places.
  109. * cpu_is_omap7xx(): True for OMAP730, OMAP850
  110. * cpu_is_omap15xx(): True for OMAP1510, OMAP5910 and OMAP310
  111. * cpu_is_omap16xx(): True for OMAP1610, OMAP5912 and OMAP1710
  112. * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
  113. * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
  114. * cpu_is_omap243x(): True for OMAP2430
  115. * cpu_is_omap343x(): True for OMAP3430
  116. */
  117. #define GET_OMAP_CLASS (omap_rev() & 0xff)
  118. #define IS_OMAP_CLASS(class, id) \
  119. static inline int is_omap ##class (void) \
  120. { \
  121. return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
  122. }
  123. #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
  124. #define IS_OMAP_SUBCLASS(subclass, id) \
  125. static inline int is_omap ##subclass (void) \
  126. { \
  127. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  128. }
  129. IS_OMAP_CLASS(7xx, 0x07)
  130. IS_OMAP_CLASS(15xx, 0x15)
  131. IS_OMAP_CLASS(16xx, 0x16)
  132. IS_OMAP_CLASS(24xx, 0x24)
  133. IS_OMAP_CLASS(34xx, 0x34)
  134. IS_OMAP_SUBCLASS(242x, 0x242)
  135. IS_OMAP_SUBCLASS(243x, 0x243)
  136. IS_OMAP_SUBCLASS(343x, 0x343)
  137. #define cpu_is_omap7xx() 0
  138. #define cpu_is_omap15xx() 0
  139. #define cpu_is_omap16xx() 0
  140. #define cpu_is_omap24xx() 0
  141. #define cpu_is_omap242x() 0
  142. #define cpu_is_omap243x() 0
  143. #define cpu_is_omap34xx() 0
  144. #define cpu_is_omap343x() 0
  145. #if defined(MULTI_OMAP1)
  146. # if defined(CONFIG_ARCH_OMAP730)
  147. # undef cpu_is_omap7xx
  148. # define cpu_is_omap7xx() is_omap7xx()
  149. # endif
  150. # if defined(CONFIG_ARCH_OMAP850)
  151. # undef cpu_is_omap7xx
  152. # define cpu_is_omap7xx() is_omap7xx()
  153. # endif
  154. # if defined(CONFIG_ARCH_OMAP15XX)
  155. # undef cpu_is_omap15xx
  156. # define cpu_is_omap15xx() is_omap15xx()
  157. # endif
  158. # if defined(CONFIG_ARCH_OMAP16XX)
  159. # undef cpu_is_omap16xx
  160. # define cpu_is_omap16xx() is_omap16xx()
  161. # endif
  162. #else
  163. # if defined(CONFIG_ARCH_OMAP730)
  164. # undef cpu_is_omap7xx
  165. # define cpu_is_omap7xx() 1
  166. # endif
  167. # if defined(CONFIG_ARCH_OMAP850)
  168. # undef cpu_is_omap7xx
  169. # define cpu_is_omap7xx() 1
  170. # endif
  171. # if defined(CONFIG_ARCH_OMAP15XX)
  172. # undef cpu_is_omap15xx
  173. # define cpu_is_omap15xx() 1
  174. # endif
  175. # if defined(CONFIG_ARCH_OMAP16XX)
  176. # undef cpu_is_omap16xx
  177. # define cpu_is_omap16xx() 1
  178. # endif
  179. #endif
  180. #if defined(MULTI_OMAP2)
  181. # if defined(CONFIG_ARCH_OMAP24XX)
  182. # undef cpu_is_omap24xx
  183. # undef cpu_is_omap242x
  184. # undef cpu_is_omap243x
  185. # define cpu_is_omap24xx() is_omap24xx()
  186. # define cpu_is_omap242x() is_omap242x()
  187. # define cpu_is_omap243x() is_omap243x()
  188. # endif
  189. # if defined(CONFIG_ARCH_OMAP34XX)
  190. # undef cpu_is_omap34xx
  191. # undef cpu_is_omap343x
  192. # define cpu_is_omap34xx() is_omap34xx()
  193. # define cpu_is_omap343x() is_omap343x()
  194. # endif
  195. #else
  196. # if defined(CONFIG_ARCH_OMAP24XX)
  197. # undef cpu_is_omap24xx
  198. # define cpu_is_omap24xx() 1
  199. # endif
  200. # if defined(CONFIG_ARCH_OMAP2420)
  201. # undef cpu_is_omap242x
  202. # define cpu_is_omap242x() 1
  203. # endif
  204. # if defined(CONFIG_ARCH_OMAP2430)
  205. # undef cpu_is_omap243x
  206. # define cpu_is_omap243x() 1
  207. # endif
  208. # if defined(CONFIG_ARCH_OMAP34XX)
  209. # undef cpu_is_omap34xx
  210. # define cpu_is_omap34xx() 1
  211. # endif
  212. # if defined(CONFIG_ARCH_OMAP3430)
  213. # undef cpu_is_omap343x
  214. # define cpu_is_omap343x() 1
  215. # endif
  216. #endif
  217. /*
  218. * Macros to detect individual cpu types.
  219. * These are only rarely needed.
  220. * cpu_is_omap330(): True for OMAP330
  221. * cpu_is_omap730(): True for OMAP730
  222. * cpu_is_omap850(): True for OMAP850
  223. * cpu_is_omap1510(): True for OMAP1510
  224. * cpu_is_omap1610(): True for OMAP1610
  225. * cpu_is_omap1611(): True for OMAP1611
  226. * cpu_is_omap5912(): True for OMAP5912
  227. * cpu_is_omap1621(): True for OMAP1621
  228. * cpu_is_omap1710(): True for OMAP1710
  229. * cpu_is_omap2420(): True for OMAP2420
  230. * cpu_is_omap2422(): True for OMAP2422
  231. * cpu_is_omap2423(): True for OMAP2423
  232. * cpu_is_omap2430(): True for OMAP2430
  233. * cpu_is_omap3430(): True for OMAP3430
  234. */
  235. #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
  236. #define IS_OMAP_TYPE(type, id) \
  237. static inline int is_omap ##type (void) \
  238. { \
  239. return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
  240. }
  241. IS_OMAP_TYPE(310, 0x0310)
  242. IS_OMAP_TYPE(730, 0x0730)
  243. IS_OMAP_TYPE(850, 0x0850)
  244. IS_OMAP_TYPE(1510, 0x1510)
  245. IS_OMAP_TYPE(1610, 0x1610)
  246. IS_OMAP_TYPE(1611, 0x1611)
  247. IS_OMAP_TYPE(5912, 0x1611)
  248. IS_OMAP_TYPE(1621, 0x1621)
  249. IS_OMAP_TYPE(1710, 0x1710)
  250. IS_OMAP_TYPE(2420, 0x2420)
  251. IS_OMAP_TYPE(2422, 0x2422)
  252. IS_OMAP_TYPE(2423, 0x2423)
  253. IS_OMAP_TYPE(2430, 0x2430)
  254. IS_OMAP_TYPE(3430, 0x3430)
  255. #define cpu_is_omap310() 0
  256. #define cpu_is_omap730() 0
  257. #define cpu_is_omap850() 0
  258. #define cpu_is_omap1510() 0
  259. #define cpu_is_omap1610() 0
  260. #define cpu_is_omap5912() 0
  261. #define cpu_is_omap1611() 0
  262. #define cpu_is_omap1621() 0
  263. #define cpu_is_omap1710() 0
  264. #define cpu_is_omap2420() 0
  265. #define cpu_is_omap2422() 0
  266. #define cpu_is_omap2423() 0
  267. #define cpu_is_omap2430() 0
  268. #define cpu_is_omap3430() 0
  269. #if defined(MULTI_OMAP1)
  270. # if defined(CONFIG_ARCH_OMAP730)
  271. # undef cpu_is_omap730
  272. # define cpu_is_omap730() is_omap730()
  273. # endif
  274. # if defined(CONFIG_ARCH_OMAP850)
  275. # undef cpu_is_omap850
  276. # define cpu_is_omap850() is_omap850()
  277. # endif
  278. #else
  279. # if defined(CONFIG_ARCH_OMAP730)
  280. # undef cpu_is_omap730
  281. # define cpu_is_omap730() 1
  282. # endif
  283. #endif
  284. #else
  285. # if defined(CONFIG_ARCH_OMAP850)
  286. # undef cpu_is_omap850
  287. # define cpu_is_omap850() 1
  288. # endif
  289. #endif
  290. /*
  291. * Whether we have MULTI_OMAP1 or not, we still need to distinguish
  292. * between 330 vs. 1510 and 1611B/5912 vs. 1710.
  293. */
  294. #if defined(CONFIG_ARCH_OMAP15XX)
  295. # undef cpu_is_omap310
  296. # undef cpu_is_omap1510
  297. # define cpu_is_omap310() is_omap310()
  298. # define cpu_is_omap1510() is_omap1510()
  299. #endif
  300. #if defined(CONFIG_ARCH_OMAP16XX)
  301. # undef cpu_is_omap1610
  302. # undef cpu_is_omap1611
  303. # undef cpu_is_omap5912
  304. # undef cpu_is_omap1621
  305. # undef cpu_is_omap1710
  306. # define cpu_is_omap1610() is_omap1610()
  307. # define cpu_is_omap1611() is_omap1611()
  308. # define cpu_is_omap5912() is_omap5912()
  309. # define cpu_is_omap1621() is_omap1621()
  310. # define cpu_is_omap1710() is_omap1710()
  311. #endif
  312. #if defined(CONFIG_ARCH_OMAP24XX)
  313. # undef cpu_is_omap2420
  314. # undef cpu_is_omap2422
  315. # undef cpu_is_omap2423
  316. # undef cpu_is_omap2430
  317. # define cpu_is_omap2420() is_omap2420()
  318. # define cpu_is_omap2422() is_omap2422()
  319. # define cpu_is_omap2423() is_omap2423()
  320. # define cpu_is_omap2430() is_omap2430()
  321. #endif
  322. #if defined(CONFIG_ARCH_OMAP34XX)
  323. # undef cpu_is_omap3430
  324. # define cpu_is_omap3430() is_omap3430()
  325. #endif
  326. /* Macros to detect if we have OMAP1 or OMAP2 */
  327. #define cpu_class_is_omap1() (cpu_is_omap7xx() || cpu_is_omap15xx() || \
  328. cpu_is_omap16xx())
  329. #define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx())
  330. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  331. /* Various silicon revisions for omap2 */
  332. #define OMAP242X_CLASS 0x24200024
  333. #define OMAP2420_REV_ES1_0 0x24200024
  334. #define OMAP2420_REV_ES2_0 0x24201024
  335. #define OMAP243X_CLASS 0x24300024
  336. #define OMAP2430_REV_ES1_0 0x24300024
  337. #define OMAP343X_CLASS 0x34300034
  338. #define OMAP3430_REV_ES1_0 0x34300034
  339. #define OMAP3430_REV_ES2_0 0x34301034
  340. #define OMAP3430_REV_ES2_1 0x34302034
  341. #define OMAP3430_REV_ES3_0 0x34303034
  342. #define OMAP3430_REV_ES3_1 0x34304034
  343. /*
  344. * omap_chip bits
  345. *
  346. * CHIP_IS_OMAP{2420,2430,3430} indicate that a particular structure is
  347. * valid on all chips of that type. CHIP_IS_OMAP3430ES{1,2} indicates
  348. * something that is only valid on that particular ES revision.
  349. *
  350. * These bits may be ORed together to indicate structures that are
  351. * available on multiple chip types.
  352. *
  353. * To test whether a particular structure matches the current OMAP chip type,
  354. * use omap_chip_is().
  355. *
  356. */
  357. #define CHIP_IS_OMAP2420 (1 << 0)
  358. #define CHIP_IS_OMAP2430 (1 << 1)
  359. #define CHIP_IS_OMAP3430 (1 << 2)
  360. #define CHIP_IS_OMAP3430ES1 (1 << 3)
  361. #define CHIP_IS_OMAP3430ES2 (1 << 4)
  362. #define CHIP_IS_OMAP3430ES3_0 (1 << 5)
  363. #define CHIP_IS_OMAP3430ES3_1 (1 << 6)
  364. #define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
  365. /*
  366. * "GE" here represents "greater than or equal to" in terms of ES
  367. * levels. So CHIP_GE_OMAP3430ES2 is intended to match all OMAP3430
  368. * chips at ES2 and beyond, but not, for example, any OMAP lines after
  369. * OMAP3.
  370. */
  371. #define CHIP_GE_OMAP3430ES2 (CHIP_IS_OMAP3430ES2 | \
  372. CHIP_IS_OMAP3430ES3_0 | \
  373. CHIP_IS_OMAP3430ES3_1)
  374. #define CHIP_GE_OMAP3430ES3_1 (CHIP_IS_OMAP3430ES3_1)
  375. int omap_chip_is(struct omap_chip_id oci);
  376. int omap_type(void);
  377. /*
  378. * Macro to detect device type i.e. EMU/HS/TST/GP/BAD
  379. */
  380. #define OMAP2_DEVICE_TYPE_TEST 0
  381. #define OMAP2_DEVICE_TYPE_EMU 1
  382. #define OMAP2_DEVICE_TYPE_SEC 2
  383. #define OMAP2_DEVICE_TYPE_GP 3
  384. #define OMAP2_DEVICE_TYPE_BAD 4
  385. void omap2_check_revision(void);
  386. #endif /* defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) */