id.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  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 <linux/random.h>
  21. #include <linux/slab.h>
  22. #ifdef CONFIG_SOC_BUS
  23. #include <linux/sys_soc.h>
  24. #endif
  25. #include <asm/cputype.h>
  26. #include "common.h"
  27. #include "id.h"
  28. #include "soc.h"
  29. #include "control.h"
  30. #define OMAP4_SILICON_TYPE_STANDARD 0x01
  31. #define OMAP4_SILICON_TYPE_PERFORMANCE 0x02
  32. #define OMAP_SOC_MAX_NAME_LENGTH 16
  33. static unsigned int omap_revision;
  34. static char soc_name[OMAP_SOC_MAX_NAME_LENGTH];
  35. static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH];
  36. u32 omap_features;
  37. unsigned int omap_rev(void)
  38. {
  39. return omap_revision;
  40. }
  41. EXPORT_SYMBOL(omap_rev);
  42. int omap_type(void)
  43. {
  44. static u32 val = OMAP2_DEVICETYPE_MASK;
  45. if (val < OMAP2_DEVICETYPE_MASK)
  46. return val;
  47. if (soc_is_omap24xx()) {
  48. val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
  49. } else if (soc_is_ti81xx()) {
  50. val = omap_ctrl_readl(TI81XX_CONTROL_STATUS);
  51. } else if (soc_is_am33xx() || soc_is_am43xx()) {
  52. val = omap_ctrl_readl(AM33XX_CONTROL_STATUS);
  53. } else if (soc_is_omap34xx()) {
  54. val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
  55. } else if (soc_is_omap44xx()) {
  56. val = omap_ctrl_readl(OMAP4_CTRL_MODULE_CORE_STATUS);
  57. } else if (soc_is_omap54xx() || soc_is_dra7xx()) {
  58. val = omap_ctrl_readl(OMAP5XXX_CONTROL_STATUS);
  59. val &= OMAP5_DEVICETYPE_MASK;
  60. val >>= 6;
  61. goto out;
  62. } else {
  63. pr_err("Cannot detect omap type!\n");
  64. goto out;
  65. }
  66. val &= OMAP2_DEVICETYPE_MASK;
  67. val >>= 8;
  68. out:
  69. return val;
  70. }
  71. EXPORT_SYMBOL(omap_type);
  72. /*----------------------------------------------------------------------------*/
  73. #define OMAP_TAP_IDCODE 0x0204
  74. #define OMAP_TAP_DIE_ID_0 0x0218
  75. #define OMAP_TAP_DIE_ID_1 0x021C
  76. #define OMAP_TAP_DIE_ID_2 0x0220
  77. #define OMAP_TAP_DIE_ID_3 0x0224
  78. #define OMAP_TAP_DIE_ID_44XX_0 0x0200
  79. #define OMAP_TAP_DIE_ID_44XX_1 0x0208
  80. #define OMAP_TAP_DIE_ID_44XX_2 0x020c
  81. #define OMAP_TAP_DIE_ID_44XX_3 0x0210
  82. #define read_tap_reg(reg) readl_relaxed(tap_base + (reg))
  83. struct omap_id {
  84. u16 hawkeye; /* Silicon type (Hawkeye id) */
  85. u8 dev; /* Device type from production_id reg */
  86. u32 type; /* Combined type id copied to omap_revision */
  87. };
  88. /* Register values to detect the OMAP version */
  89. static struct omap_id omap_ids[] __initdata = {
  90. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200024 },
  91. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201024 },
  92. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202024 },
  93. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220024 },
  94. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230024 },
  95. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300024 },
  96. };
  97. static void __iomem *tap_base;
  98. static u16 tap_prod_id;
  99. void omap_get_die_id(struct omap_die_id *odi)
  100. {
  101. if (soc_is_omap44xx() || soc_is_omap54xx() || soc_is_dra7xx()) {
  102. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_0);
  103. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_1);
  104. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_2);
  105. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_44XX_3);
  106. return;
  107. }
  108. odi->id_0 = read_tap_reg(OMAP_TAP_DIE_ID_0);
  109. odi->id_1 = read_tap_reg(OMAP_TAP_DIE_ID_1);
  110. odi->id_2 = read_tap_reg(OMAP_TAP_DIE_ID_2);
  111. odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
  112. }
  113. static int __init omap_feed_randpool(void)
  114. {
  115. struct omap_die_id odi;
  116. /* Throw the die ID into the entropy pool at boot */
  117. omap_get_die_id(&odi);
  118. add_device_randomness(&odi, sizeof(odi));
  119. return 0;
  120. }
  121. omap_device_initcall(omap_feed_randpool);
  122. void __init omap2xxx_check_revision(void)
  123. {
  124. int i, j;
  125. u32 idcode, prod_id;
  126. u16 hawkeye;
  127. u8 dev_type, rev;
  128. struct omap_die_id odi;
  129. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  130. prod_id = read_tap_reg(tap_prod_id);
  131. hawkeye = (idcode >> 12) & 0xffff;
  132. rev = (idcode >> 28) & 0x0f;
  133. dev_type = (prod_id >> 16) & 0x0f;
  134. omap_get_die_id(&odi);
  135. pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  136. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  137. pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n", odi.id_0);
  138. pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  139. odi.id_1, (odi.id_1 >> 28) & 0xf);
  140. pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n", odi.id_2);
  141. pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n", odi.id_3);
  142. pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  143. prod_id, dev_type);
  144. /* Check hawkeye ids */
  145. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  146. if (hawkeye == omap_ids[i].hawkeye)
  147. break;
  148. }
  149. if (i == ARRAY_SIZE(omap_ids)) {
  150. printk(KERN_ERR "Unknown OMAP CPU id\n");
  151. return;
  152. }
  153. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  154. if (dev_type == omap_ids[j].dev)
  155. break;
  156. }
  157. if (j == ARRAY_SIZE(omap_ids)) {
  158. pr_err("Unknown OMAP device type. Handling it as OMAP%04x\n",
  159. omap_ids[i].type >> 16);
  160. j = i;
  161. }
  162. sprintf(soc_name, "OMAP%04x", omap_rev() >> 16);
  163. sprintf(soc_rev, "ES%x", (omap_rev() >> 12) & 0xf);
  164. pr_info("%s", soc_name);
  165. if ((omap_rev() >> 8) & 0x0f)
  166. pr_info("%s", soc_rev);
  167. pr_info("\n");
  168. }
  169. #define OMAP3_SHOW_FEATURE(feat) \
  170. if (omap3_has_ ##feat()) \
  171. n += scnprintf(buf + n, sizeof(buf) - n, #feat " ");
  172. static void __init omap3_cpuinfo(void)
  173. {
  174. const char *cpu_name;
  175. char buf[64];
  176. int n = 0;
  177. memset(buf, 0, sizeof(buf));
  178. /*
  179. * OMAP3430 and OMAP3530 are assumed to be same.
  180. *
  181. * OMAP3525, OMAP3515 and OMAP3503 can be detected only based
  182. * on available features. Upon detection, update the CPU id
  183. * and CPU class bits.
  184. */
  185. if (soc_is_omap3630()) {
  186. cpu_name = "OMAP3630";
  187. } else if (soc_is_am35xx()) {
  188. cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
  189. } else if (soc_is_ti816x()) {
  190. cpu_name = "TI816X";
  191. } else if (soc_is_am335x()) {
  192. cpu_name = "AM335X";
  193. } else if (soc_is_am437x()) {
  194. cpu_name = "AM437x";
  195. } else if (soc_is_ti814x()) {
  196. cpu_name = "TI814X";
  197. } else if (omap3_has_iva() && omap3_has_sgx()) {
  198. /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
  199. cpu_name = "OMAP3430/3530";
  200. } else if (omap3_has_iva()) {
  201. cpu_name = "OMAP3525";
  202. } else if (omap3_has_sgx()) {
  203. cpu_name = "OMAP3515";
  204. } else {
  205. cpu_name = "OMAP3503";
  206. }
  207. scnprintf(soc_name, sizeof(soc_name), "%s", cpu_name);
  208. /* Print verbose information */
  209. n += scnprintf(buf, sizeof(buf) - n, "%s %s (", soc_name, soc_rev);
  210. OMAP3_SHOW_FEATURE(l2cache);
  211. OMAP3_SHOW_FEATURE(iva);
  212. OMAP3_SHOW_FEATURE(sgx);
  213. OMAP3_SHOW_FEATURE(neon);
  214. OMAP3_SHOW_FEATURE(isp);
  215. OMAP3_SHOW_FEATURE(192mhz_clk);
  216. if (*(buf + n - 1) == ' ')
  217. n--;
  218. n += scnprintf(buf + n, sizeof(buf) - n, ")\n");
  219. pr_info("%s", buf);
  220. }
  221. #define OMAP3_CHECK_FEATURE(status,feat) \
  222. if (((status & OMAP3_ ##feat## _MASK) \
  223. >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
  224. omap_features |= OMAP3_HAS_ ##feat; \
  225. }
  226. void __init omap3xxx_check_features(void)
  227. {
  228. u32 status;
  229. omap_features = 0;
  230. status = omap_ctrl_readl(OMAP3_CONTROL_OMAP_STATUS);
  231. OMAP3_CHECK_FEATURE(status, L2CACHE);
  232. OMAP3_CHECK_FEATURE(status, IVA);
  233. OMAP3_CHECK_FEATURE(status, SGX);
  234. OMAP3_CHECK_FEATURE(status, NEON);
  235. OMAP3_CHECK_FEATURE(status, ISP);
  236. if (soc_is_omap3630())
  237. omap_features |= OMAP3_HAS_192MHZ_CLK;
  238. if (soc_is_omap3430() || soc_is_omap3630())
  239. omap_features |= OMAP3_HAS_IO_WAKEUP;
  240. if (soc_is_omap3630() || omap_rev() == OMAP3430_REV_ES3_1 ||
  241. omap_rev() == OMAP3430_REV_ES3_1_2)
  242. omap_features |= OMAP3_HAS_IO_CHAIN_CTRL;
  243. omap_features |= OMAP3_HAS_SDRC;
  244. /*
  245. * am35x fixups:
  246. * - The am35x Chip ID register has bits 12, 7:5, and 3:2 marked as
  247. * reserved and therefore return 0 when read. Unfortunately,
  248. * OMAP3_CHECK_FEATURE() will interpret some of those zeroes to
  249. * mean that a feature is present even though it isn't so clear
  250. * the incorrectly set feature bits.
  251. */
  252. if (soc_is_am35xx())
  253. omap_features &= ~(OMAP3_HAS_IVA | OMAP3_HAS_ISP);
  254. /*
  255. * TODO: Get additional info (where applicable)
  256. * e.g. Size of L2 cache.
  257. */
  258. omap3_cpuinfo();
  259. }
  260. void __init omap4xxx_check_features(void)
  261. {
  262. u32 si_type;
  263. si_type =
  264. (read_tap_reg(OMAP4_CTRL_MODULE_CORE_STD_FUSE_PROD_ID_1) >> 16) & 0x03;
  265. if (si_type == OMAP4_SILICON_TYPE_PERFORMANCE)
  266. omap_features = OMAP4_HAS_PERF_SILICON;
  267. }
  268. void __init ti81xx_check_features(void)
  269. {
  270. omap_features = OMAP3_HAS_NEON;
  271. omap3_cpuinfo();
  272. }
  273. void __init am33xx_check_features(void)
  274. {
  275. u32 status;
  276. omap_features = OMAP3_HAS_NEON;
  277. status = omap_ctrl_readl(AM33XX_DEV_FEATURE);
  278. if (status & AM33XX_SGX_MASK)
  279. omap_features |= OMAP3_HAS_SGX;
  280. omap3_cpuinfo();
  281. }
  282. void __init omap3xxx_check_revision(void)
  283. {
  284. const char *cpu_rev;
  285. u32 cpuid, idcode;
  286. u16 hawkeye;
  287. u8 rev;
  288. /*
  289. * We cannot access revision registers on ES1.0.
  290. * If the processor type is Cortex-A8 and the revision is 0x0
  291. * it means its Cortex r0p0 which is 3430 ES1.0.
  292. */
  293. cpuid = read_cpuid_id();
  294. if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
  295. omap_revision = OMAP3430_REV_ES1_0;
  296. cpu_rev = "1.0";
  297. return;
  298. }
  299. /*
  300. * Detection for 34xx ES2.0 and above can be done with just
  301. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  302. * Note that rev does not map directly to our defined processor
  303. * revision numbers as ES1.0 uses value 0.
  304. */
  305. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  306. hawkeye = (idcode >> 12) & 0xffff;
  307. rev = (idcode >> 28) & 0xff;
  308. switch (hawkeye) {
  309. case 0xb7ae:
  310. /* Handle 34xx/35xx devices */
  311. switch (rev) {
  312. case 0: /* Take care of early samples */
  313. case 1:
  314. omap_revision = OMAP3430_REV_ES2_0;
  315. cpu_rev = "2.0";
  316. break;
  317. case 2:
  318. omap_revision = OMAP3430_REV_ES2_1;
  319. cpu_rev = "2.1";
  320. break;
  321. case 3:
  322. omap_revision = OMAP3430_REV_ES3_0;
  323. cpu_rev = "3.0";
  324. break;
  325. case 4:
  326. omap_revision = OMAP3430_REV_ES3_1;
  327. cpu_rev = "3.1";
  328. break;
  329. case 7:
  330. /* FALLTHROUGH */
  331. default:
  332. /* Use the latest known revision as default */
  333. omap_revision = OMAP3430_REV_ES3_1_2;
  334. cpu_rev = "3.1.2";
  335. }
  336. break;
  337. case 0xb868:
  338. /*
  339. * Handle OMAP/AM 3505/3517 devices
  340. *
  341. * Set the device to be OMAP3517 here. Actual device
  342. * is identified later based on the features.
  343. */
  344. switch (rev) {
  345. case 0:
  346. omap_revision = AM35XX_REV_ES1_0;
  347. cpu_rev = "1.0";
  348. break;
  349. case 1:
  350. /* FALLTHROUGH */
  351. default:
  352. omap_revision = AM35XX_REV_ES1_1;
  353. cpu_rev = "1.1";
  354. }
  355. break;
  356. case 0xb891:
  357. /* Handle 36xx devices */
  358. switch(rev) {
  359. case 0: /* Take care of early samples */
  360. omap_revision = OMAP3630_REV_ES1_0;
  361. cpu_rev = "1.0";
  362. break;
  363. case 1:
  364. omap_revision = OMAP3630_REV_ES1_1;
  365. cpu_rev = "1.1";
  366. break;
  367. case 2:
  368. /* FALLTHROUGH */
  369. default:
  370. omap_revision = OMAP3630_REV_ES1_2;
  371. cpu_rev = "1.2";
  372. }
  373. break;
  374. case 0xb81e:
  375. switch (rev) {
  376. case 0:
  377. omap_revision = TI8168_REV_ES1_0;
  378. cpu_rev = "1.0";
  379. break;
  380. case 1:
  381. omap_revision = TI8168_REV_ES1_1;
  382. cpu_rev = "1.1";
  383. break;
  384. case 2:
  385. omap_revision = TI8168_REV_ES2_0;
  386. cpu_rev = "2.0";
  387. break;
  388. case 3:
  389. /* FALLTHROUGH */
  390. default:
  391. omap_revision = TI8168_REV_ES2_1;
  392. cpu_rev = "2.1";
  393. }
  394. break;
  395. case 0xb944:
  396. switch (rev) {
  397. case 0:
  398. omap_revision = AM335X_REV_ES1_0;
  399. cpu_rev = "1.0";
  400. break;
  401. case 1:
  402. omap_revision = AM335X_REV_ES2_0;
  403. cpu_rev = "2.0";
  404. break;
  405. case 2:
  406. /* FALLTHROUGH */
  407. default:
  408. omap_revision = AM335X_REV_ES2_1;
  409. cpu_rev = "2.1";
  410. break;
  411. }
  412. break;
  413. case 0xb98c:
  414. switch (rev) {
  415. case 0:
  416. omap_revision = AM437X_REV_ES1_0;
  417. cpu_rev = "1.0";
  418. break;
  419. case 1:
  420. omap_revision = AM437X_REV_ES1_1;
  421. cpu_rev = "1.1";
  422. break;
  423. case 2:
  424. /* FALLTHROUGH */
  425. default:
  426. omap_revision = AM437X_REV_ES1_2;
  427. cpu_rev = "1.2";
  428. break;
  429. }
  430. break;
  431. case 0xb8f2:
  432. case 0xb968:
  433. switch (rev) {
  434. case 0:
  435. /* FALLTHROUGH */
  436. case 1:
  437. omap_revision = TI8148_REV_ES1_0;
  438. cpu_rev = "1.0";
  439. break;
  440. case 2:
  441. omap_revision = TI8148_REV_ES2_0;
  442. cpu_rev = "2.0";
  443. break;
  444. case 3:
  445. /* FALLTHROUGH */
  446. default:
  447. omap_revision = TI8148_REV_ES2_1;
  448. cpu_rev = "2.1";
  449. break;
  450. }
  451. break;
  452. default:
  453. /* Unknown default to latest silicon rev as default */
  454. omap_revision = OMAP3630_REV_ES1_2;
  455. cpu_rev = "1.2";
  456. pr_warn("Warning: unknown chip type: hawkeye %04x, assuming OMAP3630ES1.2\n",
  457. hawkeye);
  458. }
  459. sprintf(soc_rev, "ES%s", cpu_rev);
  460. }
  461. void __init omap4xxx_check_revision(void)
  462. {
  463. u32 idcode;
  464. u16 hawkeye;
  465. u8 rev;
  466. /*
  467. * The IC rev detection is done with hawkeye and rev.
  468. * Note that rev does not map directly to defined processor
  469. * revision numbers as ES1.0 uses value 0.
  470. */
  471. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  472. hawkeye = (idcode >> 12) & 0xffff;
  473. rev = (idcode >> 28) & 0xf;
  474. /*
  475. * Few initial 4430 ES2.0 samples IDCODE is same as ES1.0
  476. * Use ARM register to detect the correct ES version
  477. */
  478. if (!rev && (hawkeye != 0xb94e) && (hawkeye != 0xb975)) {
  479. idcode = read_cpuid_id();
  480. rev = (idcode & 0xf) - 1;
  481. }
  482. switch (hawkeye) {
  483. case 0xb852:
  484. switch (rev) {
  485. case 0:
  486. omap_revision = OMAP4430_REV_ES1_0;
  487. break;
  488. case 1:
  489. default:
  490. omap_revision = OMAP4430_REV_ES2_0;
  491. }
  492. break;
  493. case 0xb95c:
  494. switch (rev) {
  495. case 3:
  496. omap_revision = OMAP4430_REV_ES2_1;
  497. break;
  498. case 4:
  499. omap_revision = OMAP4430_REV_ES2_2;
  500. break;
  501. case 6:
  502. default:
  503. omap_revision = OMAP4430_REV_ES2_3;
  504. }
  505. break;
  506. case 0xb94e:
  507. switch (rev) {
  508. case 0:
  509. omap_revision = OMAP4460_REV_ES1_0;
  510. break;
  511. case 2:
  512. default:
  513. omap_revision = OMAP4460_REV_ES1_1;
  514. break;
  515. }
  516. break;
  517. case 0xb975:
  518. switch (rev) {
  519. case 0:
  520. default:
  521. omap_revision = OMAP4470_REV_ES1_0;
  522. break;
  523. }
  524. break;
  525. default:
  526. /* Unknown default to latest silicon rev as default */
  527. omap_revision = OMAP4430_REV_ES2_3;
  528. }
  529. sprintf(soc_name, "OMAP%04x", omap_rev() >> 16);
  530. sprintf(soc_rev, "ES%d.%d", (omap_rev() >> 12) & 0xf,
  531. (omap_rev() >> 8) & 0xf);
  532. pr_info("%s %s\n", soc_name, soc_rev);
  533. }
  534. void __init omap5xxx_check_revision(void)
  535. {
  536. u32 idcode;
  537. u16 hawkeye;
  538. u8 rev;
  539. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  540. hawkeye = (idcode >> 12) & 0xffff;
  541. rev = (idcode >> 28) & 0xff;
  542. switch (hawkeye) {
  543. case 0xb942:
  544. switch (rev) {
  545. case 0:
  546. /* No support for ES1.0 Test chip */
  547. BUG();
  548. case 1:
  549. default:
  550. omap_revision = OMAP5430_REV_ES2_0;
  551. }
  552. break;
  553. case 0xb998:
  554. switch (rev) {
  555. case 0:
  556. /* No support for ES1.0 Test chip */
  557. BUG();
  558. case 1:
  559. default:
  560. omap_revision = OMAP5432_REV_ES2_0;
  561. }
  562. break;
  563. default:
  564. /* Unknown default to latest silicon rev as default*/
  565. omap_revision = OMAP5430_REV_ES2_0;
  566. }
  567. sprintf(soc_name, "OMAP%04x", omap_rev() >> 16);
  568. sprintf(soc_rev, "ES%d.0", (omap_rev() >> 12) & 0xf);
  569. pr_info("%s %s\n", soc_name, soc_rev);
  570. }
  571. void __init dra7xxx_check_revision(void)
  572. {
  573. u32 idcode;
  574. u16 hawkeye;
  575. u8 rev;
  576. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  577. hawkeye = (idcode >> 12) & 0xffff;
  578. rev = (idcode >> 28) & 0xff;
  579. switch (hawkeye) {
  580. case 0xb990:
  581. switch (rev) {
  582. case 0:
  583. omap_revision = DRA752_REV_ES1_0;
  584. break;
  585. case 1:
  586. omap_revision = DRA752_REV_ES1_1;
  587. break;
  588. case 2:
  589. default:
  590. omap_revision = DRA752_REV_ES2_0;
  591. break;
  592. }
  593. break;
  594. case 0xb9bc:
  595. switch (rev) {
  596. case 0:
  597. omap_revision = DRA722_REV_ES1_0;
  598. break;
  599. case 1:
  600. default:
  601. omap_revision = DRA722_REV_ES2_0;
  602. break;
  603. }
  604. break;
  605. default:
  606. /* Unknown default to latest silicon rev as default*/
  607. pr_warn("%s: unknown idcode=0x%08x (hawkeye=0x%08x,rev=0x%x)\n",
  608. __func__, idcode, hawkeye, rev);
  609. omap_revision = DRA752_REV_ES2_0;
  610. }
  611. sprintf(soc_name, "DRA%03x", omap_rev() >> 16);
  612. sprintf(soc_rev, "ES%d.%d", (omap_rev() >> 12) & 0xf,
  613. (omap_rev() >> 8) & 0xf);
  614. pr_info("%s %s\n", soc_name, soc_rev);
  615. }
  616. /*
  617. * Set up things for map_io and processor detection later on. Gets called
  618. * pretty much first thing from board init. For multi-omap, this gets
  619. * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
  620. * detect the exact revision later on in omap2_detect_revision() once map_io
  621. * is done.
  622. */
  623. void __init omap2_set_globals_tap(u32 class, void __iomem *tap)
  624. {
  625. omap_revision = class;
  626. tap_base = tap;
  627. /* XXX What is this intended to do? */
  628. if (soc_is_omap34xx())
  629. tap_prod_id = 0x0210;
  630. else
  631. tap_prod_id = 0x0208;
  632. }
  633. #ifdef CONFIG_SOC_BUS
  634. static const char * const omap_types[] = {
  635. [OMAP2_DEVICE_TYPE_TEST] = "TST",
  636. [OMAP2_DEVICE_TYPE_EMU] = "EMU",
  637. [OMAP2_DEVICE_TYPE_SEC] = "HS",
  638. [OMAP2_DEVICE_TYPE_GP] = "GP",
  639. [OMAP2_DEVICE_TYPE_BAD] = "BAD",
  640. };
  641. static const char * __init omap_get_family(void)
  642. {
  643. if (soc_is_omap24xx())
  644. return kasprintf(GFP_KERNEL, "OMAP2");
  645. else if (soc_is_omap34xx())
  646. return kasprintf(GFP_KERNEL, "OMAP3");
  647. else if (soc_is_omap44xx())
  648. return kasprintf(GFP_KERNEL, "OMAP4");
  649. else if (soc_is_omap54xx())
  650. return kasprintf(GFP_KERNEL, "OMAP5");
  651. else if (soc_is_am33xx() || soc_is_am335x())
  652. return kasprintf(GFP_KERNEL, "AM33xx");
  653. else if (soc_is_am43xx())
  654. return kasprintf(GFP_KERNEL, "AM43xx");
  655. else if (soc_is_dra7xx())
  656. return kasprintf(GFP_KERNEL, "DRA7");
  657. else
  658. return kasprintf(GFP_KERNEL, "Unknown");
  659. }
  660. static ssize_t omap_get_type(struct device *dev,
  661. struct device_attribute *attr,
  662. char *buf)
  663. {
  664. return sprintf(buf, "%s\n", omap_types[omap_type()]);
  665. }
  666. static struct device_attribute omap_soc_attr =
  667. __ATTR(type, S_IRUGO, omap_get_type, NULL);
  668. void __init omap_soc_device_init(void)
  669. {
  670. struct device *parent;
  671. struct soc_device *soc_dev;
  672. struct soc_device_attribute *soc_dev_attr;
  673. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  674. if (!soc_dev_attr)
  675. return;
  676. soc_dev_attr->machine = soc_name;
  677. soc_dev_attr->family = omap_get_family();
  678. soc_dev_attr->revision = soc_rev;
  679. soc_dev = soc_device_register(soc_dev_attr);
  680. if (IS_ERR(soc_dev)) {
  681. kfree(soc_dev_attr);
  682. return;
  683. }
  684. parent = soc_device_to_device(soc_dev);
  685. device_create_file(parent, &omap_soc_attr);
  686. }
  687. #endif /* CONFIG_SOC_BUS */