speed.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * (C) Copyright 2004, Freescale, Inc
  3. * TsiChung Liew, Tsi-Chung.Liew@freescale.com.
  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 <mpc8220.h>
  25. #include <asm/processor.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. typedef struct pllmultiplier {
  28. u8 hid1;
  29. int multi;
  30. int vco_div;
  31. } pllcfg_t;
  32. /* ------------------------------------------------------------------------- */
  33. /*
  34. *
  35. */
  36. int get_clocks (void)
  37. {
  38. pllcfg_t bus2core[] = {
  39. {0x02, 2, 8}, /* 1 */
  40. {0x01, 2, 4},
  41. {0x0C, 3, 8}, /* 1.5 */
  42. {0x00, 3, 4},
  43. {0x18, 3, 2},
  44. {0x05, 4, 4}, /* 2 */
  45. {0x04, 4, 2},
  46. {0x11, 5, 4}, /* 2.5 */
  47. {0x06, 5, 2},
  48. {0x10, 6, 4}, /* 3 */
  49. {0x08, 6, 2},
  50. {0x0E, 7, 2}, /* 3.5 */
  51. {0x0A, 8, 2}, /* 4 */
  52. {0x07, 9, 2}, /* 4.5 */
  53. {0x0B, 10, 2}, /* 5 */
  54. {0x09, 11, 2}, /* 5.5 */
  55. {0x0D, 12, 2}, /* 6 */
  56. {0x12, 13, 2}, /* 6.5 */
  57. {0x14, 14, 2}, /* 7 */
  58. {0x16, 15, 2}, /* 7.5 */
  59. {0x1C, 16, 2} /* 8 */
  60. };
  61. u32 hid1;
  62. int i, size, pci2bus;
  63. #if !defined(CONFIG_SYS_MPC8220_CLKIN)
  64. #error clock measuring not implemented yet - define CONFIG_SYS_MPC8220_CLKIN
  65. #endif
  66. gd->inp_clk = CONFIG_SYS_MPC8220_CLKIN;
  67. /* Read XLB to PCI(INP) clock multiplier */
  68. pci2bus = (*((volatile u32 *)PCI_REG_PCIGSCR) &
  69. PCI_REG_PCIGSCR_PCI2XLB_CLK_MASK)>>PCI_REG_PCIGSCR_PCI2XLB_CLK_BIT;
  70. /* XLB bus clock */
  71. gd->bus_clk = CONFIG_SYS_MPC8220_CLKIN * pci2bus;
  72. /* PCI clock is same as input clock */
  73. gd->pci_clk = CONFIG_SYS_MPC8220_CLKIN;
  74. /* FlexBus is temporary set as the same as input clock */
  75. /* will do dynamic in the future */
  76. gd->flb_clk = CONFIG_SYS_MPC8220_CLKIN;
  77. /* CPU Clock - Read HID1 */
  78. asm volatile ("mfspr %0, 1009":"=r" (hid1):);
  79. size = sizeof (bus2core) / sizeof (pllcfg_t);
  80. hid1 >>= 27;
  81. for (i = 0; i < size; i++)
  82. if (hid1 == bus2core[i].hid1) {
  83. gd->cpu_clk = (bus2core[i].multi * gd->bus_clk) >> 1;
  84. gd->vco_clk = CONFIG_SYS_MPC8220_SYSPLL_VCO_MULTIPLIER * (gd->pci_clk * bus2core[i].vco_div)/2;
  85. break;
  86. }
  87. /* hardcoded 81MHz for now */
  88. gd->pev_clk = 81000000;
  89. return (0);
  90. }
  91. int prt_mpc8220_clks (void)
  92. {
  93. char buf1[32], buf2[32], buf3[32], buf4[32];
  94. printf (" Bus %s MHz, CPU %s MHz, PCI %s MHz, VCO %s MHz\n",
  95. strmhz(buf1, gd->bus_clk),
  96. strmhz(buf2, gd->cpu_clk),
  97. strmhz(buf3, gd->pci_clk),
  98. strmhz(buf4, gd->vco_clk)
  99. );
  100. return (0);
  101. }
  102. /* ------------------------------------------------------------------------- */