id.c 7.3 KB

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