cpu.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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. #include <linux/bitops.h>
  32. #include <plat/multi.h>
  33. /*
  34. * Omap device type i.e. EMU/HS/TST/GP/BAD
  35. */
  36. #define OMAP2_DEVICE_TYPE_TEST 0
  37. #define OMAP2_DEVICE_TYPE_EMU 1
  38. #define OMAP2_DEVICE_TYPE_SEC 2
  39. #define OMAP2_DEVICE_TYPE_GP 3
  40. #define OMAP2_DEVICE_TYPE_BAD 4
  41. int omap_type(void);
  42. struct omap_chip_id {
  43. u16 oc;
  44. u8 type;
  45. };
  46. #define OMAP_CHIP_INIT(x) { .oc = x }
  47. /*
  48. * omap_rev bits:
  49. * CPU id bits (0730, 1510, 1710, 2422...) [31:16]
  50. * CPU revision (See _REV_ defined in cpu.h) [15:08]
  51. * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
  52. */
  53. unsigned int omap_rev(void);
  54. /*
  55. * Define CPU revision bits
  56. *
  57. * Verbose meaning of the revision bits may be different for a silicon
  58. * family. This difference can be handled separately.
  59. */
  60. #define OMAP_REVBITS_00 0x00
  61. #define OMAP_REVBITS_10 0x10
  62. #define OMAP_REVBITS_20 0x20
  63. #define OMAP_REVBITS_30 0x30
  64. #define OMAP_REVBITS_40 0x40
  65. /*
  66. * Get the CPU revision for OMAP devices
  67. */
  68. #define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
  69. /*
  70. * Macros to group OMAP into cpu classes.
  71. * These can be used in most places.
  72. * cpu_is_omap7xx(): True for OMAP730, OMAP850
  73. * cpu_is_omap15xx(): True for OMAP1510, OMAP5910 and OMAP310
  74. * cpu_is_omap16xx(): True for OMAP1610, OMAP5912 and OMAP1710
  75. * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
  76. * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
  77. * cpu_is_omap243x(): True for OMAP2430
  78. * cpu_is_omap343x(): True for OMAP3430
  79. * cpu_is_omap443x(): True for OMAP4430
  80. */
  81. #define GET_OMAP_CLASS (omap_rev() & 0xff)
  82. #define IS_OMAP_CLASS(class, id) \
  83. static inline int is_omap ##class (void) \
  84. { \
  85. return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
  86. }
  87. #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
  88. #define IS_OMAP_SUBCLASS(subclass, id) \
  89. static inline int is_omap ##subclass (void) \
  90. { \
  91. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  92. }
  93. IS_OMAP_CLASS(7xx, 0x07)
  94. IS_OMAP_CLASS(15xx, 0x15)
  95. IS_OMAP_CLASS(16xx, 0x16)
  96. IS_OMAP_CLASS(24xx, 0x24)
  97. IS_OMAP_CLASS(34xx, 0x34)
  98. IS_OMAP_CLASS(44xx, 0x44)
  99. IS_OMAP_SUBCLASS(242x, 0x242)
  100. IS_OMAP_SUBCLASS(243x, 0x243)
  101. IS_OMAP_SUBCLASS(343x, 0x343)
  102. IS_OMAP_SUBCLASS(363x, 0x363)
  103. IS_OMAP_SUBCLASS(443x, 0x443)
  104. #define cpu_is_omap7xx() 0
  105. #define cpu_is_omap15xx() 0
  106. #define cpu_is_omap16xx() 0
  107. #define cpu_is_omap24xx() 0
  108. #define cpu_is_omap242x() 0
  109. #define cpu_is_omap243x() 0
  110. #define cpu_is_omap34xx() 0
  111. #define cpu_is_omap343x() 0
  112. #define cpu_is_omap44xx() 0
  113. #define cpu_is_omap443x() 0
  114. #if defined(MULTI_OMAP1)
  115. # if defined(CONFIG_ARCH_OMAP730)
  116. # undef cpu_is_omap7xx
  117. # define cpu_is_omap7xx() is_omap7xx()
  118. # endif
  119. # if defined(CONFIG_ARCH_OMAP850)
  120. # undef cpu_is_omap7xx
  121. # define cpu_is_omap7xx() is_omap7xx()
  122. # endif
  123. # if defined(CONFIG_ARCH_OMAP15XX)
  124. # undef cpu_is_omap15xx
  125. # define cpu_is_omap15xx() is_omap15xx()
  126. # endif
  127. # if defined(CONFIG_ARCH_OMAP16XX)
  128. # undef cpu_is_omap16xx
  129. # define cpu_is_omap16xx() is_omap16xx()
  130. # endif
  131. #else
  132. # if defined(CONFIG_ARCH_OMAP730)
  133. # undef cpu_is_omap7xx
  134. # define cpu_is_omap7xx() 1
  135. # endif
  136. # if defined(CONFIG_ARCH_OMAP850)
  137. # undef cpu_is_omap7xx
  138. # define cpu_is_omap7xx() 1
  139. # endif
  140. # if defined(CONFIG_ARCH_OMAP15XX)
  141. # undef cpu_is_omap15xx
  142. # define cpu_is_omap15xx() 1
  143. # endif
  144. # if defined(CONFIG_ARCH_OMAP16XX)
  145. # undef cpu_is_omap16xx
  146. # define cpu_is_omap16xx() 1
  147. # endif
  148. #endif
  149. #if defined(MULTI_OMAP2)
  150. # if defined(CONFIG_ARCH_OMAP2)
  151. # undef cpu_is_omap24xx
  152. # define cpu_is_omap24xx() is_omap24xx()
  153. # endif
  154. # if defined (CONFIG_ARCH_OMAP2420)
  155. # undef cpu_is_omap242x
  156. # define cpu_is_omap242x() is_omap242x()
  157. # endif
  158. # if defined (CONFIG_ARCH_OMAP2430)
  159. # undef cpu_is_omap243x
  160. # define cpu_is_omap243x() is_omap243x()
  161. # endif
  162. # if defined(CONFIG_ARCH_OMAP3)
  163. # undef cpu_is_omap34xx
  164. # undef cpu_is_omap343x
  165. # define cpu_is_omap34xx() is_omap34xx()
  166. # define cpu_is_omap343x() is_omap343x()
  167. # endif
  168. #else
  169. # if defined(CONFIG_ARCH_OMAP2)
  170. # undef cpu_is_omap24xx
  171. # define cpu_is_omap24xx() 1
  172. # endif
  173. # if defined(CONFIG_ARCH_OMAP2420)
  174. # undef cpu_is_omap242x
  175. # define cpu_is_omap242x() 1
  176. # endif
  177. # if defined(CONFIG_ARCH_OMAP2430)
  178. # undef cpu_is_omap243x
  179. # define cpu_is_omap243x() 1
  180. # endif
  181. # if defined(CONFIG_ARCH_OMAP3)
  182. # undef cpu_is_omap34xx
  183. # define cpu_is_omap34xx() 1
  184. # endif
  185. # if defined(CONFIG_ARCH_OMAP3430)
  186. # undef cpu_is_omap343x
  187. # define cpu_is_omap343x() 1
  188. # endif
  189. #endif
  190. /*
  191. * Macros to detect individual cpu types.
  192. * These are only rarely needed.
  193. * cpu_is_omap330(): True for OMAP330
  194. * cpu_is_omap730(): True for OMAP730
  195. * cpu_is_omap850(): True for OMAP850
  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. * cpu_is_omap4430(): True for OMAP4430
  208. * cpu_is_omap3505(): True for OMAP3505
  209. * cpu_is_omap3517(): True for OMAP3517
  210. */
  211. #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
  212. #define IS_OMAP_TYPE(type, id) \
  213. static inline int is_omap ##type (void) \
  214. { \
  215. return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
  216. }
  217. IS_OMAP_TYPE(310, 0x0310)
  218. IS_OMAP_TYPE(730, 0x0730)
  219. IS_OMAP_TYPE(850, 0x0850)
  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. IS_OMAP_TYPE(3505, 0x3505)
  232. IS_OMAP_TYPE(3517, 0x3517)
  233. #define cpu_is_omap310() 0
  234. #define cpu_is_omap730() 0
  235. #define cpu_is_omap850() 0
  236. #define cpu_is_omap1510() 0
  237. #define cpu_is_omap1610() 0
  238. #define cpu_is_omap5912() 0
  239. #define cpu_is_omap1611() 0
  240. #define cpu_is_omap1621() 0
  241. #define cpu_is_omap1710() 0
  242. #define cpu_is_omap2420() 0
  243. #define cpu_is_omap2422() 0
  244. #define cpu_is_omap2423() 0
  245. #define cpu_is_omap2430() 0
  246. #define cpu_is_omap3503() 0
  247. #define cpu_is_omap3515() 0
  248. #define cpu_is_omap3525() 0
  249. #define cpu_is_omap3530() 0
  250. #define cpu_is_omap3505() 0
  251. #define cpu_is_omap3517() 0
  252. #define cpu_is_omap3430() 0
  253. #define cpu_is_omap4430() 0
  254. #define cpu_is_omap3630() 0
  255. /*
  256. * Whether we have MULTI_OMAP1 or not, we still need to distinguish
  257. * between 730 vs 850, 330 vs. 1510 and 1611B/5912 vs. 1710.
  258. */
  259. #if defined(CONFIG_ARCH_OMAP730)
  260. # undef cpu_is_omap730
  261. # define cpu_is_omap730() is_omap730()
  262. #endif
  263. #if defined(CONFIG_ARCH_OMAP850)
  264. # undef cpu_is_omap850
  265. # define cpu_is_omap850() is_omap850()
  266. #endif
  267. #if defined(CONFIG_ARCH_OMAP15XX)
  268. # undef cpu_is_omap310
  269. # undef cpu_is_omap1510
  270. # define cpu_is_omap310() is_omap310()
  271. # define cpu_is_omap1510() is_omap1510()
  272. #endif
  273. #if defined(CONFIG_ARCH_OMAP16XX)
  274. # undef cpu_is_omap1610
  275. # undef cpu_is_omap1611
  276. # undef cpu_is_omap5912
  277. # undef cpu_is_omap1621
  278. # undef cpu_is_omap1710
  279. # define cpu_is_omap1610() is_omap1610()
  280. # define cpu_is_omap1611() is_omap1611()
  281. # define cpu_is_omap5912() is_omap5912()
  282. # define cpu_is_omap1621() is_omap1621()
  283. # define cpu_is_omap1710() is_omap1710()
  284. #endif
  285. #if defined(CONFIG_ARCH_OMAP2)
  286. # undef cpu_is_omap2420
  287. # undef cpu_is_omap2422
  288. # undef cpu_is_omap2423
  289. # undef cpu_is_omap2430
  290. # define cpu_is_omap2420() is_omap2420()
  291. # define cpu_is_omap2422() is_omap2422()
  292. # define cpu_is_omap2423() is_omap2423()
  293. # define cpu_is_omap2430() is_omap2430()
  294. #endif
  295. #if defined(CONFIG_ARCH_OMAP3)
  296. # undef cpu_is_omap3430
  297. # undef cpu_is_omap3503
  298. # undef cpu_is_omap3515
  299. # undef cpu_is_omap3525
  300. # undef cpu_is_omap3530
  301. # undef cpu_is_omap3505
  302. # undef cpu_is_omap3517
  303. # define cpu_is_omap3430() is_omap3430()
  304. # define cpu_is_omap3503() (cpu_is_omap3430() && \
  305. (!omap3_has_iva()) && \
  306. (!omap3_has_sgx()))
  307. # define cpu_is_omap3515() (cpu_is_omap3430() && \
  308. (!omap3_has_iva()) && \
  309. (omap3_has_sgx()))
  310. # define cpu_is_omap3525() (cpu_is_omap3430() && \
  311. (!omap3_has_sgx()) && \
  312. (omap3_has_iva()))
  313. # define cpu_is_omap3530() (cpu_is_omap3430())
  314. # define cpu_is_omap3505() is_omap3505()
  315. # define cpu_is_omap3517() is_omap3517()
  316. # undef cpu_is_omap3630
  317. # define cpu_is_omap3630() is_omap363x()
  318. #endif
  319. # if defined(CONFIG_ARCH_OMAP4)
  320. # undef cpu_is_omap44xx
  321. # undef cpu_is_omap443x
  322. # define cpu_is_omap44xx() is_omap44xx()
  323. # define cpu_is_omap443x() is_omap443x()
  324. # endif
  325. /* Macros to detect if we have OMAP1 or OMAP2 */
  326. #define cpu_class_is_omap1() (cpu_is_omap7xx() || cpu_is_omap15xx() || \
  327. cpu_is_omap16xx())
  328. #define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx() || \
  329. cpu_is_omap44xx())
  330. /* Various silicon revisions for omap2 */
  331. #define OMAP242X_CLASS 0x24200024
  332. #define OMAP2420_REV_ES1_0 0x24200024
  333. #define OMAP2420_REV_ES2_0 0x24201024
  334. #define OMAP243X_CLASS 0x24300024
  335. #define OMAP2430_REV_ES1_0 0x24300024
  336. #define OMAP343X_CLASS 0x34300034
  337. #define OMAP3430_REV_ES1_0 0x34300034
  338. #define OMAP3430_REV_ES2_0 0x34301034
  339. #define OMAP3430_REV_ES2_1 0x34302034
  340. #define OMAP3430_REV_ES3_0 0x34303034
  341. #define OMAP3430_REV_ES3_1 0x34304034
  342. #define OMAP3430_REV_ES3_1_2 0x34305034
  343. #define OMAP3630_REV_ES1_0 0x36300034
  344. #define OMAP35XX_CLASS 0x35000034
  345. #define OMAP3503_REV(v) (OMAP35XX_CLASS | (0x3503 << 16) | (v << 8))
  346. #define OMAP3515_REV(v) (OMAP35XX_CLASS | (0x3515 << 16) | (v << 8))
  347. #define OMAP3525_REV(v) (OMAP35XX_CLASS | (0x3525 << 16) | (v << 8))
  348. #define OMAP3530_REV(v) (OMAP35XX_CLASS | (0x3530 << 16) | (v << 8))
  349. #define OMAP3505_REV(v) (OMAP35XX_CLASS | (0x3505 << 16) | (v << 8))
  350. #define OMAP3517_REV(v) (OMAP35XX_CLASS | (0x3517 << 16) | (v << 8))
  351. #define OMAP443X_CLASS 0x44300044
  352. #define OMAP4430_REV_ES1_0 0x44300044
  353. /*
  354. * omap_chip bits
  355. *
  356. * CHIP_IS_OMAP{2420,2430,3430} indicate that a particular structure is
  357. * valid on all chips of that type. CHIP_IS_OMAP3430ES{1,2} indicates
  358. * something that is only valid on that particular ES revision.
  359. *
  360. * These bits may be ORed together to indicate structures that are
  361. * available on multiple chip types.
  362. *
  363. * To test whether a particular structure matches the current OMAP chip type,
  364. * use omap_chip_is().
  365. *
  366. */
  367. #define CHIP_IS_OMAP2420 (1 << 0)
  368. #define CHIP_IS_OMAP2430 (1 << 1)
  369. #define CHIP_IS_OMAP3430 (1 << 2)
  370. #define CHIP_IS_OMAP3430ES1 (1 << 3)
  371. #define CHIP_IS_OMAP3430ES2 (1 << 4)
  372. #define CHIP_IS_OMAP3430ES3_0 (1 << 5)
  373. #define CHIP_IS_OMAP3430ES3_1 (1 << 6)
  374. #define CHIP_IS_OMAP3630ES1 (1 << 7)
  375. #define CHIP_IS_OMAP4430ES1 (1 << 8)
  376. #define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
  377. #define CHIP_IS_OMAP4430 (CHIP_IS_OMAP4430ES1)
  378. /*
  379. * "GE" here represents "greater than or equal to" in terms of ES
  380. * levels. So CHIP_GE_OMAP3430ES2 is intended to match all OMAP3430
  381. * chips at ES2 and beyond, but not, for example, any OMAP lines after
  382. * OMAP3.
  383. */
  384. #define CHIP_GE_OMAP3430ES2 (CHIP_IS_OMAP3430ES2 | \
  385. CHIP_IS_OMAP3430ES3_0 | \
  386. CHIP_IS_OMAP3430ES3_1 | \
  387. CHIP_IS_OMAP3630ES1)
  388. #define CHIP_GE_OMAP3430ES3_1 (CHIP_IS_OMAP3430ES3_1 | \
  389. CHIP_IS_OMAP3630ES1)
  390. int omap_chip_is(struct omap_chip_id oci);
  391. void omap2_check_revision(void);
  392. /*
  393. * Runtime detection of OMAP3 features
  394. */
  395. extern u32 omap3_features;
  396. #define OMAP3_HAS_L2CACHE BIT(0)
  397. #define OMAP3_HAS_IVA BIT(1)
  398. #define OMAP3_HAS_SGX BIT(2)
  399. #define OMAP3_HAS_NEON BIT(3)
  400. #define OMAP3_HAS_ISP BIT(4)
  401. #define OMAP3_HAS_192MHZ_CLK BIT(5)
  402. #define OMAP3_HAS_FEATURE(feat,flag) \
  403. static inline unsigned int omap3_has_ ##feat(void) \
  404. { \
  405. return (omap3_features & OMAP3_HAS_ ##flag); \
  406. } \
  407. OMAP3_HAS_FEATURE(l2cache, L2CACHE)
  408. OMAP3_HAS_FEATURE(sgx, SGX)
  409. OMAP3_HAS_FEATURE(iva, IVA)
  410. OMAP3_HAS_FEATURE(neon, NEON)
  411. OMAP3_HAS_FEATURE(isp, ISP)
  412. OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
  413. #endif