id.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * linux/arch/arm/mach-omap1/id.c
  3. *
  4. * OMAP1 CPU identification code
  5. *
  6. * Copyright (C) 2004 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/system_info.h>
  18. #include "soc.h"
  19. #include <mach/hardware.h>
  20. #include "common.h"
  21. #define OMAP_DIE_ID_0 0xfffe1800
  22. #define OMAP_DIE_ID_1 0xfffe1804
  23. #define OMAP_PRODUCTION_ID_0 0xfffe2000
  24. #define OMAP_PRODUCTION_ID_1 0xfffe2004
  25. #define OMAP32_ID_0 0xfffed400
  26. #define OMAP32_ID_1 0xfffed404
  27. struct omap_id {
  28. u16 jtag_id; /* Used to determine OMAP type */
  29. u8 die_rev; /* Processor revision */
  30. u32 omap_id; /* OMAP revision */
  31. u32 type; /* Cpu id bits [31:08], cpu class bits [07:00] */
  32. };
  33. static unsigned int omap_revision;
  34. /* Register values to detect the OMAP version */
  35. static struct omap_id omap_ids[] __initdata = {
  36. { .jtag_id = 0xb574, .die_rev = 0x2, .omap_id = 0x03310315, .type = 0x03100000},
  37. { .jtag_id = 0x355f, .die_rev = 0x0, .omap_id = 0x03320000, .type = 0x07300100},
  38. { .jtag_id = 0xb55f, .die_rev = 0x0, .omap_id = 0x03320000, .type = 0x07300300},
  39. { .jtag_id = 0xb62c, .die_rev = 0x1, .omap_id = 0x03320500, .type = 0x08500000},
  40. { .jtag_id = 0xb470, .die_rev = 0x0, .omap_id = 0x03310100, .type = 0x15100000},
  41. { .jtag_id = 0xb576, .die_rev = 0x0, .omap_id = 0x03320000, .type = 0x16100000},
  42. { .jtag_id = 0xb576, .die_rev = 0x2, .omap_id = 0x03320100, .type = 0x16110000},
  43. { .jtag_id = 0xb576, .die_rev = 0x3, .omap_id = 0x03320100, .type = 0x16100c00},
  44. { .jtag_id = 0xb576, .die_rev = 0x0, .omap_id = 0x03320200, .type = 0x16100d00},
  45. { .jtag_id = 0xb613, .die_rev = 0x0, .omap_id = 0x03320300, .type = 0x1610ef00},
  46. { .jtag_id = 0xb613, .die_rev = 0x0, .omap_id = 0x03320300, .type = 0x1610ef00},
  47. { .jtag_id = 0xb576, .die_rev = 0x1, .omap_id = 0x03320100, .type = 0x16110000},
  48. { .jtag_id = 0xb58c, .die_rev = 0x2, .omap_id = 0x03320200, .type = 0x16110b00},
  49. { .jtag_id = 0xb58c, .die_rev = 0x3, .omap_id = 0x03320200, .type = 0x16110c00},
  50. { .jtag_id = 0xb65f, .die_rev = 0x0, .omap_id = 0x03320400, .type = 0x16212300},
  51. { .jtag_id = 0xb65f, .die_rev = 0x1, .omap_id = 0x03320400, .type = 0x16212300},
  52. { .jtag_id = 0xb65f, .die_rev = 0x1, .omap_id = 0x03320500, .type = 0x16212300},
  53. { .jtag_id = 0xb5f7, .die_rev = 0x0, .omap_id = 0x03330000, .type = 0x17100000},
  54. { .jtag_id = 0xb5f7, .die_rev = 0x1, .omap_id = 0x03330100, .type = 0x17100000},
  55. { .jtag_id = 0xb5f7, .die_rev = 0x2, .omap_id = 0x03330100, .type = 0x17100000},
  56. };
  57. unsigned int omap_rev(void)
  58. {
  59. return omap_revision;
  60. }
  61. EXPORT_SYMBOL(omap_rev);
  62. /*
  63. * Get OMAP type from PROD_ID.
  64. * 1710 has the PROD_ID in bits 15:00, not in 16:01 as documented in TRM.
  65. * 1510 PROD_ID is empty, and 1610 PROD_ID does not make sense.
  66. * Undocumented register in TEST BLOCK is used as fallback; This seems to
  67. * work on 1510, 1610 & 1710. The official way hopefully will work in future
  68. * processors.
  69. */
  70. static u16 __init omap_get_jtag_id(void)
  71. {
  72. u32 prod_id, omap_id;
  73. prod_id = omap_readl(OMAP_PRODUCTION_ID_1);
  74. omap_id = omap_readl(OMAP32_ID_1);
  75. /* Check for unusable OMAP_PRODUCTION_ID_1 on 1611B/5912 and 730/850 */
  76. if (((prod_id >> 20) == 0) || (prod_id == omap_id))
  77. prod_id = 0;
  78. else
  79. prod_id &= 0xffff;
  80. if (prod_id)
  81. return prod_id;
  82. /* Use OMAP32_ID_1 as fallback */
  83. prod_id = ((omap_id >> 12) & 0xffff);
  84. return prod_id;
  85. }
  86. /*
  87. * Get OMAP revision from DIE_REV.
  88. * Early 1710 processors may have broken OMAP_DIE_ID, it contains PROD_ID.
  89. * Undocumented register in the TEST BLOCK is used as fallback.
  90. * REVISIT: This does not seem to work on 1510
  91. */
  92. static u8 __init omap_get_die_rev(void)
  93. {
  94. u32 die_rev;
  95. die_rev = omap_readl(OMAP_DIE_ID_1);
  96. /* Check for broken OMAP_DIE_ID on early 1710 */
  97. if (((die_rev >> 12) & 0xffff) == omap_get_jtag_id())
  98. die_rev = 0;
  99. die_rev = (die_rev >> 17) & 0xf;
  100. if (die_rev)
  101. return die_rev;
  102. die_rev = (omap_readl(OMAP32_ID_1) >> 28) & 0xf;
  103. return die_rev;
  104. }
  105. void __init omap_check_revision(void)
  106. {
  107. int i;
  108. u16 jtag_id;
  109. u8 die_rev;
  110. u32 omap_id;
  111. u8 cpu_type;
  112. jtag_id = omap_get_jtag_id();
  113. die_rev = omap_get_die_rev();
  114. omap_id = omap_readl(OMAP32_ID_0);
  115. #ifdef DEBUG
  116. printk(KERN_DEBUG "OMAP_DIE_ID_0: 0x%08x\n", omap_readl(OMAP_DIE_ID_0));
  117. printk(KERN_DEBUG "OMAP_DIE_ID_1: 0x%08x DIE_REV: %i\n",
  118. omap_readl(OMAP_DIE_ID_1),
  119. (omap_readl(OMAP_DIE_ID_1) >> 17) & 0xf);
  120. printk(KERN_DEBUG "OMAP_PRODUCTION_ID_0: 0x%08x\n",
  121. omap_readl(OMAP_PRODUCTION_ID_0));
  122. printk(KERN_DEBUG "OMAP_PRODUCTION_ID_1: 0x%08x JTAG_ID: 0x%04x\n",
  123. omap_readl(OMAP_PRODUCTION_ID_1),
  124. omap_readl(OMAP_PRODUCTION_ID_1) & 0xffff);
  125. printk(KERN_DEBUG "OMAP32_ID_0: 0x%08x\n", omap_readl(OMAP32_ID_0));
  126. printk(KERN_DEBUG "OMAP32_ID_1: 0x%08x\n", omap_readl(OMAP32_ID_1));
  127. printk(KERN_DEBUG "JTAG_ID: 0x%04x DIE_REV: %i\n", jtag_id, die_rev);
  128. #endif
  129. system_serial_high = omap_readl(OMAP_DIE_ID_0);
  130. system_serial_low = omap_readl(OMAP_DIE_ID_1);
  131. /* First check only the major version in a safe way */
  132. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  133. if (jtag_id == (omap_ids[i].jtag_id)) {
  134. omap_revision = omap_ids[i].type;
  135. break;
  136. }
  137. }
  138. /* Check if we can find the die revision */
  139. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  140. if (jtag_id == omap_ids[i].jtag_id && die_rev == omap_ids[i].die_rev) {
  141. omap_revision = omap_ids[i].type;
  142. break;
  143. }
  144. }
  145. /* Finally check also the omap_id */
  146. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  147. if (jtag_id == omap_ids[i].jtag_id
  148. && die_rev == omap_ids[i].die_rev
  149. && omap_id == omap_ids[i].omap_id) {
  150. omap_revision = omap_ids[i].type;
  151. break;
  152. }
  153. }
  154. /* Add the cpu class info (7xx, 15xx, 16xx, 24xx) */
  155. cpu_type = omap_revision >> 24;
  156. switch (cpu_type) {
  157. case 0x07:
  158. case 0x08:
  159. omap_revision |= 0x07;
  160. break;
  161. case 0x03:
  162. case 0x15:
  163. omap_revision |= 0x15;
  164. break;
  165. case 0x16:
  166. case 0x17:
  167. omap_revision |= 0x16;
  168. break;
  169. default:
  170. printk(KERN_INFO "Unknown OMAP cpu type: 0x%02x\n", cpu_type);
  171. }
  172. pr_info("OMAP%04x", omap_revision >> 16);
  173. if ((omap_revision >> 8) & 0xff)
  174. pr_cont("%x", (omap_revision >> 8) & 0xff);
  175. pr_cont(" revision %i handled as %02xxx id: %08x%08x\n",
  176. die_rev, omap_revision & 0xff, system_serial_low,
  177. system_serial_high);
  178. }