Eran Liberty | f046ccd | 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 | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 5 | * Copyright (C) 2004-2006 Freescale Semiconductor, Inc. |
Eran Liberty | f046ccd | 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 | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #include <mpc83xx.h> |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 28 | #include <command.h> |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 29 | #include <asm/processor.h> |
| 30 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 33 | /* ----------------------------------------------------------------- */ |
| 34 | |
| 35 | typedef enum { |
| 36 | _unk, |
| 37 | _off, |
| 38 | _byp, |
| 39 | _x8, |
| 40 | _x4, |
| 41 | _x2, |
| 42 | _x1, |
| 43 | _1x, |
| 44 | _1_5x, |
| 45 | _2x, |
| 46 | _2_5x, |
| 47 | _3x |
| 48 | } mult_t; |
| 49 | |
| 50 | typedef struct { |
| 51 | mult_t core_csb_ratio; |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 52 | mult_t vco_divider; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 53 | } corecnf_t; |
| 54 | |
| 55 | corecnf_t corecnf_tab[] = { |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 56 | {_byp, _byp}, /* 0x00 */ |
| 57 | {_byp, _byp}, /* 0x01 */ |
| 58 | {_byp, _byp}, /* 0x02 */ |
| 59 | {_byp, _byp}, /* 0x03 */ |
| 60 | {_byp, _byp}, /* 0x04 */ |
| 61 | {_byp, _byp}, /* 0x05 */ |
| 62 | {_byp, _byp}, /* 0x06 */ |
| 63 | {_byp, _byp}, /* 0x07 */ |
| 64 | {_1x, _x2}, /* 0x08 */ |
| 65 | {_1x, _x4}, /* 0x09 */ |
| 66 | {_1x, _x8}, /* 0x0A */ |
| 67 | {_1x, _x8}, /* 0x0B */ |
| 68 | {_1_5x, _x2}, /* 0x0C */ |
| 69 | {_1_5x, _x4}, /* 0x0D */ |
| 70 | {_1_5x, _x8}, /* 0x0E */ |
| 71 | {_1_5x, _x8}, /* 0x0F */ |
| 72 | {_2x, _x2}, /* 0x10 */ |
| 73 | {_2x, _x4}, /* 0x11 */ |
| 74 | {_2x, _x8}, /* 0x12 */ |
| 75 | {_2x, _x8}, /* 0x13 */ |
| 76 | {_2_5x, _x2}, /* 0x14 */ |
| 77 | {_2_5x, _x4}, /* 0x15 */ |
| 78 | {_2_5x, _x8}, /* 0x16 */ |
| 79 | {_2_5x, _x8}, /* 0x17 */ |
| 80 | {_3x, _x2}, /* 0x18 */ |
| 81 | {_3x, _x4}, /* 0x19 */ |
| 82 | {_3x, _x8}, /* 0x1A */ |
| 83 | {_3x, _x8}, /* 0x1B */ |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | /* ----------------------------------------------------------------- */ |
| 87 | |
| 88 | /* |
| 89 | * |
| 90 | */ |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 91 | int get_clocks(void) |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 92 | { |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 93 | volatile immap_t *im = (immap_t *) CFG_IMMR; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 94 | u32 pci_sync_in; |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 95 | u8 spmf; |
| 96 | u8 clkin_div; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 97 | u32 sccr; |
| 98 | u32 corecnf_tab_index; |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 99 | u8 corepll; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 100 | u32 lcrr; |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 101 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 102 | u32 csb_clk; |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 103 | #if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 104 | u32 tsec1_clk; |
| 105 | u32 tsec2_clk; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 106 | u32 usbdr_clk; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 107 | #endif |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 108 | #ifdef CONFIG_MPC834X |
| 109 | u32 usbmph_clk; |
| 110 | #endif |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 111 | u32 core_clk; |
| 112 | u32 i2c1_clk; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 113 | #if !defined(CONFIG_MPC832X) |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 114 | u32 i2c2_clk; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 115 | #endif |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 116 | u32 enc_clk; |
| 117 | u32 lbiu_clk; |
| 118 | u32 lclk_clk; |
| 119 | u32 ddr_clk; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 120 | #if defined(CONFIG_MPC8360) |
| 121 | u32 ddr_sec_clk; |
| 122 | #endif |
| 123 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 124 | u32 qepmf; |
| 125 | u32 qepdf; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 126 | u32 qe_clk; |
| 127 | u32 brg_clk; |
| 128 | #endif |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 129 | |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 130 | if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im) |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 131 | return -1; |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 132 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 133 | clkin_div = ((im->clk.spmr & SPMR_CKID) >> SPMR_CKID_SHIFT); |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 134 | |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 135 | if (im->reset.rcwh & HRCWH_PCI_HOST) { |
| 136 | #if defined(CONFIG_83XX_CLKIN) |
| 137 | pci_sync_in = CONFIG_83XX_CLKIN / (1 + clkin_div); |
| 138 | #else |
| 139 | pci_sync_in = 0xDEADBEEF; |
| 140 | #endif |
| 141 | } else { |
| 142 | #if defined(CONFIG_83XX_PCICLK) |
| 143 | pci_sync_in = CONFIG_83XX_PCICLK; |
| 144 | #else |
| 145 | pci_sync_in = 0xDEADBEEF; |
| 146 | #endif |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 147 | } |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 148 | |
Dave Liu | e080313 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 149 | spmf = ((im->reset.rcwl & HRCWL_SPMF) >> HRCWL_SPMF_SHIFT); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 150 | csb_clk = pci_sync_in * (1 + clkin_div) * spmf; |
| 151 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 152 | sccr = im->clk.sccr; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 153 | |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 154 | #if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 155 | switch ((sccr & SCCR_TSEC1CM) >> SCCR_TSEC1CM_SHIFT) { |
| 156 | case 0: |
| 157 | tsec1_clk = 0; |
| 158 | break; |
| 159 | case 1: |
| 160 | tsec1_clk = csb_clk; |
| 161 | break; |
| 162 | case 2: |
| 163 | tsec1_clk = csb_clk / 2; |
| 164 | break; |
| 165 | case 3: |
| 166 | tsec1_clk = csb_clk / 3; |
| 167 | break; |
| 168 | default: |
| 169 | /* unkown SCCR_TSEC1CM value */ |
| 170 | return -4; |
| 171 | } |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 172 | |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 173 | switch ((sccr & SCCR_USBDRCM) >> SCCR_USBDRCM_SHIFT) { |
| 174 | case 0: |
| 175 | usbdr_clk = 0; |
| 176 | break; |
| 177 | case 1: |
| 178 | usbdr_clk = csb_clk; |
| 179 | break; |
| 180 | case 2: |
| 181 | usbdr_clk = csb_clk / 2; |
| 182 | break; |
| 183 | case 3: |
| 184 | usbdr_clk = csb_clk / 3; |
| 185 | break; |
| 186 | default: |
| 187 | /* unkown SCCR_USBDRCM value */ |
| 188 | return -8; |
| 189 | } |
| 190 | #endif |
| 191 | |
| 192 | #if defined(CONFIG_MPC834X) |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 193 | switch ((sccr & SCCR_TSEC2CM) >> SCCR_TSEC2CM_SHIFT) { |
| 194 | case 0: |
| 195 | tsec2_clk = 0; |
| 196 | break; |
| 197 | case 1: |
| 198 | tsec2_clk = csb_clk; |
| 199 | break; |
| 200 | case 2: |
| 201 | tsec2_clk = csb_clk / 2; |
| 202 | break; |
| 203 | case 3: |
| 204 | tsec2_clk = csb_clk / 3; |
| 205 | break; |
| 206 | default: |
| 207 | /* unkown SCCR_TSEC2CM value */ |
| 208 | return -5; |
| 209 | } |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 210 | |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 211 | i2c1_clk = tsec2_clk; |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 212 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 213 | switch ((sccr & SCCR_USBMPHCM) >> SCCR_USBMPHCM_SHIFT) { |
| 214 | case 0: |
| 215 | usbmph_clk = 0; |
| 216 | break; |
| 217 | case 1: |
| 218 | usbmph_clk = csb_clk; |
| 219 | break; |
| 220 | case 2: |
| 221 | usbmph_clk = csb_clk / 2; |
| 222 | break; |
| 223 | case 3: |
| 224 | usbmph_clk = csb_clk / 3; |
| 225 | break; |
| 226 | default: |
| 227 | /* unkown SCCR_USBMPHCM value */ |
| 228 | return -7; |
| 229 | } |
| 230 | |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 231 | if (usbmph_clk != 0 && usbdr_clk != 0 && usbmph_clk != usbdr_clk) { |
| 232 | /* if USB MPH clock is not disabled and |
| 233 | * USB DR clock is not disabled then |
| 234 | * USB MPH & USB DR must have the same rate |
| 235 | */ |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 236 | return -9; |
| 237 | } |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 238 | #elif defined(CONFIG_MPC831X) |
| 239 | tsec2_clk = tsec1_clk; |
| 240 | |
| 241 | if (!(sccr & SCCR_TSEC1ON)) |
| 242 | tsec1_clk = 0; |
| 243 | if (!(sccr & SCCR_TSEC2ON)) |
| 244 | tsec2_clk = 0; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 245 | #endif |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 246 | |
| 247 | #if !defined(CONFIG_MPC834X) |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 248 | i2c1_clk = csb_clk; |
| 249 | #endif |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 250 | #if !defined(CONFIG_MPC832X) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 251 | i2c2_clk = csb_clk; /* i2c-2 clk is equal to csb clk */ |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 252 | #endif |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 253 | |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 254 | switch ((sccr & SCCR_ENCCM) >> SCCR_ENCCM_SHIFT) { |
| 255 | case 0: |
| 256 | enc_clk = 0; |
| 257 | break; |
| 258 | case 1: |
| 259 | enc_clk = csb_clk; |
| 260 | break; |
| 261 | case 2: |
| 262 | enc_clk = csb_clk / 2; |
| 263 | break; |
| 264 | case 3: |
| 265 | enc_clk = csb_clk / 3; |
| 266 | break; |
| 267 | default: |
| 268 | /* unkown SCCR_ENCCM value */ |
| 269 | return -6; |
| 270 | } |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 271 | |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 272 | lbiu_clk = csb_clk * |
Dave Liu | e080313 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 273 | (1 + ((im->reset.rcwl & HRCWL_LBIUCM) >> HRCWL_LBIUCM_SHIFT)); |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 274 | lcrr = (im->lbus.lcrr & LCRR_CLKDIV) >> LCRR_CLKDIV_SHIFT; |
| 275 | switch (lcrr) { |
| 276 | case 2: |
| 277 | case 4: |
| 278 | case 8: |
| 279 | lclk_clk = lbiu_clk / lcrr; |
| 280 | break; |
| 281 | default: |
| 282 | /* unknown lcrr */ |
| 283 | return -10; |
| 284 | } |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 285 | |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 286 | ddr_clk = csb_clk * |
Dave Liu | e080313 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 287 | (1 + ((im->reset.rcwl & HRCWL_DDRCM) >> HRCWL_DDRCM_SHIFT)); |
| 288 | corepll = (im->reset.rcwl & HRCWL_COREPLL) >> HRCWL_COREPLL_SHIFT; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 289 | #if defined(CONFIG_MPC8360) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 290 | ddr_sec_clk = csb_clk * (1 + |
Dave Liu | e080313 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 291 | ((im->reset.rcwl & HRCWL_LBIUCM) >> HRCWL_LBIUCM_SHIFT)); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 292 | #endif |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 293 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 294 | corecnf_tab_index = ((corepll & 0x1F) << 2) | ((corepll & 0x60) >> 5); |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 295 | if (corecnf_tab_index > (sizeof(corecnf_tab) / sizeof(corecnf_t))) { |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 296 | /* corecnf_tab_index is too high, possibly worng value */ |
| 297 | return -11; |
| 298 | } |
| 299 | switch (corecnf_tab[corecnf_tab_index].core_csb_ratio) { |
| 300 | case _byp: |
| 301 | case _x1: |
| 302 | case _1x: |
| 303 | core_clk = csb_clk; |
| 304 | break; |
| 305 | case _1_5x: |
| 306 | core_clk = (3 * csb_clk) / 2; |
| 307 | break; |
| 308 | case _2x: |
| 309 | core_clk = 2 * csb_clk; |
| 310 | break; |
| 311 | case _2_5x: |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 312 | core_clk = (5 * csb_clk) / 2; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 313 | break; |
| 314 | case _3x: |
| 315 | core_clk = 3 * csb_clk; |
| 316 | break; |
| 317 | default: |
| 318 | /* unkown core to csb ratio */ |
| 319 | return -12; |
| 320 | } |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 321 | |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 322 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Dave Liu | e080313 | 2006-12-07 21:11:58 +0800 | [diff] [blame] | 323 | qepmf = (im->reset.rcwl & HRCWL_CEPMF) >> HRCWL_CEPMF_SHIFT; |
| 324 | qepdf = (im->reset.rcwl & HRCWL_CEPDF) >> HRCWL_CEPDF_SHIFT; |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 325 | qe_clk = (pci_sync_in * qepmf) / (1 + qepdf); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 326 | brg_clk = qe_clk / 2; |
| 327 | #endif |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 328 | |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 329 | gd->csb_clk = csb_clk; |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 330 | #if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 331 | gd->tsec1_clk = tsec1_clk; |
| 332 | gd->tsec2_clk = tsec2_clk; |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 333 | gd->usbdr_clk = usbdr_clk; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 334 | #endif |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 335 | #if defined(CONFIG_MPC834X) |
| 336 | gd->usbmph_clk = usbmph_clk; |
| 337 | #endif |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 338 | gd->core_clk = core_clk; |
| 339 | gd->i2c1_clk = i2c1_clk; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 340 | #if !defined(CONFIG_MPC832X) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 341 | gd->i2c2_clk = i2c2_clk; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 342 | #endif |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 343 | gd->enc_clk = enc_clk; |
| 344 | gd->lbiu_clk = lbiu_clk; |
| 345 | gd->lclk_clk = lclk_clk; |
| 346 | gd->ddr_clk = ddr_clk; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 347 | #if defined(CONFIG_MPC8360) |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 348 | gd->ddr_sec_clk = ddr_sec_clk; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 349 | #endif |
| 350 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 351 | gd->qe_clk = qe_clk; |
| 352 | gd->brg_clk = brg_clk; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 353 | #endif |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 354 | gd->cpu_clk = gd->core_clk; |
| 355 | gd->bus_clk = gd->csb_clk; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 356 | return 0; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 357 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | /******************************************** |
| 361 | * get_bus_freq |
| 362 | * return system bus freq in Hz |
| 363 | *********************************************/ |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 364 | ulong get_bus_freq(ulong dummy) |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 365 | { |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 366 | return gd->csb_clk; |
| 367 | } |
| 368 | |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 369 | int do_clocks (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 370 | { |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 371 | printf("Clock configuration:\n"); |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 372 | printf(" Core: %4d MHz\n", gd->core_clk / 1000000); |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 373 | printf(" Coherent System Bus: %4d MHz\n", gd->csb_clk / 1000000); |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 374 | #if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 375 | printf(" QE: %4d MHz\n", gd->qe_clk / 1000000); |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 376 | printf(" BRG: %4d MHz\n", gd->brg_clk / 1000000); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 377 | #endif |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 378 | printf(" Local Bus Controller:%4d MHz\n", gd->lbiu_clk / 1000000); |
| 379 | printf(" Local Bus: %4d MHz\n", gd->lclk_clk / 1000000); |
| 380 | printf(" DDR: %4d MHz\n", gd->ddr_clk / 1000000); |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 381 | #if defined(CONFIG_MPC8360) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 382 | printf(" DDR Secondary: %4d MHz\n", gd->ddr_sec_clk / 1000000); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 383 | #endif |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 384 | printf(" SEC: %4d MHz\n", gd->enc_clk / 1000000); |
| 385 | printf(" I2C1: %4d MHz\n", gd->i2c1_clk / 1000000); |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 386 | #if !defined(CONFIG_MPC832X) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 387 | printf(" I2C2: %4d MHz\n", gd->i2c2_clk / 1000000); |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 388 | #endif |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 389 | #if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 390 | printf(" TSEC1: %4d MHz\n", gd->tsec1_clk / 1000000); |
| 391 | printf(" TSEC2: %4d MHz\n", gd->tsec2_clk / 1000000); |
Kim Phillips | f7fb2e7 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 392 | printf(" USB DR: %4d MHz\n", gd->usbdr_clk / 1000000); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 393 | #endif |
Scott Wood | 7c98e51 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 394 | #if defined(CONFIG_MPC834X) |
| 395 | printf(" USB MPH: %4d MHz\n", gd->usbmph_clk / 1000000); |
| 396 | #endif |
Jon Loeliger | de1d0a6 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 397 | return 0; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 398 | } |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 399 | |
| 400 | U_BOOT_CMD(clocks, 1, 0, do_clocks, |
| 401 | "clocks - print clock configuration\n", |
| 402 | " clocks\n" |
| 403 | ); |