id.c 12 KB

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