sys_info.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * sys_info.c
  3. *
  4. * System information functions
  5. *
  6. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  7. *
  8. * Derived from Beagle Board and 3430 SDP code by
  9. * Richard Woodruff <r-woodruff2@ti.com>
  10. * Syed Mohammed Khasim <khasim@ti.com>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  20. * GNU General Public License for more details.
  21. */
  22. #include <common.h>
  23. #include <asm/io.h>
  24. #include <asm/arch/sys_proto.h>
  25. #include <asm/arch/cpu.h>
  26. #include <asm/arch/clock.h>
  27. struct ctrl_stat *cstat = (struct ctrl_stat *)CTRL_BASE;
  28. /**
  29. * get_cpu_rev(void) - extract rev info
  30. */
  31. u32 get_cpu_rev(void)
  32. {
  33. u32 id;
  34. u32 rev;
  35. id = readl(DEVICE_ID);
  36. rev = (id >> 28) & 0xff;
  37. return rev;
  38. }
  39. /**
  40. * get_cpu_type(void) - extract cpu info
  41. */
  42. u32 get_cpu_type(void)
  43. {
  44. u32 id = 0;
  45. u32 partnum;
  46. id = readl(DEVICE_ID);
  47. partnum = (id >> 12) & 0xffff;
  48. return partnum;
  49. }
  50. /**
  51. * get_board_rev() - setup to pass kernel board revision information
  52. * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
  53. */
  54. u32 get_board_rev(void)
  55. {
  56. return BOARD_REV_ID;
  57. }
  58. /**
  59. * get_device_type(): tell if GP/HS/EMU/TST
  60. */
  61. u32 get_device_type(void)
  62. {
  63. int mode;
  64. mode = readl(&cstat->statusreg) & (DEVICE_MASK);
  65. return mode >>= 8;
  66. }
  67. /**
  68. * get_sysboot_value(void) - return SYS_BOOT[4:0]
  69. */
  70. u32 get_sysboot_value(void)
  71. {
  72. int mode;
  73. mode = readl(&cstat->statusreg) & (SYSBOOT_MASK);
  74. return mode;
  75. }
  76. #ifdef CONFIG_DISPLAY_CPUINFO
  77. /**
  78. * Print CPU information
  79. */
  80. int print_cpuinfo(void)
  81. {
  82. char *cpu_s, *sec_s;
  83. int arm_freq, ddr_freq;
  84. switch (get_cpu_type()) {
  85. case AM335X:
  86. cpu_s = "AM335X";
  87. break;
  88. default:
  89. cpu_s = "Unknown cpu type";
  90. break;
  91. }
  92. switch (get_device_type()) {
  93. case TST_DEVICE:
  94. sec_s = "TST";
  95. break;
  96. case EMU_DEVICE:
  97. sec_s = "EMU";
  98. break;
  99. case HS_DEVICE:
  100. sec_s = "HS";
  101. break;
  102. case GP_DEVICE:
  103. sec_s = "GP";
  104. break;
  105. default:
  106. sec_s = "?";
  107. }
  108. printf("AM%s-%s rev %d\n",
  109. cpu_s, sec_s, get_cpu_rev());
  110. /* TODO: Print ARM and DDR frequencies */
  111. return 0;
  112. }
  113. #endif /* CONFIG_DISPLAY_CPUINFO */