id.c 13 KB

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