id.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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 <plat/common.h>
  22. #include <plat/cpu.h>
  23. #include <mach/id.h>
  24. #include "control.h"
  25. static struct omap_chip_id omap_chip;
  26. static unsigned int omap_revision;
  27. u32 omap_features;
  28. unsigned int omap_rev(void)
  29. {
  30. return omap_revision;
  31. }
  32. EXPORT_SYMBOL(omap_rev);
  33. /**
  34. * omap_chip_is - test whether currently running OMAP matches a chip type
  35. * @oc: omap_chip_t to test against
  36. *
  37. * Test whether the currently-running OMAP chip matches the supplied
  38. * chip type 'oc'. Returns 1 upon a match; 0 upon failure.
  39. */
  40. int omap_chip_is(struct omap_chip_id oci)
  41. {
  42. return (oci.oc & omap_chip.oc) ? 1 : 0;
  43. }
  44. EXPORT_SYMBOL(omap_chip_is);
  45. int omap_type(void)
  46. {
  47. u32 val = 0;
  48. if (cpu_is_omap24xx()) {
  49. val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
  50. } else if (cpu_is_omap34xx()) {
  51. val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
  52. } else if (cpu_is_omap44xx()) {
  53. val = omap_ctrl_readl(OMAP4_CTRL_MODULE_CORE_STATUS);
  54. } else {
  55. pr_err("Cannot detect omap type!\n");
  56. goto out;
  57. }
  58. val &= OMAP2_DEVICETYPE_MASK;
  59. val >>= 8;
  60. out:
  61. return val;
  62. }
  63. EXPORT_SYMBOL(omap_type);
  64. /*----------------------------------------------------------------------------*/
  65. #define OMAP_TAP_IDCODE 0x0204
  66. #define OMAP_TAP_DIE_ID_0 0x0218
  67. #define OMAP_TAP_DIE_ID_1 0x021C
  68. #define OMAP_TAP_DIE_ID_2 0x0220
  69. #define OMAP_TAP_DIE_ID_3 0x0224
  70. #define OMAP_TAP_DIE_ID_44XX_0 0x0200
  71. #define OMAP_TAP_DIE_ID_44XX_1 0x0208
  72. #define OMAP_TAP_DIE_ID_44XX_2 0x020c
  73. #define OMAP_TAP_DIE_ID_44XX_3 0x0210
  74. #define read_tap_reg(reg) __raw_readl(tap_base + (reg))
  75. struct omap_id {
  76. u16 hawkeye; /* Silicon type (Hawkeye id) */
  77. u8 dev; /* Device type from production_id reg */
  78. u32 type; /* Combined type id copied to omap_revision */
  79. };
  80. /* Register values to detect the OMAP version */
  81. static struct omap_id omap_ids[] __initdata = {
  82. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200024 },
  83. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201024 },
  84. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202024 },
  85. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220024 },
  86. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230024 },
  87. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300024 },
  88. };
  89. static void __iomem *tap_base;
  90. static u16 tap_prod_id;
  91. void omap_get_die_id(struct omap_die_id *odi)
  92. {
  93. if (cpu_is_omap44xx()) {
  94. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_0);
  95. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_1);
  96. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_2);
  97. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_3);
  98. return;
  99. }
  100. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_0);
  101. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_1);
  102. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_2);
  103. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
  104. }
  105. static void __init omap24xx_check_revision(void)
  106. {
  107. int i, j;
  108. u32 idcode, prod_id;
  109. u16 hawkeye;
  110. u8 dev_type, rev;
  111. struct omap_die_id odi;
  112. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  113. prod_id = read_tap_reg(tap_prod_id);
  114. hawkeye = (idcode >> 12) & 0xffff;
  115. rev = (idcode >> 28) & 0x0f;
  116. dev_type = (prod_id >> 16) & 0x0f;
  117. omap_get_die_id(&odi);
  118. pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  119. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  120. pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n", odi.id_0);
  121. pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  122. odi.id_1, (odi.id_1 >> 28) & 0xf);
  123. pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n", odi.id_2);
  124. pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n", odi.id_3);
  125. pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  126. prod_id, dev_type);
  127. /* Check hawkeye ids */
  128. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  129. if (hawkeye == omap_ids[i].hawkeye)
  130. break;
  131. }
  132. if (i == ARRAY_SIZE(omap_ids)) {
  133. printk(KERN_ERR "Unknown OMAP CPU id\n");
  134. return;
  135. }
  136. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  137. if (dev_type == omap_ids[j].dev)
  138. break;
  139. }
  140. if (j == ARRAY_SIZE(omap_ids)) {
  141. printk(KERN_ERR "Unknown OMAP device type. "
  142. "Handling it as OMAP%04x\n",
  143. omap_ids[i].type >> 16);
  144. j = i;
  145. }
  146. pr_info("OMAP%04x", omap_rev() >> 16);
  147. if ((omap_rev() >> 8) & 0x0f)
  148. pr_info("ES%x", (omap_rev() >> 12) & 0xf);
  149. pr_info("\n");
  150. }
  151. #define OMAP3_CHECK_FEATURE(status,feat) \
  152. if (((status & OMAP3_ ##feat## _MASK) \
  153. >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
  154. omap_features |= OMAP3_HAS_ ##feat; \
  155. }
  156. static void __init omap3_check_features(void)
  157. {
  158. u32 status;
  159. omap_features = 0;
  160. status = omap_ctrl_readl(OMAP3_CONTROL_OMAP_STATUS);
  161. OMAP3_CHECK_FEATURE(status, L2CACHE);
  162. OMAP3_CHECK_FEATURE(status, IVA);
  163. OMAP3_CHECK_FEATURE(status, SGX);
  164. OMAP3_CHECK_FEATURE(status, NEON);
  165. OMAP3_CHECK_FEATURE(status, ISP);
  166. if (cpu_is_omap3630())
  167. omap_features |= OMAP3_HAS_192MHZ_CLK;
  168. if (!cpu_is_omap3505() && !cpu_is_omap3517())
  169. omap_features |= OMAP3_HAS_IO_WAKEUP;
  170. omap_features |= OMAP3_HAS_SDRC;
  171. /*
  172. * TODO: Get additional info (where applicable)
  173. * e.g. Size of L2 cache.
  174. */
  175. }
  176. static void __init omap4_check_features(void)
  177. {
  178. u32 si_type;
  179. if (cpu_is_omap443x())
  180. omap_features |= OMAP4_HAS_MPU_1GHZ;
  181. if (cpu_is_omap446x()) {
  182. si_type =
  183. read_tap_reg(OMAP4_CTRL_MODULE_CORE_STD_FUSE_PROD_ID_1);
  184. switch ((si_type & (3 << 16)) >> 16) {
  185. case 2:
  186. /* High performance device */
  187. omap_features |= OMAP4_HAS_MPU_1_5GHZ;
  188. break;
  189. case 1:
  190. default:
  191. /* Standard device */
  192. omap_features |= OMAP4_HAS_MPU_1_2GHZ;
  193. break;
  194. }
  195. }
  196. }
  197. static void __init ti816x_check_features(void)
  198. {
  199. omap_features = OMAP3_HAS_NEON;
  200. }
  201. static void __init omap3_check_revision(void)
  202. {
  203. u32 cpuid, idcode;
  204. u16 hawkeye;
  205. u8 rev;
  206. omap_chip.oc = CHIP_IS_OMAP3430;
  207. /*
  208. * We cannot access revision registers on ES1.0.
  209. * If the processor type is Cortex-A8 and the revision is 0x0
  210. * it means its Cortex r0p0 which is 3430 ES1.0.
  211. */
  212. cpuid = read_cpuid(CPUID_ID);
  213. if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
  214. omap_revision = OMAP3430_REV_ES1_0;
  215. omap_chip.oc |= CHIP_IS_OMAP3430ES1;
  216. return;
  217. }
  218. /*
  219. * Detection for 34xx ES2.0 and above can be done with just
  220. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  221. * Note that rev does not map directly to our defined processor
  222. * revision numbers as ES1.0 uses value 0.
  223. */
  224. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  225. hawkeye = (idcode >> 12) & 0xffff;
  226. rev = (idcode >> 28) & 0xff;
  227. switch (hawkeye) {
  228. case 0xb7ae:
  229. /* Handle 34xx/35xx devices */
  230. switch (rev) {
  231. case 0: /* Take care of early samples */
  232. case 1:
  233. omap_revision = OMAP3430_REV_ES2_0;
  234. omap_chip.oc |= CHIP_IS_OMAP3430ES2;
  235. break;
  236. case 2:
  237. omap_revision = OMAP3430_REV_ES2_1;
  238. omap_chip.oc |= CHIP_IS_OMAP3430ES2;
  239. break;
  240. case 3:
  241. omap_revision = OMAP3430_REV_ES3_0;
  242. omap_chip.oc |= CHIP_IS_OMAP3430ES3_0;
  243. break;
  244. case 4:
  245. omap_revision = OMAP3430_REV_ES3_1;
  246. omap_chip.oc |= CHIP_IS_OMAP3430ES3_1;
  247. break;
  248. case 7:
  249. /* FALLTHROUGH */
  250. default:
  251. /* Use the latest known revision as default */
  252. omap_revision = OMAP3430_REV_ES3_1_2;
  253. /* REVISIT: Add CHIP_IS_OMAP3430ES3_1_2? */
  254. omap_chip.oc |= CHIP_IS_OMAP3430ES3_1;
  255. }
  256. break;
  257. case 0xb868:
  258. /* Handle OMAP35xx/AM35xx devices
  259. *
  260. * Set the device to be OMAP3505 here. Actual device
  261. * is identified later based on the features.
  262. *
  263. * REVISIT: AM3505/AM3517 should have their own CHIP_IS
  264. */
  265. omap_revision = OMAP3505_REV(rev);
  266. omap_chip.oc |= CHIP_IS_OMAP3430ES3_1;
  267. break;
  268. case 0xb891:
  269. /* Handle 36xx devices */
  270. omap_chip.oc |= CHIP_IS_OMAP3630ES1;
  271. switch(rev) {
  272. case 0: /* Take care of early samples */
  273. omap_revision = OMAP3630_REV_ES1_0;
  274. break;
  275. case 1:
  276. omap_revision = OMAP3630_REV_ES1_1;
  277. omap_chip.oc |= CHIP_IS_OMAP3630ES1_1;
  278. break;
  279. case 2:
  280. default:
  281. omap_revision = OMAP3630_REV_ES1_2;
  282. omap_chip.oc |= CHIP_IS_OMAP3630ES1_2;
  283. }
  284. break;
  285. case 0xb81e:
  286. omap_chip.oc = CHIP_IS_TI816X;
  287. switch (rev) {
  288. case 0:
  289. omap_revision = TI8168_REV_ES1_0;
  290. break;
  291. case 1:
  292. omap_revision = TI8168_REV_ES1_1;
  293. break;
  294. default:
  295. omap_revision = TI8168_REV_ES1_1;
  296. }
  297. break;
  298. default:
  299. /* Unknown default to latest silicon rev as default*/
  300. omap_revision = OMAP3630_REV_ES1_2;
  301. omap_chip.oc |= CHIP_IS_OMAP3630ES1_2;
  302. }
  303. }
  304. static void __init omap4_check_revision(void)
  305. {
  306. u32 idcode;
  307. u16 hawkeye;
  308. u8 rev;
  309. /*
  310. * The IC rev detection is done with hawkeye and rev.
  311. * Note that rev does not map directly to defined processor
  312. * revision numbers as ES1.0 uses value 0.
  313. */
  314. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  315. hawkeye = (idcode >> 12) & 0xffff;
  316. rev = (idcode >> 28) & 0xf;
  317. /*
  318. * Few initial 4430 ES2.0 samples IDCODE is same as ES1.0
  319. * Use ARM register to detect the correct ES version
  320. */
  321. if (!rev && (hawkeye != 0xb94e)) {
  322. idcode = read_cpuid(CPUID_ID);
  323. rev = (idcode & 0xf) - 1;
  324. }
  325. switch (hawkeye) {
  326. case 0xb852:
  327. switch (rev) {
  328. case 0:
  329. omap_revision = OMAP4430_REV_ES1_0;
  330. omap_chip.oc |= CHIP_IS_OMAP4430ES1;
  331. break;
  332. case 1:
  333. default:
  334. omap_revision = OMAP4430_REV_ES2_0;
  335. omap_chip.oc |= CHIP_IS_OMAP4430ES2;
  336. }
  337. break;
  338. case 0xb95c:
  339. switch (rev) {
  340. case 3:
  341. omap_revision = OMAP4430_REV_ES2_1;
  342. omap_chip.oc |= CHIP_IS_OMAP4430ES2_1;
  343. break;
  344. case 4:
  345. default:
  346. omap_revision = OMAP4430_REV_ES2_2;
  347. omap_chip.oc |= CHIP_IS_OMAP4430ES2_2;
  348. }
  349. break;
  350. case 0xb94e:
  351. switch (rev) {
  352. case 0:
  353. default:
  354. omap_revision = OMAP4460_REV_ES1_0;
  355. omap_chip.oc |= CHIP_IS_OMAP4460ES1_0;
  356. break;
  357. }
  358. break;
  359. default:
  360. /* Unknown default to latest silicon rev as default */
  361. omap_revision = OMAP4430_REV_ES2_2;
  362. omap_chip.oc |= CHIP_IS_OMAP4430ES2_2;
  363. }
  364. pr_info("OMAP%04x ES%d.%d\n", omap_rev() >> 16,
  365. ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf));
  366. }
  367. #define OMAP3_SHOW_FEATURE(feat) \
  368. if (omap3_has_ ##feat()) \
  369. printk(#feat" ");
  370. static void __init omap3_cpuinfo(void)
  371. {
  372. u8 rev = GET_OMAP_REVISION();
  373. char cpu_name[16], cpu_rev[16];
  374. /* OMAP3430 and OMAP3530 are assumed to be same.
  375. *
  376. * OMAP3525, OMAP3515 and OMAP3503 can be detected only based
  377. * on available features. Upon detection, update the CPU id
  378. * and CPU class bits.
  379. */
  380. if (cpu_is_omap3630()) {
  381. strcpy(cpu_name, "OMAP3630");
  382. } else if (cpu_is_omap3505()) {
  383. /*
  384. * AM35xx devices
  385. */
  386. if (omap3_has_sgx()) {
  387. omap_revision = OMAP3517_REV(rev);
  388. strcpy(cpu_name, "AM3517");
  389. } else {
  390. /* Already set in omap3_check_revision() */
  391. strcpy(cpu_name, "AM3505");
  392. }
  393. } else if (cpu_is_ti816x()) {
  394. strcpy(cpu_name, "TI816X");
  395. } else if (omap3_has_iva() && omap3_has_sgx()) {
  396. /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
  397. strcpy(cpu_name, "OMAP3430/3530");
  398. } else if (omap3_has_iva()) {
  399. omap_revision = OMAP3525_REV(rev);
  400. strcpy(cpu_name, "OMAP3525");
  401. } else if (omap3_has_sgx()) {
  402. omap_revision = OMAP3515_REV(rev);
  403. strcpy(cpu_name, "OMAP3515");
  404. } else {
  405. omap_revision = OMAP3503_REV(rev);
  406. strcpy(cpu_name, "OMAP3503");
  407. }
  408. if (cpu_is_omap3630() || cpu_is_ti816x()) {
  409. switch (rev) {
  410. case OMAP_REVBITS_00:
  411. strcpy(cpu_rev, "1.0");
  412. break;
  413. case OMAP_REVBITS_01:
  414. strcpy(cpu_rev, "1.1");
  415. break;
  416. case OMAP_REVBITS_02:
  417. /* FALLTHROUGH */
  418. default:
  419. /* Use the latest known revision as default */
  420. strcpy(cpu_rev, "1.2");
  421. }
  422. } else if (cpu_is_omap3505() || cpu_is_omap3517()) {
  423. switch (rev) {
  424. case OMAP_REVBITS_00:
  425. strcpy(cpu_rev, "1.0");
  426. break;
  427. case OMAP_REVBITS_01:
  428. /* FALLTHROUGH */
  429. default:
  430. /* Use the latest known revision as default */
  431. strcpy(cpu_rev, "1.1");
  432. }
  433. } else {
  434. switch (rev) {
  435. case OMAP_REVBITS_00:
  436. strcpy(cpu_rev, "1.0");
  437. break;
  438. case OMAP_REVBITS_01:
  439. strcpy(cpu_rev, "2.0");
  440. break;
  441. case OMAP_REVBITS_02:
  442. strcpy(cpu_rev, "2.1");
  443. break;
  444. case OMAP_REVBITS_03:
  445. strcpy(cpu_rev, "3.0");
  446. break;
  447. case OMAP_REVBITS_04:
  448. strcpy(cpu_rev, "3.1");
  449. break;
  450. case OMAP_REVBITS_05:
  451. /* FALLTHROUGH */
  452. default:
  453. /* Use the latest known revision as default */
  454. strcpy(cpu_rev, "3.1.2");
  455. }
  456. }
  457. /* Print verbose information */
  458. pr_info("%s ES%s (", cpu_name, cpu_rev);
  459. OMAP3_SHOW_FEATURE(l2cache);
  460. OMAP3_SHOW_FEATURE(iva);
  461. OMAP3_SHOW_FEATURE(sgx);
  462. OMAP3_SHOW_FEATURE(neon);
  463. OMAP3_SHOW_FEATURE(isp);
  464. OMAP3_SHOW_FEATURE(192mhz_clk);
  465. printk(")\n");
  466. }
  467. /*
  468. * Try to detect the exact revision of the omap we're running on
  469. */
  470. void __init omap2_check_revision(void)
  471. {
  472. /*
  473. * At this point we have an idea about the processor revision set
  474. * earlier with omap2_set_globals_tap().
  475. */
  476. if (cpu_is_omap24xx()) {
  477. omap24xx_check_revision();
  478. } else if (cpu_is_omap34xx()) {
  479. omap3_check_revision();
  480. /* TI816X doesn't have feature register */
  481. if (!cpu_is_ti816x())
  482. omap3_check_features();
  483. else
  484. ti816x_check_features();
  485. omap3_cpuinfo();
  486. return;
  487. } else if (cpu_is_omap44xx()) {
  488. omap4_check_revision();
  489. omap4_check_features();
  490. return;
  491. } else {
  492. pr_err("OMAP revision unknown, please fix!\n");
  493. }
  494. /*
  495. * OK, now we know the exact revision. Initialize omap_chip bits
  496. * for powerdowmain and clockdomain code.
  497. */
  498. if (cpu_is_omap243x()) {
  499. /* Currently only supports 2430ES2.1 and 2430-all */
  500. omap_chip.oc |= CHIP_IS_OMAP2430;
  501. return;
  502. } else if (cpu_is_omap242x()) {
  503. /* Currently only supports 2420ES2.1.1 and 2420-all */
  504. omap_chip.oc |= CHIP_IS_OMAP2420;
  505. return;
  506. }
  507. pr_err("Uninitialized omap_chip, please fix!\n");
  508. }
  509. /*
  510. * Set up things for map_io and processor detection later on. Gets called
  511. * pretty much first thing from board init. For multi-omap, this gets
  512. * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
  513. * detect the exact revision later on in omap2_detect_revision() once map_io
  514. * is done.
  515. */
  516. void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
  517. {
  518. omap_revision = omap2_globals->class;
  519. tap_base = omap2_globals->tap;
  520. if (cpu_is_omap34xx())
  521. tap_prod_id = 0x0210;
  522. else
  523. tap_prod_id = 0x0208;
  524. }