id.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 <asm/io.h>
  16. #define JTAG_ID_BASE 0x01c40028
  17. struct davinci_id {
  18. u8 variant; /* JTAG ID bits 31:28 */
  19. u16 part_no; /* JTAG ID bits 27:12 */
  20. u32 manufacturer; /* JTAG ID bits 11:1 */
  21. u32 type; /* Cpu id bits [31:8], cpu class bits [7:0] */
  22. };
  23. /* Register values to detect the DaVinci version */
  24. static struct davinci_id davinci_ids[] __initdata = {
  25. {
  26. /* DM6446 */
  27. .part_no = 0xb700,
  28. .variant = 0x0,
  29. .manufacturer = 0x017,
  30. .type = 0x64460000,
  31. },
  32. };
  33. /*
  34. * Get Device Part No. from JTAG ID register
  35. */
  36. static u16 __init davinci_get_part_no(void)
  37. {
  38. u32 dev_id, part_no;
  39. dev_id = davinci_readl(JTAG_ID_BASE);
  40. part_no = ((dev_id >> 12) & 0xffff);
  41. return part_no;
  42. }
  43. /*
  44. * Get Device Revision from JTAG ID register
  45. */
  46. static u8 __init davinci_get_variant(void)
  47. {
  48. u32 variant;
  49. variant = davinci_readl(JTAG_ID_BASE);
  50. variant = (variant >> 28) & 0xf;
  51. return variant;
  52. }
  53. void __init davinci_check_revision(void)
  54. {
  55. int i;
  56. u16 part_no;
  57. u8 variant;
  58. part_no = davinci_get_part_no();
  59. variant = davinci_get_variant();
  60. /* First check only the major version in a safe way */
  61. for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
  62. if (part_no == (davinci_ids[i].part_no)) {
  63. system_rev = davinci_ids[i].type;
  64. break;
  65. }
  66. }
  67. /* Check if we can find the dev revision */
  68. for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
  69. if (part_no == davinci_ids[i].part_no &&
  70. variant == davinci_ids[i].variant) {
  71. system_rev = davinci_ids[i].type;
  72. break;
  73. }
  74. }
  75. printk("DaVinci DM%04x variant 0x%x\n", system_rev >> 16, variant);
  76. }