]>
Commit | Line | Data |
---|---|---|
4a9cbbe8 WD |
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 | |
3a473b2a | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4a9cbbe8 WD |
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 | ||
24 | #include <common.h> | |
25 | #include <74xx_7xx.h> | |
26 | #include <asm/processor.h> | |
27 | ||
c7de829c WD |
28 | #ifdef CONFIG_AMIGAONEG3SE |
29 | #include "../board/MAI/AmigaOneG3SE/via686.h" | |
30 | #endif | |
31 | ||
d87080b7 WD |
32 | DECLARE_GLOBAL_DATA_PTR; |
33 | ||
4a9cbbe8 WD |
34 | static const int hid1_multipliers_x_10[] = { |
35 | 25, /* 0000 - 2.5x */ | |
36 | 75, /* 0001 - 7.5x */ | |
37 | 70, /* 0010 - 7x */ | |
38 | 10, /* 0011 - bypass */ | |
39 | 20, /* 0100 - 2x */ | |
40 | 65, /* 0101 - 6.5x */ | |
41 | 100, /* 0110 - 10x */ | |
42 | 45, /* 0111 - 4.5x */ | |
43 | 30, /* 1000 - 3x */ | |
44 | 55, /* 1001 - 5.5x */ | |
45 | 40, /* 1010 - 4x */ | |
46 | 50, /* 1011 - 5x */ | |
47 | 80, /* 1100 - 8x */ | |
48 | 60, /* 1101 - 6x */ | |
49 | 35, /* 1110 - 3.5x */ | |
50 | 0 /* 1111 - off */ | |
51 | }; | |
52 | ||
72755c71 | 53 | static const int hid1_fx_multipliers_x_10[] = { |
3a473b2a WD |
54 | 00, /* 0000 - off */ |
55 | 00, /* 0001 - off */ | |
56 | 10, /* 0010 - bypass */ | |
57 | 10, /* 0011 - bypass */ | |
58 | 20, /* 0100 - 2x */ | |
59 | 25, /* 0101 - 2.5x */ | |
60 | 30, /* 0110 - 3x */ | |
61 | 35, /* 0111 - 3.5x */ | |
62 | 40, /* 1000 - 4x */ | |
63 | 45, /* 1001 - 4.5x */ | |
64 | 50, /* 1010 - 5x */ | |
65 | 55, /* 1011 - 5.5x */ | |
66 | 60, /* 1100 - 6x */ | |
67 | 65, /* 1101 - 6.5x */ | |
68 | 70, /* 1110 - 7x */ | |
69 | 75, /* 1111 - 7.5 */ | |
70 | 80, /* 10000 - 8x */ | |
71 | 85, /* 10001 - 8.5x */ | |
72 | 90, /* 10010 - 9x */ | |
73 | 95, /* 10011 - 9.5x */ | |
74 | 100, /* 10100 - 10x */ | |
75 | 110, /* 10101 - 11x */ | |
76 | 120, /* 10110 - 12x */ | |
72755c71 WD |
77 | }; |
78 | ||
79 | ||
4a9cbbe8 WD |
80 | /* ------------------------------------------------------------------------- */ |
81 | ||
82 | /* | |
83 | * Measure CPU clock speed (core clock GCLK1, GCLK2) | |
84 | * | |
85 | * (Approx. GCLK frequency in Hz) | |
86 | */ | |
87 | ||
88 | int get_clocks (void) | |
89 | { | |
3a473b2a WD |
90 | ulong clock = 0; |
91 | ||
92 | /* calculate the clock frequency based upon the CPU type */ | |
93 | switch (get_cpu_type()) { | |
94 | case CPU_7455: | |
95 | case CPU_7457: | |
96 | /* | |
97 | * It is assumed that the PLL_EXT line is zero. | |
98 | * Make sure division is done before multiplication to prevent 32-bit | |
99 | * arithmetic overflows which will cause a negative number | |
100 | */ | |
101 | clock = (CFG_BUS_CLK / 10) * hid1_multipliers_x_10[(get_hid1 () >> 13) & 0xF]; | |
102 | break; | |
103 | ||
104 | case CPU_750GX: | |
105 | case CPU_750FX: | |
106 | clock = CFG_BUS_CLK * hid1_fx_multipliers_x_10[get_hid1 () >> 27] / 10; | |
107 | break; | |
108 | ||
109 | case CPU_7450: | |
110 | case CPU_740: | |
111 | case CPU_740P: | |
112 | case CPU_745: | |
113 | case CPU_750CX: | |
114 | case CPU_750: | |
115 | case CPU_750P: | |
116 | case CPU_755: | |
117 | case CPU_7400: | |
118 | case CPU_7410: | |
119 | /* | |
120 | * Make sure division is done before multiplication to prevent 32-bit | |
121 | * arithmetic overflows which will cause a negative number | |
122 | */ | |
123 | clock = (CFG_BUS_CLK / 10) * hid1_multipliers_x_10[get_hid1 () >> 28]; | |
124 | break; | |
125 | ||
126 | case CPU_UNKNOWN: | |
127 | printf ("get_gclk_freq(): unknown CPU type\n"); | |
128 | clock = 0; | |
129 | return (1); | |
130 | } | |
131 | ||
4a9cbbe8 WD |
132 | gd->cpu_clk = clock; |
133 | gd->bus_clk = CFG_BUS_CLK; | |
134 | ||
135 | return (0); | |
136 | } | |
137 | ||
138 | /* ------------------------------------------------------------------------- */ |