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 /* PLL_CFG[0:4] table for cpu 7448/7447A/7455/7457 */
56 static const int hid1_74xx_multipliers_x_10[] = {
57 115, /* 00000 - 11.5x */
58 170, /* 00001 - 17x */
59 75, /* 00010 - 7.5x */
60 150, /* 00011 - 15x */
62 180, /* 00101 - 18x */
63 10, /* 00110 - bypass */
64 200, /* 00111 - 20x */
66 210, /* 01001 - 21x */
67 65, /* 01010 - 6.5x */
68 130, /* 01011 - 13x */
69 85, /* 01100 - 8.5x */
70 240, /* 01101 - 24x */
71 95, /* 01110 - 9.5x */
74 105, /* 10001 - 10.5x */
75 55, /* 10010 - 5.5x */
76 110, /* 10011 - 11x */
78 100, /* 10101 - 10x */
80 120, /* 10111 - 12x */
82 140, /* 11001 - 14x */
84 160, /* 11011 - 16x */
85 135, /* 11100 - 13.5x */
86 280, /* 11101 - 28x */
88 125 /* 11111 - 12.5x */
91 static const int hid1_fx_multipliers_x_10[] = {
94 10, /* 0010 - bypass */
95 10, /* 0011 - bypass */
101 45, /* 1001 - 4.5x */
103 55, /* 1011 - 5.5x */
105 65, /* 1101 - 6.5x */
109 85, /* 10001 - 8.5x */
111 95, /* 10011 - 9.5x */
112 100, /* 10100 - 10x */
113 110, /* 10101 - 11x */
114 120, /* 10110 - 12x */
118 /* ------------------------------------------------------------------------- */
121 * Measure CPU clock speed (core clock GCLK1, GCLK2)
123 * (Approx. GCLK frequency in Hz)
126 int get_clocks (void)
130 #ifdef CONFIG_SYS_BUS_CLK
131 gd->bus_clk = CONFIG_SYS_BUS_CLK; /* bus clock is a fixed frequency */
133 gd->bus_clk = get_board_bus_clk (); /* bus clock is configurable */
136 /* calculate the clock frequency based upon the CPU type */
137 switch (get_cpu_type()) {
143 * Make sure division is done before multiplication to prevent 32-bit
144 * arithmetic overflows which will cause a negative number
146 clock = (gd->bus_clk / 10) *
147 hid1_74xx_multipliers_x_10[(get_hid1 () >> 12) & 0x1F];
152 clock = (gd->bus_clk / 10) *
153 hid1_fx_multipliers_x_10[get_hid1 () >> 27];
167 * Make sure division is done before multiplication to prevent 32-bit
168 * arithmetic overflows which will cause a negative number
170 clock = (gd->bus_clk / 10) *
171 hid1_multipliers_x_10[get_hid1 () >> 28];
175 printf ("get_gclk_freq(): unknown CPU type\n");
185 /* ------------------------------------------------------------------------- */