id.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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 (cpu_is_omap3517()) {
  157. /* AM35xx devices */
  158. cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
  159. } else if (cpu_is_ti816x()) {
  160. cpu_name = "TI816X";
  161. } else if (cpu_is_am335x()) {
  162. cpu_name = "AM335X";
  163. } else if (cpu_is_ti814x()) {
  164. cpu_name = "TI814X";
  165. } else if (omap3_has_iva() && omap3_has_sgx()) {
  166. /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
  167. cpu_name = "OMAP3430/3530";
  168. } else if (omap3_has_iva()) {
  169. cpu_name = "OMAP3525";
  170. } else if (omap3_has_sgx()) {
  171. cpu_name = "OMAP3515";
  172. } else {
  173. cpu_name = "OMAP3503";
  174. }
  175. /* Print verbose information */
  176. pr_info("%s ES%s (", cpu_name, cpu_rev);
  177. OMAP3_SHOW_FEATURE(l2cache);
  178. OMAP3_SHOW_FEATURE(iva);
  179. OMAP3_SHOW_FEATURE(sgx);
  180. OMAP3_SHOW_FEATURE(neon);
  181. OMAP3_SHOW_FEATURE(isp);
  182. OMAP3_SHOW_FEATURE(192mhz_clk);
  183. printk(")\n");
  184. }
  185. #define OMAP3_CHECK_FEATURE(status,feat) \
  186. if (((status & OMAP3_ ##feat## _MASK) \
  187. >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
  188. omap_features |= OMAP3_HAS_ ##feat; \
  189. }
  190. void __init omap3xxx_check_features(void)
  191. {
  192. u32 status;
  193. omap_features = 0;
  194. status = omap_ctrl_readl(OMAP3_CONTROL_OMAP_STATUS);
  195. OMAP3_CHECK_FEATURE(status, L2CACHE);
  196. OMAP3_CHECK_FEATURE(status, IVA);
  197. OMAP3_CHECK_FEATURE(status, SGX);
  198. OMAP3_CHECK_FEATURE(status, NEON);
  199. OMAP3_CHECK_FEATURE(status, ISP);
  200. if (cpu_is_omap3630())
  201. omap_features |= OMAP3_HAS_192MHZ_CLK;
  202. if (cpu_is_omap3430() || cpu_is_omap3630())
  203. omap_features |= OMAP3_HAS_IO_WAKEUP;
  204. if (cpu_is_omap3630() || omap_rev() == OMAP3430_REV_ES3_1 ||
  205. omap_rev() == OMAP3430_REV_ES3_1_2)
  206. omap_features |= OMAP3_HAS_IO_CHAIN_CTRL;
  207. omap_features |= OMAP3_HAS_SDRC;
  208. /*
  209. * TODO: Get additional info (where applicable)
  210. * e.g. Size of L2 cache.
  211. */
  212. omap3_cpuinfo();
  213. }
  214. void __init omap4xxx_check_features(void)
  215. {
  216. u32 si_type;
  217. if (cpu_is_omap443x())
  218. omap_features |= OMAP4_HAS_MPU_1GHZ;
  219. if (cpu_is_omap446x()) {
  220. si_type =
  221. read_tap_reg(OMAP4_CTRL_MODULE_CORE_STD_FUSE_PROD_ID_1);
  222. switch ((si_type & (3 << 16)) >> 16) {
  223. case 2:
  224. /* High performance device */
  225. omap_features |= OMAP4_HAS_MPU_1_5GHZ;
  226. break;
  227. case 1:
  228. default:
  229. /* Standard device */
  230. omap_features |= OMAP4_HAS_MPU_1_2GHZ;
  231. break;
  232. }
  233. }
  234. }
  235. void __init ti81xx_check_features(void)
  236. {
  237. omap_features = OMAP3_HAS_NEON;
  238. omap3_cpuinfo();
  239. }
  240. void __init omap3xxx_check_revision(void)
  241. {
  242. u32 cpuid, idcode;
  243. u16 hawkeye;
  244. u8 rev;
  245. /*
  246. * We cannot access revision registers on ES1.0.
  247. * If the processor type is Cortex-A8 and the revision is 0x0
  248. * it means its Cortex r0p0 which is 3430 ES1.0.
  249. */
  250. cpuid = read_cpuid(CPUID_ID);
  251. if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
  252. omap_revision = OMAP3430_REV_ES1_0;
  253. cpu_rev = "1.0";
  254. return;
  255. }
  256. /*
  257. * Detection for 34xx ES2.0 and above can be done with just
  258. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  259. * Note that rev does not map directly to our defined processor
  260. * revision numbers as ES1.0 uses value 0.
  261. */
  262. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  263. hawkeye = (idcode >> 12) & 0xffff;
  264. rev = (idcode >> 28) & 0xff;
  265. switch (hawkeye) {
  266. case 0xb7ae:
  267. /* Handle 34xx/35xx devices */
  268. switch (rev) {
  269. case 0: /* Take care of early samples */
  270. case 1:
  271. omap_revision = OMAP3430_REV_ES2_0;
  272. cpu_rev = "2.0";
  273. break;
  274. case 2:
  275. omap_revision = OMAP3430_REV_ES2_1;
  276. cpu_rev = "2.1";
  277. break;
  278. case 3:
  279. omap_revision = OMAP3430_REV_ES3_0;
  280. cpu_rev = "3.0";
  281. break;
  282. case 4:
  283. omap_revision = OMAP3430_REV_ES3_1;
  284. cpu_rev = "3.1";
  285. break;
  286. case 7:
  287. /* FALLTHROUGH */
  288. default:
  289. /* Use the latest known revision as default */
  290. omap_revision = OMAP3430_REV_ES3_1_2;
  291. cpu_rev = "3.1.2";
  292. }
  293. break;
  294. case 0xb868:
  295. /*
  296. * Handle OMAP/AM 3505/3517 devices
  297. *
  298. * Set the device to be OMAP3517 here. Actual device
  299. * is identified later based on the features.
  300. */
  301. switch (rev) {
  302. case 0:
  303. omap_revision = OMAP3517_REV_ES1_0;
  304. cpu_rev = "1.0";
  305. break;
  306. case 1:
  307. /* FALLTHROUGH */
  308. default:
  309. omap_revision = OMAP3517_REV_ES1_1;
  310. cpu_rev = "1.1";
  311. }
  312. break;
  313. case 0xb891:
  314. /* Handle 36xx devices */
  315. switch(rev) {
  316. case 0: /* Take care of early samples */
  317. omap_revision = OMAP3630_REV_ES1_0;
  318. cpu_rev = "1.0";
  319. break;
  320. case 1:
  321. omap_revision = OMAP3630_REV_ES1_1;
  322. cpu_rev = "1.1";
  323. break;
  324. case 2:
  325. /* FALLTHROUGH */
  326. default:
  327. omap_revision = OMAP3630_REV_ES1_2;
  328. cpu_rev = "1.2";
  329. }
  330. break;
  331. case 0xb81e:
  332. switch (rev) {
  333. case 0:
  334. omap_revision = TI8168_REV_ES1_0;
  335. cpu_rev = "1.0";
  336. break;
  337. case 1:
  338. /* FALLTHROUGH */
  339. default:
  340. omap_revision = TI8168_REV_ES1_1;
  341. cpu_rev = "1.1";
  342. break;
  343. }
  344. break;
  345. case 0xb944:
  346. omap_revision = AM335X_REV_ES1_0;
  347. cpu_rev = "1.0";
  348. break;
  349. case 0xb8f2:
  350. switch (rev) {
  351. case 0:
  352. /* FALLTHROUGH */
  353. case 1:
  354. omap_revision = TI8148_REV_ES1_0;
  355. cpu_rev = "1.0";
  356. break;
  357. case 2:
  358. omap_revision = TI8148_REV_ES2_0;
  359. cpu_rev = "2.0";
  360. break;
  361. case 3:
  362. /* FALLTHROUGH */
  363. default:
  364. omap_revision = TI8148_REV_ES2_1;
  365. cpu_rev = "2.1";
  366. break;
  367. }
  368. break;
  369. default:
  370. /* Unknown default to latest silicon rev as default */
  371. omap_revision = OMAP3630_REV_ES1_2;
  372. cpu_rev = "1.2";
  373. pr_warn("Warning: unknown chip type; assuming OMAP3630ES1.2\n");
  374. }
  375. }
  376. void __init omap4xxx_check_revision(void)
  377. {
  378. u32 idcode;
  379. u16 hawkeye;
  380. u8 rev;
  381. /*
  382. * The IC rev detection is done with hawkeye and rev.
  383. * Note that rev does not map directly to defined processor
  384. * revision numbers as ES1.0 uses value 0.
  385. */
  386. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  387. hawkeye = (idcode >> 12) & 0xffff;
  388. rev = (idcode >> 28) & 0xf;
  389. /*
  390. * Few initial 4430 ES2.0 samples IDCODE is same as ES1.0
  391. * Use ARM register to detect the correct ES version
  392. */
  393. if (!rev && (hawkeye != 0xb94e) && (hawkeye != 0xb975)) {
  394. idcode = read_cpuid(CPUID_ID);
  395. rev = (idcode & 0xf) - 1;
  396. }
  397. switch (hawkeye) {
  398. case 0xb852:
  399. switch (rev) {
  400. case 0:
  401. omap_revision = OMAP4430_REV_ES1_0;
  402. break;
  403. case 1:
  404. default:
  405. omap_revision = OMAP4430_REV_ES2_0;
  406. }
  407. break;
  408. case 0xb95c:
  409. switch (rev) {
  410. case 3:
  411. omap_revision = OMAP4430_REV_ES2_1;
  412. break;
  413. case 4:
  414. omap_revision = OMAP4430_REV_ES2_2;
  415. break;
  416. case 6:
  417. default:
  418. omap_revision = OMAP4430_REV_ES2_3;
  419. }
  420. break;
  421. case 0xb94e:
  422. switch (rev) {
  423. case 0:
  424. default:
  425. omap_revision = OMAP4460_REV_ES1_0;
  426. break;
  427. }
  428. break;
  429. case 0xb975:
  430. switch (rev) {
  431. case 0:
  432. default:
  433. omap_revision = OMAP4470_REV_ES1_0;
  434. break;
  435. }
  436. break;
  437. default:
  438. /* Unknown default to latest silicon rev as default */
  439. omap_revision = OMAP4430_REV_ES2_3;
  440. }
  441. pr_info("OMAP%04x ES%d.%d\n", omap_rev() >> 16,
  442. ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf));
  443. }
  444. /*
  445. * Set up things for map_io and processor detection later on. Gets called
  446. * pretty much first thing from board init. For multi-omap, this gets
  447. * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
  448. * detect the exact revision later on in omap2_detect_revision() once map_io
  449. * is done.
  450. */
  451. void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
  452. {
  453. omap_revision = omap2_globals->class;
  454. tap_base = omap2_globals->tap;
  455. if (cpu_is_omap34xx())
  456. tap_prod_id = 0x0210;
  457. else
  458. tap_prod_id = 0x0208;
  459. }