2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/processor.h>
12 DECLARE_GLOBAL_DATA_PTR;
14 extern unsigned long get_board_bus_clk (void);
16 static const int hid1_multipliers_x_10[] = {
20 10, /* 0011 - bypass */
35 /* PLL_CFG[0:4] table for cpu 7448/7447A/7455/7457 */
36 static const int hid1_74xx_multipliers_x_10[] = {
37 115, /* 00000 - 11.5x */
38 170, /* 00001 - 17x */
39 75, /* 00010 - 7.5x */
40 150, /* 00011 - 15x */
42 180, /* 00101 - 18x */
43 10, /* 00110 - bypass */
44 200, /* 00111 - 20x */
46 210, /* 01001 - 21x */
47 65, /* 01010 - 6.5x */
48 130, /* 01011 - 13x */
49 85, /* 01100 - 8.5x */
50 240, /* 01101 - 24x */
51 95, /* 01110 - 9.5x */
54 105, /* 10001 - 10.5x */
55 55, /* 10010 - 5.5x */
56 110, /* 10011 - 11x */
58 100, /* 10101 - 10x */
60 120, /* 10111 - 12x */
62 140, /* 11001 - 14x */
64 160, /* 11011 - 16x */
65 135, /* 11100 - 13.5x */
66 280, /* 11101 - 28x */
68 125 /* 11111 - 12.5x */
71 static const int hid1_fx_multipliers_x_10[] = {
74 10, /* 0010 - bypass */
75 10, /* 0011 - bypass */
89 85, /* 10001 - 8.5x */
91 95, /* 10011 - 9.5x */
92 100, /* 10100 - 10x */
93 110, /* 10101 - 11x */
94 120, /* 10110 - 12x */
98 /* ------------------------------------------------------------------------- */
101 * Measure CPU clock speed (core clock GCLK1, GCLK2)
103 * (Approx. GCLK frequency in Hz)
106 int get_clocks (void)
110 #ifdef CONFIG_SYS_BUS_CLK
111 gd->bus_clk = CONFIG_SYS_BUS_CLK; /* bus clock is a fixed frequency */
113 gd->bus_clk = get_board_bus_clk (); /* bus clock is configurable */
116 /* calculate the clock frequency based upon the CPU type */
117 switch (get_cpu_type()) {
123 * Make sure division is done before multiplication to prevent 32-bit
124 * arithmetic overflows which will cause a negative number
126 clock = (gd->bus_clk / 10) *
127 hid1_74xx_multipliers_x_10[(get_hid1 () >> 12) & 0x1F];
132 clock = (gd->bus_clk / 10) *
133 hid1_fx_multipliers_x_10[get_hid1 () >> 27];
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 () >> 28];
155 printf ("get_gclk_freq(): unknown CPU type\n");
165 /* ------------------------------------------------------------------------- */