id.c 16 KB

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