cpu.h 9.9 KB

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