id.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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-11 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 "common.h"
  22. #include <plat/cpu.h>
  23. #include <mach/id.h>
  24. #include "control.h"
  25. static unsigned int omap_revision;
  26. static const char *cpu_rev;
  27. u32 omap_features;
  28. unsigned int omap_rev(void)
  29. {
  30. return omap_revision;
  31. }
  32. EXPORT_SYMBOL(omap_rev);
  33. int omap_type(void)
  34. {
  35. u32 val = 0;
  36. if (cpu_is_omap24xx()) {
  37. val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
  38. } else if (cpu_is_am33xx()) {
  39. val = omap_ctrl_readl(AM33XX_CONTROL_STATUS);
  40. } else if (cpu_is_omap34xx()) {
  41. val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
  42. } else if (cpu_is_omap44xx()) {
  43. val = omap_ctrl_readl(OMAP4_CTRL_MODULE_CORE_STATUS);
  44. } else {
  45. pr_err("Cannot detect omap type!\n");
  46. goto out;
  47. }
  48. val &= OMAP2_DEVICETYPE_MASK;
  49. val >>= 8;
  50. out:
  51. return val;
  52. }
  53. EXPORT_SYMBOL(omap_type);
  54. /*----------------------------------------------------------------------------*/
  55. #define OMAP_TAP_IDCODE 0x0204
  56. #define OMAP_TAP_DIE_ID_0 0x0218
  57. #define OMAP_TAP_DIE_ID_1 0x021C
  58. #define OMAP_TAP_DIE_ID_2 0x0220
  59. #define OMAP_TAP_DIE_ID_3 0x0224
  60. #define OMAP_TAP_DIE_ID_44XX_0 0x0200
  61. #define OMAP_TAP_DIE_ID_44XX_1 0x0208
  62. #define OMAP_TAP_DIE_ID_44XX_2 0x020c
  63. #define OMAP_TAP_DIE_ID_44XX_3 0x0210
  64. #define read_tap_reg(reg) __raw_readl(tap_base + (reg))
  65. struct omap_id {
  66. u16 hawkeye; /* Silicon type (Hawkeye id) */
  67. u8 dev; /* Device type from production_id reg */
  68. u32 type; /* Combined type id copied to omap_revision */
  69. };
  70. /* Register values to detect the OMAP version */
  71. static struct omap_id omap_ids[] __initdata = {
  72. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200024 },
  73. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201024 },
  74. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202024 },
  75. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220024 },
  76. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230024 },
  77. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300024 },
  78. };
  79. static void __iomem *tap_base;
  80. static u16 tap_prod_id;
  81. void omap_get_die_id(struct omap_die_id *odi)
  82. {
  83. if (cpu_is_omap44xx()) {
  84. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_0);
  85. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_1);
  86. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_2);
  87. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_3);
  88. return;
  89. }
  90. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_0);
  91. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_1);
  92. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_2);
  93. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
  94. }
  95. void __init omap2xxx_check_revision(void)
  96. {
  97. int i, j;
  98. u32 idcode, prod_id;
  99. u16 hawkeye;
  100. u8 dev_type, rev;
  101. struct omap_die_id odi;
  102. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  103. prod_id = read_tap_reg(tap_prod_id);
  104. hawkeye = (idcode >> 12) & 0xffff;
  105. rev = (idcode >> 28) & 0x0f;
  106. dev_type = (prod_id >> 16) & 0x0f;
  107. omap_get_die_id(&odi);
  108. pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  109. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  110. pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n", odi.id_0);
  111. pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  112. odi.id_1, (odi.id_1 >> 28) & 0xf);
  113. pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n", odi.id_2);
  114. pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n", odi.id_3);
  115. pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  116. prod_id, dev_type);
  117. /* Check hawkeye ids */
  118. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  119. if (hawkeye == omap_ids[i].hawkeye)
  120. break;
  121. }
  122. if (i == ARRAY_SIZE(omap_ids)) {
  123. printk(KERN_ERR "Unknown OMAP CPU id\n");
  124. return;
  125. }
  126. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  127. if (dev_type == omap_ids[j].dev)
  128. break;
  129. }
  130. if (j == ARRAY_SIZE(omap_ids)) {
  131. printk(KERN_ERR "Unknown OMAP device type. "
  132. "Handling it as OMAP%04x\n",
  133. omap_ids[i].type >> 16);
  134. j = i;
  135. }
  136. pr_info("OMAP%04x", omap_rev() >> 16);
  137. if ((omap_rev() >> 8) & 0x0f)
  138. pr_info("ES%x", (omap_rev() >> 12) & 0xf);
  139. pr_info("\n");
  140. }
  141. #define OMAP3_SHOW_FEATURE(feat) \
  142. if (omap3_has_ ##feat()) \
  143. printk(#feat" ");
  144. static void __init omap3_cpuinfo(void)
  145. {
  146. const char *cpu_name;
  147. /*
  148. * OMAP3430 and OMAP3530 are assumed to be same.
  149. *
  150. * OMAP3525, OMAP3515 and OMAP3503 can be detected only based
  151. * on available features. Upon detection, update the CPU id
  152. * and CPU class bits.
  153. */
  154. if (cpu_is_omap3630()) {
  155. cpu_name = "OMAP3630";
  156. } else if (soc_is_am35xx()) {
  157. cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
  158. } else if (cpu_is_ti816x()) {
  159. cpu_name = "TI816X";
  160. } else if (cpu_is_am335x()) {
  161. cpu_name = "AM335X";
  162. } else if (cpu_is_ti814x()) {
  163. cpu_name = "TI814X";
  164. } else if (omap3_has_iva() && omap3_has_sgx()) {
  165. /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
  166. cpu_name = "OMAP3430/3530";
  167. } else if (omap3_has_iva()) {
  168. cpu_name = "OMAP3525";
  169. } else if (omap3_has_sgx()) {
  170. cpu_name = "OMAP3515";
  171. } else {
  172. cpu_name = "OMAP3503";
  173. }
  174. /* Print verbose information */
  175. pr_info("%s ES%s (", cpu_name, cpu_rev);
  176. OMAP3_SHOW_FEATURE(l2cache);
  177. OMAP3_SHOW_FEATURE(iva);
  178. OMAP3_SHOW_FEATURE(sgx);
  179. OMAP3_SHOW_FEATURE(neon);
  180. OMAP3_SHOW_FEATURE(isp);
  181. OMAP3_SHOW_FEATURE(192mhz_clk);
  182. printk(")\n");
  183. }
  184. #define OMAP3_CHECK_FEATURE(status,feat) \
  185. if (((status & OMAP3_ ##feat## _MASK) \
  186. >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
  187. omap_features |= OMAP3_HAS_ ##feat; \
  188. }
  189. void __init omap3xxx_check_features(void)
  190. {
  191. u32 status;
  192. omap_features = 0;
  193. status = omap_ctrl_readl(OMAP3_CONTROL_OMAP_STATUS);
  194. OMAP3_CHECK_FEATURE(status, L2CACHE);
  195. OMAP3_CHECK_FEATURE(status, IVA);
  196. OMAP3_CHECK_FEATURE(status, SGX);
  197. OMAP3_CHECK_FEATURE(status, NEON);
  198. OMAP3_CHECK_FEATURE(status, ISP);
  199. if (cpu_is_omap3630())
  200. omap_features |= OMAP3_HAS_192MHZ_CLK;
  201. if (cpu_is_omap3430() || cpu_is_omap3630())
  202. omap_features |= OMAP3_HAS_IO_WAKEUP;
  203. if (cpu_is_omap3630() || omap_rev() == OMAP3430_REV_ES3_1 ||
  204. omap_rev() == OMAP3430_REV_ES3_1_2)
  205. omap_features |= OMAP3_HAS_IO_CHAIN_CTRL;
  206. omap_features |= OMAP3_HAS_SDRC;
  207. /*
  208. * am35x fixups:
  209. * - The am35x Chip ID register has bits 12, 7:5, and 3:2 marked as
  210. * reserved and therefore return 0 when read. Unfortunately,
  211. * OMAP3_CHECK_FEATURE() will interpret some of those zeroes to
  212. * mean that a feature is present even though it isn't so clear
  213. * the incorrectly set feature bits.
  214. */
  215. if (soc_is_am35xx())
  216. omap_features &= ~(OMAP3_HAS_IVA | OMAP3_HAS_ISP);
  217. /*
  218. * TODO: Get additional info (where applicable)
  219. * e.g. Size of L2 cache.
  220. */
  221. omap3_cpuinfo();
  222. }
  223. void __init omap4xxx_check_features(void)
  224. {
  225. u32 si_type;
  226. if (cpu_is_omap443x())
  227. omap_features |= OMAP4_HAS_MPU_1GHZ;
  228. if (cpu_is_omap446x()) {
  229. si_type =
  230. read_tap_reg(OMAP4_CTRL_MODULE_CORE_STD_FUSE_PROD_ID_1);
  231. switch ((si_type & (3 << 16)) >> 16) {
  232. case 2:
  233. /* High performance device */
  234. omap_features |= OMAP4_HAS_MPU_1_5GHZ;
  235. break;
  236. case 1:
  237. default:
  238. /* Standard device */
  239. omap_features |= OMAP4_HAS_MPU_1_2GHZ;
  240. break;
  241. }
  242. }
  243. }
  244. void __init ti81xx_check_features(void)
  245. {
  246. omap_features = OMAP3_HAS_NEON;
  247. omap3_cpuinfo();
  248. }
  249. void __init omap3xxx_check_revision(void)
  250. {
  251. u32 cpuid, idcode;
  252. u16 hawkeye;
  253. u8 rev;
  254. /*
  255. * We cannot access revision registers on ES1.0.
  256. * If the processor type is Cortex-A8 and the revision is 0x0
  257. * it means its Cortex r0p0 which is 3430 ES1.0.
  258. */
  259. cpuid = read_cpuid(CPUID_ID);
  260. if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
  261. omap_revision = OMAP3430_REV_ES1_0;
  262. cpu_rev = "1.0";
  263. return;
  264. }
  265. /*
  266. * Detection for 34xx ES2.0 and above can be done with just
  267. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  268. * Note that rev does not map directly to our defined processor
  269. * revision numbers as ES1.0 uses value 0.
  270. */
  271. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  272. hawkeye = (idcode >> 12) & 0xffff;
  273. rev = (idcode >> 28) & 0xff;
  274. switch (hawkeye) {
  275. case 0xb7ae:
  276. /* Handle 34xx/35xx devices */
  277. switch (rev) {
  278. case 0: /* Take care of early samples */
  279. case 1:
  280. omap_revision = OMAP3430_REV_ES2_0;
  281. cpu_rev = "2.0";
  282. break;
  283. case 2:
  284. omap_revision = OMAP3430_REV_ES2_1;
  285. cpu_rev = "2.1";
  286. break;
  287. case 3:
  288. omap_revision = OMAP3430_REV_ES3_0;
  289. cpu_rev = "3.0";
  290. break;
  291. case 4:
  292. omap_revision = OMAP3430_REV_ES3_1;
  293. cpu_rev = "3.1";
  294. break;
  295. case 7:
  296. /* FALLTHROUGH */
  297. default:
  298. /* Use the latest known revision as default */
  299. omap_revision = OMAP3430_REV_ES3_1_2;
  300. cpu_rev = "3.1.2";
  301. }
  302. break;
  303. case 0xb868:
  304. /*
  305. * Handle OMAP/AM 3505/3517 devices
  306. *
  307. * Set the device to be OMAP3517 here. Actual device
  308. * is identified later based on the features.
  309. */
  310. switch (rev) {
  311. case 0:
  312. omap_revision = AM35XX_REV_ES1_0;
  313. cpu_rev = "1.0";
  314. break;
  315. case 1:
  316. /* FALLTHROUGH */
  317. default:
  318. omap_revision = AM35XX_REV_ES1_1;
  319. cpu_rev = "1.1";
  320. }
  321. break;
  322. case 0xb891:
  323. /* Handle 36xx devices */
  324. switch(rev) {
  325. case 0: /* Take care of early samples */
  326. omap_revision = OMAP3630_REV_ES1_0;
  327. cpu_rev = "1.0";
  328. break;
  329. case 1:
  330. omap_revision = OMAP3630_REV_ES1_1;
  331. cpu_rev = "1.1";
  332. break;
  333. case 2:
  334. /* FALLTHROUGH */
  335. default:
  336. omap_revision = OMAP3630_REV_ES1_2;
  337. cpu_rev = "1.2";
  338. }
  339. break;
  340. case 0xb81e:
  341. switch (rev) {
  342. case 0:
  343. omap_revision = TI8168_REV_ES1_0;
  344. cpu_rev = "1.0";
  345. break;
  346. case 1:
  347. /* FALLTHROUGH */
  348. default:
  349. omap_revision = TI8168_REV_ES1_1;
  350. cpu_rev = "1.1";
  351. break;
  352. }
  353. break;
  354. case 0xb944:
  355. omap_revision = AM335X_REV_ES1_0;
  356. cpu_rev = "1.0";
  357. break;
  358. case 0xb8f2:
  359. switch (rev) {
  360. case 0:
  361. /* FALLTHROUGH */
  362. case 1:
  363. omap_revision = TI8148_REV_ES1_0;
  364. cpu_rev = "1.0";
  365. break;
  366. case 2:
  367. omap_revision = TI8148_REV_ES2_0;
  368. cpu_rev = "2.0";
  369. break;
  370. case 3:
  371. /* FALLTHROUGH */
  372. default:
  373. omap_revision = TI8148_REV_ES2_1;
  374. cpu_rev = "2.1";
  375. break;
  376. }
  377. break;
  378. default:
  379. /* Unknown default to latest silicon rev as default */
  380. omap_revision = OMAP3630_REV_ES1_2;
  381. cpu_rev = "1.2";
  382. pr_warn("Warning: unknown chip type; assuming OMAP3630ES1.2\n");
  383. }
  384. }
  385. void __init omap4xxx_check_revision(void)
  386. {
  387. u32 idcode;
  388. u16 hawkeye;
  389. u8 rev;
  390. /*
  391. * The IC rev detection is done with hawkeye and rev.
  392. * Note that rev does not map directly to defined processor
  393. * revision numbers as ES1.0 uses value 0.
  394. */
  395. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  396. hawkeye = (idcode >> 12) & 0xffff;
  397. rev = (idcode >> 28) & 0xf;
  398. /*
  399. * Few initial 4430 ES2.0 samples IDCODE is same as ES1.0
  400. * Use ARM register to detect the correct ES version
  401. */
  402. if (!rev && (hawkeye != 0xb94e) && (hawkeye != 0xb975)) {
  403. idcode = read_cpuid(CPUID_ID);
  404. rev = (idcode & 0xf) - 1;
  405. }
  406. switch (hawkeye) {
  407. case 0xb852:
  408. switch (rev) {
  409. case 0:
  410. omap_revision = OMAP4430_REV_ES1_0;
  411. break;
  412. case 1:
  413. default:
  414. omap_revision = OMAP4430_REV_ES2_0;
  415. }
  416. break;
  417. case 0xb95c:
  418. switch (rev) {
  419. case 3:
  420. omap_revision = OMAP4430_REV_ES2_1;
  421. break;
  422. case 4:
  423. omap_revision = OMAP4430_REV_ES2_2;
  424. break;
  425. case 6:
  426. default:
  427. omap_revision = OMAP4430_REV_ES2_3;
  428. }
  429. break;
  430. case 0xb94e:
  431. switch (rev) {
  432. case 0:
  433. omap_revision = OMAP4460_REV_ES1_0;
  434. break;
  435. case 2:
  436. default:
  437. omap_revision = OMAP4460_REV_ES1_1;
  438. break;
  439. }
  440. break;
  441. case 0xb975:
  442. switch (rev) {
  443. case 0:
  444. default:
  445. omap_revision = OMAP4470_REV_ES1_0;
  446. break;
  447. }
  448. break;
  449. default:
  450. /* Unknown default to latest silicon rev as default */
  451. omap_revision = OMAP4430_REV_ES2_3;
  452. }
  453. pr_info("OMAP%04x ES%d.%d\n", omap_rev() >> 16,
  454. ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf));
  455. }
  456. /*
  457. * Set up things for map_io and processor detection later on. Gets called
  458. * pretty much first thing from board init. For multi-omap, this gets
  459. * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
  460. * detect the exact revision later on in omap2_detect_revision() once map_io
  461. * is done.
  462. */
  463. void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
  464. {
  465. omap_revision = omap2_globals->class;
  466. tap_base = omap2_globals->tap;
  467. if (cpu_is_omap34xx())
  468. tap_prod_id = 0x0210;
  469. else
  470. tap_prod_id = 0x0208;
  471. }