speed.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * (C) Copyright 2000-2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <74xx_7xx.h>
  25. #include <asm/processor.h>
  26. #ifdef CONFIG_AMIGAONEG3SE
  27. #include "../board/MAI/AmigaOneG3SE/via686.h"
  28. #endif
  29. static const int hid1_multipliers_x_10[] = {
  30. 25, /* 0000 - 2.5x */
  31. 75, /* 0001 - 7.5x */
  32. 70, /* 0010 - 7x */
  33. 10, /* 0011 - bypass */
  34. 20, /* 0100 - 2x */
  35. 65, /* 0101 - 6.5x */
  36. 100, /* 0110 - 10x */
  37. 45, /* 0111 - 4.5x */
  38. 30, /* 1000 - 3x */
  39. 55, /* 1001 - 5.5x */
  40. 40, /* 1010 - 4x */
  41. 50, /* 1011 - 5x */
  42. 80, /* 1100 - 8x */
  43. 60, /* 1101 - 6x */
  44. 35, /* 1110 - 3.5x */
  45. 0 /* 1111 - off */
  46. };
  47. static const int hid1_fx_multipliers_x_10[] = {
  48. 00, /* 0000 - off */
  49. 00, /* 0001 - off */
  50. 10, /* 0010 - bypass */
  51. 10, /* 0011 - bypass */
  52. 20, /* 0100 - 2x */
  53. 25, /* 0101 - 2.5x */
  54. 30, /* 0110 - 3x */
  55. 35, /* 0111 - 3.5x */
  56. 40, /* 1000 - 4x */
  57. 45, /* 1001 - 4.5x */
  58. 50, /* 1010 - 5x */
  59. 55, /* 1011 - 5.5x */
  60. 60, /* 1100 - 6x */
  61. 65, /* 1101 - 6.5x */
  62. 70, /* 1110 - 7x */
  63. 75, /* 1111 - 7.5 */
  64. 80, /* 10000 - 8x */
  65. 85, /* 10001 - 8.5x */
  66. 90, /* 10010 - 9x */
  67. 95, /* 10011 - 9.5x */
  68. 100, /* 10100 - 10x */
  69. 110, /* 10101 - 11x */
  70. 120, /* 10110 - 12x */
  71. };
  72. /* ------------------------------------------------------------------------- */
  73. /*
  74. * Measure CPU clock speed (core clock GCLK1, GCLK2)
  75. *
  76. * (Approx. GCLK frequency in Hz)
  77. */
  78. int get_clocks (void)
  79. {
  80. DECLARE_GLOBAL_DATA_PTR;
  81. #ifdef CONFIG_750FX
  82. ulong clock = CFG_BUS_CLK * \
  83. hid1_fx_multipliers_x_10[get_hid1 () >> 27] / 10;
  84. #else
  85. ulong clock = CFG_BUS_CLK * \
  86. hid1_multipliers_x_10[get_hid1 () >> 28] / 10;
  87. #endif
  88. gd->cpu_clk = clock;
  89. gd->bus_clk = CFG_BUS_CLK;
  90. return (0);
  91. }
  92. /* ------------------------------------------------------------------------- */
  93. #if 0 /* disabled XXX - use global data instead */
  94. ulong get_bus_freq (ulong gclk_freq)
  95. {
  96. return CFG_BUS_CLK;
  97. }
  98. #endif /* 0 */
  99. /* ------------------------------------------------------------------------- */