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 #ifdef CONFIG_AMIGAONEG3SE
29 #include "../board/MAI/AmigaOneG3SE/via686.h"
32 DECLARE_GLOBAL_DATA_PTR;
34 extern unsigned long get_board_bus_clk (void);
36 static const int hid1_multipliers_x_10[] = {
40 10, /* 0011 - bypass */
55 static const int hid1_7447A_multipliers_x_10[] = {
56 115, /* 00000 - 11.5x */
57 170, /* 00001 - 17x */
58 75, /* 00010 - 7.5x */
59 150, /* 00011 - 15x */
61 180, /* 00101 - 18x */
62 10, /* 00110 - bypass */
63 200, /* 00111 - 20x */
65 210, /* 01001 - 21x */
66 65, /* 01010 - 6.5x */
67 130, /* 01011 - 13x */
68 85, /* 01100 - 8.5x */
69 240, /* 01101 - 13x */
70 95, /* 01110 - 9.5x */
73 105, /* 10001 - 10.5x */
74 55, /* 10010 - 5.5x */
75 110, /* 10011 - 11x */
77 100, /* 10101 - 10x */
79 120, /* 10111 - 12x */
81 140, /* 11001 - 14x */
83 160, /* 11011 - 16x */
84 135, /* 11100 - 13.5x */
85 280, /* 11101 - 28x */
87 125 /* 11111 - 12.5x */
90 static const int hid1_fx_multipliers_x_10[] = {
93 10, /* 0010 - bypass */
94 10, /* 0011 - bypass */
100 45, /* 1001 - 4.5x */
102 55, /* 1011 - 5.5x */
104 65, /* 1101 - 6.5x */
108 85, /* 10001 - 8.5x */
110 95, /* 10011 - 9.5x */
111 100, /* 10100 - 10x */
112 110, /* 10101 - 11x */
113 120, /* 10110 - 12x */
117 /* ------------------------------------------------------------------------- */
120 * Measure CPU clock speed (core clock GCLK1, GCLK2)
122 * (Approx. GCLK frequency in Hz)
125 int get_clocks (void)
129 #ifdef CFG_CONFIG_BUS_CLK
130 gd->bus_clk = get_board_bus_clk (); /* bus clock is configurable */
132 gd->bus_clk = CFG_BUS_CLK; /* bus clock is a fixed frequency */
135 /* calculate the clock frequency based upon the CPU type */
136 switch (get_cpu_type()) {
139 clock = (gd->bus_clk / 10) *
140 hid1_7447A_multipliers_x_10[(get_hid1 () >> 12) & 0x1F];
146 * It is assumed that the PLL_EXT line is zero.
147 * Make sure division is done before multiplication to prevent 32-bit
148 * arithmetic overflows which will cause a negative number
150 clock = (gd->bus_clk / 10) *
151 hid1_multipliers_x_10[(get_hid1 () >> 13) & 0xF];
156 clock = gd->bus_clk *
157 hid1_fx_multipliers_x_10[get_hid1 () >> 27] / 10;
171 * Make sure division is done before multiplication to prevent 32-bit
172 * arithmetic overflows which will cause a negative number
174 clock = (gd->bus_clk / 10) *
175 hid1_multipliers_x_10[get_hid1 () >> 28];
179 printf ("get_gclk_freq(): unknown CPU type\n");
189 /* ------------------------------------------------------------------------- */