2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
26 #include <asm/processor.h>
28 DECLARE_GLOBAL_DATA_PTR;
30 extern unsigned long get_board_bus_clk (void);
32 static const int hid1_multipliers_x_10[] = {
36 10, /* 0011 - bypass */
51 /* PLL_CFG[0:4] table for cpu 7448/7447A/7455/7457 */
52 static const int hid1_74xx_multipliers_x_10[] = {
53 115, /* 00000 - 11.5x */
54 170, /* 00001 - 17x */
55 75, /* 00010 - 7.5x */
56 150, /* 00011 - 15x */
58 180, /* 00101 - 18x */
59 10, /* 00110 - bypass */
60 200, /* 00111 - 20x */
62 210, /* 01001 - 21x */
63 65, /* 01010 - 6.5x */
64 130, /* 01011 - 13x */
65 85, /* 01100 - 8.5x */
66 240, /* 01101 - 24x */
67 95, /* 01110 - 9.5x */
70 105, /* 10001 - 10.5x */
71 55, /* 10010 - 5.5x */
72 110, /* 10011 - 11x */
74 100, /* 10101 - 10x */
76 120, /* 10111 - 12x */
78 140, /* 11001 - 14x */
80 160, /* 11011 - 16x */
81 135, /* 11100 - 13.5x */
82 280, /* 11101 - 28x */
84 125 /* 11111 - 12.5x */
87 static const int hid1_fx_multipliers_x_10[] = {
90 10, /* 0010 - bypass */
91 10, /* 0011 - bypass */
101 65, /* 1101 - 6.5x */
105 85, /* 10001 - 8.5x */
107 95, /* 10011 - 9.5x */
108 100, /* 10100 - 10x */
109 110, /* 10101 - 11x */
110 120, /* 10110 - 12x */
114 /* ------------------------------------------------------------------------- */
117 * Measure CPU clock speed (core clock GCLK1, GCLK2)
119 * (Approx. GCLK frequency in Hz)
122 int get_clocks (void)
126 #ifdef CONFIG_SYS_BUS_CLK
127 gd->bus_clk = CONFIG_SYS_BUS_CLK; /* bus clock is a fixed frequency */
129 gd->bus_clk = get_board_bus_clk (); /* bus clock is configurable */
132 /* calculate the clock frequency based upon the CPU type */
133 switch (get_cpu_type()) {
139 * Make sure division is done before multiplication to prevent 32-bit
140 * arithmetic overflows which will cause a negative number
142 clock = (gd->bus_clk / 10) *
143 hid1_74xx_multipliers_x_10[(get_hid1 () >> 12) & 0x1F];
148 clock = (gd->bus_clk / 10) *
149 hid1_fx_multipliers_x_10[get_hid1 () >> 27];
163 * Make sure division is done before multiplication to prevent 32-bit
164 * arithmetic overflows which will cause a negative number
166 clock = (gd->bus_clk / 10) *
167 hid1_multipliers_x_10[get_hid1 () >> 28];
171 printf ("get_gclk_freq(): unknown CPU type\n");
181 /* ------------------------------------------------------------------------- */