speed.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 <mpc8260.h>
  25. #include <asm/processor.h>
  26. /* ------------------------------------------------------------------------- */
  27. /* Bus-to-Core Multiplier */
  28. #define _1x 2
  29. #define _1_5x 3
  30. #define _2x 4
  31. #define _2_5x 5
  32. #define _3x 6
  33. #define _3_5x 7
  34. #define _4x 8
  35. #define _4_5x 9
  36. #define _5x 10
  37. #define _5_5x 11
  38. #define _6x 12
  39. #define _6_5x 13
  40. #define _7x 14
  41. #define _7_5x 15
  42. #define _8x 16
  43. #define _byp -1
  44. #define _off -2
  45. #define _unk -3
  46. typedef struct {
  47. int b2c_mult;
  48. int vco_div;
  49. char *freq_60x;
  50. char *freq_core;
  51. } corecnf_t;
  52. /*
  53. * this table based on "Errata to MPC8260 PowerQUICC II User's Manual",
  54. * Rev. 1, 8/2000, page 10.
  55. */
  56. corecnf_t corecnf_tab[] = {
  57. { _1_5x, 4, " 33-100", " 33-100" }, /* 0x00 */
  58. { _1x, 4, " 50-150", " 50-150" }, /* 0x01 */
  59. { _1x, 8, " 25-75 ", " 25-75 " }, /* 0x02 */
  60. { _byp, -1, " ?-? ", " ?-? " }, /* 0x03 */
  61. { _2x, 2, " 50-150", "100-300" }, /* 0x04 */
  62. { _2x, 4, " 25-75 ", " 50-150" }, /* 0x05 */
  63. { _2_5x, 2, " 40-120", "100-240" }, /* 0x06 */
  64. { _4_5x, 2, " 22-65 ", "100-300" }, /* 0x07 */
  65. { _3x, 2, " 33-100", "100-300" }, /* 0x08 */
  66. { _5_5x, 2, " 18-55 ", "100-300" }, /* 0x09 */
  67. { _4x, 2, " 25-75 ", "100-300" }, /* 0x0A */
  68. { _5x, 2, " 20-60 ", "100-300" }, /* 0x0B */
  69. { _1_5x, 8, " 16-50 ", " 16-50 " }, /* 0x0C */
  70. { _6x, 2, " 16-50 ", "100-300" }, /* 0x0D */
  71. { _3_5x, 2, " 30-85 ", "100-300" }, /* 0x0E */
  72. { _off, -1, " ?-? ", " ?-? " }, /* 0x0F */
  73. { _3x, 4, " 16-50 ", " 50-150" }, /* 0x10 */
  74. { _2_5x, 4, " 20-60 ", " 50-120" }, /* 0x11 */
  75. { _6_5x, 2, " 15-46 ", "100-300" }, /* 0x12 */
  76. { _byp, -1, " ?-? ", " ?-? " }, /* 0x13 */
  77. { _7x, 2, " 14-43 ", "100-300" }, /* 0x14 */
  78. { _2x, 4, " 25-75 ", " 50-150" }, /* 0x15 */
  79. { _7_5x, 2, " 13-40 ", "100-300" }, /* 0x16 */
  80. { _4_5x, 2, " 22-65 ", "100-300" }, /* 0x17 */
  81. { _unk, -1, " ?-? ", " ?-? " }, /* 0x18 */
  82. { _5_5x, 2, " 18-55 ", "100-300" }, /* 0x19 */
  83. { _4x, 2, " 25-75 ", "100-300" }, /* 0x1A */
  84. { _5x, 2, " 20-60 ", "100-300" }, /* 0x1B */
  85. { _8x, 2, " 12-38 ", "100-300" }, /* 0x1C */
  86. { _6x, 2, " 16-50 ", "100-300" }, /* 0x1D */
  87. { _3_5x, 2, " 30-85 ", "100-300" }, /* 0x1E */
  88. { _off, -1, " ?-? ", " ?-? " }, /* 0x1F */
  89. };
  90. /* ------------------------------------------------------------------------- */
  91. /*
  92. *
  93. */
  94. int get_clocks (void)
  95. {
  96. DECLARE_GLOBAL_DATA_PTR;
  97. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  98. ulong clkin;
  99. ulong sccr, dfbrg;
  100. ulong scmr, corecnf, busdf, cpmdf, plldf, pllmf;
  101. corecnf_t *cp;
  102. #if !defined(CONFIG_8260_CLKIN)
  103. #error clock measuring not implemented yet - define CONFIG_8260_CLKIN
  104. #else
  105. clkin = CONFIG_8260_CLKIN;
  106. #endif
  107. sccr = immap->im_clkrst.car_sccr;
  108. dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
  109. scmr = immap->im_clkrst.car_scmr;
  110. corecnf = (scmr & SCMR_CORECNF_MSK) >> SCMR_CORECNF_SHIFT;
  111. busdf = (scmr & SCMR_BUSDF_MSK) >> SCMR_BUSDF_SHIFT;
  112. cpmdf = (scmr & SCMR_CPMDF_MSK) >> SCMR_CPMDF_SHIFT;
  113. plldf = (scmr & SCMR_PLLDF) ? 1 : 0;
  114. pllmf = (scmr & SCMR_PLLMF_MSK) >> SCMR_PLLMF_SHIFT;
  115. cp = &corecnf_tab[corecnf];
  116. gd->vco_out = (clkin * 2 * (pllmf + 1)) / (plldf + 1);
  117. #if 0
  118. if (gd->vco_out / (busdf + 1) != clkin) {
  119. /* aaarrrggghhh!!! */
  120. return (1);
  121. }
  122. #endif
  123. gd->cpm_clk = gd->vco_out / 2;
  124. gd->bus_clk = clkin;
  125. gd->scc_clk = gd->vco_out / 4;
  126. gd->brg_clk = gd->vco_out / (1 << (2 * (dfbrg + 1)));
  127. if (cp->b2c_mult > 0) {
  128. gd->cpu_clk = (clkin * cp->b2c_mult) / 2;
  129. } else {
  130. gd->cpu_clk = clkin;
  131. }
  132. return (0);
  133. }
  134. int prt_8260_clks (void)
  135. {
  136. DECLARE_GLOBAL_DATA_PTR;
  137. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  138. ulong sccr, dfbrg;
  139. ulong scmr, corecnf, busdf, cpmdf, plldf, pllmf;
  140. corecnf_t *cp;
  141. sccr = immap->im_clkrst.car_sccr;
  142. dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
  143. scmr = immap->im_clkrst.car_scmr;
  144. corecnf = (scmr & SCMR_CORECNF_MSK) >> SCMR_CORECNF_SHIFT;
  145. busdf = (scmr & SCMR_BUSDF_MSK) >> SCMR_BUSDF_SHIFT;
  146. cpmdf = (scmr & SCMR_CPMDF_MSK) >> SCMR_CPMDF_SHIFT;
  147. plldf = (scmr & SCMR_PLLDF) ? 1 : 0;
  148. pllmf = (scmr & SCMR_PLLMF_MSK) >> SCMR_PLLMF_SHIFT;
  149. cp = &corecnf_tab[corecnf];
  150. printf ("MPC8260 Clock Configuration\n - Bus-to-Core Mult ");
  151. switch (cp->b2c_mult) {
  152. case _byp:
  153. printf ("BYPASS");
  154. break;
  155. case _off:
  156. printf ("OFF");
  157. break;
  158. case _unk:
  159. printf ("UNKNOWN");
  160. break;
  161. default:
  162. printf ("%d%sx",
  163. cp->b2c_mult / 2,
  164. (cp->b2c_mult % 2) ? ".5" : "");
  165. break;
  166. }
  167. printf (", VCO Div %d, 60x Bus Freq %s, Core Freq %s\n",
  168. cp->vco_div, cp->freq_60x, cp->freq_core);
  169. printf (" - dfbrg %ld, corecnf 0x%02lx, busdf %ld, cpmdf %ld, "
  170. "plldf %ld, pllmf %ld\n", dfbrg, corecnf, busdf, cpmdf, plldf,
  171. pllmf);
  172. printf (" - vco_out %10ld, scc_clk %10ld, brg_clk %10ld\n",
  173. gd->vco_out, gd->scc_clk, gd->brg_clk);
  174. printf (" - cpu_clk %10ld, cpm_clk %10ld, bus_clk %10ld\n\n",
  175. gd->cpu_clk, gd->cpm_clk, gd->bus_clk);
  176. return (0);
  177. }
  178. /* ------------------------------------------------------------------------- */