blob: 5353e3d535071718ac18b1dffcc82f31eecd7456 [file] [log] [blame]
wdenk945af8d2003-07-16 21:53:01 +00001/*
2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <mpc5xxx.h>
26#include <asm/processor.h>
27
Wolfgang Denkd87080b2006-03-31 18:32:53 +020028DECLARE_GLOBAL_DATA_PTR;
29
wdenk945af8d2003-07-16 21:53:01 +000030/* ------------------------------------------------------------------------- */
31
32/* Bus-to-Core Multipliers */
33
34static int bus2core[] = {
wdenk7cb22f92003-12-27 19:24:54 +000035 3, 2, 2, 2, 4, 4, 5, 9,
36 6, 11, 8, 10, 3, 12, 7, 0,
37 6, 5, 13, 2, 14, 4, 15, 9,
38 0, 11, 8, 10, 16, 12, 7, 0
wdenk945af8d2003-07-16 21:53:01 +000039};
40/* ------------------------------------------------------------------------- */
41
42/*
43 *
44 */
45
46int get_clocks (void)
47{
wdenk945af8d2003-07-16 21:53:01 +000048 ulong val, vco;
49
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020050#if !defined(CONFIG_SYS_MPC5XXX_CLKIN)
51#error clock measuring not implemented yet - define CONFIG_SYS_MPC5XXX_CLKIN
wdenk945af8d2003-07-16 21:53:01 +000052#endif
53
54 val = *(vu_long *)MPC5XXX_CDM_PORCFG;
55 if (val & (1 << 6)) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056 vco = CONFIG_SYS_MPC5XXX_CLKIN * 12;
wdenk945af8d2003-07-16 21:53:01 +000057 } else {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020058 vco = CONFIG_SYS_MPC5XXX_CLKIN * 16;
wdenk945af8d2003-07-16 21:53:01 +000059 }
60 if (val & (1 << 5)) {
61 gd->bus_clk = vco / 8;
62 } else {
63 gd->bus_clk = vco / 4;
64 }
wdenk7cb22f92003-12-27 19:24:54 +000065 gd->cpu_clk = gd->bus_clk * bus2core[val & 0x1f] / 2;
wdenk945af8d2003-07-16 21:53:01 +000066
67 val = *(vu_long *)MPC5XXX_CDM_CFG;
68 if (val & (1 << 8)) {
Simon Glassb2877492012-12-13 20:48:53 +000069 gd->arch.ipb_clk = gd->bus_clk / 2;
wdenk945af8d2003-07-16 21:53:01 +000070 } else {
Simon Glassb2877492012-12-13 20:48:53 +000071 gd->arch.ipb_clk = gd->bus_clk;
wdenk945af8d2003-07-16 21:53:01 +000072 }
73 switch (val & 3) {
Simon Glassb2877492012-12-13 20:48:53 +000074 case 0:
75 gd->pci_clk = gd->arch.ipb_clk;
76 break;
77 case 1:
78 gd->pci_clk = gd->arch.ipb_clk / 2;
79 break;
80 default:
81 gd->pci_clk = gd->bus_clk / 4;
82 break;
wdenk945af8d2003-07-16 21:53:01 +000083 }
84
85 return (0);
86}
87
88int prt_mpc5xxx_clks (void)
89{
Wolfgang Denk08ef89e2008-10-19 02:35:49 +020090 char buf1[32], buf2[32], buf3[32];
wdenk945af8d2003-07-16 21:53:01 +000091
Wolfgang Denk08ef89e2008-10-19 02:35:49 +020092 printf (" Bus %s MHz, IPB %s MHz, PCI %s MHz\n",
93 strmhz(buf1, gd->bus_clk),
Simon Glassb2877492012-12-13 20:48:53 +000094 strmhz(buf2, gd->arch.ipb_clk),
Wolfgang Denk08ef89e2008-10-19 02:35:49 +020095 strmhz(buf3, gd->pci_clk)
96 );
wdenk945af8d2003-07-16 21:53:01 +000097 return (0);
98}
99
100/* ------------------------------------------------------------------------- */