id.c 13 KB

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