id.c 12 KB

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