blob: 23dfb30414959618b2c081062375ee74eb47c939 [file] [log] [blame]
Eran Liberty9095d4a2005-07-28 10:08:46 -05001/*
2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Dave Liu5245ff52007-09-18 12:36:11 +08005 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
Eran Liberty9095d4a2005-07-28 10:08:46 -05006 *
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 Liberty9095d4a2005-07-28 10:08:46 -050024 */
25
26#include <common.h>
27#include <mpc83xx.h>
Kim Phillipsd82b0772007-04-30 15:26:21 -050028#include <command.h>
Eran Liberty9095d4a2005-07-28 10:08:46 -050029#include <asm/processor.h>
30
Wolfgang Denk6405a152006-03-31 18:32:53 +020031DECLARE_GLOBAL_DATA_PTR;
32
Eran Liberty9095d4a2005-07-28 10:08:46 -050033/* ----------------------------------------------------------------- */
34
35typedef 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
50typedef struct {
51 mult_t core_csb_ratio;
Kim Phillipsbae24792006-11-02 19:47:11 -060052 mult_t vco_divider;
Eran Liberty9095d4a2005-07-28 10:08:46 -050053} corecnf_t;
54
55corecnf_t corecnf_tab[] = {
Kim Phillipsbae24792006-11-02 19:47:11 -060056 {_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 Liberty9095d4a2005-07-28 10:08:46 -050084};
85
86/* ----------------------------------------------------------------- */
87
88/*
89 *
90 */
Kim Phillipsbae24792006-11-02 19:47:11 -060091int get_clocks(void)
Eran Liberty9095d4a2005-07-28 10:08:46 -050092{
Timur Tabi386a2802006-11-03 12:00:28 -060093 volatile immap_t *im = (immap_t *) CFG_IMMR;
Eran Liberty9095d4a2005-07-28 10:08:46 -050094 u32 pci_sync_in;
Kim Phillipsbae24792006-11-02 19:47:11 -060095 u8 spmf;
96 u8 clkin_div;
Eran Liberty9095d4a2005-07-28 10:08:46 -050097 u32 sccr;
98 u32 corecnf_tab_index;
Kim Phillipsbae24792006-11-02 19:47:11 -060099 u8 corepll;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500100 u32 lcrr;
Jon Loeligerebc72242005-08-01 13:20:47 -0500101
Eran Liberty9095d4a2005-07-28 10:08:46 -0500102 u32 csb_clk;
Dave Liu5245ff52007-09-18 12:36:11 +0800103#if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) || defined(CONFIG_MPC837X)
Eran Liberty9095d4a2005-07-28 10:08:46 -0500104 u32 tsec1_clk;
105 u32 tsec2_clk;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500106 u32 usbdr_clk;
Dave Liua46daea2006-11-03 19:33:44 -0600107#endif
Scott Woodc036fc92007-04-16 14:34:19 -0500108#ifdef CONFIG_MPC834X
109 u32 usbmph_clk;
110#endif
Dave Liua46daea2006-11-03 19:33:44 -0600111 u32 core_clk;
112 u32 i2c1_clk;
Dave Liue740c462006-12-07 21:13:15 +0800113#if !defined(CONFIG_MPC832X)
Dave Liua46daea2006-11-03 19:33:44 -0600114 u32 i2c2_clk;
Dave Liue740c462006-12-07 21:13:15 +0800115#endif
Dave Liu5245ff52007-09-18 12:36:11 +0800116#if defined(CONFIG_MPC837X)
117 u32 sdhc_clk;
118#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500119 u32 enc_clk;
120 u32 lbiu_clk;
121 u32 lclk_clk;
122 u32 ddr_clk;
Dave Liue740c462006-12-07 21:13:15 +0800123#if defined(CONFIG_MPC8360)
124 u32 ddr_sec_clk;
125#endif
126#if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X)
Dave Liua46daea2006-11-03 19:33:44 -0600127 u32 qepmf;
128 u32 qepdf;
Dave Liua46daea2006-11-03 19:33:44 -0600129 u32 qe_clk;
130 u32 brg_clk;
131#endif
Dave Liu5245ff52007-09-18 12:36:11 +0800132#if defined(CONFIG_MPC837X)
133 u32 pciexp1_clk;
134 u32 pciexp2_clk;
135 u32 sata_clk;
136#endif
Jon Loeligerebc72242005-08-01 13:20:47 -0500137
Kim Phillipsbae24792006-11-02 19:47:11 -0600138 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
Eran Liberty9095d4a2005-07-28 10:08:46 -0500139 return -1;
Jon Loeligerebc72242005-08-01 13:20:47 -0500140
Dave Liua46daea2006-11-03 19:33:44 -0600141 clkin_div = ((im->clk.spmr & SPMR_CKID) >> SPMR_CKID_SHIFT);
Marian Balakowicz513b4a12005-10-11 19:09:42 +0200142
Dave Liua46daea2006-11-03 19:33:44 -0600143 if (im->reset.rcwh & HRCWH_PCI_HOST) {
144#if defined(CONFIG_83XX_CLKIN)
145 pci_sync_in = CONFIG_83XX_CLKIN / (1 + clkin_div);
146#else
147 pci_sync_in = 0xDEADBEEF;
148#endif
149 } else {
150#if defined(CONFIG_83XX_PCICLK)
151 pci_sync_in = CONFIG_83XX_PCICLK;
152#else
153 pci_sync_in = 0xDEADBEEF;
154#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500155 }
Marian Balakowicz513b4a12005-10-11 19:09:42 +0200156
Dave Liu0b6bc772006-12-07 21:11:58 +0800157 spmf = ((im->reset.rcwl & HRCWL_SPMF) >> HRCWL_SPMF_SHIFT);
Dave Liua46daea2006-11-03 19:33:44 -0600158 csb_clk = pci_sync_in * (1 + clkin_div) * spmf;
Jon Loeligerebc72242005-08-01 13:20:47 -0500159
Eran Liberty9095d4a2005-07-28 10:08:46 -0500160 sccr = im->clk.sccr;
Dave Liua46daea2006-11-03 19:33:44 -0600161
Dave Liu5245ff52007-09-18 12:36:11 +0800162#if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) || defined(CONFIG_MPC837X)
Eran Liberty9095d4a2005-07-28 10:08:46 -0500163 switch ((sccr & SCCR_TSEC1CM) >> SCCR_TSEC1CM_SHIFT) {
164 case 0:
165 tsec1_clk = 0;
166 break;
167 case 1:
168 tsec1_clk = csb_clk;
169 break;
170 case 2:
171 tsec1_clk = csb_clk / 2;
172 break;
173 case 3:
174 tsec1_clk = csb_clk / 3;
175 break;
176 default:
177 /* unkown SCCR_TSEC1CM value */
Dave Liu5245ff52007-09-18 12:36:11 +0800178 return -2;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500179 }
Jon Loeligerebc72242005-08-01 13:20:47 -0500180
Scott Woodc036fc92007-04-16 14:34:19 -0500181 switch ((sccr & SCCR_USBDRCM) >> SCCR_USBDRCM_SHIFT) {
182 case 0:
183 usbdr_clk = 0;
184 break;
185 case 1:
186 usbdr_clk = csb_clk;
187 break;
188 case 2:
189 usbdr_clk = csb_clk / 2;
190 break;
191 case 3:
192 usbdr_clk = csb_clk / 3;
193 break;
194 default:
195 /* unkown SCCR_USBDRCM value */
Dave Liu5245ff52007-09-18 12:36:11 +0800196 return -3;
Scott Woodc036fc92007-04-16 14:34:19 -0500197 }
198#endif
199
Dave Liu5245ff52007-09-18 12:36:11 +0800200#if defined(CONFIG_MPC834X) || defined(CONFIG_MPC837X)
Eran Liberty9095d4a2005-07-28 10:08:46 -0500201 switch ((sccr & SCCR_TSEC2CM) >> SCCR_TSEC2CM_SHIFT) {
202 case 0:
203 tsec2_clk = 0;
204 break;
205 case 1:
206 tsec2_clk = csb_clk;
207 break;
208 case 2:
209 tsec2_clk = csb_clk / 2;
210 break;
211 case 3:
212 tsec2_clk = csb_clk / 3;
213 break;
214 default:
215 /* unkown SCCR_TSEC2CM value */
Dave Liu5245ff52007-09-18 12:36:11 +0800216 return -4;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500217 }
Dave Liu5245ff52007-09-18 12:36:11 +0800218#elif defined(CONFIG_MPC831X)
219 tsec2_clk = tsec1_clk;
Jon Loeligerebc72242005-08-01 13:20:47 -0500220
Dave Liu5245ff52007-09-18 12:36:11 +0800221 if (!(sccr & SCCR_TSEC1ON))
222 tsec1_clk = 0;
223 if (!(sccr & SCCR_TSEC2ON))
224 tsec2_clk = 0;
225#endif
Jon Loeligerebc72242005-08-01 13:20:47 -0500226
Dave Liu5245ff52007-09-18 12:36:11 +0800227#if defined(CONFIG_MPC834X)
Eran Liberty9095d4a2005-07-28 10:08:46 -0500228 switch ((sccr & SCCR_USBMPHCM) >> SCCR_USBMPHCM_SHIFT) {
229 case 0:
230 usbmph_clk = 0;
231 break;
232 case 1:
233 usbmph_clk = csb_clk;
234 break;
235 case 2:
236 usbmph_clk = csb_clk / 2;
237 break;
238 case 3:
239 usbmph_clk = csb_clk / 3;
240 break;
241 default:
242 /* unkown SCCR_USBMPHCM value */
Dave Liu5245ff52007-09-18 12:36:11 +0800243 return -5;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500244 }
245
Kim Phillipsbae24792006-11-02 19:47:11 -0600246 if (usbmph_clk != 0 && usbdr_clk != 0 && usbmph_clk != usbdr_clk) {
247 /* if USB MPH clock is not disabled and
248 * USB DR clock is not disabled then
249 * USB MPH & USB DR must have the same rate
250 */
Dave Liu5245ff52007-09-18 12:36:11 +0800251 return -6;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500252 }
Dave Liu5245ff52007-09-18 12:36:11 +0800253#endif
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 -7;
270 }
Scott Woodc036fc92007-04-16 14:34:19 -0500271
Dave Liu5245ff52007-09-18 12:36:11 +0800272#if defined(CONFIG_MPC837X)
273 switch ((sccr & SCCR_SDHCCM) >> SCCR_SDHCCM_SHIFT) {
274 case 0:
275 sdhc_clk = 0;
276 break;
277 case 1:
278 sdhc_clk = csb_clk;
279 break;
280 case 2:
281 sdhc_clk = csb_clk / 2;
282 break;
283 case 3:
284 sdhc_clk = csb_clk / 3;
285 break;
286 default:
287 /* unkown SCCR_SDHCCM value */
288 return -8;
289 }
Dave Liua46daea2006-11-03 19:33:44 -0600290#endif
Scott Woodc036fc92007-04-16 14:34:19 -0500291
Dave Liu5245ff52007-09-18 12:36:11 +0800292#if defined(CONFIG_MPC834X)
293 i2c1_clk = tsec2_clk;
294#elif defined(CONFIG_MPC8360)
Dave Liua46daea2006-11-03 19:33:44 -0600295 i2c1_clk = csb_clk;
Dave Liu5245ff52007-09-18 12:36:11 +0800296#elif defined(CONFIG_MPC832X)
297 i2c1_clk = enc_clk;
298#elif defined(CONFIG_MPC831X)
299 i2c1_clk = enc_clk;
300#elif defined(CONFIG_MPC837X)
301 i2c1_clk = sdhc_clk;
Dave Liua46daea2006-11-03 19:33:44 -0600302#endif
Dave Liue740c462006-12-07 21:13:15 +0800303#if !defined(CONFIG_MPC832X)
Dave Liu5245ff52007-09-18 12:36:11 +0800304 i2c2_clk = csb_clk; /* i2c-2 clk is equal to csb clk */
Dave Liue740c462006-12-07 21:13:15 +0800305#endif
Jon Loeligerebc72242005-08-01 13:20:47 -0500306
Dave Liu5245ff52007-09-18 12:36:11 +0800307#if defined(CONFIG_MPC837X)
308 switch ((sccr & SCCR_PCIEXP1CM) >> SCCR_PCIEXP1CM_SHIFT) {
Dave Liua46daea2006-11-03 19:33:44 -0600309 case 0:
Dave Liu5245ff52007-09-18 12:36:11 +0800310 pciexp1_clk = 0;
Dave Liua46daea2006-11-03 19:33:44 -0600311 break;
312 case 1:
Dave Liu5245ff52007-09-18 12:36:11 +0800313 pciexp1_clk = csb_clk;
Dave Liua46daea2006-11-03 19:33:44 -0600314 break;
315 case 2:
Dave Liu5245ff52007-09-18 12:36:11 +0800316 pciexp1_clk = csb_clk / 2;
Dave Liua46daea2006-11-03 19:33:44 -0600317 break;
318 case 3:
Dave Liu5245ff52007-09-18 12:36:11 +0800319 pciexp1_clk = csb_clk / 3;
Dave Liua46daea2006-11-03 19:33:44 -0600320 break;
321 default:
Dave Liu5245ff52007-09-18 12:36:11 +0800322 /* unkown SCCR_PCIEXP1CM value */
323 return -9;
Dave Liua46daea2006-11-03 19:33:44 -0600324 }
Dave Liue740c462006-12-07 21:13:15 +0800325
Dave Liu5245ff52007-09-18 12:36:11 +0800326 switch ((sccr & SCCR_PCIEXP2CM) >> SCCR_PCIEXP2CM_SHIFT) {
327 case 0:
328 pciexp2_clk = 0;
329 break;
330 case 1:
331 pciexp2_clk = csb_clk;
332 break;
333 case 2:
334 pciexp2_clk = csb_clk / 2;
335 break;
336 case 3:
337 pciexp2_clk = csb_clk / 3;
338 break;
339 default:
340 /* unkown SCCR_PCIEXP2CM value */
341 return -10;
342 }
343#endif
344
345#if defined(CONFIG_MPC837X)
346 switch ((sccr & SCCR_SATA1CM) >> SCCR_SATA1CM_SHIFT) {
347 case 0:
348 sata_clk = 0;
349 break;
350 case 1:
351 sata_clk = csb_clk;
352 break;
353 case 2:
354 sata_clk = csb_clk / 2;
355 break;
356 case 3:
357 sata_clk = csb_clk / 3;
358 break;
359 default:
360 /* unkown SCCR_SATA1CM value */
361 return -11;
362 }
363#endif
364
Kim Phillipsbae24792006-11-02 19:47:11 -0600365 lbiu_clk = csb_clk *
Dave Liu0b6bc772006-12-07 21:11:58 +0800366 (1 + ((im->reset.rcwl & HRCWL_LBIUCM) >> HRCWL_LBIUCM_SHIFT));
Eran Liberty9095d4a2005-07-28 10:08:46 -0500367 lcrr = (im->lbus.lcrr & LCRR_CLKDIV) >> LCRR_CLKDIV_SHIFT;
368 switch (lcrr) {
369 case 2:
370 case 4:
371 case 8:
372 lclk_clk = lbiu_clk / lcrr;
373 break;
374 default:
375 /* unknown lcrr */
Dave Liu5245ff52007-09-18 12:36:11 +0800376 return -12;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500377 }
Dave Liue740c462006-12-07 21:13:15 +0800378
Kim Phillipsbae24792006-11-02 19:47:11 -0600379 ddr_clk = csb_clk *
Dave Liu0b6bc772006-12-07 21:11:58 +0800380 (1 + ((im->reset.rcwl & HRCWL_DDRCM) >> HRCWL_DDRCM_SHIFT));
381 corepll = (im->reset.rcwl & HRCWL_COREPLL) >> HRCWL_COREPLL_SHIFT;
Dave Liue740c462006-12-07 21:13:15 +0800382#if defined(CONFIG_MPC8360)
Kim Phillipsbae24792006-11-02 19:47:11 -0600383 ddr_sec_clk = csb_clk * (1 +
Dave Liu0b6bc772006-12-07 21:11:58 +0800384 ((im->reset.rcwl & HRCWL_LBIUCM) >> HRCWL_LBIUCM_SHIFT));
Dave Liua46daea2006-11-03 19:33:44 -0600385#endif
Dave Liua46daea2006-11-03 19:33:44 -0600386
Eran Liberty9095d4a2005-07-28 10:08:46 -0500387 corecnf_tab_index = ((corepll & 0x1F) << 2) | ((corepll & 0x60) >> 5);
Kim Phillipsbae24792006-11-02 19:47:11 -0600388 if (corecnf_tab_index > (sizeof(corecnf_tab) / sizeof(corecnf_t))) {
Eran Liberty9095d4a2005-07-28 10:08:46 -0500389 /* corecnf_tab_index is too high, possibly worng value */
390 return -11;
391 }
392 switch (corecnf_tab[corecnf_tab_index].core_csb_ratio) {
393 case _byp:
394 case _x1:
395 case _1x:
396 core_clk = csb_clk;
397 break;
398 case _1_5x:
399 core_clk = (3 * csb_clk) / 2;
400 break;
401 case _2x:
402 core_clk = 2 * csb_clk;
403 break;
404 case _2_5x:
Kim Phillipsbae24792006-11-02 19:47:11 -0600405 core_clk = (5 * csb_clk) / 2;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500406 break;
407 case _3x:
408 core_clk = 3 * csb_clk;
409 break;
410 default:
411 /* unkown core to csb ratio */
Dave Liu5245ff52007-09-18 12:36:11 +0800412 return -13;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500413 }
Jon Loeligerebc72242005-08-01 13:20:47 -0500414
Dave Liue740c462006-12-07 21:13:15 +0800415#if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X)
Dave Liu0b6bc772006-12-07 21:11:58 +0800416 qepmf = (im->reset.rcwl & HRCWL_CEPMF) >> HRCWL_CEPMF_SHIFT;
417 qepdf = (im->reset.rcwl & HRCWL_CEPDF) >> HRCWL_CEPDF_SHIFT;
Kim Phillipsbae24792006-11-02 19:47:11 -0600418 qe_clk = (pci_sync_in * qepmf) / (1 + qepdf);
Dave Liua46daea2006-11-03 19:33:44 -0600419 brg_clk = qe_clk / 2;
420#endif
Jon Loeligerebc72242005-08-01 13:20:47 -0500421
Kim Phillipsbae24792006-11-02 19:47:11 -0600422 gd->csb_clk = csb_clk;
Dave Liu5245ff52007-09-18 12:36:11 +0800423#if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) || defined(CONFIG_MPC837X)
Kim Phillipsbae24792006-11-02 19:47:11 -0600424 gd->tsec1_clk = tsec1_clk;
425 gd->tsec2_clk = tsec2_clk;
Kim Phillipsbae24792006-11-02 19:47:11 -0600426 gd->usbdr_clk = usbdr_clk;
Dave Liua46daea2006-11-03 19:33:44 -0600427#endif
Scott Woodc036fc92007-04-16 14:34:19 -0500428#if defined(CONFIG_MPC834X)
429 gd->usbmph_clk = usbmph_clk;
430#endif
Dave Liu5245ff52007-09-18 12:36:11 +0800431#if defined(CONFIG_MPC837X)
432 gd->sdhc_clk = sdhc_clk;
433#endif
Kim Phillipsbae24792006-11-02 19:47:11 -0600434 gd->core_clk = core_clk;
435 gd->i2c1_clk = i2c1_clk;
Dave Liue740c462006-12-07 21:13:15 +0800436#if !defined(CONFIG_MPC832X)
Kim Phillipsbae24792006-11-02 19:47:11 -0600437 gd->i2c2_clk = i2c2_clk;
Dave Liue740c462006-12-07 21:13:15 +0800438#endif
Kim Phillipsbae24792006-11-02 19:47:11 -0600439 gd->enc_clk = enc_clk;
440 gd->lbiu_clk = lbiu_clk;
441 gd->lclk_clk = lclk_clk;
442 gd->ddr_clk = ddr_clk;
Dave Liue740c462006-12-07 21:13:15 +0800443#if defined(CONFIG_MPC8360)
Dave Liua46daea2006-11-03 19:33:44 -0600444 gd->ddr_sec_clk = ddr_sec_clk;
Dave Liue740c462006-12-07 21:13:15 +0800445#endif
446#if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X)
Kim Phillipsbae24792006-11-02 19:47:11 -0600447 gd->qe_clk = qe_clk;
448 gd->brg_clk = brg_clk;
Dave Liua46daea2006-11-03 19:33:44 -0600449#endif
Dave Liu5245ff52007-09-18 12:36:11 +0800450#if defined(CONFIG_MPC837X)
451 gd->pciexp1_clk = pciexp1_clk;
452 gd->pciexp2_clk = pciexp2_clk;
453 gd->sata_clk = sata_clk;
454#endif
Kim Phillipscd9fd702007-08-15 22:30:19 -0500455 gd->pci_clk = pci_sync_in;
Kim Phillipsbae24792006-11-02 19:47:11 -0600456 gd->cpu_clk = gd->core_clk;
457 gd->bus_clk = gd->csb_clk;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500458 return 0;
Dave Liua46daea2006-11-03 19:33:44 -0600459
Eran Liberty9095d4a2005-07-28 10:08:46 -0500460}
461
462/********************************************
463 * get_bus_freq
464 * return system bus freq in Hz
465 *********************************************/
Kim Phillipsbae24792006-11-02 19:47:11 -0600466ulong get_bus_freq(ulong dummy)
Eran Liberty9095d4a2005-07-28 10:08:46 -0500467{
Eran Liberty9095d4a2005-07-28 10:08:46 -0500468 return gd->csb_clk;
469}
470
Kim Phillipsd82b0772007-04-30 15:26:21 -0500471int do_clocks (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
Eran Liberty9095d4a2005-07-28 10:08:46 -0500472{
Eran Liberty9095d4a2005-07-28 10:08:46 -0500473 printf("Clock configuration:\n");
Kim Phillipsbae24792006-11-02 19:47:11 -0600474 printf(" Core: %4d MHz\n", gd->core_clk / 1000000);
Kim Phillipsd82b0772007-04-30 15:26:21 -0500475 printf(" Coherent System Bus: %4d MHz\n", gd->csb_clk / 1000000);
Dave Liue740c462006-12-07 21:13:15 +0800476#if defined(CONFIG_MPC8360) || defined(CONFIG_MPC832X)
Kim Phillipsbae24792006-11-02 19:47:11 -0600477 printf(" QE: %4d MHz\n", gd->qe_clk / 1000000);
Dave Liue740c462006-12-07 21:13:15 +0800478 printf(" BRG: %4d MHz\n", gd->brg_clk / 1000000);
Dave Liua46daea2006-11-03 19:33:44 -0600479#endif
Kim Phillipsbae24792006-11-02 19:47:11 -0600480 printf(" Local Bus Controller:%4d MHz\n", gd->lbiu_clk / 1000000);
481 printf(" Local Bus: %4d MHz\n", gd->lclk_clk / 1000000);
482 printf(" DDR: %4d MHz\n", gd->ddr_clk / 1000000);
Dave Liue740c462006-12-07 21:13:15 +0800483#if defined(CONFIG_MPC8360)
Kim Phillipsbae24792006-11-02 19:47:11 -0600484 printf(" DDR Secondary: %4d MHz\n", gd->ddr_sec_clk / 1000000);
Dave Liua46daea2006-11-03 19:33:44 -0600485#endif
Kim Phillipsbae24792006-11-02 19:47:11 -0600486 printf(" SEC: %4d MHz\n", gd->enc_clk / 1000000);
487 printf(" I2C1: %4d MHz\n", gd->i2c1_clk / 1000000);
Dave Liue740c462006-12-07 21:13:15 +0800488#if !defined(CONFIG_MPC832X)
Kim Phillipsbae24792006-11-02 19:47:11 -0600489 printf(" I2C2: %4d MHz\n", gd->i2c2_clk / 1000000);
Dave Liue740c462006-12-07 21:13:15 +0800490#endif
Dave Liu5245ff52007-09-18 12:36:11 +0800491#if defined(CONFIG_MPC837X)
492 printf(" SDHC: %4d MHz\n", gd->sdhc_clk / 1000000);
493#endif
494#if defined(CONFIG_MPC834X) || defined(CONFIG_MPC831X) || defined(CONFIG_MPC837X)
Kim Phillipsbae24792006-11-02 19:47:11 -0600495 printf(" TSEC1: %4d MHz\n", gd->tsec1_clk / 1000000);
496 printf(" TSEC2: %4d MHz\n", gd->tsec2_clk / 1000000);
Kim Phillipsbae24792006-11-02 19:47:11 -0600497 printf(" USB DR: %4d MHz\n", gd->usbdr_clk / 1000000);
Dave Liua46daea2006-11-03 19:33:44 -0600498#endif
Scott Woodc036fc92007-04-16 14:34:19 -0500499#if defined(CONFIG_MPC834X)
500 printf(" USB MPH: %4d MHz\n", gd->usbmph_clk / 1000000);
501#endif
Dave Liu5245ff52007-09-18 12:36:11 +0800502#if defined(CONFIG_MPC837X)
503 printf(" PCIEXP1: %4d MHz\n", gd->pciexp1_clk / 1000000);
504 printf(" PCIEXP2: %4d MHz\n", gd->pciexp2_clk / 1000000);
505 printf(" SATA: %4d MHz\n", gd->sata_clk / 1000000);
506#endif
Jon Loeligerebc72242005-08-01 13:20:47 -0500507 return 0;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500508}
Kim Phillipsd82b0772007-04-30 15:26:21 -0500509
510U_BOOT_CMD(clocks, 1, 0, do_clocks,
511 "clocks - print clock configuration\n",
512 " clocks\n"
513);