speed.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <mpc5xxx.h>
  25. #include <asm/processor.h>
  26. /* ------------------------------------------------------------------------- */
  27. /* Bus-to-Core Multipliers */
  28. static int bus2core[] = {
  29. 0, 0, 0, 10, 20, 20, 25, 45,
  30. 30, 55, 40, 50, 0, 60, 35, 0,
  31. 30, 25, 65, 10, 70, 20, 75, 45,
  32. 0, 55, 40, 50, 80, 60, 35, 0
  33. };
  34. /* ------------------------------------------------------------------------- */
  35. /*
  36. *
  37. */
  38. int get_clocks (void)
  39. {
  40. DECLARE_GLOBAL_DATA_PTR;
  41. ulong val, vco;
  42. #if !defined(CFG_MPC5XXX_CLKIN)
  43. #error clock measuring not implemented yet - define CFG_MPC5XXX_CLKIN
  44. #endif
  45. val = *(vu_long *)MPC5XXX_CDM_PORCFG;
  46. if (val & (1 << 6)) {
  47. vco = CFG_MPC5XXX_CLKIN * 12;
  48. } else {
  49. vco = CFG_MPC5XXX_CLKIN * 16;
  50. }
  51. if (val & (1 << 5)) {
  52. gd->bus_clk = vco / 8;
  53. } else {
  54. gd->bus_clk = vco / 4;
  55. }
  56. gd->cpu_clk = gd->bus_clk * bus2core[val & 0x1f] / 10;
  57. val = *(vu_long *)MPC5XXX_CDM_CFG;
  58. if (val & (1 << 8)) {
  59. gd->ipb_clk = gd->bus_clk / 2;
  60. } else {
  61. gd->ipb_clk = gd->bus_clk;
  62. }
  63. switch (val & 3) {
  64. case 0: gd->pci_clk = gd->ipb_clk; break;
  65. case 1: gd->pci_clk = gd->ipb_clk / 2; break;
  66. default: gd->pci_clk = gd->bus_clk / 4; break;
  67. }
  68. return (0);
  69. }
  70. int prt_mpc5xxx_clks (void)
  71. {
  72. DECLARE_GLOBAL_DATA_PTR;
  73. printf(" Bus %ld MHz, IPB %ld MHz, PCI %ld MHz\n",
  74. gd->bus_clk / 1000000, gd->ipb_clk / 1000000,
  75. gd->pci_clk / 1000000);
  76. return (0);
  77. }
  78. /* ------------------------------------------------------------------------- */