Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 5 | * Copyright (C) 2004-2006 Freescale Semiconductor, Inc. |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #include <mpc83xx.h> |
| 28 | #include <asm/processor.h> |
| 29 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 32 | /* ----------------------------------------------------------------- */ |
| 33 | |
| 34 | typedef enum { |
| 35 | _unk, |
| 36 | _off, |
| 37 | _byp, |
| 38 | _x8, |
| 39 | _x4, |
| 40 | _x2, |
| 41 | _x1, |
| 42 | _1x, |
| 43 | _1_5x, |
| 44 | _2x, |
| 45 | _2_5x, |
| 46 | _3x |
| 47 | } mult_t; |
| 48 | |
| 49 | typedef struct { |
| 50 | mult_t core_csb_ratio; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 51 | mult_t vco_divider; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 52 | } corecnf_t; |
| 53 | |
| 54 | corecnf_t corecnf_tab[] = { |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 55 | {_byp, _byp}, /* 0x00 */ |
| 56 | {_byp, _byp}, /* 0x01 */ |
| 57 | {_byp, _byp}, /* 0x02 */ |
| 58 | {_byp, _byp}, /* 0x03 */ |
| 59 | {_byp, _byp}, /* 0x04 */ |
| 60 | {_byp, _byp}, /* 0x05 */ |
| 61 | {_byp, _byp}, /* 0x06 */ |
| 62 | {_byp, _byp}, /* 0x07 */ |
| 63 | {_1x, _x2}, /* 0x08 */ |
| 64 | {_1x, _x4}, /* 0x09 */ |
| 65 | {_1x, _x8}, /* 0x0A */ |
| 66 | {_1x, _x8}, /* 0x0B */ |
| 67 | {_1_5x, _x2}, /* 0x0C */ |
| 68 | {_1_5x, _x4}, /* 0x0D */ |
| 69 | {_1_5x, _x8}, /* 0x0E */ |
| 70 | {_1_5x, _x8}, /* 0x0F */ |
| 71 | {_2x, _x2}, /* 0x10 */ |
| 72 | {_2x, _x4}, /* 0x11 */ |
| 73 | {_2x, _x8}, /* 0x12 */ |
| 74 | {_2x, _x8}, /* 0x13 */ |
| 75 | {_2_5x, _x2}, /* 0x14 */ |
| 76 | {_2_5x, _x4}, /* 0x15 */ |
| 77 | {_2_5x, _x8}, /* 0x16 */ |
| 78 | {_2_5x, _x8}, /* 0x17 */ |
| 79 | {_3x, _x2}, /* 0x18 */ |
| 80 | {_3x, _x4}, /* 0x19 */ |
| 81 | {_3x, _x8}, /* 0x1A */ |
| 82 | {_3x, _x8}, /* 0x1B */ |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | /* ----------------------------------------------------------------- */ |
| 86 | |
| 87 | /* |
| 88 | * |
| 89 | */ |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 90 | int get_clocks(void) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 91 | { |
Timur Tabi | 386a280 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 92 | volatile immap_t *im = (immap_t *) CFG_IMMR; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 93 | u32 pci_sync_in; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 94 | u8 spmf; |
| 95 | u8 clkin_div; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 96 | u32 sccr; |
| 97 | u32 corecnf_tab_index; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 98 | u8 corepll; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 99 | u32 lcrr; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 100 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 101 | u32 csb_clk; |
Kumar Gala | b7870e7 | 2007-01-30 14:08:30 -0600 | [diff] [blame] | 102 | #if defined(CONFIG_MPC834X) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 103 | u32 tsec1_clk; |
| 104 | u32 tsec2_clk; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 105 | u32 usbmph_clk; |
| 106 | u32 usbdr_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 107 | #endif |
| 108 | u32 core_clk; |
| 109 | u32 i2c1_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 110 | #if !defined(CONFIG_MPC832X) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 111 | u32 i2c2_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 112 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 113 | u32 enc_clk; |
| 114 | u32 lbiu_clk; |
| 115 | u32 lclk_clk; |
| 116 | u32 ddr_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 117 | #if defined(CONFIG_MPC8360) |
| 118 | u32 ddr_sec_clk; |
| 119 | #endif |
| 120 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 121 | u32 qepmf; |
| 122 | u32 qepdf; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 123 | u32 qe_clk; |
| 124 | u32 brg_clk; |
| 125 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 126 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 127 | if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 128 | return -1; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 129 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 130 | clkin_div = ((im->clk.spmr & SPMR_CKID) >> SPMR_CKID_SHIFT); |
Marian Balakowicz | 513b4a1 | 2005-10-11 19:09:42 +0200 | [diff] [blame] | 131 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 132 | if (im->reset.rcwh & HRCWH_PCI_HOST) { |
| 133 | #if defined(CONFIG_83XX_CLKIN) |
| 134 | pci_sync_in = CONFIG_83XX_CLKIN / (1 + clkin_div); |
| 135 | #else |
| 136 | pci_sync_in = 0xDEADBEEF; |
| 137 | #endif |
| 138 | } else { |
| 139 | #if defined(CONFIG_83XX_PCICLK) |
| 140 | pci_sync_in = CONFIG_83XX_PCICLK; |
| 141 | #else |
| 142 | pci_sync_in = 0xDEADBEEF; |
| 143 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 144 | } |
Marian Balakowicz | 513b4a1 | 2005-10-11 19:09:42 +0200 | [diff] [blame] | 145 | |
Dave Liu | 0b6bc77 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 146 | spmf = ((im->reset.rcwl & HRCWL_SPMF) >> HRCWL_SPMF_SHIFT); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 147 | csb_clk = pci_sync_in * (1 + clkin_div) * spmf; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 148 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 149 | sccr = im->clk.sccr; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 150 | |
Kumar Gala | b7870e7 | 2007-01-30 14:08:30 -0600 | [diff] [blame] | 151 | #if defined(CONFIG_MPC834X) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 152 | switch ((sccr & SCCR_TSEC1CM) >> SCCR_TSEC1CM_SHIFT) { |
| 153 | case 0: |
| 154 | tsec1_clk = 0; |
| 155 | break; |
| 156 | case 1: |
| 157 | tsec1_clk = csb_clk; |
| 158 | break; |
| 159 | case 2: |
| 160 | tsec1_clk = csb_clk / 2; |
| 161 | break; |
| 162 | case 3: |
| 163 | tsec1_clk = csb_clk / 3; |
| 164 | break; |
| 165 | default: |
| 166 | /* unkown SCCR_TSEC1CM value */ |
| 167 | return -4; |
| 168 | } |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 169 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 170 | switch ((sccr & SCCR_TSEC2CM) >> SCCR_TSEC2CM_SHIFT) { |
| 171 | case 0: |
| 172 | tsec2_clk = 0; |
| 173 | break; |
| 174 | case 1: |
| 175 | tsec2_clk = csb_clk; |
| 176 | break; |
| 177 | case 2: |
| 178 | tsec2_clk = csb_clk / 2; |
| 179 | break; |
| 180 | case 3: |
| 181 | tsec2_clk = csb_clk / 3; |
| 182 | break; |
| 183 | default: |
| 184 | /* unkown SCCR_TSEC2CM value */ |
| 185 | return -5; |
| 186 | } |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 187 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 188 | i2c1_clk = tsec2_clk; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 189 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 190 | switch ((sccr & SCCR_USBMPHCM) >> SCCR_USBMPHCM_SHIFT) { |
| 191 | case 0: |
| 192 | usbmph_clk = 0; |
| 193 | break; |
| 194 | case 1: |
| 195 | usbmph_clk = csb_clk; |
| 196 | break; |
| 197 | case 2: |
| 198 | usbmph_clk = csb_clk / 2; |
| 199 | break; |
| 200 | case 3: |
| 201 | usbmph_clk = csb_clk / 3; |
| 202 | break; |
| 203 | default: |
| 204 | /* unkown SCCR_USBMPHCM value */ |
| 205 | return -7; |
| 206 | } |
| 207 | |
| 208 | switch ((sccr & SCCR_USBDRCM) >> SCCR_USBDRCM_SHIFT) { |
| 209 | case 0: |
| 210 | usbdr_clk = 0; |
| 211 | break; |
| 212 | case 1: |
| 213 | usbdr_clk = csb_clk; |
| 214 | break; |
| 215 | case 2: |
| 216 | usbdr_clk = csb_clk / 2; |
| 217 | break; |
| 218 | case 3: |
| 219 | usbdr_clk = csb_clk / 3; |
| 220 | break; |
| 221 | default: |
| 222 | /* unkown SCCR_USBDRCM value */ |
| 223 | return -8; |
| 224 | } |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 225 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 226 | if (usbmph_clk != 0 && usbdr_clk != 0 && usbmph_clk != usbdr_clk) { |
| 227 | /* if USB MPH clock is not disabled and |
| 228 | * USB DR clock is not disabled then |
| 229 | * USB MPH & USB DR must have the same rate |
| 230 | */ |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 231 | return -9; |
| 232 | } |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 233 | #endif |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 234 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 235 | i2c1_clk = csb_clk; |
| 236 | #endif |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 237 | #if !defined(CONFIG_MPC832X) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 238 | i2c2_clk = csb_clk; /* i2c-2 clk is equal to csb clk */ |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 239 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 240 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 241 | switch ((sccr & SCCR_ENCCM) >> SCCR_ENCCM_SHIFT) { |
| 242 | case 0: |
| 243 | enc_clk = 0; |
| 244 | break; |
| 245 | case 1: |
| 246 | enc_clk = csb_clk; |
| 247 | break; |
| 248 | case 2: |
| 249 | enc_clk = csb_clk / 2; |
| 250 | break; |
| 251 | case 3: |
| 252 | enc_clk = csb_clk / 3; |
| 253 | break; |
| 254 | default: |
| 255 | /* unkown SCCR_ENCCM value */ |
| 256 | return -6; |
| 257 | } |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 258 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 259 | lbiu_clk = csb_clk * |
Dave Liu | 0b6bc77 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 260 | (1 + ((im->reset.rcwl & HRCWL_LBIUCM) >> HRCWL_LBIUCM_SHIFT)); |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 261 | lcrr = (im->lbus.lcrr & LCRR_CLKDIV) >> LCRR_CLKDIV_SHIFT; |
| 262 | switch (lcrr) { |
| 263 | case 2: |
| 264 | case 4: |
| 265 | case 8: |
| 266 | lclk_clk = lbiu_clk / lcrr; |
| 267 | break; |
| 268 | default: |
| 269 | /* unknown lcrr */ |
| 270 | return -10; |
| 271 | } |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 272 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 273 | ddr_clk = csb_clk * |
Dave Liu | 0b6bc77 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 274 | (1 + ((im->reset.rcwl & HRCWL_DDRCM) >> HRCWL_DDRCM_SHIFT)); |
| 275 | corepll = (im->reset.rcwl & HRCWL_COREPLL) >> HRCWL_COREPLL_SHIFT; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 276 | #if defined(CONFIG_MPC8360) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 277 | ddr_sec_clk = csb_clk * (1 + |
Dave Liu | 0b6bc77 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 278 | ((im->reset.rcwl & HRCWL_LBIUCM) >> HRCWL_LBIUCM_SHIFT)); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 279 | #endif |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 280 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 281 | corecnf_tab_index = ((corepll & 0x1F) << 2) | ((corepll & 0x60) >> 5); |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 282 | if (corecnf_tab_index > (sizeof(corecnf_tab) / sizeof(corecnf_t))) { |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 283 | /* corecnf_tab_index is too high, possibly worng value */ |
| 284 | return -11; |
| 285 | } |
| 286 | switch (corecnf_tab[corecnf_tab_index].core_csb_ratio) { |
| 287 | case _byp: |
| 288 | case _x1: |
| 289 | case _1x: |
| 290 | core_clk = csb_clk; |
| 291 | break; |
| 292 | case _1_5x: |
| 293 | core_clk = (3 * csb_clk) / 2; |
| 294 | break; |
| 295 | case _2x: |
| 296 | core_clk = 2 * csb_clk; |
| 297 | break; |
| 298 | case _2_5x: |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 299 | core_clk = (5 * csb_clk) / 2; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 300 | break; |
| 301 | case _3x: |
| 302 | core_clk = 3 * csb_clk; |
| 303 | break; |
| 304 | default: |
| 305 | /* unkown core to csb ratio */ |
| 306 | return -12; |
| 307 | } |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 308 | |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 309 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Dave Liu | 0b6bc77 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 310 | qepmf = (im->reset.rcwl & HRCWL_CEPMF) >> HRCWL_CEPMF_SHIFT; |
| 311 | qepdf = (im->reset.rcwl & HRCWL_CEPDF) >> HRCWL_CEPDF_SHIFT; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 312 | qe_clk = (pci_sync_in * qepmf) / (1 + qepdf); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 313 | brg_clk = qe_clk / 2; |
| 314 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 315 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 316 | gd->csb_clk = csb_clk; |
Kumar Gala | b7870e7 | 2007-01-30 14:08:30 -0600 | [diff] [blame] | 317 | #if defined(CONFIG_MPC834X) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 318 | gd->tsec1_clk = tsec1_clk; |
| 319 | gd->tsec2_clk = tsec2_clk; |
| 320 | gd->usbmph_clk = usbmph_clk; |
| 321 | gd->usbdr_clk = usbdr_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 322 | #endif |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 323 | gd->core_clk = core_clk; |
| 324 | gd->i2c1_clk = i2c1_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 325 | #if !defined(CONFIG_MPC832X) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 326 | gd->i2c2_clk = i2c2_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 327 | #endif |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 328 | gd->enc_clk = enc_clk; |
| 329 | gd->lbiu_clk = lbiu_clk; |
| 330 | gd->lclk_clk = lclk_clk; |
| 331 | gd->ddr_clk = ddr_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 332 | #if defined(CONFIG_MPC8360) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 333 | gd->ddr_sec_clk = ddr_sec_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 334 | #endif |
| 335 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 336 | gd->qe_clk = qe_clk; |
| 337 | gd->brg_clk = brg_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 338 | #endif |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 339 | gd->cpu_clk = gd->core_clk; |
| 340 | gd->bus_clk = gd->csb_clk; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 341 | return 0; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 342 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /******************************************** |
| 346 | * get_bus_freq |
| 347 | * return system bus freq in Hz |
| 348 | *********************************************/ |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 349 | ulong get_bus_freq(ulong dummy) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 350 | { |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 351 | return gd->csb_clk; |
| 352 | } |
| 353 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 354 | int print_clock_conf(void) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 355 | { |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 356 | printf("Clock configuration:\n"); |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 357 | printf(" Coherent System Bus: %4d MHz\n", gd->csb_clk / 1000000); |
| 358 | printf(" Core: %4d MHz\n", gd->core_clk / 1000000); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 359 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 360 | printf(" QE: %4d MHz\n", gd->qe_clk / 1000000); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 361 | printf(" BRG: %4d MHz\n", gd->brg_clk / 1000000); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 362 | #endif |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 363 | printf(" Local Bus Controller:%4d MHz\n", gd->lbiu_clk / 1000000); |
| 364 | printf(" Local Bus: %4d MHz\n", gd->lclk_clk / 1000000); |
| 365 | printf(" DDR: %4d MHz\n", gd->ddr_clk / 1000000); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 366 | #if defined(CONFIG_MPC8360) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 367 | printf(" DDR Secondary: %4d MHz\n", gd->ddr_sec_clk / 1000000); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 368 | #endif |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 369 | printf(" SEC: %4d MHz\n", gd->enc_clk / 1000000); |
| 370 | printf(" I2C1: %4d MHz\n", gd->i2c1_clk / 1000000); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 371 | #if !defined(CONFIG_MPC832X) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 372 | printf(" I2C2: %4d MHz\n", gd->i2c2_clk / 1000000); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 373 | #endif |
Kumar Gala | b7870e7 | 2007-01-30 14:08:30 -0600 | [diff] [blame] | 374 | #if defined(CONFIG_MPC834X) |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 375 | printf(" TSEC1: %4d MHz\n", gd->tsec1_clk / 1000000); |
| 376 | printf(" TSEC2: %4d MHz\n", gd->tsec2_clk / 1000000); |
| 377 | printf(" USB MPH: %4d MHz\n", gd->usbmph_clk / 1000000); |
| 378 | printf(" USB DR: %4d MHz\n", gd->usbdr_clk / 1000000); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 379 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 380 | return 0; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 381 | } |