cpu.h 9.8 KB

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