cpu.h 11 KB

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