soc.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. /*
  2. * OMAP cpu type detection
  3. *
  4. * Copyright (C) 2004, 2008 Nokia Corporation
  5. *
  6. * Copyright (C) 2009-11 Texas Instruments.
  7. *
  8. * Written by Tony Lindgren <tony.lindgren@nokia.com>
  9. *
  10. * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. *
  26. */
  27. #include "omap24xx.h"
  28. #include "omap34xx.h"
  29. #include "omap44xx.h"
  30. #include "ti81xx.h"
  31. #include "am33xx.h"
  32. #include "omap54xx.h"
  33. #ifndef __ASSEMBLY__
  34. #include <linux/bitops.h>
  35. /*
  36. * Test if multicore OMAP support is needed
  37. */
  38. #undef MULTI_OMAP2
  39. #undef OMAP_NAME
  40. #ifdef CONFIG_SOC_OMAP2420
  41. # ifdef OMAP_NAME
  42. # undef MULTI_OMAP2
  43. # define MULTI_OMAP2
  44. # else
  45. # define OMAP_NAME omap2420
  46. # endif
  47. #endif
  48. #ifdef CONFIG_SOC_OMAP2430
  49. # ifdef OMAP_NAME
  50. # undef MULTI_OMAP2
  51. # define MULTI_OMAP2
  52. # else
  53. # define OMAP_NAME omap2430
  54. # endif
  55. #endif
  56. #ifdef CONFIG_ARCH_OMAP3
  57. # ifdef OMAP_NAME
  58. # undef MULTI_OMAP2
  59. # define MULTI_OMAP2
  60. # else
  61. # define OMAP_NAME omap3
  62. # endif
  63. #endif
  64. #ifdef CONFIG_ARCH_OMAP4
  65. # ifdef OMAP_NAME
  66. # undef MULTI_OMAP2
  67. # define MULTI_OMAP2
  68. # else
  69. # define OMAP_NAME omap4
  70. # endif
  71. #endif
  72. #ifdef CONFIG_SOC_OMAP5
  73. # ifdef OMAP_NAME
  74. # undef MULTI_OMAP2
  75. # define MULTI_OMAP2
  76. # else
  77. # define OMAP_NAME omap5
  78. # endif
  79. #endif
  80. #ifdef CONFIG_SOC_AM33XX
  81. # ifdef OMAP_NAME
  82. # undef MULTI_OMAP2
  83. # define MULTI_OMAP2
  84. # else
  85. # define OMAP_NAME am33xx
  86. # endif
  87. #endif
  88. /*
  89. * Omap device type i.e. EMU/HS/TST/GP/BAD
  90. */
  91. #define OMAP2_DEVICE_TYPE_TEST 0
  92. #define OMAP2_DEVICE_TYPE_EMU 1
  93. #define OMAP2_DEVICE_TYPE_SEC 2
  94. #define OMAP2_DEVICE_TYPE_GP 3
  95. #define OMAP2_DEVICE_TYPE_BAD 4
  96. int omap_type(void);
  97. /*
  98. * omap_rev bits:
  99. * CPU id bits (0730, 1510, 1710, 2422...) [31:16]
  100. * CPU revision (See _REV_ defined in cpu.h) [15:08]
  101. * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]
  102. */
  103. unsigned int omap_rev(void);
  104. /*
  105. * Get the CPU revision for OMAP devices
  106. */
  107. #define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)
  108. /*
  109. * Macros to group OMAP into cpu classes.
  110. * These can be used in most places.
  111. * cpu_is_omap24xx(): True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
  112. * cpu_is_omap242x(): True for OMAP2420, OMAP2422, OMAP2423
  113. * cpu_is_omap243x(): True for OMAP2430
  114. * cpu_is_omap343x(): True for OMAP3430
  115. * cpu_is_omap443x(): True for OMAP4430
  116. * cpu_is_omap446x(): True for OMAP4460
  117. * cpu_is_omap447x(): True for OMAP4470
  118. * soc_is_omap543x(): True for OMAP5430, OMAP5432
  119. */
  120. #define GET_OMAP_CLASS (omap_rev() & 0xff)
  121. #define IS_OMAP_CLASS(class, id) \
  122. static inline int is_omap ##class (void) \
  123. { \
  124. return (GET_OMAP_CLASS == (id)) ? 1 : 0; \
  125. }
  126. #define GET_AM_CLASS ((omap_rev() >> 24) & 0xff)
  127. #define IS_AM_CLASS(class, id) \
  128. static inline int is_am ##class (void) \
  129. { \
  130. return (GET_AM_CLASS == (id)) ? 1 : 0; \
  131. }
  132. #define GET_TI_CLASS ((omap_rev() >> 24) & 0xff)
  133. #define IS_TI_CLASS(class, id) \
  134. static inline int is_ti ##class (void) \
  135. { \
  136. return (GET_TI_CLASS == (id)) ? 1 : 0; \
  137. }
  138. #define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)
  139. #define IS_OMAP_SUBCLASS(subclass, id) \
  140. static inline int is_omap ##subclass (void) \
  141. { \
  142. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  143. }
  144. #define IS_TI_SUBCLASS(subclass, id) \
  145. static inline int is_ti ##subclass (void) \
  146. { \
  147. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  148. }
  149. #define IS_AM_SUBCLASS(subclass, id) \
  150. static inline int is_am ##subclass (void) \
  151. { \
  152. return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
  153. }
  154. IS_OMAP_CLASS(24xx, 0x24)
  155. IS_OMAP_CLASS(34xx, 0x34)
  156. IS_OMAP_CLASS(44xx, 0x44)
  157. IS_AM_CLASS(35xx, 0x35)
  158. IS_OMAP_CLASS(54xx, 0x54)
  159. IS_AM_CLASS(33xx, 0x33)
  160. IS_TI_CLASS(81xx, 0x81)
  161. IS_OMAP_SUBCLASS(242x, 0x242)
  162. IS_OMAP_SUBCLASS(243x, 0x243)
  163. IS_OMAP_SUBCLASS(343x, 0x343)
  164. IS_OMAP_SUBCLASS(363x, 0x363)
  165. IS_OMAP_SUBCLASS(443x, 0x443)
  166. IS_OMAP_SUBCLASS(446x, 0x446)
  167. IS_OMAP_SUBCLASS(447x, 0x447)
  168. IS_OMAP_SUBCLASS(543x, 0x543)
  169. IS_TI_SUBCLASS(816x, 0x816)
  170. IS_TI_SUBCLASS(814x, 0x814)
  171. IS_AM_SUBCLASS(335x, 0x335)
  172. #define cpu_is_omap24xx() 0
  173. #define cpu_is_omap242x() 0
  174. #define cpu_is_omap243x() 0
  175. #define cpu_is_omap34xx() 0
  176. #define cpu_is_omap343x() 0
  177. #define cpu_is_ti81xx() 0
  178. #define cpu_is_ti816x() 0
  179. #define cpu_is_ti814x() 0
  180. #define soc_is_am35xx() 0
  181. #define soc_is_am33xx() 0
  182. #define soc_is_am335x() 0
  183. #define cpu_is_omap44xx() 0
  184. #define cpu_is_omap443x() 0
  185. #define cpu_is_omap446x() 0
  186. #define cpu_is_omap447x() 0
  187. #define soc_is_omap54xx() 0
  188. #define soc_is_omap543x() 0
  189. #if defined(MULTI_OMAP2)
  190. # if defined(CONFIG_ARCH_OMAP2)
  191. # undef cpu_is_omap24xx
  192. # define cpu_is_omap24xx() is_omap24xx()
  193. # endif
  194. # if defined (CONFIG_SOC_OMAP2420)
  195. # undef cpu_is_omap242x
  196. # define cpu_is_omap242x() is_omap242x()
  197. # endif
  198. # if defined (CONFIG_SOC_OMAP2430)
  199. # undef cpu_is_omap243x
  200. # define cpu_is_omap243x() is_omap243x()
  201. # endif
  202. # if defined(CONFIG_ARCH_OMAP3)
  203. # undef cpu_is_omap34xx
  204. # undef cpu_is_omap343x
  205. # define cpu_is_omap34xx() is_omap34xx()
  206. # define cpu_is_omap343x() is_omap343x()
  207. # endif
  208. #else
  209. # if defined(CONFIG_ARCH_OMAP2)
  210. # undef cpu_is_omap24xx
  211. # define cpu_is_omap24xx() 1
  212. # endif
  213. # if defined(CONFIG_SOC_OMAP2420)
  214. # undef cpu_is_omap242x
  215. # define cpu_is_omap242x() 1
  216. # endif
  217. # if defined(CONFIG_SOC_OMAP2430)
  218. # undef cpu_is_omap243x
  219. # define cpu_is_omap243x() 1
  220. # endif
  221. # if defined(CONFIG_ARCH_OMAP3)
  222. # undef cpu_is_omap34xx
  223. # define cpu_is_omap34xx() 1
  224. # endif
  225. # if defined(CONFIG_SOC_OMAP3430)
  226. # undef cpu_is_omap343x
  227. # define cpu_is_omap343x() 1
  228. # endif
  229. #endif
  230. /*
  231. * Macros to detect individual cpu types.
  232. * These are only rarely needed.
  233. * cpu_is_omap2420(): True for OMAP2420
  234. * cpu_is_omap2422(): True for OMAP2422
  235. * cpu_is_omap2423(): True for OMAP2423
  236. * cpu_is_omap2430(): True for OMAP2430
  237. * cpu_is_omap3430(): True for OMAP3430
  238. */
  239. #define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)
  240. #define IS_OMAP_TYPE(type, id) \
  241. static inline int is_omap ##type (void) \
  242. { \
  243. return (GET_OMAP_TYPE == (id)) ? 1 : 0; \
  244. }
  245. IS_OMAP_TYPE(2420, 0x2420)
  246. IS_OMAP_TYPE(2422, 0x2422)
  247. IS_OMAP_TYPE(2423, 0x2423)
  248. IS_OMAP_TYPE(2430, 0x2430)
  249. IS_OMAP_TYPE(3430, 0x3430)
  250. #define cpu_is_omap2420() 0
  251. #define cpu_is_omap2422() 0
  252. #define cpu_is_omap2423() 0
  253. #define cpu_is_omap2430() 0
  254. #define cpu_is_omap3430() 0
  255. #define cpu_is_omap3630() 0
  256. #define soc_is_omap5430() 0
  257. /* These are needed for the common code */
  258. #ifdef CONFIG_ARCH_OMAP2PLUS
  259. #define cpu_is_omap7xx() 0
  260. #define cpu_is_omap15xx() 0
  261. #define cpu_is_omap16xx() 0
  262. #define cpu_is_omap1510() 0
  263. #define cpu_is_omap1610() 0
  264. #define cpu_is_omap1611() 0
  265. #define cpu_is_omap1621() 0
  266. #define cpu_is_omap1710() 0
  267. #define cpu_class_is_omap1() 0
  268. #define cpu_class_is_omap2() 1
  269. #endif
  270. #if defined(CONFIG_ARCH_OMAP2)
  271. # undef cpu_is_omap2420
  272. # undef cpu_is_omap2422
  273. # undef cpu_is_omap2423
  274. # undef cpu_is_omap2430
  275. # define cpu_is_omap2420() is_omap2420()
  276. # define cpu_is_omap2422() is_omap2422()
  277. # define cpu_is_omap2423() is_omap2423()
  278. # define cpu_is_omap2430() is_omap2430()
  279. #endif
  280. #if defined(CONFIG_ARCH_OMAP3)
  281. # undef cpu_is_omap3430
  282. # undef cpu_is_ti81xx
  283. # undef cpu_is_ti816x
  284. # undef cpu_is_ti814x
  285. # undef soc_is_am35xx
  286. # define cpu_is_omap3430() is_omap3430()
  287. # undef cpu_is_omap3630
  288. # define cpu_is_omap3630() is_omap363x()
  289. # define cpu_is_ti81xx() is_ti81xx()
  290. # define cpu_is_ti816x() is_ti816x()
  291. # define cpu_is_ti814x() is_ti814x()
  292. # define soc_is_am35xx() is_am35xx()
  293. #endif
  294. # if defined(CONFIG_SOC_AM33XX)
  295. # undef soc_is_am33xx
  296. # undef soc_is_am335x
  297. # define soc_is_am33xx() is_am33xx()
  298. # define soc_is_am335x() is_am335x()
  299. #endif
  300. # if defined(CONFIG_ARCH_OMAP4)
  301. # undef cpu_is_omap44xx
  302. # undef cpu_is_omap443x
  303. # undef cpu_is_omap446x
  304. # undef cpu_is_omap447x
  305. # define cpu_is_omap44xx() is_omap44xx()
  306. # define cpu_is_omap443x() is_omap443x()
  307. # define cpu_is_omap446x() is_omap446x()
  308. # define cpu_is_omap447x() is_omap447x()
  309. # endif
  310. # if defined(CONFIG_SOC_OMAP5)
  311. # undef soc_is_omap54xx
  312. # undef soc_is_omap543x
  313. # define soc_is_omap54xx() is_omap54xx()
  314. # define soc_is_omap543x() is_omap543x()
  315. #endif
  316. /* Various silicon revisions for omap2 */
  317. #define OMAP242X_CLASS 0x24200024
  318. #define OMAP2420_REV_ES1_0 OMAP242X_CLASS
  319. #define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (0x1 << 8))
  320. #define OMAP243X_CLASS 0x24300024
  321. #define OMAP2430_REV_ES1_0 OMAP243X_CLASS
  322. #define OMAP343X_CLASS 0x34300034
  323. #define OMAP3430_REV_ES1_0 OMAP343X_CLASS
  324. #define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (0x1 << 8))
  325. #define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (0x2 << 8))
  326. #define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (0x3 << 8))
  327. #define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (0x4 << 8))
  328. #define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (0x5 << 8))
  329. #define OMAP363X_CLASS 0x36300034
  330. #define OMAP3630_REV_ES1_0 OMAP363X_CLASS
  331. #define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (0x1 << 8))
  332. #define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (0x2 << 8))
  333. #define TI816X_CLASS 0x81600034
  334. #define TI8168_REV_ES1_0 TI816X_CLASS
  335. #define TI8168_REV_ES1_1 (TI816X_CLASS | (0x1 << 8))
  336. #define TI814X_CLASS 0x81400034
  337. #define TI8148_REV_ES1_0 TI814X_CLASS
  338. #define TI8148_REV_ES2_0 (TI814X_CLASS | (0x1 << 8))
  339. #define TI8148_REV_ES2_1 (TI814X_CLASS | (0x2 << 8))
  340. #define AM35XX_CLASS 0x35170034
  341. #define AM35XX_REV_ES1_0 AM35XX_CLASS
  342. #define AM35XX_REV_ES1_1 (AM35XX_CLASS | (0x1 << 8))
  343. #define AM335X_CLASS 0x33500033
  344. #define AM335X_REV_ES1_0 AM335X_CLASS
  345. #define OMAP443X_CLASS 0x44300044
  346. #define OMAP4430_REV_ES1_0 (OMAP443X_CLASS | (0x10 << 8))
  347. #define OMAP4430_REV_ES2_0 (OMAP443X_CLASS | (0x20 << 8))
  348. #define OMAP4430_REV_ES2_1 (OMAP443X_CLASS | (0x21 << 8))
  349. #define OMAP4430_REV_ES2_2 (OMAP443X_CLASS | (0x22 << 8))
  350. #define OMAP4430_REV_ES2_3 (OMAP443X_CLASS | (0x23 << 8))
  351. #define OMAP446X_CLASS 0x44600044
  352. #define OMAP4460_REV_ES1_0 (OMAP446X_CLASS | (0x10 << 8))
  353. #define OMAP4460_REV_ES1_1 (OMAP446X_CLASS | (0x11 << 8))
  354. #define OMAP447X_CLASS 0x44700044
  355. #define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
  356. #define OMAP54XX_CLASS 0x54000054
  357. #define OMAP5430_REV_ES1_0 (OMAP54XX_CLASS | (0x30 << 16) | (0x10 << 8))
  358. #define OMAP5432_REV_ES1_0 (OMAP54XX_CLASS | (0x32 << 16) | (0x10 << 8))
  359. void omap2xxx_check_revision(void);
  360. void omap3xxx_check_revision(void);
  361. void omap4xxx_check_revision(void);
  362. void omap5xxx_check_revision(void);
  363. void omap3xxx_check_features(void);
  364. void ti81xx_check_features(void);
  365. void omap4xxx_check_features(void);
  366. /*
  367. * Runtime detection of OMAP3 features
  368. *
  369. * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
  370. * family have OS-level control over the I/O chain clock. This is
  371. * to avoid a window during which wakeups could potentially be lost
  372. * during powerdomain transitions. If this bit is set, it
  373. * indicates that the chip does support OS-level control of this
  374. * feature.
  375. */
  376. extern u32 omap_features;
  377. #define OMAP3_HAS_L2CACHE BIT(0)
  378. #define OMAP3_HAS_IVA BIT(1)
  379. #define OMAP3_HAS_SGX BIT(2)
  380. #define OMAP3_HAS_NEON BIT(3)
  381. #define OMAP3_HAS_ISP BIT(4)
  382. #define OMAP3_HAS_192MHZ_CLK BIT(5)
  383. #define OMAP3_HAS_IO_WAKEUP BIT(6)
  384. #define OMAP3_HAS_SDRC BIT(7)
  385. #define OMAP3_HAS_IO_CHAIN_CTRL BIT(8)
  386. #define OMAP4_HAS_PERF_SILICON BIT(9)
  387. #define OMAP3_HAS_FEATURE(feat,flag) \
  388. static inline unsigned int omap3_has_ ##feat(void) \
  389. { \
  390. return omap_features & OMAP3_HAS_ ##flag; \
  391. } \
  392. OMAP3_HAS_FEATURE(l2cache, L2CACHE)
  393. OMAP3_HAS_FEATURE(sgx, SGX)
  394. OMAP3_HAS_FEATURE(iva, IVA)
  395. OMAP3_HAS_FEATURE(neon, NEON)
  396. OMAP3_HAS_FEATURE(isp, ISP)
  397. OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
  398. OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
  399. OMAP3_HAS_FEATURE(sdrc, SDRC)
  400. OMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
  401. /*
  402. * Runtime detection of OMAP4 features
  403. */
  404. #define OMAP4_HAS_FEATURE(feat, flag) \
  405. static inline unsigned int omap4_has_ ##feat(void) \
  406. { \
  407. return omap_features & OMAP4_HAS_ ##flag; \
  408. } \
  409. OMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
  410. #endif /* __ASSEMBLY__ */