cpu.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 >> 8) & 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. #ifdef CONFIG_ARCH_OMAP24XX
  60. # if (defined(OMAP_NAME) || defined(MULTI_OMAP1))
  61. # error "OMAP1 and OMAP2 can't be selected at the same time"
  62. # else
  63. # undef MULTI_OMAP2
  64. # define OMAP_NAME omap24xx
  65. # endif
  66. #endif
  67. /*
  68. * Macros to group OMAP into cpu classes.
  69. * These can be used in most places.
  70. * cpu_is_omap7xx(): True for OMAP730
  71. * cpu_is_omap15xx(): True for OMAP1510, OMAP5910 and OMAP310
  72. * cpu_is_omap16xx(): True for OMAP1610, OMAP5912 and OMAP1710
  73. * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
  74. * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
  75. * cpu_is_omap243x(): True for OMAP2430
  76. */
  77. #define GET_OMAP_CLASS (system_rev & 0xff)
  78. #define IS_OMAP_CLASS(class, id) \
  79. static inline int is_omap ##class (void) \
  80. { \
  81. return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
  82. }
  83. #define GET_OMAP_SUBCLASS ((system_rev >> 20) & 0x0fff)
  84. #define IS_OMAP_SUBCLASS(subclass, id) \
  85. static inline int is_omap ##subclass (void) \
  86. { \
  87. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  88. }
  89. IS_OMAP_CLASS(7xx, 0x07)
  90. IS_OMAP_CLASS(15xx, 0x15)
  91. IS_OMAP_CLASS(16xx, 0x16)
  92. IS_OMAP_CLASS(24xx, 0x24)
  93. IS_OMAP_SUBCLASS(242x, 0x242)
  94. IS_OMAP_SUBCLASS(243x, 0x243)
  95. #define cpu_is_omap7xx() 0
  96. #define cpu_is_omap15xx() 0
  97. #define cpu_is_omap16xx() 0
  98. #define cpu_is_omap24xx() 0
  99. #define cpu_is_omap242x() 0
  100. #define cpu_is_omap243x() 0
  101. #if defined(MULTI_OMAP1)
  102. # if defined(CONFIG_ARCH_OMAP730)
  103. # undef cpu_is_omap7xx
  104. # define cpu_is_omap7xx() is_omap7xx()
  105. # endif
  106. # if defined(CONFIG_ARCH_OMAP15XX)
  107. # undef cpu_is_omap15xx
  108. # define cpu_is_omap15xx() is_omap15xx()
  109. # endif
  110. # if defined(CONFIG_ARCH_OMAP16XX)
  111. # undef cpu_is_omap16xx
  112. # define cpu_is_omap16xx() is_omap16xx()
  113. # endif
  114. #else
  115. # if defined(CONFIG_ARCH_OMAP730)
  116. # undef cpu_is_omap7xx
  117. # define cpu_is_omap7xx() 1
  118. # endif
  119. # if defined(CONFIG_ARCH_OMAP15XX)
  120. # undef cpu_is_omap15xx
  121. # define cpu_is_omap15xx() 1
  122. # endif
  123. # if defined(CONFIG_ARCH_OMAP16XX)
  124. # undef cpu_is_omap16xx
  125. # define cpu_is_omap16xx() 1
  126. # endif
  127. # if defined(CONFIG_ARCH_OMAP24XX)
  128. # undef cpu_is_omap24xx
  129. # undef cpu_is_omap242x
  130. # undef cpu_is_omap243x
  131. # define cpu_is_omap24xx() 1
  132. # define cpu_is_omap242x() is_omap242x()
  133. # define cpu_is_omap243x() is_omap243x()
  134. # endif
  135. #endif
  136. /*
  137. * Macros to detect individual cpu types.
  138. * These are only rarely needed.
  139. * cpu_is_omap330(): True for OMAP330
  140. * cpu_is_omap730(): True for OMAP730
  141. * cpu_is_omap1510(): True for OMAP1510
  142. * cpu_is_omap1610(): True for OMAP1610
  143. * cpu_is_omap1611(): True for OMAP1611
  144. * cpu_is_omap5912(): True for OMAP5912
  145. * cpu_is_omap1621(): True for OMAP1621
  146. * cpu_is_omap1710(): True for OMAP1710
  147. * cpu_is_omap2420(): True for OMAP2420
  148. * cpu_is_omap2422(): True for OMAP2422
  149. * cpu_is_omap2423(): True for OMAP2423
  150. * cpu_is_omap2430(): True for OMAP2430
  151. */
  152. #define GET_OMAP_TYPE ((system_rev >> 16) & 0xffff)
  153. #define IS_OMAP_TYPE(type, id) \
  154. static inline int is_omap ##type (void) \
  155. { \
  156. return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
  157. }
  158. IS_OMAP_TYPE(310, 0x0310)
  159. IS_OMAP_TYPE(730, 0x0730)
  160. IS_OMAP_TYPE(1510, 0x1510)
  161. IS_OMAP_TYPE(1610, 0x1610)
  162. IS_OMAP_TYPE(1611, 0x1611)
  163. IS_OMAP_TYPE(5912, 0x1611)
  164. IS_OMAP_TYPE(1621, 0x1621)
  165. IS_OMAP_TYPE(1710, 0x1710)
  166. IS_OMAP_TYPE(2420, 0x2420)
  167. IS_OMAP_TYPE(2422, 0x2422)
  168. IS_OMAP_TYPE(2423, 0x2423)
  169. IS_OMAP_TYPE(2430, 0x2430)
  170. #define cpu_is_omap310() 0
  171. #define cpu_is_omap730() 0
  172. #define cpu_is_omap1510() 0
  173. #define cpu_is_omap1610() 0
  174. #define cpu_is_omap5912() 0
  175. #define cpu_is_omap1611() 0
  176. #define cpu_is_omap1621() 0
  177. #define cpu_is_omap1710() 0
  178. #define cpu_is_omap2420() 0
  179. #define cpu_is_omap2422() 0
  180. #define cpu_is_omap2423() 0
  181. #define cpu_is_omap2430() 0
  182. #if defined(MULTI_OMAP1)
  183. # if defined(CONFIG_ARCH_OMAP730)
  184. # undef cpu_is_omap730
  185. # define cpu_is_omap730() is_omap730()
  186. # endif
  187. #else
  188. # if defined(CONFIG_ARCH_OMAP730)
  189. # undef cpu_is_omap730
  190. # define cpu_is_omap730() 1
  191. # endif
  192. #endif
  193. /*
  194. * Whether we have MULTI_OMAP1 or not, we still need to distinguish
  195. * between 330 vs. 1510 and 1611B/5912 vs. 1710.
  196. */
  197. #if defined(CONFIG_ARCH_OMAP15XX)
  198. # undef cpu_is_omap310
  199. # undef cpu_is_omap1510
  200. # define cpu_is_omap310() is_omap310()
  201. # define cpu_is_omap1510() is_omap1510()
  202. #endif
  203. #if defined(CONFIG_ARCH_OMAP16XX)
  204. # undef cpu_is_omap1610
  205. # undef cpu_is_omap1611
  206. # undef cpu_is_omap5912
  207. # undef cpu_is_omap1621
  208. # undef cpu_is_omap1710
  209. # define cpu_is_omap1610() is_omap1610()
  210. # define cpu_is_omap1611() is_omap1611()
  211. # define cpu_is_omap5912() is_omap5912()
  212. # define cpu_is_omap1621() is_omap1621()
  213. # define cpu_is_omap1710() is_omap1710()
  214. #endif
  215. #if defined(CONFIG_ARCH_OMAP24XX)
  216. # undef cpu_is_omap2420
  217. # undef cpu_is_omap2422
  218. # undef cpu_is_omap2423
  219. # undef cpu_is_omap2430
  220. # define cpu_is_omap2420() is_omap2420()
  221. # define cpu_is_omap2422() is_omap2422()
  222. # define cpu_is_omap2423() is_omap2423()
  223. # define cpu_is_omap2430() is_omap2430()
  224. #endif
  225. /* Macros to detect if we have OMAP1 or OMAP2 */
  226. #define cpu_class_is_omap1() (cpu_is_omap730() || cpu_is_omap15xx() || \
  227. cpu_is_omap16xx())
  228. #define cpu_class_is_omap2() cpu_is_omap24xx()
  229. #endif