id.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 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 <asm/cputype.h>
  21. #include <mach/common.h>
  22. #include <mach/control.h>
  23. #include <mach/cpu.h>
  24. static struct omap_chip_id omap_chip;
  25. static unsigned int omap_revision;
  26. unsigned int omap_rev(void)
  27. {
  28. return omap_revision;
  29. }
  30. EXPORT_SYMBOL(omap_rev);
  31. /**
  32. * omap_chip_is - test whether currently running OMAP matches a chip type
  33. * @oc: omap_chip_t to test against
  34. *
  35. * Test whether the currently-running OMAP chip matches the supplied
  36. * chip type 'oc'. Returns 1 upon a match; 0 upon failure.
  37. */
  38. int omap_chip_is(struct omap_chip_id oci)
  39. {
  40. return (oci.oc & omap_chip.oc) ? 1 : 0;
  41. }
  42. EXPORT_SYMBOL(omap_chip_is);
  43. /*----------------------------------------------------------------------------*/
  44. #define OMAP_TAP_IDCODE 0x0204
  45. #define OMAP_TAP_DIE_ID_0 0x0218
  46. #define OMAP_TAP_DIE_ID_1 0x021C
  47. #define OMAP_TAP_DIE_ID_2 0x0220
  48. #define OMAP_TAP_DIE_ID_3 0x0224
  49. #define read_tap_reg(reg) __raw_readl(tap_base + (reg))
  50. struct omap_id {
  51. u16 hawkeye; /* Silicon type (Hawkeye id) */
  52. u8 dev; /* Device type from production_id reg */
  53. u32 type; /* Combined type id copied to omap_revision */
  54. };
  55. /* Register values to detect the OMAP version */
  56. static struct omap_id omap_ids[] __initdata = {
  57. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200024 },
  58. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201024 },
  59. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202024 },
  60. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220024 },
  61. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230024 },
  62. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300024 },
  63. };
  64. static void __iomem *tap_base;
  65. static u16 tap_prod_id;
  66. void __init omap24xx_check_revision(void)
  67. {
  68. int i, j;
  69. u32 idcode, prod_id;
  70. u16 hawkeye;
  71. u8 dev_type, rev;
  72. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  73. prod_id = read_tap_reg(tap_prod_id);
  74. hawkeye = (idcode >> 12) & 0xffff;
  75. rev = (idcode >> 28) & 0x0f;
  76. dev_type = (prod_id >> 16) & 0x0f;
  77. pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  78. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  79. pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n",
  80. read_tap_reg(OMAP_TAP_DIE_ID_0));
  81. pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  82. read_tap_reg(OMAP_TAP_DIE_ID_1),
  83. (read_tap_reg(OMAP_TAP_DIE_ID_1) >> 28) & 0xf);
  84. pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n",
  85. read_tap_reg(OMAP_TAP_DIE_ID_2));
  86. pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n",
  87. read_tap_reg(OMAP_TAP_DIE_ID_3));
  88. pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  89. prod_id, dev_type);
  90. /* Check hawkeye ids */
  91. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  92. if (hawkeye == omap_ids[i].hawkeye)
  93. break;
  94. }
  95. if (i == ARRAY_SIZE(omap_ids)) {
  96. printk(KERN_ERR "Unknown OMAP CPU id\n");
  97. return;
  98. }
  99. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  100. if (dev_type == omap_ids[j].dev)
  101. break;
  102. }
  103. if (j == ARRAY_SIZE(omap_ids)) {
  104. printk(KERN_ERR "Unknown OMAP device type. "
  105. "Handling it as OMAP%04x\n",
  106. omap_ids[i].type >> 16);
  107. j = i;
  108. }
  109. pr_info("OMAP%04x", omap_rev() >> 16);
  110. if ((omap_rev() >> 8) & 0x0f)
  111. pr_info("ES%x", (omap_rev() >> 12) & 0xf);
  112. pr_info("\n");
  113. }
  114. void __init omap34xx_check_revision(void)
  115. {
  116. u32 cpuid, idcode;
  117. u16 hawkeye;
  118. u8 rev;
  119. char *rev_name = "ES1.0";
  120. /*
  121. * We cannot access revision registers on ES1.0.
  122. * If the processor type is Cortex-A8 and the revision is 0x0
  123. * it means its Cortex r0p0 which is 3430 ES1.0.
  124. */
  125. cpuid = read_cpuid(CPUID_ID);
  126. if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
  127. omap_revision = OMAP3430_REV_ES1_0;
  128. goto out;
  129. }
  130. /*
  131. * Detection for 34xx ES2.0 and above can be done with just
  132. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  133. * Note that rev does not map directly to our defined processor
  134. * revision numbers as ES1.0 uses value 0.
  135. */
  136. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  137. hawkeye = (idcode >> 12) & 0xffff;
  138. rev = (idcode >> 28) & 0xff;
  139. if (hawkeye == 0xb7ae) {
  140. switch (rev) {
  141. case 0:
  142. omap_revision = OMAP3430_REV_ES2_0;
  143. rev_name = "ES2.0";
  144. break;
  145. case 2:
  146. omap_revision = OMAP3430_REV_ES2_1;
  147. rev_name = "ES2.1";
  148. break;
  149. case 3:
  150. omap_revision = OMAP3430_REV_ES3_0;
  151. rev_name = "ES3.0";
  152. break;
  153. case 4:
  154. omap_revision = OMAP3430_REV_ES3_1;
  155. rev_name = "ES3.1";
  156. break;
  157. default:
  158. /* Use the latest known revision as default */
  159. omap_revision = OMAP3430_REV_ES3_1;
  160. rev_name = "Unknown revision\n";
  161. }
  162. }
  163. out:
  164. pr_info("OMAP%04x %s\n", omap_rev() >> 16, rev_name);
  165. }
  166. /*
  167. * Try to detect the exact revision of the omap we're running on
  168. */
  169. void __init omap2_check_revision(void)
  170. {
  171. /*
  172. * At this point we have an idea about the processor revision set
  173. * earlier with omap2_set_globals_tap().
  174. */
  175. if (cpu_is_omap24xx())
  176. omap24xx_check_revision();
  177. else if (cpu_is_omap34xx())
  178. omap34xx_check_revision();
  179. else if (cpu_is_omap44xx()) {
  180. printk(KERN_INFO "FIXME: CPU revision = OMAP4430\n");
  181. return;
  182. } else
  183. pr_err("OMAP revision unknown, please fix!\n");
  184. /*
  185. * OK, now we know the exact revision. Initialize omap_chip bits
  186. * for powerdowmain and clockdomain code.
  187. */
  188. if (cpu_is_omap243x()) {
  189. /* Currently only supports 2430ES2.1 and 2430-all */
  190. omap_chip.oc |= CHIP_IS_OMAP2430;
  191. } else if (cpu_is_omap242x()) {
  192. /* Currently only supports 2420ES2.1.1 and 2420-all */
  193. omap_chip.oc |= CHIP_IS_OMAP2420;
  194. } else if (cpu_is_omap343x()) {
  195. omap_chip.oc = CHIP_IS_OMAP3430;
  196. if (omap_rev() == OMAP3430_REV_ES1_0)
  197. omap_chip.oc |= CHIP_IS_OMAP3430ES1;
  198. else if (omap_rev() >= OMAP3430_REV_ES2_0 &&
  199. omap_rev() <= OMAP3430_REV_ES2_1)
  200. omap_chip.oc |= CHIP_IS_OMAP3430ES2;
  201. else if (omap_rev() == OMAP3430_REV_ES3_0)
  202. omap_chip.oc |= CHIP_IS_OMAP3430ES3_0;
  203. else if (omap_rev() == OMAP3430_REV_ES3_1)
  204. omap_chip.oc |= CHIP_IS_OMAP3430ES3_1;
  205. } else {
  206. pr_err("Uninitialized omap_chip, please fix!\n");
  207. }
  208. }
  209. /*
  210. * Set up things for map_io and processor detection later on. Gets called
  211. * pretty much first thing from board init. For multi-omap, this gets
  212. * cpu_is_omapxxxx() working accurately enough for map_io. Then we'll try to
  213. * detect the exact revision later on in omap2_detect_revision() once map_io
  214. * is done.
  215. */
  216. void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
  217. {
  218. omap_revision = omap2_globals->class;
  219. tap_base = omap2_globals->tap;
  220. if (cpu_is_omap34xx())
  221. tap_prod_id = 0x0210;
  222. else
  223. tap_prod_id = 0x0208;
  224. }