cpu.h 11 KB

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