id.c 13 KB

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