id.c 17 KB

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