id.c 10 KB

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