id.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Davinci CPU identification code
  3. *
  4. * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
  5. *
  6. * Derived from OMAP1 CPU identification code.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #define JTAG_ID_BASE IO_ADDRESS(0x01c40028)
  17. static unsigned int davinci_revision;
  18. struct davinci_id {
  19. u8 variant; /* JTAG ID bits 31:28 */
  20. u16 part_no; /* JTAG ID bits 27:12 */
  21. u32 manufacturer; /* JTAG ID bits 11:1 */
  22. u32 type; /* Cpu id bits [31:8], cpu class bits [7:0] */
  23. };
  24. /* Register values to detect the DaVinci version */
  25. static struct davinci_id davinci_ids[] __initdata = {
  26. {
  27. /* DM6446 */
  28. .part_no = 0xb700,
  29. .variant = 0x0,
  30. .manufacturer = 0x017,
  31. .type = 0x64460000,
  32. },
  33. {
  34. /* DM646X */
  35. .part_no = 0xb770,
  36. .variant = 0x0,
  37. .manufacturer = 0x017,
  38. .type = 0x64670000,
  39. },
  40. {
  41. /* DM355 */
  42. .part_no = 0xb73b,
  43. .variant = 0x0,
  44. .manufacturer = 0x00f,
  45. .type = 0x03550000,
  46. },
  47. };
  48. /*
  49. * Get Device Part No. from JTAG ID register
  50. */
  51. static u16 __init davinci_get_part_no(void)
  52. {
  53. u32 dev_id, part_no;
  54. dev_id = __raw_readl(JTAG_ID_BASE);
  55. part_no = ((dev_id >> 12) & 0xffff);
  56. return part_no;
  57. }
  58. /*
  59. * Get Device Revision from JTAG ID register
  60. */
  61. static u8 __init davinci_get_variant(void)
  62. {
  63. u32 variant;
  64. variant = __raw_readl(JTAG_ID_BASE);
  65. variant = (variant >> 28) & 0xf;
  66. return variant;
  67. }
  68. unsigned int davinci_rev(void)
  69. {
  70. return davinci_revision >> 16;
  71. }
  72. EXPORT_SYMBOL(davinci_rev);
  73. void __init davinci_check_revision(void)
  74. {
  75. int i;
  76. u16 part_no;
  77. u8 variant;
  78. part_no = davinci_get_part_no();
  79. variant = davinci_get_variant();
  80. /* First check only the major version in a safe way */
  81. for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
  82. if (part_no == (davinci_ids[i].part_no)) {
  83. davinci_revision = davinci_ids[i].type;
  84. break;
  85. }
  86. }
  87. /* Check if we can find the dev revision */
  88. for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
  89. if (part_no == davinci_ids[i].part_no &&
  90. variant == davinci_ids[i].variant) {
  91. davinci_revision = davinci_ids[i].type;
  92. break;
  93. }
  94. }
  95. printk(KERN_INFO "DaVinci DM%04x variant 0x%x\n",
  96. davinci_rev(), variant);
  97. }