cpu.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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-11 Texas Instruments.
  9. *
  10. * Written by Tony Lindgren <tony.lindgren@nokia.com>
  11. *
  12. * Added OMAP4/5 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. /*
  43. * omap_rev bits:
  44. * CPU id bits (0730, 1510, 1710, 2422...) [31:16]
  45. * CPU revision (See _REV_ defined in cpu.h) [15:08]
  46. * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
  47. */
  48. unsigned int omap_rev(void);
  49. /*
  50. * Get the CPU revision for OMAP devices
  51. */
  52. #define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
  53. /*
  54. * Macros to group OMAP into cpu classes.
  55. * These can be used in most places.
  56. * cpu_is_omap7xx(): True for OMAP730, OMAP850
  57. * cpu_is_omap15xx(): True for OMAP1510, OMAP5910 and OMAP310
  58. * cpu_is_omap16xx(): True for OMAP1610, OMAP5912 and OMAP1710
  59. * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
  60. * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
  61. * cpu_is_omap243x(): True for OMAP2430
  62. * cpu_is_omap343x(): True for OMAP3430
  63. * cpu_is_omap443x(): True for OMAP4430
  64. * cpu_is_omap446x(): True for OMAP4460
  65. * cpu_is_omap447x(): True for OMAP4470
  66. * soc_is_omap543x(): True for OMAP5430, OMAP5432
  67. */
  68. #define GET_OMAP_CLASS (omap_rev() & 0xff)
  69. #define IS_OMAP_CLASS(class, id) \
  70. static inline int is_omap ##class (void) \
  71. { \
  72. return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
  73. }
  74. #define GET_AM_CLASS ((omap_rev() >> 24) & 0xff)
  75. #define IS_AM_CLASS(class, id) \
  76. static inline int is_am ##class (void) \
  77. { \
  78. return (GET_AM_CLASS == (id)) ? 1 : 0; \
  79. }
  80. #define GET_TI_CLASS ((omap_rev() >> 24) & 0xff)
  81. #define IS_TI_CLASS(class, id) \
  82. static inline int is_ti ##class (void) \
  83. { \
  84. return (GET_TI_CLASS == (id)) ? 1 : 0; \
  85. }
  86. #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
  87. #define IS_OMAP_SUBCLASS(subclass, id) \
  88. static inline int is_omap ##subclass (void) \
  89. { \
  90. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  91. }
  92. #define IS_TI_SUBCLASS(subclass, id) \
  93. static inline int is_ti ##subclass (void) \
  94. { \
  95. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  96. }
  97. #define IS_AM_SUBCLASS(subclass, id) \
  98. static inline int is_am ##subclass (void) \
  99. { \
  100. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  101. }
  102. IS_OMAP_CLASS(7xx, 0x07)
  103. IS_OMAP_CLASS(15xx, 0x15)
  104. IS_OMAP_CLASS(16xx, 0x16)
  105. IS_OMAP_CLASS(24xx, 0x24)
  106. IS_OMAP_CLASS(34xx, 0x34)
  107. IS_OMAP_CLASS(44xx, 0x44)
  108. IS_AM_CLASS(35xx, 0x35)
  109. IS_OMAP_CLASS(54xx, 0x54)
  110. IS_AM_CLASS(33xx, 0x33)
  111. IS_TI_CLASS(81xx, 0x81)
  112. IS_OMAP_SUBCLASS(242x, 0x242)
  113. IS_OMAP_SUBCLASS(243x, 0x243)
  114. IS_OMAP_SUBCLASS(343x, 0x343)
  115. IS_OMAP_SUBCLASS(363x, 0x363)
  116. IS_OMAP_SUBCLASS(443x, 0x443)
  117. IS_OMAP_SUBCLASS(446x, 0x446)
  118. IS_OMAP_SUBCLASS(447x, 0x447)
  119. IS_OMAP_SUBCLASS(543x, 0x543)
  120. IS_TI_SUBCLASS(816x, 0x816)
  121. IS_TI_SUBCLASS(814x, 0x814)
  122. IS_AM_SUBCLASS(335x, 0x335)
  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. #define cpu_is_ti81xx() 0
  132. #define cpu_is_ti816x() 0
  133. #define cpu_is_ti814x() 0
  134. #define soc_is_am35xx() 0
  135. #define soc_is_am33xx() 0
  136. #define soc_is_am335x() 0
  137. #define cpu_is_omap44xx() 0
  138. #define cpu_is_omap443x() 0
  139. #define cpu_is_omap446x() 0
  140. #define cpu_is_omap447x() 0
  141. #define soc_is_omap54xx() 0
  142. #define soc_is_omap543x() 0
  143. #if defined(MULTI_OMAP1)
  144. # if defined(CONFIG_ARCH_OMAP730)
  145. # undef cpu_is_omap7xx
  146. # define cpu_is_omap7xx() is_omap7xx()
  147. # endif
  148. # if defined(CONFIG_ARCH_OMAP850)
  149. # undef cpu_is_omap7xx
  150. # define cpu_is_omap7xx() is_omap7xx()
  151. # endif
  152. # if defined(CONFIG_ARCH_OMAP15XX)
  153. # undef cpu_is_omap15xx
  154. # define cpu_is_omap15xx() is_omap15xx()
  155. # endif
  156. # if defined(CONFIG_ARCH_OMAP16XX)
  157. # undef cpu_is_omap16xx
  158. # define cpu_is_omap16xx() is_omap16xx()
  159. # endif
  160. #else
  161. # if defined(CONFIG_ARCH_OMAP730)
  162. # undef cpu_is_omap7xx
  163. # define cpu_is_omap7xx() 1
  164. # endif
  165. # if defined(CONFIG_ARCH_OMAP850)
  166. # undef cpu_is_omap7xx
  167. # define cpu_is_omap7xx() 1
  168. # endif
  169. # if defined(CONFIG_ARCH_OMAP15XX)
  170. # undef cpu_is_omap15xx
  171. # define cpu_is_omap15xx() 1
  172. # endif
  173. # if defined(CONFIG_ARCH_OMAP16XX)
  174. # undef cpu_is_omap16xx
  175. # define cpu_is_omap16xx() 1
  176. # endif
  177. #endif
  178. #if defined(MULTI_OMAP2)
  179. # if defined(CONFIG_ARCH_OMAP2)
  180. # undef cpu_is_omap24xx
  181. # define cpu_is_omap24xx() is_omap24xx()
  182. # endif
  183. # if defined (CONFIG_SOC_OMAP2420)
  184. # undef cpu_is_omap242x
  185. # define cpu_is_omap242x() is_omap242x()
  186. # endif
  187. # if defined (CONFIG_SOC_OMAP2430)
  188. # undef cpu_is_omap243x
  189. # define cpu_is_omap243x() is_omap243x()
  190. # endif
  191. # if defined(CONFIG_ARCH_OMAP3)
  192. # undef cpu_is_omap34xx
  193. # undef cpu_is_omap343x
  194. # define cpu_is_omap34xx() is_omap34xx()
  195. # define cpu_is_omap343x() is_omap343x()
  196. # endif
  197. #else
  198. # if defined(CONFIG_ARCH_OMAP2)
  199. # undef cpu_is_omap24xx
  200. # define cpu_is_omap24xx() 1
  201. # endif
  202. # if defined(CONFIG_SOC_OMAP2420)
  203. # undef cpu_is_omap242x
  204. # define cpu_is_omap242x() 1
  205. # endif
  206. # if defined(CONFIG_SOC_OMAP2430)
  207. # undef cpu_is_omap243x
  208. # define cpu_is_omap243x() 1
  209. # endif
  210. # if defined(CONFIG_ARCH_OMAP3)
  211. # undef cpu_is_omap34xx
  212. # define cpu_is_omap34xx() 1
  213. # endif
  214. # if defined(CONFIG_SOC_OMAP3430)
  215. # undef cpu_is_omap343x
  216. # define cpu_is_omap343x() 1
  217. # endif
  218. #endif
  219. /*
  220. * Macros to detect individual cpu types.
  221. * These are only rarely needed.
  222. * cpu_is_omap310(): True for OMAP310
  223. * cpu_is_omap1510(): True for OMAP1510
  224. * cpu_is_omap1610(): True for OMAP1610
  225. * cpu_is_omap1611(): True for OMAP1611
  226. * cpu_is_omap5912(): True for OMAP5912
  227. * cpu_is_omap1621(): True for OMAP1621
  228. * cpu_is_omap1710(): True for OMAP1710
  229. * cpu_is_omap2420(): True for OMAP2420
  230. * cpu_is_omap2422(): True for OMAP2422
  231. * cpu_is_omap2423(): True for OMAP2423
  232. * cpu_is_omap2430(): True for OMAP2430
  233. * cpu_is_omap3430(): True for OMAP3430
  234. */
  235. #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
  236. #define IS_OMAP_TYPE(type, id) \
  237. static inline int is_omap ##type (void) \
  238. { \
  239. return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
  240. }
  241. IS_OMAP_TYPE(310, 0x0310)
  242. IS_OMAP_TYPE(1510, 0x1510)
  243. IS_OMAP_TYPE(1610, 0x1610)
  244. IS_OMAP_TYPE(1611, 0x1611)
  245. IS_OMAP_TYPE(5912, 0x1611)
  246. IS_OMAP_TYPE(1621, 0x1621)
  247. IS_OMAP_TYPE(1710, 0x1710)
  248. IS_OMAP_TYPE(2420, 0x2420)
  249. IS_OMAP_TYPE(2422, 0x2422)
  250. IS_OMAP_TYPE(2423, 0x2423)
  251. IS_OMAP_TYPE(2430, 0x2430)
  252. IS_OMAP_TYPE(3430, 0x3430)
  253. #define cpu_is_omap310() 0
  254. #define cpu_is_omap1510() 0
  255. #define cpu_is_omap1610() 0
  256. #define cpu_is_omap5912() 0
  257. #define cpu_is_omap1611() 0
  258. #define cpu_is_omap1621() 0
  259. #define cpu_is_omap1710() 0
  260. #define cpu_is_omap2420() 0
  261. #define cpu_is_omap2422() 0
  262. #define cpu_is_omap2423() 0
  263. #define cpu_is_omap2430() 0
  264. #define cpu_is_omap3430() 0
  265. #define cpu_is_omap3630() 0
  266. #define soc_is_omap5430() 0
  267. /*
  268. * Whether we have MULTI_OMAP1 or not, we still need to distinguish
  269. * between 310 vs. 1510 and 1611B/5912 vs. 1710.
  270. */
  271. #if defined(CONFIG_ARCH_OMAP15XX)
  272. # undef cpu_is_omap310
  273. # undef cpu_is_omap1510
  274. # define cpu_is_omap310() is_omap310()
  275. # define cpu_is_omap1510() is_omap1510()
  276. #endif
  277. #if defined(CONFIG_ARCH_OMAP16XX)
  278. # undef cpu_is_omap1610
  279. # undef cpu_is_omap1611
  280. # undef cpu_is_omap5912
  281. # undef cpu_is_omap1621
  282. # undef cpu_is_omap1710
  283. # define cpu_is_omap1610() is_omap1610()
  284. # define cpu_is_omap1611() is_omap1611()
  285. # define cpu_is_omap5912() is_omap5912()
  286. # define cpu_is_omap1621() is_omap1621()
  287. # define cpu_is_omap1710() is_omap1710()
  288. #endif
  289. #if defined(CONFIG_ARCH_OMAP2)
  290. # undef cpu_is_omap2420
  291. # undef cpu_is_omap2422
  292. # undef cpu_is_omap2423
  293. # undef cpu_is_omap2430
  294. # define cpu_is_omap2420() is_omap2420()
  295. # define cpu_is_omap2422() is_omap2422()
  296. # define cpu_is_omap2423() is_omap2423()
  297. # define cpu_is_omap2430() is_omap2430()
  298. #endif
  299. #if defined(CONFIG_ARCH_OMAP3)
  300. # undef cpu_is_omap3430
  301. # undef cpu_is_ti81xx
  302. # undef cpu_is_ti816x
  303. # undef cpu_is_ti814x
  304. # undef soc_is_am35xx
  305. # define cpu_is_omap3430() is_omap3430()
  306. # undef cpu_is_omap3630
  307. # define cpu_is_omap3630() is_omap363x()
  308. # define cpu_is_ti81xx() is_ti81xx()
  309. # define cpu_is_ti816x() is_ti816x()
  310. # define cpu_is_ti814x() is_ti814x()
  311. # define soc_is_am35xx() is_am35xx()
  312. #endif
  313. # if defined(CONFIG_SOC_AM33XX)
  314. # undef soc_is_am33xx
  315. # undef soc_is_am335x
  316. # define soc_is_am33xx() is_am33xx()
  317. # define soc_is_am335x() is_am335x()
  318. #endif
  319. # if defined(CONFIG_ARCH_OMAP4)
  320. # undef cpu_is_omap44xx
  321. # undef cpu_is_omap443x
  322. # undef cpu_is_omap446x
  323. # undef cpu_is_omap447x
  324. # define cpu_is_omap44xx() is_omap44xx()
  325. # define cpu_is_omap443x() is_omap443x()
  326. # define cpu_is_omap446x() is_omap446x()
  327. # define cpu_is_omap447x() is_omap447x()
  328. # endif
  329. # if defined(CONFIG_SOC_OMAP5)
  330. # undef soc_is_omap54xx
  331. # undef soc_is_omap543x
  332. # define soc_is_omap54xx() is_omap54xx()
  333. # define soc_is_omap543x() is_omap543x()
  334. #endif
  335. /* Macros to detect if we have OMAP1 or OMAP2 */
  336. #define cpu_class_is_omap1() (cpu_is_omap7xx() || cpu_is_omap15xx() || \
  337. cpu_is_omap16xx())
  338. #define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx() || \
  339. cpu_is_omap44xx() || soc_is_omap54xx())
  340. /* Various silicon revisions for omap2 */
  341. #define OMAP242X_CLASS 0x24200024
  342. #define OMAP2420_REV_ES1_0 OMAP242X_CLASS
  343. #define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (0x1 << 8))
  344. #define OMAP243X_CLASS 0x24300024
  345. #define OMAP2430_REV_ES1_0 OMAP243X_CLASS
  346. #define OMAP343X_CLASS 0x34300034
  347. #define OMAP3430_REV_ES1_0 OMAP343X_CLASS
  348. #define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (0x1 << 8))
  349. #define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (0x2 << 8))
  350. #define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (0x3 << 8))
  351. #define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (0x4 << 8))
  352. #define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (0x5 << 8))
  353. #define OMAP363X_CLASS 0x36300034
  354. #define OMAP3630_REV_ES1_0 OMAP363X_CLASS
  355. #define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (0x1 << 8))
  356. #define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (0x2 << 8))
  357. #define TI816X_CLASS 0x81600034
  358. #define TI8168_REV_ES1_0 TI816X_CLASS
  359. #define TI8168_REV_ES1_1 (TI816X_CLASS | (0x1 << 8))
  360. #define TI814X_CLASS 0x81400034
  361. #define TI8148_REV_ES1_0 TI814X_CLASS
  362. #define TI8148_REV_ES2_0 (TI814X_CLASS | (0x1 << 8))
  363. #define TI8148_REV_ES2_1 (TI814X_CLASS | (0x2 << 8))
  364. #define AM35XX_CLASS 0x35170034
  365. #define AM35XX_REV_ES1_0 AM35XX_CLASS
  366. #define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8))
  367. #define AM335X_CLASS 0x33500033
  368. #define AM335X_REV_ES1_0 AM335X_CLASS
  369. #define OMAP443X_CLASS 0x44300044
  370. #define OMAP4430_REV_ES1_0 (OMAP443X_CLASS | (0x10 << 8))
  371. #define OMAP4430_REV_ES2_0 (OMAP443X_CLASS | (0x20 << 8))
  372. #define OMAP4430_REV_ES2_1 (OMAP443X_CLASS | (0x21 << 8))
  373. #define OMAP4430_REV_ES2_2 (OMAP443X_CLASS | (0x22 << 8))
  374. #define OMAP4430_REV_ES2_3 (OMAP443X_CLASS | (0x23 << 8))
  375. #define OMAP446X_CLASS 0x44600044
  376. #define OMAP4460_REV_ES1_0 (OMAP446X_CLASS | (0x10 << 8))
  377. #define OMAP4460_REV_ES1_1 (OMAP446X_CLASS | (0x11 << 8))
  378. #define OMAP447X_CLASS 0x44700044
  379. #define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
  380. #define OMAP54XX_CLASS 0x54000054
  381. #define OMAP5430_REV_ES1_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x10 << 8))
  382. #define OMAP5432_REV_ES1_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x10 << 8))
  383. void omap2xxx_check_revision(void);
  384. void omap3xxx_check_revision(void);
  385. void omap4xxx_check_revision(void);
  386. void omap5xxx_check_revision(void);
  387. void omap3xxx_check_features(void);
  388. void ti81xx_check_features(void);
  389. void omap4xxx_check_features(void);
  390. /*
  391. * Runtime detection of OMAP3 features
  392. *
  393. * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
  394. * family have OS-level control over the I/O chain clock. This is
  395. * to avoid a window during which wakeups could potentially be lost
  396. * during powerdomain transitions. If this bit is set, it
  397. * indicates that the chip does support OS-level control of this
  398. * feature.
  399. */
  400. extern u32 omap_features;
  401. #define OMAP3_HAS_L2CACHE BIT(0)
  402. #define OMAP3_HAS_IVA BIT(1)
  403. #define OMAP3_HAS_SGX BIT(2)
  404. #define OMAP3_HAS_NEON BIT(3)
  405. #define OMAP3_HAS_ISP BIT(4)
  406. #define OMAP3_HAS_192MHZ_CLK BIT(5)
  407. #define OMAP3_HAS_IO_WAKEUP BIT(6)
  408. #define OMAP3_HAS_SDRC BIT(7)
  409. #define OMAP3_HAS_IO_CHAIN_CTRL BIT(8)
  410. #define OMAP4_HAS_MPU_1GHZ BIT(9)
  411. #define OMAP4_HAS_MPU_1_2GHZ BIT(10)
  412. #define OMAP4_HAS_MPU_1_5GHZ BIT(11)
  413. #define OMAP3_HAS_FEATURE(feat,flag) \
  414. static inline unsigned int omap3_has_ ##feat(void) \
  415. { \
  416. return omap_features & OMAP3_HAS_ ##flag; \
  417. } \
  418. OMAP3_HAS_FEATURE(l2cache, L2CACHE)
  419. OMAP3_HAS_FEATURE(sgx, SGX)
  420. OMAP3_HAS_FEATURE(iva, IVA)
  421. OMAP3_HAS_FEATURE(neon, NEON)
  422. OMAP3_HAS_FEATURE(isp, ISP)
  423. OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
  424. OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
  425. OMAP3_HAS_FEATURE(sdrc, SDRC)
  426. OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
  427. /*
  428. * Runtime detection of OMAP4 features
  429. */
  430. #define OMAP4_HAS_FEATURE(feat, flag) \
  431. static inline unsigned int omap4_has_ ##feat(void) \
  432. { \
  433. return omap_features & OMAP4_HAS_ ##flag; \
  434. } \
  435. OMAP4_HAS_FEATURE(mpu_1ghz, MPU_1GHZ)
  436. OMAP4_HAS_FEATURE(mpu_1_2ghz, MPU_1_2GHZ)
  437. OMAP4_HAS_FEATURE(mpu_1_5ghz, MPU_1_5GHZ)
  438. #endif