id.c 12 KB

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