blob: 360404f0cfd444807fe1a98a5c4d23f72fa948d9 [file] [log] [blame]
wdenk4a9cbbe2002-08-27 09:48:53 +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 <mpc8260.h>
26#include <asm/processor.h>
27
Wolfgang Denkd87080b2006-03-31 18:32:53 +020028DECLARE_GLOBAL_DATA_PTR;
29
wdenk4a9cbbe2002-08-27 09:48:53 +000030/* ------------------------------------------------------------------------- */
31
32/* Bus-to-Core Multiplier */
33#define _1x 2
34#define _1_5x 3
35#define _2x 4
36#define _2_5x 5
37#define _3x 6
38#define _3_5x 7
39#define _4x 8
40#define _4_5x 9
41#define _5x 10
42#define _5_5x 11
43#define _6x 12
44#define _6_5x 13
45#define _7x 14
46#define _7_5x 15
47#define _8x 16
48#define _byp -1
49#define _off -2
50#define _unk -3
51
52typedef struct {
53 int b2c_mult;
54 int vco_div;
55 char *freq_60x;
56 char *freq_core;
57} corecnf_t;
58
59/*
60 * this table based on "Errata to MPC8260 PowerQUICC II User's Manual",
61 * Rev. 1, 8/2000, page 10.
62 */
63corecnf_t corecnf_tab[] = {
64 { _1_5x, 4, " 33-100", " 33-100" }, /* 0x00 */
65 { _1x, 4, " 50-150", " 50-150" }, /* 0x01 */
66 { _1x, 8, " 25-75 ", " 25-75 " }, /* 0x02 */
67 { _byp, -1, " ?-? ", " ?-? " }, /* 0x03 */
68 { _2x, 2, " 50-150", "100-300" }, /* 0x04 */
69 { _2x, 4, " 25-75 ", " 50-150" }, /* 0x05 */
70 { _2_5x, 2, " 40-120", "100-240" }, /* 0x06 */
71 { _4_5x, 2, " 22-65 ", "100-300" }, /* 0x07 */
72 { _3x, 2, " 33-100", "100-300" }, /* 0x08 */
73 { _5_5x, 2, " 18-55 ", "100-300" }, /* 0x09 */
74 { _4x, 2, " 25-75 ", "100-300" }, /* 0x0A */
75 { _5x, 2, " 20-60 ", "100-300" }, /* 0x0B */
76 { _1_5x, 8, " 16-50 ", " 16-50 " }, /* 0x0C */
77 { _6x, 2, " 16-50 ", "100-300" }, /* 0x0D */
78 { _3_5x, 2, " 30-85 ", "100-300" }, /* 0x0E */
79 { _off, -1, " ?-? ", " ?-? " }, /* 0x0F */
80 { _3x, 4, " 16-50 ", " 50-150" }, /* 0x10 */
81 { _2_5x, 4, " 20-60 ", " 50-120" }, /* 0x11 */
82 { _6_5x, 2, " 15-46 ", "100-300" }, /* 0x12 */
83 { _byp, -1, " ?-? ", " ?-? " }, /* 0x13 */
84 { _7x, 2, " 14-43 ", "100-300" }, /* 0x14 */
85 { _2x, 4, " 25-75 ", " 50-150" }, /* 0x15 */
86 { _7_5x, 2, " 13-40 ", "100-300" }, /* 0x16 */
87 { _4_5x, 2, " 22-65 ", "100-300" }, /* 0x17 */
88 { _unk, -1, " ?-? ", " ?-? " }, /* 0x18 */
89 { _5_5x, 2, " 18-55 ", "100-300" }, /* 0x19 */
90 { _4x, 2, " 25-75 ", "100-300" }, /* 0x1A */
91 { _5x, 2, " 20-60 ", "100-300" }, /* 0x1B */
92 { _8x, 2, " 12-38 ", "100-300" }, /* 0x1C */
93 { _6x, 2, " 16-50 ", "100-300" }, /* 0x1D */
94 { _3_5x, 2, " 30-85 ", "100-300" }, /* 0x1E */
95 { _off, -1, " ?-? ", " ?-? " }, /* 0x1F */
96};
97
98/* ------------------------------------------------------------------------- */
99
100/*
101 *
102 */
103
104int get_clocks (void)
105{
wdenk4a9cbbe2002-08-27 09:48:53 +0000106 volatile immap_t *immap = (immap_t *) CFG_IMMR;
107 ulong clkin;
108 ulong sccr, dfbrg;
109 ulong scmr, corecnf, busdf, cpmdf, plldf, pllmf;
110 corecnf_t *cp;
111
112#if !defined(CONFIG_8260_CLKIN)
113#error clock measuring not implemented yet - define CONFIG_8260_CLKIN
114#else
115 clkin = CONFIG_8260_CLKIN;
116#endif
117
118 sccr = immap->im_clkrst.car_sccr;
119 dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
120
121 scmr = immap->im_clkrst.car_scmr;
122 corecnf = (scmr & SCMR_CORECNF_MSK) >> SCMR_CORECNF_SHIFT;
wdenk4a9cbbe2002-08-27 09:48:53 +0000123 cp = &corecnf_tab[corecnf];
124
wdenk8564acf2003-07-14 22:13:32 +0000125 busdf = (scmr & SCMR_BUSDF_MSK) >> SCMR_BUSDF_SHIFT;
126 cpmdf = (scmr & SCMR_CPMDF_MSK) >> SCMR_CPMDF_SHIFT;
wdenk4a9cbbe2002-08-27 09:48:53 +0000127
wdenke1599e82004-10-10 23:27:33 +0000128 /* HiP7, HiP7 Rev01, HiP7 RevA */
129 if ((get_pvr () == PVR_8260_HIP7) ||
130 (get_pvr () == PVR_8260_HIP7R1) ||
131 (get_pvr () == PVR_8260_HIP7RA)) {
wdenk8564acf2003-07-14 22:13:32 +0000132 pllmf = (scmr & SCMR_PLLMF_MSKH7) >> SCMR_PLLMF_SHIFT;
133 gd->vco_out = clkin * (pllmf + 1);
134 } else { /* HiP3, HiP4 */
135 pllmf = (scmr & SCMR_PLLMF_MSK) >> SCMR_PLLMF_SHIFT;
136 plldf = (scmr & SCMR_PLLDF) ? 1 : 0;
137 gd->vco_out = (clkin * 2 * (pllmf + 1)) / (plldf + 1);
138 }
wdenk4a9cbbe2002-08-27 09:48:53 +0000139#if 0
140 if (gd->vco_out / (busdf + 1) != clkin) {
141 /* aaarrrggghhh!!! */
142 return (1);
143 }
144#endif
145
146 gd->cpm_clk = gd->vco_out / 2;
147 gd->bus_clk = clkin;
148 gd->scc_clk = gd->vco_out / 4;
149 gd->brg_clk = gd->vco_out / (1 << (2 * (dfbrg + 1)));
150
151 if (cp->b2c_mult > 0) {
152 gd->cpu_clk = (clkin * cp->b2c_mult) / 2;
153 } else {
154 gd->cpu_clk = clkin;
155 }
156
157 return (0);
158}
159
160int prt_8260_clks (void)
161{
wdenk4a9cbbe2002-08-27 09:48:53 +0000162 volatile immap_t *immap = (immap_t *) CFG_IMMR;
163 ulong sccr, dfbrg;
Wolfgang Denk23466d62006-03-12 16:14:29 +0100164 ulong scmr, corecnf, busdf, cpmdf, plldf, pllmf, pcidf;
wdenk4a9cbbe2002-08-27 09:48:53 +0000165 corecnf_t *cp;
166
167 sccr = immap->im_clkrst.car_sccr;
168 dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
169
170 scmr = immap->im_clkrst.car_scmr;
171 corecnf = (scmr & SCMR_CORECNF_MSK) >> SCMR_CORECNF_SHIFT;
172 busdf = (scmr & SCMR_BUSDF_MSK) >> SCMR_BUSDF_SHIFT;
173 cpmdf = (scmr & SCMR_CPMDF_MSK) >> SCMR_CPMDF_SHIFT;
174 plldf = (scmr & SCMR_PLLDF) ? 1 : 0;
175 pllmf = (scmr & SCMR_PLLMF_MSK) >> SCMR_PLLMF_SHIFT;
Wolfgang Denk23466d62006-03-12 16:14:29 +0100176 pcidf = (sccr & SCCR_PCIDF_MSK) >> SCCR_PCIDF_SHIFT;
wdenk4a9cbbe2002-08-27 09:48:53 +0000177
178 cp = &corecnf_tab[corecnf];
179
wdenk4b9206e2004-03-23 22:14:11 +0000180 puts (CPU_ID_STR " Clock Configuration\n - Bus-to-Core Mult ");
wdenk4a9cbbe2002-08-27 09:48:53 +0000181
182 switch (cp->b2c_mult) {
183 case _byp:
wdenk4b9206e2004-03-23 22:14:11 +0000184 puts ("BYPASS");
wdenk4a9cbbe2002-08-27 09:48:53 +0000185 break;
186
187 case _off:
wdenk4b9206e2004-03-23 22:14:11 +0000188 puts ("OFF");
wdenk4a9cbbe2002-08-27 09:48:53 +0000189 break;
190
191 case _unk:
wdenk4b9206e2004-03-23 22:14:11 +0000192 puts ("UNKNOWN");
wdenk4a9cbbe2002-08-27 09:48:53 +0000193 break;
194
195 default:
196 printf ("%d%sx",
197 cp->b2c_mult / 2,
198 (cp->b2c_mult % 2) ? ".5" : "");
199 break;
200 }
201
202 printf (", VCO Div %d, 60x Bus Freq %s, Core Freq %s\n",
203 cp->vco_div, cp->freq_60x, cp->freq_core);
204
205 printf (" - dfbrg %ld, corecnf 0x%02lx, busdf %ld, cpmdf %ld, "
Wolfgang Denk23466d62006-03-12 16:14:29 +0100206 "plldf %ld, pllmf %ld, pcidf %ld\n",
207 dfbrg, corecnf, busdf, cpmdf,
208 plldf, pllmf, pcidf);
wdenk4a9cbbe2002-08-27 09:48:53 +0000209
210 printf (" - vco_out %10ld, scc_clk %10ld, brg_clk %10ld\n",
211 gd->vco_out, gd->scc_clk, gd->brg_clk);
212
wdenk4b9206e2004-03-23 22:14:11 +0000213 printf (" - cpu_clk %10ld, cpm_clk %10ld, bus_clk %10ld\n",
wdenk4a9cbbe2002-08-27 09:48:53 +0000214 gd->cpu_clk, gd->cpm_clk, gd->bus_clk);
wdenk4b9206e2004-03-23 22:14:11 +0000215
216 if (sccr & SCCR_PCI_MODE) {
217 uint pci_div;
Wolfgang Denk23466d62006-03-12 16:14:29 +0100218 uint pcidf = (sccr & SCCR_PCIDF_MSK) >> SCCR_PCIDF_SHIFT;
wdenk4b9206e2004-03-23 22:14:11 +0000219
Wolfgang Denk23466d62006-03-12 16:14:29 +0100220 if (sccr & SCCR_PCI_MODCK) {
221 pci_div = 2;
222 if (pcidf == 9) {
223 pci_div *= 5;
224 } else if (pcidf == 0xB) {
225 pci_div *= 6;
226 } else {
227 pci_div *= (pcidf + 1);
228 }
229 } else {
230 pci_div = pcidf + 1;
231 }
wdenk4b9206e2004-03-23 22:14:11 +0000232
233 printf (" - pci_clk %10ld\n", (gd->cpm_clk * 2) / pci_div);
234 }
235 putc ('\n');
236
wdenk4a9cbbe2002-08-27 09:48:53 +0000237 return (0);
238}