id.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /*
  2. * linux/arch/arm/mach-omap2/id.c
  3. *
  4. * OMAP2 CPU identification code
  5. *
  6. * Copyright (C) 2005 Nokia Corporation
  7. * Written by Tony Lindgren <tony@atomide.com>
  8. *
  9. * Copyright (C) 2009 Texas Instruments
  10. * Added OMAP4 support - 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 version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/io.h>
  20. #include <asm/cputype.h>
  21. #include <plat/common.h>
  22. #include <plat/control.h>
  23. #include <plat/cpu.h>
  24. static struct omap_chip_id omap_chip;
  25. static unsigned int omap_revision;
  26. u32 omap3_features;
  27. unsigned int omap_rev(void)
  28. {
  29. return omap_revision;
  30. }
  31. EXPORT_SYMBOL(omap_rev);
  32. /**
  33. * omap_chip_is - test whether currently running OMAP matches a chip type
  34. * @oc: omap_chip_t to test against
  35. *
  36. * Test whether the currently-running OMAP chip matches the supplied
  37. * chip type 'oc'. Returns 1 upon a match; 0 upon failure.
  38. */
  39. int omap_chip_is(struct omap_chip_id oci)
  40. {
  41. return (oci.oc & omap_chip.oc) ? 1 : 0;
  42. }
  43. EXPORT_SYMBOL(omap_chip_is);
  44. int omap_type(void)
  45. {
  46. u32 val = 0;
  47. if (cpu_is_omap24xx()) {
  48. val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
  49. } else if (cpu_is_omap34xx()) {
  50. val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
  51. } else if (cpu_is_omap44xx()) {
  52. val = omap_ctrl_readl(OMAP44XX_CONTROL_STATUS);
  53. } else {
  54. pr_err("Cannot detect omap type!\n");
  55. goto out;
  56. }
  57. val &= OMAP2_DEVICETYPE_MASK;
  58. val >>= 8;
  59. out:
  60. return val;
  61. }
  62. EXPORT_SYMBOL(omap_type);
  63. /*----------------------------------------------------------------------------*/
  64. #define OMAP_TAP_IDCODE 0x0204
  65. #define OMAP_TAP_DIE_ID_0 0x0218
  66. #define OMAP_TAP_DIE_ID_1 0x021C
  67. #define OMAP_TAP_DIE_ID_2 0x0220
  68. #define OMAP_TAP_DIE_ID_3 0x0224
  69. #define read_tap_reg(reg) __raw_readl(tap_base + (reg))
  70. struct omap_id {
  71. u16 hawkeye; /* Silicon type (Hawkeye id) */
  72. u8 dev; /* Device type from production_id reg */
  73. u32 type; /* Combined type id copied to omap_revision */
  74. };
  75. /* Register values to detect the OMAP version */
  76. static struct omap_id omap_ids[] __initdata = {
  77. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200024 },
  78. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201024 },
  79. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202024 },
  80. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220024 },
  81. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230024 },
  82. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300024 },
  83. };
  84. static void __iomem *tap_base;
  85. static u16 tap_prod_id;
  86. static void __init omap24xx_check_revision(void)
  87. {
  88. int i, j;
  89. u32 idcode, prod_id;
  90. u16 hawkeye;
  91. u8 dev_type, rev;
  92. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  93. prod_id = read_tap_reg(tap_prod_id);
  94. hawkeye = (idcode >> 12) & 0xffff;
  95. rev = (idcode >> 28) & 0x0f;
  96. dev_type = (prod_id >> 16) & 0x0f;
  97. pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  98. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  99. pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n",
  100. read_tap_reg(OMAP_TAP_DIE_ID_0));
  101. pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  102. read_tap_reg(OMAP_TAP_DIE_ID_1),
  103. (read_tap_reg(OMAP_TAP_DIE_ID_1) >> 28) & 0xf);
  104. pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n",
  105. read_tap_reg(OMAP_TAP_DIE_ID_2));
  106. pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n",
  107. read_tap_reg(OMAP_TAP_DIE_ID_3));
  108. pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  109. prod_id, dev_type);
  110. /* Check hawkeye ids */
  111. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  112. if (hawkeye == omap_ids[i].hawkeye)
  113. break;
  114. }
  115. if (i == ARRAY_SIZE(omap_ids)) {
  116. printk(KERN_ERR "Unknown OMAP CPU id\n");
  117. return;
  118. }
  119. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  120. if (dev_type == omap_ids[j].dev)
  121. break;
  122. }
  123. if (j == ARRAY_SIZE(omap_ids)) {
  124. printk(KERN_ERR "Unknown OMAP device type. "
  125. "Handling it as OMAP%04x\n",
  126. omap_ids[i].type >> 16);
  127. j = i;
  128. }
  129. pr_info("OMAP%04x", omap_rev() >> 16);
  130. if ((omap_rev() >> 8) & 0x0f)
  131. pr_info("ES%x", (omap_rev() >> 12) & 0xf);
  132. pr_info("\n");
  133. }
  134. #define OMAP3_CHECK_FEATURE(status,feat) \
  135. if (((status & OMAP3_ ##feat## _MASK) \
  136. >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
  137. omap3_features |= OMAP3_HAS_ ##feat; \
  138. }
  139. static void __init omap3_check_features(void)
  140. {
  141. u32 status;
  142. omap3_features = 0;
  143. status = omap_ctrl_readl(OMAP3_CONTROL_OMAP_STATUS);
  144. OMAP3_CHECK_FEATURE(status, L2CACHE);
  145. OMAP3_CHECK_FEATURE(status, IVA);
  146. OMAP3_CHECK_FEATURE(status, SGX);
  147. OMAP3_CHECK_FEATURE(status, NEON);
  148. OMAP3_CHECK_FEATURE(status, ISP);
  149. if (cpu_is_omap3630())
  150. omap3_features |= OMAP3_HAS_192MHZ_CLK;
  151. if (!cpu_is_omap3505() && !cpu_is_omap3517())
  152. omap3_features |= OMAP3_HAS_IO_WAKEUP;
  153. /*
  154. * TODO: Get additional info (where applicable)
  155. * e.g. Size of L2 cache.
  156. */
  157. }
  158. static void __init omap3_check_revision(void)
  159. {
  160. u32 cpuid, idcode;
  161. u16 hawkeye;
  162. u8 rev;
  163. omap_chip.oc = CHIP_IS_OMAP3430;
  164. /*
  165. * We cannot access revision registers on ES1.0.
  166. * If the processor type is Cortex-A8 and the revision is 0x0
  167. * it means its Cortex r0p0 which is 3430 ES1.0.
  168. */
  169. cpuid = read_cpuid(CPUID_ID);
  170. if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
  171. omap_revision = OMAP3430_REV_ES1_0;
  172. omap_chip.oc |= CHIP_IS_OMAP3430ES1;
  173. return;
  174. }
  175. /*
  176. * Detection for 34xx ES2.0 and above can be done with just
  177. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  178. * Note that rev does not map directly to our defined processor
  179. * revision numbers as ES1.0 uses value 0.
  180. */
  181. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  182. hawkeye = (idcode >> 12) & 0xffff;
  183. rev = (idcode >> 28) & 0xff;
  184. switch (hawkeye) {
  185. case 0xb7ae:
  186. /* Handle 34xx/35xx devices */
  187. switch (rev) {
  188. case 0: /* Take care of early samples */
  189. case 1:
  190. omap_revision = OMAP3430_REV_ES2_0;
  191. omap_chip.oc |= CHIP_IS_OMAP3430ES2;
  192. break;
  193. case 2:
  194. omap_revision = OMAP3430_REV_ES2_1;
  195. omap_chip.oc |= CHIP_IS_OMAP3430ES2;
  196. break;
  197. case 3:
  198. omap_revision = OMAP3430_REV_ES3_0;
  199. omap_chip.oc |= CHIP_IS_OMAP3430ES3_0;
  200. break;
  201. case 4:
  202. omap_revision = OMAP3430_REV_ES3_1;
  203. omap_chip.oc |= CHIP_IS_OMAP3430ES3_1;
  204. break;
  205. case 7:
  206. /* FALLTHROUGH */
  207. default:
  208. /* Use the latest known revision as default */
  209. omap_revision = OMAP3430_REV_ES3_1_2;
  210. /* REVISIT: Add CHIP_IS_OMAP3430ES3_1_2? */
  211. omap_chip.oc |= CHIP_IS_OMAP3430ES3_1;
  212. }
  213. break;
  214. case 0xb868:
  215. /* Handle OMAP35xx/AM35xx devices
  216. *
  217. * Set the device to be OMAP3505 here. Actual device
  218. * is identified later based on the features.
  219. *
  220. * REVISIT: AM3505/AM3517 should have their own CHIP_IS
  221. */
  222. omap_revision = OMAP3505_REV(rev);
  223. omap_chip.oc |= CHIP_IS_OMAP3430ES3_1;
  224. break;
  225. case 0xb891:
  226. /* FALLTHROUGH */
  227. default:
  228. /* Unknown default to latest silicon rev as default*/
  229. omap_revision = OMAP3630_REV_ES1_0;
  230. omap_chip.oc |= CHIP_IS_OMAP3630ES1;
  231. }
  232. }
  233. static void __init omap4_check_revision(void)
  234. {
  235. u32 idcode;
  236. u16 hawkeye;
  237. u8 rev;
  238. char *rev_name = "ES1.0";
  239. /*
  240. * The IC rev detection is done with hawkeye and rev.
  241. * Note that rev does not map directly to defined processor
  242. * revision numbers as ES1.0 uses value 0.
  243. */
  244. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  245. hawkeye = (idcode >> 12) & 0xffff;
  246. rev = (idcode >> 28) & 0xff;
  247. if ((hawkeye == 0xb852) && (rev == 0x0)) {
  248. omap_revision = OMAP4430_REV_ES1_0;
  249. omap_chip.oc |= CHIP_IS_OMAP4430ES1;
  250. pr_info("OMAP%04x %s\n", omap_rev() >> 16, rev_name);
  251. return;
  252. }
  253. pr_err("Unknown OMAP4 CPU id\n");
  254. }
  255. #define OMAP3_SHOW_FEATURE(feat) \
  256. if (omap3_has_ ##feat()) \
  257. printk(#feat" ");
  258. static void __init omap3_cpuinfo(void)
  259. {
  260. u8 rev = GET_OMAP_REVISION();
  261. char cpu_name[16], cpu_rev[16];
  262. /* OMAP3430 and OMAP3530 are assumed to be same.
  263. *
  264. * OMAP3525, OMAP3515 and OMAP3503 can be detected only based
  265. * on available features. Upon detection, update the CPU id
  266. * and CPU class bits.
  267. */
  268. if (cpu_is_omap3630()) {
  269. strcpy(cpu_name, "OMAP3630");
  270. } else if (cpu_is_omap3505()) {
  271. /*
  272. * AM35xx devices
  273. */
  274. if (omap3_has_sgx()) {
  275. omap_revision = OMAP3517_REV(rev);
  276. strcpy(cpu_name, "AM3517");
  277. } else {
  278. /* Already set in omap3_check_revision() */
  279. strcpy(cpu_name, "AM3505");
  280. }
  281. } else if (omap3_has_iva() && omap3_has_sgx()) {
  282. /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
  283. strcpy(cpu_name, "OMAP3430/3530");
  284. } else if (omap3_has_iva()) {
  285. omap_revision = OMAP3525_REV(rev);
  286. strcpy(cpu_name, "OMAP3525");
  287. } else if (omap3_has_sgx()) {
  288. omap_revision = OMAP3515_REV(rev);
  289. strcpy(cpu_name, "OMAP3515");
  290. } else {
  291. omap_revision = OMAP3503_REV(rev);
  292. strcpy(cpu_name, "OMAP3503");
  293. }
  294. switch (rev) {
  295. case OMAP_REVBITS_00:
  296. strcpy(cpu_rev, "1.0");
  297. break;
  298. case OMAP_REVBITS_10:
  299. strcpy(cpu_rev, "2.0");
  300. break;
  301. case OMAP_REVBITS_20:
  302. strcpy(cpu_rev, "2.1");
  303. break;
  304. case OMAP_REVBITS_30:
  305. strcpy(cpu_rev, "3.0");
  306. break;
  307. case OMAP_REVBITS_40:
  308. /* FALLTHROUGH */
  309. default:
  310. /* Use the latest known revision as default */
  311. strcpy(cpu_rev, "3.1");
  312. }
  313. /* Print verbose information */
  314. pr_info("%s ES%s (", cpu_name, cpu_rev);
  315. OMAP3_SHOW_FEATURE(l2cache);
  316. OMAP3_SHOW_FEATURE(iva);
  317. OMAP3_SHOW_FEATURE(sgx);
  318. OMAP3_SHOW_FEATURE(neon);
  319. OMAP3_SHOW_FEATURE(isp);
  320. OMAP3_SHOW_FEATURE(192mhz_clk);
  321. printk(")\n");
  322. }
  323. /*
  324. * Try to detect the exact revision of the omap we're running on
  325. */
  326. void __init omap2_check_revision(void)
  327. {
  328. /*
  329. * At this point we have an idea about the processor revision set
  330. * earlier with omap2_set_globals_tap().
  331. */
  332. if (cpu_is_omap24xx()) {
  333. omap24xx_check_revision();
  334. } else if (cpu_is_omap34xx()) {
  335. omap3_check_revision();
  336. omap3_check_features();
  337. omap3_cpuinfo();
  338. return;
  339. } else if (cpu_is_omap44xx()) {
  340. omap4_check_revision();
  341. return;
  342. } else {
  343. pr_err("OMAP revision unknown, please fix!\n");
  344. }
  345. /*
  346. * OK, now we know the exact revision. Initialize omap_chip bits
  347. * for powerdowmain and clockdomain code.
  348. */
  349. if (cpu_is_omap243x()) {
  350. /* Currently only supports 2430ES2.1 and 2430-all */
  351. omap_chip.oc |= CHIP_IS_OMAP2430;
  352. return;
  353. } else if (cpu_is_omap242x()) {
  354. /* Currently only supports 2420ES2.1.1 and 2420-all */
  355. omap_chip.oc |= CHIP_IS_OMAP2420;
  356. return;
  357. }
  358. pr_err("Uninitialized omap_chip, please fix!\n");
  359. }
  360. /*
  361. * Set up things for map_io and processor detection later on. Gets called
  362. * pretty much first thing from board init. For multi-omap, this gets
  363. * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
  364. * detect the exact revision later on in omap2_detect_revision() once map_io
  365. * is done.
  366. */
  367. void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
  368. {
  369. omap_revision = omap2_globals->class;
  370. tap_base = omap2_globals->tap;
  371. if (cpu_is_omap34xx())
  372. tap_prod_id = 0x0210;
  373. else
  374. tap_prod_id = 0x0208;
  375. }