id.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  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_cont("%s", soc_rev);
  167. pr_cont("\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. if (omap3_has_iva() && omap3_has_sgx()) {
  187. cpu_name = (omap3_has_isp()) ? "OMAP3630/DM3730" : "OMAP3621";
  188. } else if (omap3_has_iva()) {
  189. cpu_name = "DM3725";
  190. } else if (omap3_has_sgx()) {
  191. cpu_name = "OMAP3615/AM3715";
  192. } else {
  193. cpu_name = (omap3_has_isp()) ? "AM3703" : "OMAP3611";
  194. }
  195. } else if (soc_is_am35xx()) {
  196. cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
  197. } else if (soc_is_ti816x()) {
  198. cpu_name = "TI816X";
  199. } else if (soc_is_am335x()) {
  200. cpu_name = "AM335X";
  201. } else if (soc_is_am437x()) {
  202. cpu_name = "AM437x";
  203. } else if (soc_is_ti814x()) {
  204. cpu_name = "TI814X";
  205. } else if (omap3_has_iva() && omap3_has_sgx()) {
  206. /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
  207. cpu_name = "OMAP3430/3530";
  208. } else if (omap3_has_iva()) {
  209. cpu_name = "OMAP3525";
  210. } else if (omap3_has_sgx()) {
  211. cpu_name = "OMAP3515";
  212. } else {
  213. cpu_name = "OMAP3503";
  214. }
  215. scnprintf(soc_name, sizeof(soc_name), "%s", cpu_name);
  216. /* Print verbose information */
  217. n += scnprintf(buf, sizeof(buf) - n, "%s %s (", soc_name, soc_rev);
  218. OMAP3_SHOW_FEATURE(l2cache);
  219. OMAP3_SHOW_FEATURE(iva);
  220. OMAP3_SHOW_FEATURE(sgx);
  221. OMAP3_SHOW_FEATURE(neon);
  222. OMAP3_SHOW_FEATURE(isp);
  223. OMAP3_SHOW_FEATURE(192mhz_clk);
  224. if (*(buf + n - 1) == ' ')
  225. n--;
  226. n += scnprintf(buf + n, sizeof(buf) - n, ")\n");
  227. pr_info("%s", buf);
  228. }
  229. #define OMAP3_CHECK_FEATURE(status,feat) \
  230. if (((status & OMAP3_ ##feat## _MASK) \
  231. >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
  232. omap_features |= OMAP3_HAS_ ##feat; \
  233. }
  234. void __init omap3xxx_check_features(void)
  235. {
  236. u32 status;
  237. omap_features = 0;
  238. status = omap_ctrl_readl(OMAP3_CONTROL_OMAP_STATUS);
  239. OMAP3_CHECK_FEATURE(status, L2CACHE);
  240. OMAP3_CHECK_FEATURE(status, IVA);
  241. OMAP3_CHECK_FEATURE(status, SGX);
  242. OMAP3_CHECK_FEATURE(status, NEON);
  243. OMAP3_CHECK_FEATURE(status, ISP);
  244. if (soc_is_omap3630())
  245. omap_features |= OMAP3_HAS_192MHZ_CLK;
  246. if (soc_is_omap3430() || soc_is_omap3630())
  247. omap_features |= OMAP3_HAS_IO_WAKEUP;
  248. if (soc_is_omap3630() || omap_rev() == OMAP3430_REV_ES3_1 ||
  249. omap_rev() == OMAP3430_REV_ES3_1_2)
  250. omap_features |= OMAP3_HAS_IO_CHAIN_CTRL;
  251. omap_features |= OMAP3_HAS_SDRC;
  252. /*
  253. * am35x fixups:
  254. * - The am35x Chip ID register has bits 12, 7:5, and 3:2 marked as
  255. * reserved and therefore return 0 when read. Unfortunately,
  256. * OMAP3_CHECK_FEATURE() will interpret some of those zeroes to
  257. * mean that a feature is present even though it isn't so clear
  258. * the incorrectly set feature bits.
  259. */
  260. if (soc_is_am35xx())
  261. omap_features &= ~(OMAP3_HAS_IVA | OMAP3_HAS_ISP);
  262. /*
  263. * TODO: Get additional info (where applicable)
  264. * e.g. Size of L2 cache.
  265. */
  266. omap3_cpuinfo();
  267. }
  268. void __init omap4xxx_check_features(void)
  269. {
  270. u32 si_type;
  271. si_type =
  272. (read_tap_reg(OMAP4_CTRL_MODULE_CORE_STD_FUSE_PROD_ID_1) >> 16) & 0x03;
  273. if (si_type == OMAP4_SILICON_TYPE_PERFORMANCE)
  274. omap_features = OMAP4_HAS_PERF_SILICON;
  275. }
  276. void __init ti81xx_check_features(void)
  277. {
  278. omap_features = OMAP3_HAS_NEON;
  279. omap3_cpuinfo();
  280. }
  281. void __init am33xx_check_features(void)
  282. {
  283. u32 status;
  284. omap_features = OMAP3_HAS_NEON;
  285. status = omap_ctrl_readl(AM33XX_DEV_FEATURE);
  286. if (status & AM33XX_SGX_MASK)
  287. omap_features |= OMAP3_HAS_SGX;
  288. omap3_cpuinfo();
  289. }
  290. void __init omap3xxx_check_revision(void)
  291. {
  292. const char *cpu_rev;
  293. u32 cpuid, idcode;
  294. u16 hawkeye;
  295. u8 rev;
  296. /*
  297. * We cannot access revision registers on ES1.0.
  298. * If the processor type is Cortex-A8 and the revision is 0x0
  299. * it means its Cortex r0p0 which is 3430 ES1.0.
  300. */
  301. cpuid = read_cpuid_id();
  302. if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
  303. omap_revision = OMAP3430_REV_ES1_0;
  304. cpu_rev = "1.0";
  305. return;
  306. }
  307. /*
  308. * Detection for 34xx ES2.0 and above can be done with just
  309. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  310. * Note that rev does not map directly to our defined processor
  311. * revision numbers as ES1.0 uses value 0.
  312. */
  313. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  314. hawkeye = (idcode >> 12) & 0xffff;
  315. rev = (idcode >> 28) & 0xff;
  316. switch (hawkeye) {
  317. case 0xb7ae:
  318. /* Handle 34xx/35xx devices */
  319. switch (rev) {
  320. case 0: /* Take care of early samples */
  321. case 1:
  322. omap_revision = OMAP3430_REV_ES2_0;
  323. cpu_rev = "2.0";
  324. break;
  325. case 2:
  326. omap_revision = OMAP3430_REV_ES2_1;
  327. cpu_rev = "2.1";
  328. break;
  329. case 3:
  330. omap_revision = OMAP3430_REV_ES3_0;
  331. cpu_rev = "3.0";
  332. break;
  333. case 4:
  334. omap_revision = OMAP3430_REV_ES3_1;
  335. cpu_rev = "3.1";
  336. break;
  337. case 7:
  338. /* FALLTHROUGH */
  339. default:
  340. /* Use the latest known revision as default */
  341. omap_revision = OMAP3430_REV_ES3_1_2;
  342. cpu_rev = "3.1.2";
  343. }
  344. break;
  345. case 0xb868:
  346. /*
  347. * Handle OMAP/AM 3505/3517 devices
  348. *
  349. * Set the device to be OMAP3517 here. Actual device
  350. * is identified later based on the features.
  351. */
  352. switch (rev) {
  353. case 0:
  354. omap_revision = AM35XX_REV_ES1_0;
  355. cpu_rev = "1.0";
  356. break;
  357. case 1:
  358. /* FALLTHROUGH */
  359. default:
  360. omap_revision = AM35XX_REV_ES1_1;
  361. cpu_rev = "1.1";
  362. }
  363. break;
  364. case 0xb891:
  365. /* Handle 36xx devices */
  366. switch(rev) {
  367. case 0: /* Take care of early samples */
  368. omap_revision = OMAP3630_REV_ES1_0;
  369. cpu_rev = "1.0";
  370. break;
  371. case 1:
  372. omap_revision = OMAP3630_REV_ES1_1;
  373. cpu_rev = "1.1";
  374. break;
  375. case 2:
  376. /* FALLTHROUGH */
  377. default:
  378. omap_revision = OMAP3630_REV_ES1_2;
  379. cpu_rev = "1.2";
  380. }
  381. break;
  382. case 0xb81e:
  383. switch (rev) {
  384. case 0:
  385. omap_revision = TI8168_REV_ES1_0;
  386. cpu_rev = "1.0";
  387. break;
  388. case 1:
  389. omap_revision = TI8168_REV_ES1_1;
  390. cpu_rev = "1.1";
  391. break;
  392. case 2:
  393. omap_revision = TI8168_REV_ES2_0;
  394. cpu_rev = "2.0";
  395. break;
  396. case 3:
  397. /* FALLTHROUGH */
  398. default:
  399. omap_revision = TI8168_REV_ES2_1;
  400. cpu_rev = "2.1";
  401. }
  402. break;
  403. case 0xb944:
  404. switch (rev) {
  405. case 0:
  406. omap_revision = AM335X_REV_ES1_0;
  407. cpu_rev = "1.0";
  408. break;
  409. case 1:
  410. omap_revision = AM335X_REV_ES2_0;
  411. cpu_rev = "2.0";
  412. break;
  413. case 2:
  414. /* FALLTHROUGH */
  415. default:
  416. omap_revision = AM335X_REV_ES2_1;
  417. cpu_rev = "2.1";
  418. break;
  419. }
  420. break;
  421. case 0xb98c:
  422. switch (rev) {
  423. case 0:
  424. omap_revision = AM437X_REV_ES1_0;
  425. cpu_rev = "1.0";
  426. break;
  427. case 1:
  428. omap_revision = AM437X_REV_ES1_1;
  429. cpu_rev = "1.1";
  430. break;
  431. case 2:
  432. /* FALLTHROUGH */
  433. default:
  434. omap_revision = AM437X_REV_ES1_2;
  435. cpu_rev = "1.2";
  436. break;
  437. }
  438. break;
  439. case 0xb8f2:
  440. case 0xb968:
  441. switch (rev) {
  442. case 0:
  443. /* FALLTHROUGH */
  444. case 1:
  445. omap_revision = TI8148_REV_ES1_0;
  446. cpu_rev = "1.0";
  447. break;
  448. case 2:
  449. omap_revision = TI8148_REV_ES2_0;
  450. cpu_rev = "2.0";
  451. break;
  452. case 3:
  453. /* FALLTHROUGH */
  454. default:
  455. omap_revision = TI8148_REV_ES2_1;
  456. cpu_rev = "2.1";
  457. break;
  458. }
  459. break;
  460. default:
  461. /* Unknown default to latest silicon rev as default */
  462. omap_revision = OMAP3630_REV_ES1_2;
  463. cpu_rev = "1.2";
  464. pr_warn("Warning: unknown chip type: hawkeye %04x, assuming OMAP3630ES1.2\n",
  465. hawkeye);
  466. }
  467. sprintf(soc_rev, "ES%s", cpu_rev);
  468. }
  469. void __init omap4xxx_check_revision(void)
  470. {
  471. u32 idcode;
  472. u16 hawkeye;
  473. u8 rev;
  474. /*
  475. * The IC rev detection is done with hawkeye and rev.
  476. * Note that rev does not map directly to defined processor
  477. * revision numbers as ES1.0 uses value 0.
  478. */
  479. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  480. hawkeye = (idcode >> 12) & 0xffff;
  481. rev = (idcode >> 28) & 0xf;
  482. /*
  483. * Few initial 4430 ES2.0 samples IDCODE is same as ES1.0
  484. * Use ARM register to detect the correct ES version
  485. */
  486. if (!rev && (hawkeye != 0xb94e) && (hawkeye != 0xb975)) {
  487. idcode = read_cpuid_id();
  488. rev = (idcode & 0xf) - 1;
  489. }
  490. switch (hawkeye) {
  491. case 0xb852:
  492. switch (rev) {
  493. case 0:
  494. omap_revision = OMAP4430_REV_ES1_0;
  495. break;
  496. case 1:
  497. default:
  498. omap_revision = OMAP4430_REV_ES2_0;
  499. }
  500. break;
  501. case 0xb95c:
  502. switch (rev) {
  503. case 3:
  504. omap_revision = OMAP4430_REV_ES2_1;
  505. break;
  506. case 4:
  507. omap_revision = OMAP4430_REV_ES2_2;
  508. break;
  509. case 6:
  510. default:
  511. omap_revision = OMAP4430_REV_ES2_3;
  512. }
  513. break;
  514. case 0xb94e:
  515. switch (rev) {
  516. case 0:
  517. omap_revision = OMAP4460_REV_ES1_0;
  518. break;
  519. case 2:
  520. default:
  521. omap_revision = OMAP4460_REV_ES1_1;
  522. break;
  523. }
  524. break;
  525. case 0xb975:
  526. switch (rev) {
  527. case 0:
  528. default:
  529. omap_revision = OMAP4470_REV_ES1_0;
  530. break;
  531. }
  532. break;
  533. default:
  534. /* Unknown default to latest silicon rev as default */
  535. omap_revision = OMAP4430_REV_ES2_3;
  536. }
  537. sprintf(soc_name, "OMAP%04x", omap_rev() >> 16);
  538. sprintf(soc_rev, "ES%d.%d", (omap_rev() >> 12) & 0xf,
  539. (omap_rev() >> 8) & 0xf);
  540. pr_info("%s %s\n", soc_name, soc_rev);
  541. }
  542. void __init omap5xxx_check_revision(void)
  543. {
  544. u32 idcode;
  545. u16 hawkeye;
  546. u8 rev;
  547. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  548. hawkeye = (idcode >> 12) & 0xffff;
  549. rev = (idcode >> 28) & 0xff;
  550. switch (hawkeye) {
  551. case 0xb942:
  552. switch (rev) {
  553. case 0:
  554. /* No support for ES1.0 Test chip */
  555. BUG();
  556. case 1:
  557. default:
  558. omap_revision = OMAP5430_REV_ES2_0;
  559. }
  560. break;
  561. case 0xb998:
  562. switch (rev) {
  563. case 0:
  564. /* No support for ES1.0 Test chip */
  565. BUG();
  566. case 1:
  567. default:
  568. omap_revision = OMAP5432_REV_ES2_0;
  569. }
  570. break;
  571. default:
  572. /* Unknown default to latest silicon rev as default*/
  573. omap_revision = OMAP5430_REV_ES2_0;
  574. }
  575. sprintf(soc_name, "OMAP%04x", omap_rev() >> 16);
  576. sprintf(soc_rev, "ES%d.0", (omap_rev() >> 12) & 0xf);
  577. pr_info("%s %s\n", soc_name, soc_rev);
  578. }
  579. void __init dra7xxx_check_revision(void)
  580. {
  581. u32 idcode;
  582. u16 hawkeye;
  583. u8 rev, package;
  584. struct omap_die_id odi;
  585. omap_get_die_id(&odi);
  586. package = (odi.id_2 >> 16) & 0x3;
  587. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  588. hawkeye = (idcode >> 12) & 0xffff;
  589. rev = (idcode >> 28) & 0xff;
  590. switch (hawkeye) {
  591. case 0xbb50:
  592. switch (rev) {
  593. case 0:
  594. default:
  595. switch (package) {
  596. case 0x2:
  597. omap_revision = DRA762_ABZ_REV_ES1_0;
  598. break;
  599. case 0x3:
  600. omap_revision = DRA762_ACD_REV_ES1_0;
  601. break;
  602. default:
  603. omap_revision = DRA762_REV_ES1_0;
  604. break;
  605. }
  606. break;
  607. }
  608. break;
  609. case 0xb990:
  610. switch (rev) {
  611. case 0:
  612. omap_revision = DRA752_REV_ES1_0;
  613. break;
  614. case 1:
  615. omap_revision = DRA752_REV_ES1_1;
  616. break;
  617. case 2:
  618. default:
  619. omap_revision = DRA752_REV_ES2_0;
  620. break;
  621. }
  622. break;
  623. case 0xb9bc:
  624. switch (rev) {
  625. case 0:
  626. omap_revision = DRA722_REV_ES1_0;
  627. break;
  628. case 1:
  629. omap_revision = DRA722_REV_ES2_0;
  630. break;
  631. case 2:
  632. default:
  633. omap_revision = DRA722_REV_ES2_1;
  634. break;
  635. }
  636. break;
  637. default:
  638. /* Unknown default to latest silicon rev as default*/
  639. pr_warn("%s: unknown idcode=0x%08x (hawkeye=0x%08x,rev=0x%x)\n",
  640. __func__, idcode, hawkeye, rev);
  641. omap_revision = DRA752_REV_ES2_0;
  642. }
  643. sprintf(soc_name, "DRA%03x", omap_rev() >> 16);
  644. sprintf(soc_rev, "ES%d.%d", (omap_rev() >> 12) & 0xf,
  645. (omap_rev() >> 8) & 0xf);
  646. pr_info("%s %s\n", soc_name, soc_rev);
  647. }
  648. /*
  649. * Set up things for map_io and processor detection later on. Gets called
  650. * pretty much first thing from board init. For multi-omap, this gets
  651. * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
  652. * detect the exact revision later on in omap2_detect_revision() once map_io
  653. * is done.
  654. */
  655. void __init omap2_set_globals_tap(u32 class, void __iomem *tap)
  656. {
  657. omap_revision = class;
  658. tap_base = tap;
  659. /* XXX What is this intended to do? */
  660. if (soc_is_omap34xx())
  661. tap_prod_id = 0x0210;
  662. else
  663. tap_prod_id = 0x0208;
  664. }
  665. #ifdef CONFIG_SOC_BUS
  666. static const char * const omap_types[] = {
  667. [OMAP2_DEVICE_TYPE_TEST] = "TST",
  668. [OMAP2_DEVICE_TYPE_EMU] = "EMU",
  669. [OMAP2_DEVICE_TYPE_SEC] = "HS",
  670. [OMAP2_DEVICE_TYPE_GP] = "GP",
  671. [OMAP2_DEVICE_TYPE_BAD] = "BAD",
  672. };
  673. static const char * __init omap_get_family(void)
  674. {
  675. if (soc_is_omap24xx())
  676. return kasprintf(GFP_KERNEL, "OMAP2");
  677. else if (soc_is_omap34xx())
  678. return kasprintf(GFP_KERNEL, "OMAP3");
  679. else if (soc_is_omap44xx())
  680. return kasprintf(GFP_KERNEL, "OMAP4");
  681. else if (soc_is_omap54xx())
  682. return kasprintf(GFP_KERNEL, "OMAP5");
  683. else if (soc_is_am33xx() || soc_is_am335x())
  684. return kasprintf(GFP_KERNEL, "AM33xx");
  685. else if (soc_is_am43xx())
  686. return kasprintf(GFP_KERNEL, "AM43xx");
  687. else if (soc_is_dra7xx())
  688. return kasprintf(GFP_KERNEL, "DRA7");
  689. else
  690. return kasprintf(GFP_KERNEL, "Unknown");
  691. }
  692. static ssize_t omap_get_type(struct device *dev,
  693. struct device_attribute *attr,
  694. char *buf)
  695. {
  696. return sprintf(buf, "%s\n", omap_types[omap_type()]);
  697. }
  698. static struct device_attribute omap_soc_attr =
  699. __ATTR(type, S_IRUGO, omap_get_type, NULL);
  700. void __init omap_soc_device_init(void)
  701. {
  702. struct device *parent;
  703. struct soc_device *soc_dev;
  704. struct soc_device_attribute *soc_dev_attr;
  705. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  706. if (!soc_dev_attr)
  707. return;
  708. soc_dev_attr->machine = soc_name;
  709. soc_dev_attr->family = omap_get_family();
  710. soc_dev_attr->revision = soc_rev;
  711. soc_dev = soc_device_register(soc_dev_attr);
  712. if (IS_ERR(soc_dev)) {
  713. kfree(soc_dev_attr);
  714. return;
  715. }
  716. parent = soc_device_to_device(soc_dev);
  717. device_create_file(parent, &omap_soc_attr);
  718. }
  719. #endif /* CONFIG_SOC_BUS */