id.c 7.3 KB

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