id.c 16 KB

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