]>
Commit | Line | Data |
---|---|---|
debb7354 JL |
1 | /* |
2 | * Copyright 2004 Freescale Semiconductor. | |
c934f655 | 3 | * Jeff Brown |
debb7354 JL |
4 | * Srikanth Srinivasan (srikanth.srinivasan@freescale.com) |
5 | * | |
6 | * (C) Copyright 2000-2002 | |
7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
8 | * | |
9 | * See file CREDITS for list of people who contributed to this | |
10 | * project. | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or | |
13 | * modify it under the terms of the GNU General Public License as | |
14 | * published by the Free Software Foundation; either version 2 of | |
15 | * the License, or (at your option) any later version. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, | |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | * GNU General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License | |
23 | * along with this program; if not, write to the Free Software | |
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
25 | * MA 02111-1307 USA | |
26 | */ | |
27 | ||
28 | #include <common.h> | |
29 | #include <mpc86xx.h> | |
30 | #include <asm/processor.h> | |
31 | ||
1218abf1 | 32 | DECLARE_GLOBAL_DATA_PTR; |
debb7354 | 33 | |
409ecdc0 WD |
34 | /* used in some defintiions of CONFIG_SYS_CLK_FREQ */ |
35 | extern unsigned long get_board_sys_clk(unsigned long dummy); | |
36 | ||
ffff3ae5 | 37 | void get_sys_info(sys_info_t *sysInfo) |
debb7354 | 38 | { |
6d0f6bcf | 39 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
debb7354 JL |
40 | volatile ccsr_gur_t *gur = &immap->im_gur; |
41 | uint plat_ratio, e600_ratio; | |
42 | ||
c934f655 | 43 | plat_ratio = (gur->porpllsr) & 0x0000003e; |
debb7354 | 44 | plat_ratio >>= 1; |
5c9efb36 | 45 | |
ffff3ae5 | 46 | switch (plat_ratio) { |
c934f655 | 47 | case 0x0: |
debb7354 JL |
48 | sysInfo->freqSystemBus = 16 * CONFIG_SYS_CLK_FREQ; |
49 | break; | |
50 | case 0x02: | |
51 | case 0x03: | |
52 | case 0x04: | |
53 | case 0x05: | |
54 | case 0x06: | |
55 | case 0x08: | |
56 | case 0x09: | |
57 | case 0x0a: | |
58 | case 0x0c: | |
c934f655 JL |
59 | case 0x10: |
60 | sysInfo->freqSystemBus = plat_ratio * CONFIG_SYS_CLK_FREQ; | |
61 | break; | |
debb7354 | 62 | default: |
ffff3ae5 | 63 | sysInfo->freqSystemBus = 0; |
debb7354 JL |
64 | break; |
65 | } | |
66 | ||
debb7354 JL |
67 | e600_ratio = (gur->porpllsr) & 0x003f0000; |
68 | e600_ratio >>= 16; | |
5c9efb36 JL |
69 | |
70 | switch (e600_ratio) { | |
debb7354 | 71 | case 0x10: |
5c9efb36 | 72 | sysInfo->freqProcessor = 2 * sysInfo->freqSystemBus; |
debb7354 | 73 | break; |
c934f655 | 74 | case 0x19: |
ffff3ae5 | 75 | sysInfo->freqProcessor = 5 * sysInfo->freqSystemBus / 2; |
debb7354 JL |
76 | break; |
77 | case 0x20: | |
5c9efb36 | 78 | sysInfo->freqProcessor = 3 * sysInfo->freqSystemBus; |
debb7354 | 79 | break; |
c934f655 | 80 | case 0x39: |
ffff3ae5 | 81 | sysInfo->freqProcessor = 7 * sysInfo->freqSystemBus / 2; |
debb7354 JL |
82 | break; |
83 | case 0x28: | |
5c9efb36 | 84 | sysInfo->freqProcessor = 4 * sysInfo->freqSystemBus; |
debb7354 JL |
85 | break; |
86 | case 0x1d: | |
ffff3ae5 | 87 | sysInfo->freqProcessor = 9 * sysInfo->freqSystemBus / 2; |
debb7354 | 88 | break; |
c934f655 | 89 | default: |
5c9efb36 | 90 | sysInfo->freqProcessor = e600_ratio + sysInfo->freqSystemBus; |
debb7354 JL |
91 | break; |
92 | } | |
debb7354 JL |
93 | } |
94 | ||
95 | ||
debb7354 JL |
96 | /* |
97 | * Measure CPU clock speed (core clock GCLK1, GCLK2) | |
debb7354 JL |
98 | * (Approx. GCLK frequency in Hz) |
99 | */ | |
100 | ||
5c9efb36 | 101 | int get_clocks(void) |
debb7354 | 102 | { |
debb7354 JL |
103 | sys_info_t sys_info; |
104 | ||
5c9efb36 | 105 | get_sys_info(&sys_info); |
debb7354 JL |
106 | gd->cpu_clk = sys_info.freqProcessor; |
107 | gd->bus_clk = sys_info.freqSystemBus; | |
1b9ed257 TT |
108 | |
109 | /* | |
110 | * The base clock for I2C depends on the actual SOC. Unfortunately, | |
111 | * there is no pattern that can be used to determine the frequency, so | |
112 | * the only choice is to look up the actual SOC number and use the value | |
113 | * for that SOC. This information is taken from application note | |
114 | * AN2919. | |
115 | */ | |
116 | #ifdef CONFIG_MPC8610 | |
943afa22 | 117 | gd->i2c1_clk = sys_info.freqSystemBus; |
1b9ed257 TT |
118 | #else |
119 | gd->i2c1_clk = sys_info.freqSystemBus / 2; | |
120 | #endif | |
121 | gd->i2c2_clk = gd->i2c1_clk; | |
5c9efb36 JL |
122 | |
123 | if (gd->cpu_clk != 0) | |
124 | return 0; | |
125 | else | |
126 | return 1; | |
debb7354 JL |
127 | } |
128 | ||
5c9efb36 JL |
129 | |
130 | /* | |
debb7354 | 131 | * get_bus_freq |
5c9efb36 JL |
132 | * Return system bus freq in Hz |
133 | */ | |
c934f655 | 134 | |
5c9efb36 | 135 | ulong get_bus_freq(ulong dummy) |
debb7354 JL |
136 | { |
137 | ulong val; | |
debb7354 JL |
138 | sys_info_t sys_info; |
139 | ||
5c9efb36 | 140 | get_sys_info(&sys_info); |
debb7354 JL |
141 | val = sys_info.freqSystemBus; |
142 | ||
143 | return val; | |
144 | } |