id.c 7.1 KB

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