id.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/config.h>
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <asm/io.h>
  18. #define OMAP24XX_TAP_BASE io_p2v(0x48014000)
  19. #define OMAP_TAP_IDCODE 0x0204
  20. #define OMAP_TAP_PROD_ID 0x0208
  21. #define OMAP_TAP_DIE_ID_0 0x0218
  22. #define OMAP_TAP_DIE_ID_1 0x021C
  23. #define OMAP_TAP_DIE_ID_2 0x0220
  24. #define OMAP_TAP_DIE_ID_3 0x0224
  25. /* system_rev fields for OMAP2 processors:
  26. * CPU id bits [31:16],
  27. * CPU device type [15:12], (unprg,normal,POP)
  28. * CPU revision [11:08]
  29. * CPU class bits [07:00]
  30. */
  31. struct omap_id {
  32. u16 hawkeye; /* Silicon type (Hawkeye id) */
  33. u8 dev; /* Device type from production_id reg */
  34. u32 type; /* combined type id copied to system_rev */
  35. };
  36. /* Register values to detect the OMAP version */
  37. static struct omap_id omap_ids[] __initdata = {
  38. { .hawkeye = 0xb5d9, .dev = 0x0, .type = 0x24200000 },
  39. { .hawkeye = 0xb5d9, .dev = 0x1, .type = 0x24201000 },
  40. { .hawkeye = 0xb5d9, .dev = 0x2, .type = 0x24202000 },
  41. { .hawkeye = 0xb5d9, .dev = 0x4, .type = 0x24220000 },
  42. { .hawkeye = 0xb5d9, .dev = 0x8, .type = 0x24230000 },
  43. { .hawkeye = 0xb68a, .dev = 0x0, .type = 0x24300000 },
  44. };
  45. static u32 __init read_tap_reg(int reg)
  46. {
  47. return __raw_readl(OMAP24XX_TAP_BASE + reg);
  48. }
  49. void __init omap2_check_revision(void)
  50. {
  51. int i, j;
  52. u32 idcode;
  53. u32 prod_id;
  54. u16 hawkeye;
  55. u8 dev_type;
  56. u8 rev;
  57. idcode = read_tap_reg(OMAP_TAP_IDCODE);
  58. prod_id = read_tap_reg(OMAP_TAP_PROD_ID);
  59. hawkeye = (idcode >> 12) & 0xffff;
  60. rev = (idcode >> 28) & 0x0f;
  61. dev_type = (prod_id >> 16) & 0x0f;
  62. #ifdef DEBUG
  63. printk(KERN_DEBUG "OMAP_TAP_IDCODE 0x%08x REV %i HAWKEYE 0x%04x MANF %03x\n",
  64. idcode, rev, hawkeye, (idcode >> 1) & 0x7ff);
  65. printk(KERN_DEBUG "OMAP_TAP_DIE_ID_0: 0x%08x\n",
  66. read_tap_reg(OMAP_TAP_DIE_ID_0));
  67. printk(KERN_DEBUG "OMAP_TAP_DIE_ID_1: 0x%08x DEV_REV: %i\n",
  68. read_tap_reg(OMAP_TAP_DIE_ID_1),
  69. (read_tap_reg(OMAP_TAP_DIE_ID_1) >> 28) & 0xf);
  70. printk(KERN_DEBUG "OMAP_TAP_DIE_ID_2: 0x%08x\n",
  71. read_tap_reg(OMAP_TAP_DIE_ID_2));
  72. printk(KERN_DEBUG "OMAP_TAP_DIE_ID_3: 0x%08x\n",
  73. read_tap_reg(OMAP_TAP_DIE_ID_3));
  74. printk(KERN_DEBUG "OMAP_TAP_PROD_ID_0: 0x%08x DEV_TYPE: %i\n",
  75. prod_id, dev_type);
  76. #endif
  77. /* Check hawkeye ids */
  78. for (i = 0; i < ARRAY_SIZE(omap_ids); i++) {
  79. if (hawkeye == omap_ids[i].hawkeye)
  80. break;
  81. }
  82. if (i == ARRAY_SIZE(omap_ids)) {
  83. printk(KERN_ERR "Unknown OMAP CPU id\n");
  84. return;
  85. }
  86. for (j = i; j < ARRAY_SIZE(omap_ids); j++) {
  87. if (dev_type == omap_ids[j].dev)
  88. break;
  89. }
  90. if (j == ARRAY_SIZE(omap_ids)) {
  91. printk(KERN_ERR "Unknown OMAP device type. "
  92. "Handling it as OMAP%04x\n",
  93. omap_ids[i].type >> 16);
  94. j = i;
  95. }
  96. system_rev = omap_ids[j].type;
  97. system_rev |= rev << 8;
  98. /* Add the cpu class info (24xx) */
  99. system_rev |= 0x24;
  100. pr_info("OMAP%04x", system_rev >> 16);
  101. if ((system_rev >> 8) & 0x0f)
  102. printk("%x", (system_rev >> 8) & 0x0f);
  103. printk("\n");
  104. }