id.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <asm/io.h>
  17. #include <mach/common.h>
  18. #include <mach/control.h>
  19. #include <mach/cpu.h>
  20. static u32 class;
  21. static void __iomem *tap_base;
  22. static u16 tap_prod_id;
  23. #define OMAP_TAP_IDCODE 0x0204
  24. #define OMAP_TAP_DIE_ID_0 0x0218
  25. #define OMAP_TAP_DIE_ID_1 0x021C
  26. #define OMAP_TAP_DIE_ID_2 0x0220
  27. #define OMAP_TAP_DIE_ID_3 0x0224
  28. /* system_rev fields for OMAP2 processors:
  29. * CPU id bits [31:16],
  30. * CPU device type [15:12], (unprg,normal,POP)
  31. * CPU revision [11:08]
  32. * CPU class bits [07:00]
  33. */
  34. struct omap_id {
  35. u16 hawkeye; /* Silicon type (Hawkeye id) */
  36. u8 dev; /* Device type from production_id reg */
  37. u32 type; /* combined type id copied to system_rev */
  38. };
  39. /* Register values to detect the OMAP version */
  40. static struct omap_id omap_ids[] __initdata = {
  41. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200000 },
  42. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201000 },
  43. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202000 },
  44. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220000 },
  45. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230000 },
  46. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300000 },
  47. };
  48. static struct omap_chip_id omap_chip;
  49. /**
  50. * omap_chip_is - test whether currently running OMAP matches a chip type
  51. * @oc: omap_chip_t to test against
  52. *
  53. * Test whether the currently-running OMAP chip matches the supplied
  54. * chip type 'oc'. Returns 1 upon a match; 0 upon failure.
  55. */
  56. int omap_chip_is(struct omap_chip_id oci)
  57. {
  58. return (oci.oc & omap_chip.oc) ? 1 : 0;
  59. }
  60. EXPORT_SYMBOL(omap_chip_is);
  61. static u32 __init read_tap_reg(int reg)
  62. {
  63. unsigned int regval = 0;
  64. u32 cpuid;
  65. /* Reading the IDCODE register on 3430 ES1 results in a
  66. * data abort as the register is not exposed on the OCP
  67. * Hence reading the Cortex Rev
  68. */
  69. cpuid = read_cpuid(CPUID_ID);
  70. /* If the processor type is Cortex-A8 and the revision is 0x0
  71. * it means its Cortex r0p0 which is 3430 ES1
  72. */
  73. if ((((cpuid >> 4) & 0xFFF) == 0xC08) && ((cpuid & 0xF) == 0x0)) {
  74. if (reg == tap_prod_id) {
  75. regval = 0x000F00F0;
  76. goto out;
  77. }
  78. switch (reg) {
  79. case OMAP_TAP_IDCODE : regval = 0x0B7AE02F; break;
  80. /* Making DevType as 0xF in ES1 to differ from ES2 */
  81. case OMAP_TAP_DIE_ID_0: regval = 0x01000000; break;
  82. case OMAP_TAP_DIE_ID_1: regval = 0x1012d687; break;
  83. case OMAP_TAP_DIE_ID_2: regval = 0x00000000; break;
  84. case OMAP_TAP_DIE_ID_3: regval = 0x2d2c0000; break;
  85. }
  86. } else
  87. regval = __raw_readl(tap_base + reg);
  88. out:
  89. return regval;
  90. }
  91. /*
  92. * _set_system_rev - set the system_rev global based on current OMAP chip type
  93. *
  94. * Set the system_rev global. This is primarily used by the cpu_is_omapxxxx()
  95. * macros.
  96. */
  97. static void __init _set_system_rev(u32 type, u8 rev)
  98. {
  99. u32 i, ctrl_status;
  100. /*
  101. * system_rev encoding is as follows
  102. * system_rev & 0xff000000 -> Omap Class (24xx/34xx)
  103. * system_rev & 0xfff00000 -> Omap Sub Class (242x/343x)
  104. * system_rev & 0xffff0000 -> Omap type (2420/2422/2423/2430/3430)
  105. * system_rev & 0x0000f000 -> Silicon revision (ES1, ES2 )
  106. * system_rev & 0x00000700 -> Device Type ( EMU/HS/GP/BAD )
  107. * system_rev & 0x000000c0 -> IDCODE revision[6:7]
  108. * system_rev & 0x0000003f -> sys_boot[0:5]
  109. */
  110. /* Embedding the ES revision info in type field */
  111. system_rev = type;
  112. /* Also add IDCODE revision info only two lower bits */
  113. system_rev |= ((rev & 0x3) << 6);
  114. /* Add in the device type and sys_boot fields (see above) */
  115. if (cpu_is_omap24xx()) {
  116. i = OMAP24XX_CONTROL_STATUS;
  117. } else if (cpu_is_omap343x()) {
  118. i = OMAP343X_CONTROL_STATUS;
  119. } else {
  120. printk(KERN_ERR "id: unknown CPU type\n");
  121. BUG();
  122. }
  123. ctrl_status = omap_ctrl_readl(i);
  124. system_rev |= (ctrl_status & (OMAP2_SYSBOOT_5_MASK |
  125. OMAP2_SYSBOOT_4_MASK |
  126. OMAP2_SYSBOOT_3_MASK |
  127. OMAP2_SYSBOOT_2_MASK |
  128. OMAP2_SYSBOOT_1_MASK |
  129. OMAP2_SYSBOOT_0_MASK));
  130. system_rev |= (ctrl_status & OMAP2_DEVICETYPE_MASK);
  131. }
  132. /*
  133. * _set_omap_chip - set the omap_chip global based on OMAP chip type
  134. *
  135. * Build the omap_chip bits. This variable is used by powerdomain and
  136. * clockdomain code to indicate whether structures are applicable for
  137. * the current OMAP chip type by ANDing it against a 'platform' bitfield
  138. * in the structure.
  139. */
  140. static void __init _set_omap_chip(void)
  141. {
  142. if (cpu_is_omap343x()) {
  143. omap_chip.oc = CHIP_IS_OMAP3430;
  144. if (is_sil_rev_equal_to(OMAP3430_REV_ES1_0))
  145. omap_chip.oc |= CHIP_IS_OMAP3430ES1;
  146. else if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
  147. omap_chip.oc |= CHIP_IS_OMAP3430ES2;
  148. } else if (cpu_is_omap243x()) {
  149. /* Currently only supports 2430ES2.1 and 2430-all */
  150. omap_chip.oc |= CHIP_IS_OMAP2430;
  151. } else if (cpu_is_omap242x()) {
  152. /* Currently only supports 2420ES2.1.1 and 2420-all */
  153. omap_chip.oc |= CHIP_IS_OMAP2420;
  154. } else {
  155. /* Current CPU not supported by this code. */
  156. printk(KERN_WARNING "OMAP chip type code does not yet support "
  157. "this CPU type.\n");
  158. WARN_ON(1);
  159. }
  160. }
  161. void __init omap2_check_revision(void)
  162. {
  163. int i, j;
  164. u32 idcode;
  165. u32 prod_id;
  166. u16 hawkeye;
  167. u8 dev_type;
  168. u8 rev;
  169. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  170. prod_id = read_tap_reg(tap_prod_id);
  171. hawkeye = (idcode >> 12) & 0xffff;
  172. rev = (idcode >> 28) & 0x0f;
  173. dev_type = (prod_id >> 16) & 0x0f;
  174. pr_debug("OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  175. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  176. pr_debug("OMAP_TAP_DIE_ID_0: 0x%08x\n",
  177. read_tap_reg(OMAP_TAP_DIE_ID_0));
  178. pr_debug("OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  179. read_tap_reg(OMAP_TAP_DIE_ID_1),
  180. (read_tap_reg(OMAP_TAP_DIE_ID_1) >> 28) & 0xf);
  181. pr_debug("OMAP_TAP_DIE_ID_2: 0x%08x\n",
  182. read_tap_reg(OMAP_TAP_DIE_ID_2));
  183. pr_debug("OMAP_TAP_DIE_ID_3: 0x%08x\n",
  184. read_tap_reg(OMAP_TAP_DIE_ID_3));
  185. pr_debug("OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  186. prod_id, dev_type);
  187. /*
  188. * Detection for 34xx ES2.0 and above can be done with just
  189. * hawkeye and rev. See TRM 1.5.2 Device Identification.
  190. * Note that rev cannot be used directly as ES1.0 uses value 0.
  191. */
  192. if (hawkeye == 0xb7ae) {
  193. system_rev = 0x34300000 | ((1 + rev) << 12);
  194. pr_info("OMAP%04x ES2.%i\n", system_rev >> 16, rev);
  195. _set_omap_chip();
  196. return;
  197. }
  198. /* Check hawkeye ids */
  199. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  200. if (hawkeye == omap_ids[i].hawkeye)
  201. break;
  202. }
  203. if (i == ARRAY_SIZE(omap_ids)) {
  204. printk(KERN_ERR "Unknown OMAP CPU id\n");
  205. return;
  206. }
  207. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  208. if (dev_type == omap_ids[j].dev)
  209. break;
  210. }
  211. if (j == ARRAY_SIZE(omap_ids)) {
  212. printk(KERN_ERR "Unknown OMAP device type. "
  213. "Handling it as OMAP%04x\n",
  214. omap_ids[i].type >> 16);
  215. j = i;
  216. }
  217. _set_system_rev(omap_ids[j].type, rev);
  218. _set_omap_chip();
  219. pr_info("OMAP%04x", system_rev >> 16);
  220. if ((system_rev >> 8) & 0x0f)
  221. pr_info("ES%x", (system_rev >> 12) & 0xf);
  222. pr_info("\n");
  223. }
  224. void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
  225. {
  226. class = omap2_globals->class;
  227. tap_base = omap2_globals->tap;
  228. if (class == 0x3430)
  229. tap_prod_id = 0x0210;
  230. else
  231. tap_prod_id = 0x0208;
  232. }