id.c 7.3 KB

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