blob: e229a5c5a7e0cc15901f70170728af52001729d9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk9c53f402003-10-15 23:53:47 +00002/*
Dipen Dudhat5d51bf92011-01-19 12:46:27 +05303 * Copyright 2004, 2007-2011 Freescale Semiconductor, Inc.
Kumar Galadccd9e32009-03-19 02:46:19 -05004 *
wdenk9c53f402003-10-15 23:53:47 +00005 * (C) Copyright 2003 Motorola Inc.
6 * Xianghua Xiao, (X.Xiao@motorola.com)
7 *
8 * (C) Copyright 2000
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenk9c53f402003-10-15 23:53:47 +000010 */
11
12#include <common.h>
Simon Glass33d1e702019-11-14 12:57:32 -070013#include <cpu_func.h>
wdenk9c53f402003-10-15 23:53:47 +000014#include <ppc_asm.tmpl>
Simon Glass3ba929a2020-10-30 21:38:53 -060015#include <asm/global_data.h>
Haiying Wang8cb2af72011-02-11 01:25:30 -060016#include <linux/compiler.h>
wdenk9c53f402003-10-15 23:53:47 +000017#include <asm/processor.h>
Trent Piepho0b691fc2008-12-03 15:16:37 -080018#include <asm/io.h>
wdenk9c53f402003-10-15 23:53:47 +000019
Wolfgang Denk6405a152006-03-31 18:32:53 +020020DECLARE_GLOBAL_DATA_PTR;
21
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +053022
23#ifndef CONFIG_SYS_FSL_NUM_CC_PLLS
24#define CONFIG_SYS_FSL_NUM_CC_PLLS 6
25#endif
wdenk9c53f402003-10-15 23:53:47 +000026/* --------------------------------------------------------------- */
27
Prabhakar Kushwahad1698082013-08-16 14:52:26 +053028void get_sys_info(sys_info_t *sys_info)
wdenk9c53f402003-10-15 23:53:47 +000029{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020030 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Kumar Galadccd9e32009-03-19 02:46:19 -050031#ifdef CONFIG_FSL_CORENET
32 volatile ccsr_clk_t *clk = (void *)(CONFIG_SYS_FSL_CORENET_CLK_ADDR);
Timur Tabi47289422011-08-05 16:15:24 -050033 unsigned int cpu;
Shaveta Leekhadbf0bc82015-01-19 12:46:54 +053034#ifdef CONFIG_HETROGENOUS_CLUSTERS
35 unsigned int dsp_cpu;
36 uint rcw_tmp1, rcw_tmp2;
37#endif
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +053038#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
39 int cc_group[12] = CONFIG_SYS_FSL_CLUSTER_CLOCKS;
40#endif
York Sun7c355f52014-10-27 11:31:33 -070041 __maybe_unused u32 svr;
Kumar Galadccd9e32009-03-19 02:46:19 -050042
43 const u8 core_cplx_PLL[16] = {
44 [ 0] = 0, /* CC1 PPL / 1 */
45 [ 1] = 0, /* CC1 PPL / 2 */
46 [ 2] = 0, /* CC1 PPL / 4 */
47 [ 4] = 1, /* CC2 PPL / 1 */
48 [ 5] = 1, /* CC2 PPL / 2 */
49 [ 6] = 1, /* CC2 PPL / 4 */
50 [ 8] = 2, /* CC3 PPL / 1 */
51 [ 9] = 2, /* CC3 PPL / 2 */
52 [10] = 2, /* CC3 PPL / 4 */
53 [12] = 3, /* CC4 PPL / 1 */
54 [13] = 3, /* CC4 PPL / 2 */
55 [14] = 3, /* CC4 PPL / 4 */
56 };
57
Prabhakar Kushwahad1698082013-08-16 14:52:26 +053058 const u8 core_cplx_pll_div[16] = {
Kumar Galadccd9e32009-03-19 02:46:19 -050059 [ 0] = 1, /* CC1 PPL / 1 */
60 [ 1] = 2, /* CC1 PPL / 2 */
61 [ 2] = 4, /* CC1 PPL / 4 */
62 [ 4] = 1, /* CC2 PPL / 1 */
63 [ 5] = 2, /* CC2 PPL / 2 */
64 [ 6] = 4, /* CC2 PPL / 4 */
65 [ 8] = 1, /* CC3 PPL / 1 */
66 [ 9] = 2, /* CC3 PPL / 2 */
67 [10] = 4, /* CC3 PPL / 4 */
68 [12] = 1, /* CC4 PPL / 1 */
69 [13] = 2, /* CC4 PPL / 2 */
70 [14] = 4, /* CC4 PPL / 4 */
71 };
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +053072 uint i, freq_c_pll[CONFIG_SYS_FSL_NUM_CC_PLLS];
Yangbo Lud9adb4e2019-12-19 18:59:27 +080073#if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV)
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +053074 uint rcw_tmp;
75#endif
76 uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS];
Kumar Galadccd9e32009-03-19 02:46:19 -050077 unsigned long sysclk = CONFIG_SYS_CLK_FREQ;
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +080078 uint mem_pll_rat;
Kumar Galadccd9e32009-03-19 02:46:19 -050079
Prabhakar Kushwahad1698082013-08-16 14:52:26 +053080 sys_info->freq_systembus = sysclk;
Priyanka Jaine9dcaa82013-12-17 14:25:52 +053081#ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
vijay raid84fd502014-04-15 11:34:12 +053082 uint ddr_refclk_sel;
83 unsigned int porsr1_sys_clk;
84 porsr1_sys_clk = in_be32(&gur->porsr1) >> FSL_DCFG_PORSR1_SYSCLK_SHIFT
85 & FSL_DCFG_PORSR1_SYSCLK_MASK;
86 if (porsr1_sys_clk == FSL_DCFG_PORSR1_SYSCLK_DIFF)
87 sys_info->diff_sysclk = 1;
88 else
89 sys_info->diff_sysclk = 0;
90
Priyanka Jaine9dcaa82013-12-17 14:25:52 +053091 /*
92 * DDR_REFCLK_SEL rcw bit is used to determine if DDR PLLS
93 * are driven by separate DDR Refclock or single source
94 * differential clock.
95 */
vijay raid84fd502014-04-15 11:34:12 +053096 ddr_refclk_sel = (in_be32(&gur->rcwsr[5]) >>
Priyanka Jaine9dcaa82013-12-17 14:25:52 +053097 FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT) &
98 FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK;
99 /*
vijay raid84fd502014-04-15 11:34:12 +0530100 * For single source clocking, both ddrclock and sysclock
Priyanka Jaine9dcaa82013-12-17 14:25:52 +0530101 * are driven by differential sysclock.
102 */
vijay raid84fd502014-04-15 11:34:12 +0530103 if (ddr_refclk_sel == FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK)
Priyanka Jaine9dcaa82013-12-17 14:25:52 +0530104 sys_info->freq_ddrbus = CONFIG_SYS_CLK_FREQ;
vijay raid84fd502014-04-15 11:34:12 +0530105 else
Priyanka Jaine9dcaa82013-12-17 14:25:52 +0530106#endif
York Sun3b5179f2012-10-08 07:44:31 +0000107#ifdef CONFIG_DDR_CLK_FREQ
Priyanka Jaine9dcaa82013-12-17 14:25:52 +0530108 sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ;
York Sun3b5179f2012-10-08 07:44:31 +0000109#else
Priyanka Jaine9dcaa82013-12-17 14:25:52 +0530110 sys_info->freq_ddrbus = sysclk;
York Sun3b5179f2012-10-08 07:44:31 +0000111#endif
Kumar Galadccd9e32009-03-19 02:46:19 -0500112
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530113 sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
York Sunb8a076b2012-10-08 07:44:09 +0000114 mem_pll_rat = (in_be32(&gur->rcwsr[0]) >>
115 FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT)
116 & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK;
York Sun7b083df2014-03-28 15:07:27 -0700117#ifdef CONFIG_SYS_FSL_ERRATUM_A007212
118 if (mem_pll_rat == 0) {
119 mem_pll_rat = (in_be32(&gur->rcwsr[0]) >>
120 FSL_CORENET_RCWSR0_MEM_PLL_RAT_RESV_SHIFT) &
121 FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK;
122 }
123#endif
Zang Roy-R619111b1e5cf2013-11-28 13:23:37 +0800124 /* T4240/T4160 Rev2.0 MEM_PLL_RAT uses a value which is half of
125 * T4240/T4160 Rev1.0. eg. It's 12 in Rev1.0, however, for Rev2.0
126 * it uses 6.
York Sun7c355f52014-10-27 11:31:33 -0700127 * T2080 rev 1.1 and later also use half mem_pll comparing with rev 1.0
Zang Roy-R619111b1e5cf2013-11-28 13:23:37 +0800128 */
Tom Rinia7ffa3d2021-05-23 10:58:05 -0400129#if defined(CONFIG_ARCH_T4240) || defined(CONFIG_ARCH_T2080)
York Sun7c355f52014-10-27 11:31:33 -0700130 svr = get_svr();
131 switch (SVR_SOC_VER(svr)) {
132 case SVR_T4240:
133 case SVR_T4160:
134 case SVR_T4120:
135 case SVR_T4080:
136 if (SVR_MAJ(svr) >= 2)
137 mem_pll_rat *= 2;
138 break;
139 case SVR_T2080:
140 case SVR_T2081:
141 if ((SVR_MAJ(svr) > 1) || (SVR_MIN(svr) >= 1))
142 mem_pll_rat *= 2;
143 break;
144 default:
145 break;
146 }
Zang Roy-R619111b1e5cf2013-11-28 13:23:37 +0800147#endif
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +0800148 if (mem_pll_rat > 2)
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530149 sys_info->freq_ddrbus *= mem_pll_rat;
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +0800150 else
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530151 sys_info->freq_ddrbus = sys_info->freq_systembus * mem_pll_rat;
Kumar Galadccd9e32009-03-19 02:46:19 -0500152
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530153 for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) {
154 ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0x3f;
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +0800155 if (ratio[i] > 4)
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530156 freq_c_pll[i] = sysclk * ratio[i];
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +0800157 else
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530158 freq_c_pll[i] = sys_info->freq_systembus * ratio[i];
Srikanth Srinivasanf58c2a42010-02-10 17:32:43 +0800159 }
Shaveta Leekhadbf0bc82015-01-19 12:46:54 +0530160
York Sund7778f72012-10-08 07:44:11 +0000161#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
162 /*
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530163 * As per CHASSIS2 architeture total 12 clusters are posible and
York Sund7778f72012-10-08 07:44:11 +0000164 * Each cluster has up to 4 cores, sharing the same PLL selection.
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530165 * The cluster clock assignment is SoC defined.
166 *
167 * Total 4 clock groups are possible with 3 PLLs each.
168 * as per array indices, clock group A has 0, 1, 2 numbered PLLs &
169 * clock group B has 3, 4, 6 and so on.
170 *
171 * Clock group A having PLL1, PLL2, PLL3, feeding cores of any cluster
172 * depends upon the SoC architeture. Same applies to other
173 * clock groups and clusters.
174 *
York Sund7778f72012-10-08 07:44:11 +0000175 */
Timur Tabi47289422011-08-05 16:15:24 -0500176 for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) {
York Sunaa150bb2013-03-25 07:40:07 +0000177 int cluster = fsl_qoriq_core_to_cluster(cpu);
178 u32 c_pll_sel = (in_be32(&clk->clkcsr[cluster].clkcncsr) >> 27)
York Sund7778f72012-10-08 07:44:11 +0000179 & 0xf;
Kumar Galadccd9e32009-03-19 02:46:19 -0500180 u32 cplx_pll = core_cplx_PLL[c_pll_sel];
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530181 cplx_pll += cc_group[cluster] - 1;
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530182 sys_info->freq_processor[cpu] =
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530183 freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel];
Kumar Galadccd9e32009-03-19 02:46:19 -0500184 }
Shaveta Leekhadbf0bc82015-01-19 12:46:54 +0530185
186#ifdef CONFIG_HETROGENOUS_CLUSTERS
187 for_each_cpu(i, dsp_cpu, cpu_num_dspcores(), cpu_dsp_mask()) {
188 int dsp_cluster = fsl_qoriq_dsp_core_to_cluster(dsp_cpu);
189 u32 c_pll_sel = (in_be32
190 (&clk->clkcsr[dsp_cluster].clkcncsr) >> 27)
191 & 0xf;
192 u32 cplx_pll = core_cplx_PLL[c_pll_sel];
193 cplx_pll += cc_group[dsp_cluster] - 1;
194 sys_info->freq_processor_dsp[dsp_cpu] =
195 freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel];
196 }
197#endif
198
York Sunfda566d2016-11-18 11:56:57 -0800199#if defined(CONFIG_ARCH_B4860) || defined(CONFIG_ARCH_B4420) || \
Tom Rini3ec582b2021-02-20 20:06:21 -0500200 defined(CONFIG_ARCH_T2080)
Sandeep Singhf7dfe252013-03-25 07:33:09 +0000201#define FM1_CLK_SEL 0xe0000000
202#define FM1_CLK_SHIFT 29
Tom Rinib4e60262021-05-14 21:34:22 -0400203#elif defined(CONFIG_ARCH_T1024)
Shengzhou Liue6fb7702014-11-24 17:11:54 +0800204#define FM1_CLK_SEL 0x00000007
205#define FM1_CLK_SHIFT 0
Sandeep Singhf7dfe252013-03-25 07:33:09 +0000206#else
York Sund7778f72012-10-08 07:44:11 +0000207#define PME_CLK_SEL 0xe0000000
208#define PME_CLK_SHIFT 29
209#define FM1_CLK_SEL 0x1c000000
210#define FM1_CLK_SHIFT 26
Sandeep Singhf7dfe252013-03-25 07:33:09 +0000211#endif
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530212#if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV)
Tom Rinib4e60262021-05-14 21:34:22 -0400213#if defined(CONFIG_ARCH_T1024)
Shengzhou Liue6fb7702014-11-24 17:11:54 +0800214 rcw_tmp = in_be32(&gur->rcwsr[15]) - 4;
215#else
York Sund7778f72012-10-08 07:44:11 +0000216 rcw_tmp = in_be32(&gur->rcwsr[7]);
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530217#endif
Shengzhou Liue6fb7702014-11-24 17:11:54 +0800218#endif
York Sund7778f72012-10-08 07:44:11 +0000219
220#ifdef CONFIG_SYS_DPAA_PME
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530221#ifndef CONFIG_PME_PLAT_CLK_DIV
York Sund7778f72012-10-08 07:44:11 +0000222 switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) {
223 case 1:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530224 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK];
York Sund7778f72012-10-08 07:44:11 +0000225 break;
226 case 2:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530227 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2;
York Sund7778f72012-10-08 07:44:11 +0000228 break;
229 case 3:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530230 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3;
York Sund7778f72012-10-08 07:44:11 +0000231 break;
232 case 4:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530233 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4;
York Sund7778f72012-10-08 07:44:11 +0000234 break;
235 case 6:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530236 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 2;
York Sund7778f72012-10-08 07:44:11 +0000237 break;
238 case 7:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530239 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 3;
York Sund7778f72012-10-08 07:44:11 +0000240 break;
241 default:
242 printf("Error: Unknown PME clock select!\n");
243 case 0:
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530244 sys_info->freq_pme = sys_info->freq_systembus / 2;
York Sund7778f72012-10-08 07:44:11 +0000245 break;
246
247 }
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530248#else
249 sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK;
250
251#endif
York Sund7778f72012-10-08 07:44:11 +0000252#endif
253
Haiying Wang09d0aa92012-10-11 07:13:39 +0000254#ifdef CONFIG_SYS_DPAA_QBMAN
Shengzhou Liue6fb7702014-11-24 17:11:54 +0800255#ifndef CONFIG_QBMAN_CLK_DIV
256#define CONFIG_QBMAN_CLK_DIV 2
257#endif
258 sys_info->freq_qman = sys_info->freq_systembus / CONFIG_QBMAN_CLK_DIV;
Haiying Wang09d0aa92012-10-11 07:13:39 +0000259#endif
260
Shaveta Leekhadbf0bc82015-01-19 12:46:54 +0530261#if defined(CONFIG_SYS_MAPLE)
262#define CPRI_CLK_SEL 0x1C000000
263#define CPRI_CLK_SHIFT 26
264#define CPRI_ALT_CLK_SEL 0x00007000
265#define CPRI_ALT_CLK_SHIFT 12
266
267 rcw_tmp1 = in_be32(&gur->rcwsr[7]); /* Reading RCW bits: 224-255*/
268 rcw_tmp2 = in_be32(&gur->rcwsr[15]); /* Reading RCW bits: 480-511*/
269 /* For MAPLE and CPRI frequency */
270 switch ((rcw_tmp1 & CPRI_CLK_SEL) >> CPRI_CLK_SHIFT) {
271 case 1:
272 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK];
273 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK];
274 break;
275 case 2:
276 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 2;
277 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 2;
278 break;
279 case 3:
280 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 3;
281 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 3;
282 break;
283 case 4:
284 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 4;
285 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 4;
286 break;
287 case 5:
288 if (((rcw_tmp2 & CPRI_ALT_CLK_SEL)
289 >> CPRI_ALT_CLK_SHIFT) == 6) {
290 sys_info->freq_maple =
291 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 2;
292 sys_info->freq_cpri =
293 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 2;
294 }
295 if (((rcw_tmp2 & CPRI_ALT_CLK_SEL)
296 >> CPRI_ALT_CLK_SHIFT) == 7) {
297 sys_info->freq_maple =
298 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 3;
299 sys_info->freq_cpri =
300 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 3;
301 }
302 break;
303 case 6:
304 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 2;
305 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 2;
306 break;
307 case 7:
308 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 3;
309 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 3;
310 break;
311 default:
312 printf("Error: Unknown MAPLE/CPRI clock select!\n");
313 }
314
315 /* For MAPLE ULB and eTVPE frequencies */
316#define ULB_CLK_SEL 0x00000038
317#define ULB_CLK_SHIFT 3
318#define ETVPE_CLK_SEL 0x00000007
319#define ETVPE_CLK_SHIFT 0
320
321 switch ((rcw_tmp2 & ULB_CLK_SEL) >> ULB_CLK_SHIFT) {
322 case 1:
323 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK];
324 break;
325 case 2:
326 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 2;
327 break;
328 case 3:
329 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 3;
330 break;
331 case 4:
332 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 4;
333 break;
334 case 5:
335 sys_info->freq_maple_ulb = sys_info->freq_systembus;
336 break;
337 case 6:
338 sys_info->freq_maple_ulb =
339 freq_c_pll[CONFIG_SYS_ULB_CLK - 1] / 2;
340 break;
341 case 7:
342 sys_info->freq_maple_ulb =
343 freq_c_pll[CONFIG_SYS_ULB_CLK - 1] / 3;
344 break;
345 default:
346 printf("Error: Unknown MAPLE ULB clock select!\n");
347 }
348
349 switch ((rcw_tmp2 & ETVPE_CLK_SEL) >> ETVPE_CLK_SHIFT) {
350 case 1:
351 sys_info->freq_maple_etvpe = freq_c_pll[CONFIG_SYS_ETVPE_CLK];
352 break;
353 case 2:
354 sys_info->freq_maple_etvpe =
355 freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 2;
356 break;
357 case 3:
358 sys_info->freq_maple_etvpe =
359 freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 3;
360 break;
361 case 4:
362 sys_info->freq_maple_etvpe =
363 freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 4;
364 break;
365 case 5:
366 sys_info->freq_maple_etvpe = sys_info->freq_systembus;
367 break;
368 case 6:
369 sys_info->freq_maple_etvpe =
370 freq_c_pll[CONFIG_SYS_ETVPE_CLK - 1] / 2;
371 break;
372 case 7:
373 sys_info->freq_maple_etvpe =
374 freq_c_pll[CONFIG_SYS_ETVPE_CLK - 1] / 3;
375 break;
376 default:
377 printf("Error: Unknown MAPLE eTVPE clock select!\n");
378 }
379
380#endif
381
York Sund7778f72012-10-08 07:44:11 +0000382#ifdef CONFIG_SYS_DPAA_FMAN
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530383#ifndef CONFIG_FM_PLAT_CLK_DIV
York Sund7778f72012-10-08 07:44:11 +0000384 switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) {
385 case 1:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530386 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK];
York Sund7778f72012-10-08 07:44:11 +0000387 break;
388 case 2:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530389 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 2;
York Sund7778f72012-10-08 07:44:11 +0000390 break;
391 case 3:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530392 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 3;
York Sund7778f72012-10-08 07:44:11 +0000393 break;
394 case 4:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530395 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 4;
York Sund7778f72012-10-08 07:44:11 +0000396 break;
Sandeep Singhf7dfe252013-03-25 07:33:09 +0000397 case 5:
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530398 sys_info->freq_fman[0] = sys_info->freq_systembus;
Sandeep Singhf7dfe252013-03-25 07:33:09 +0000399 break;
York Sund7778f72012-10-08 07:44:11 +0000400 case 6:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530401 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 2;
York Sund7778f72012-10-08 07:44:11 +0000402 break;
403 case 7:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530404 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 3;
York Sund7778f72012-10-08 07:44:11 +0000405 break;
406 default:
407 printf("Error: Unknown FMan1 clock select!\n");
408 case 0:
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530409 sys_info->freq_fman[0] = sys_info->freq_systembus / 2;
York Sund7778f72012-10-08 07:44:11 +0000410 break;
411 }
412#if (CONFIG_SYS_NUM_FMAN) == 2
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530413#ifdef CONFIG_SYS_FM2_CLK
York Sund7778f72012-10-08 07:44:11 +0000414#define FM2_CLK_SEL 0x00000038
415#define FM2_CLK_SHIFT 3
416 rcw_tmp = in_be32(&gur->rcwsr[15]);
417 switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) {
418 case 1:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530419 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1];
York Sund7778f72012-10-08 07:44:11 +0000420 break;
421 case 2:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530422 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 2;
York Sund7778f72012-10-08 07:44:11 +0000423 break;
424 case 3:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530425 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 3;
York Sund7778f72012-10-08 07:44:11 +0000426 break;
427 case 4:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530428 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 4;
York Sund7778f72012-10-08 07:44:11 +0000429 break;
Shaohui Xie45359a32013-11-28 13:52:51 +0800430 case 5:
431 sys_info->freq_fman[1] = sys_info->freq_systembus;
432 break;
York Sund7778f72012-10-08 07:44:11 +0000433 case 6:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530434 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 2;
York Sund7778f72012-10-08 07:44:11 +0000435 break;
436 case 7:
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530437 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 3;
York Sund7778f72012-10-08 07:44:11 +0000438 break;
439 default:
440 printf("Error: Unknown FMan2 clock select!\n");
441 case 0:
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530442 sys_info->freq_fman[1] = sys_info->freq_systembus / 2;
York Sund7778f72012-10-08 07:44:11 +0000443 break;
444 }
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530445#endif
York Sund7778f72012-10-08 07:44:11 +0000446#endif /* CONFIG_SYS_NUM_FMAN == 2 */
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530447#else
448 sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK;
449#endif
450#endif
Kumar Galadccd9e32009-03-19 02:46:19 -0500451
York Sund7778f72012-10-08 07:44:11 +0000452#else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
453
454 for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) {
York Sunaa150bb2013-03-25 07:40:07 +0000455 u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27)
456 & 0xf;
York Sund7778f72012-10-08 07:44:11 +0000457 u32 cplx_pll = core_cplx_PLL[c_pll_sel];
458
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530459 sys_info->freq_processor[cpu] =
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530460 freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel];
York Sund7778f72012-10-08 07:44:11 +0000461 }
Kumar Galadccd9e32009-03-19 02:46:19 -0500462#define PME_CLK_SEL 0x80000000
463#define FM1_CLK_SEL 0x40000000
464#define FM2_CLK_SEL 0x20000000
Kumar Gala3842bb52011-02-16 02:03:29 -0600465#define HWA_ASYNC_DIV 0x04000000
466#if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2)
467#define HWA_CC_PLL 1
Timur Tabid5e13882012-10-05 11:09:19 +0000468#elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3)
469#define HWA_CC_PLL 2
Kumar Gala3842bb52011-02-16 02:03:29 -0600470#elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4)
Wolfgang Denk80f70212011-05-19 22:21:41 +0200471#define HWA_CC_PLL 2
Kumar Gala3842bb52011-02-16 02:03:29 -0600472#else
473#error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case
474#endif
Kumar Galadccd9e32009-03-19 02:46:19 -0500475 rcw_tmp = in_be32(&gur->rcwsr[7]);
476
477#ifdef CONFIG_SYS_DPAA_PME
Kumar Gala3842bb52011-02-16 02:03:29 -0600478 if (rcw_tmp & PME_CLK_SEL) {
479 if (rcw_tmp & HWA_ASYNC_DIV)
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530480 sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4;
Kumar Gala3842bb52011-02-16 02:03:29 -0600481 else
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530482 sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2;
Kumar Gala3842bb52011-02-16 02:03:29 -0600483 } else {
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530484 sys_info->freq_pme = sys_info->freq_systembus / 2;
Kumar Gala3842bb52011-02-16 02:03:29 -0600485 }
Kumar Galadccd9e32009-03-19 02:46:19 -0500486#endif
487
488#ifdef CONFIG_SYS_DPAA_FMAN
Kumar Gala3842bb52011-02-16 02:03:29 -0600489 if (rcw_tmp & FM1_CLK_SEL) {
490 if (rcw_tmp & HWA_ASYNC_DIV)
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530491 sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4;
Kumar Gala3842bb52011-02-16 02:03:29 -0600492 else
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530493 sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2;
Kumar Gala3842bb52011-02-16 02:03:29 -0600494 } else {
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530495 sys_info->freq_fman[0] = sys_info->freq_systembus / 2;
Kumar Gala3842bb52011-02-16 02:03:29 -0600496 }
Kumar Galadccd9e32009-03-19 02:46:19 -0500497#if (CONFIG_SYS_NUM_FMAN) == 2
Kumar Gala3842bb52011-02-16 02:03:29 -0600498 if (rcw_tmp & FM2_CLK_SEL) {
499 if (rcw_tmp & HWA_ASYNC_DIV)
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530500 sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4;
Kumar Gala3842bb52011-02-16 02:03:29 -0600501 else
Prabhakar Kushwaha7e8382f2013-09-03 11:20:15 +0530502 sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2;
Kumar Gala3842bb52011-02-16 02:03:29 -0600503 } else {
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530504 sys_info->freq_fman[1] = sys_info->freq_systembus / 2;
Kumar Gala3842bb52011-02-16 02:03:29 -0600505 }
Kumar Galadccd9e32009-03-19 02:46:19 -0500506#endif
507#endif
508
Shaohui Xie835c9ad2013-03-25 07:33:25 +0000509#ifdef CONFIG_SYS_DPAA_QBMAN
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530510 sys_info->freq_qman = sys_info->freq_systembus / 2;
Shaohui Xie835c9ad2013-03-25 07:33:25 +0000511#endif
512
York Sund7778f72012-10-08 07:44:11 +0000513#endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
514
Zhao Qiangb818ba22014-03-21 16:21:45 +0800515#ifdef CONFIG_U_QE
516 sys_info->freq_qe = sys_info->freq_systembus / 2;
517#endif
518
York Sund7778f72012-10-08 07:44:11 +0000519#else /* CONFIG_FSL_CORENET */
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530520 uint plat_ratio, e500_ratio, half_freq_systembus;
Haiying Wangbb8aea72009-01-15 11:58:35 -0500521 int i;
Haiying Wang61414682009-05-20 12:30:29 -0400522#ifdef CONFIG_QE
Haiying Wang8cb2af72011-02-11 01:25:30 -0600523 __maybe_unused u32 qe_ratio;
Haiying Wang61414682009-05-20 12:30:29 -0400524#endif
wdenk9c53f402003-10-15 23:53:47 +0000525
526 plat_ratio = (gur->porpllsr) & 0x0000003e;
527 plat_ratio >>= 1;
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530528 sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ;
Andy Fleming6d972762007-04-23 02:37:47 -0500529
530 /* Divide before multiply to avoid integer
531 * overflow for processor speeds above 2GHz */
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530532 half_freq_systembus = sys_info->freq_systembus/2;
Poonam Aggrwal4baef822009-07-31 12:08:14 +0530533 for (i = 0; i < cpu_numcores(); i++) {
Haiying Wangbb8aea72009-01-15 11:58:35 -0500534 e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f;
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530535 sys_info->freq_processor[i] = e500_ratio * half_freq_systembus;
Haiying Wangbb8aea72009-01-15 11:58:35 -0500536 }
James Yangd1d51ad2008-02-08 18:05:08 -0600537
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530538 /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */
539 sys_info->freq_ddrbus = sys_info->freq_systembus;
Kumar Gala07db1702007-12-07 04:59:26 -0600540
541#ifdef CONFIG_DDR_CLK_FREQ
542 {
Jason Jinbfcd6c32008-09-27 14:40:57 +0800543 u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO)
544 >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
Kumar Gala07db1702007-12-07 04:59:26 -0600545 if (ddr_ratio != 0x7)
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530546 sys_info->freq_ddrbus = ddr_ratio * CONFIG_DDR_CLK_FREQ;
Kumar Gala07db1702007-12-07 04:59:26 -0600547 }
548#endif
Trent Piepho0b691fc2008-12-03 15:16:37 -0800549
Haiying Wang61414682009-05-20 12:30:29 -0400550#ifdef CONFIG_QE
York Sun0f577972016-11-18 11:05:38 -0800551#if defined(CONFIG_ARCH_P1021) || defined(CONFIG_ARCH_P1025)
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530552 sys_info->freq_qe = sys_info->freq_systembus;
Haiying Wang8cb2af72011-02-11 01:25:30 -0600553#else
Haiying Wang61414682009-05-20 12:30:29 -0400554 qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO)
555 >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT;
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530556 sys_info->freq_qe = qe_ratio * CONFIG_SYS_CLK_FREQ;
Haiying Wang61414682009-05-20 12:30:29 -0400557#endif
Haiying Wang8cb2af72011-02-11 01:25:30 -0600558#endif
Haiying Wang325a12f2011-01-20 22:26:31 +0000559
560#ifdef CONFIG_SYS_DPAA_FMAN
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530561 sys_info->freq_fman[0] = sys_info->freq_systembus;
Haiying Wang325a12f2011-01-20 22:26:31 +0000562#endif
563
564#endif /* CONFIG_FSL_CORENET */
Haiying Wang61414682009-05-20 12:30:29 -0400565
Dipen Dudhat5d51bf92011-01-19 12:46:27 +0530566#if defined(CONFIG_FSL_LBC)
Prabhakar Kushwahabedc5622017-02-02 15:02:00 +0530567 sys_info->freq_localbus = sys_info->freq_systembus /
568 CONFIG_SYS_FSL_LBC_CLK_DIV;
Dipen Dudhat5d51bf92011-01-19 12:46:27 +0530569#endif
Kumar Gala17ec6fa2012-10-08 07:44:06 +0000570
571#if defined(CONFIG_FSL_IFC)
Prabhakar Kushwaha3c48f582017-02-02 15:01:26 +0530572 sys_info->freq_localbus = sys_info->freq_systembus /
573 CONFIG_SYS_FSL_IFC_CLK_DIV;
Kumar Gala17ec6fa2012-10-08 07:44:06 +0000574#endif
wdenk9c53f402003-10-15 23:53:47 +0000575}
576
Simon Glass85d65312019-12-28 10:44:58 -0700577int get_clocks(void)
wdenk9c53f402003-10-15 23:53:47 +0000578{
wdenk9c53f402003-10-15 23:53:47 +0000579 sys_info_t sys_info;
York Sun5ac012a2016-11-15 13:57:15 -0800580#ifdef CONFIG_ARCH_MPC8544
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200581 volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR;
Timur Tabi44befe02008-04-04 11:15:58 -0500582#endif
Jon Loeligerf5ad3782005-07-23 10:37:35 -0500583#if defined(CONFIG_CPM2)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200584 volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR;
wdenk9c53f402003-10-15 23:53:47 +0000585 uint sccr, dfbrg;
586
587 /* set VCO = 4 * BRG */
Kumar Galacd113a02007-11-28 00:36:33 -0600588 cpm->im_cpm_intctl.sccr &= 0xfffffffc;
589 sccr = cpm->im_cpm_intctl.sccr;
wdenk9c53f402003-10-15 23:53:47 +0000590 dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
591#endif
592 get_sys_info (&sys_info);
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530593 gd->cpu_clk = sys_info.freq_processor[0];
594 gd->bus_clk = sys_info.freq_systembus;
595 gd->mem_clk = sys_info.freq_ddrbus;
596 gd->arch.lbc_clk = sys_info.freq_localbus;
Timur Tabi44befe02008-04-04 11:15:58 -0500597
Haiying Wang61414682009-05-20 12:30:29 -0400598#ifdef CONFIG_QE
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530599 gd->arch.qe_clk = sys_info.freq_qe;
Simon Glass8518b172012-12-13 20:48:50 +0000600 gd->arch.brg_clk = gd->arch.qe_clk / 2;
Haiying Wang61414682009-05-20 12:30:29 -0400601#endif
Timur Tabi44befe02008-04-04 11:15:58 -0500602 /*
603 * The base clock for I2C depends on the actual SOC. Unfortunately,
604 * there is no pattern that can be used to determine the frequency, so
605 * the only choice is to look up the actual SOC number and use the value
606 * for that SOC. This information is taken from application note
607 * AN2919.
608 */
Tom Rini0b730a02021-05-14 21:34:21 -0400609#if defined(CONFIG_ARCH_MPC8540) || defined(CONFIG_ARCH_MPC8560)
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530610 gd->arch.i2c1_clk = sys_info.freq_systembus;
York Sun5ac012a2016-11-15 13:57:15 -0800611#elif defined(CONFIG_ARCH_MPC8544)
Timur Tabi44befe02008-04-04 11:15:58 -0500612 /*
613 * On the 8544, the I2C clock is the same as the SEC clock. This can be
614 * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See
615 * 4.4.3.3 of the 8544 RM. Note that this might actually work for all
616 * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the
617 * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544.
618 */
619 if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG)
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530620 gd->arch.i2c1_clk = sys_info.freq_systembus / 3;
Kumar Gala9632f662008-10-16 21:58:49 -0500621 else
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530622 gd->arch.i2c1_clk = sys_info.freq_systembus / 2;
Timur Tabi44befe02008-04-04 11:15:58 -0500623#else
624 /* Most 85xx SOCs use CCB/2, so this is the default behavior. */
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530625 gd->arch.i2c1_clk = sys_info.freq_systembus / 2;
Timur Tabi44befe02008-04-04 11:15:58 -0500626#endif
Simon Glassc2baaec2012-12-13 20:48:49 +0000627 gd->arch.i2c2_clk = gd->arch.i2c1_clk;
Timur Tabic1499f482008-01-09 14:35:26 -0600628
Dipen Dudhat9af188d2009-09-01 17:27:00 +0530629#if defined(CONFIG_FSL_ESDHC)
Tom Rini12084d22021-02-20 20:06:29 -0500630#if defined(CONFIG_ARCH_P1010)
Simon Glass9e247d12012-12-13 20:49:05 +0000631 gd->arch.sdhc_clk = gd->bus_clk;
Anton Vorontsovda225942009-10-15 17:47:06 +0400632#else
Simon Glass9e247d12012-12-13 20:49:05 +0000633 gd->arch.sdhc_clk = gd->bus_clk / 2;
Kumar Galacd777282008-08-12 11:14:19 -0500634#endif
Anton Vorontsovda225942009-10-15 17:47:06 +0400635#endif /* defined(CONFIG_FSL_ESDHC) */
Kumar Galacd777282008-08-12 11:14:19 -0500636
Jon Loeligerf5ad3782005-07-23 10:37:35 -0500637#if defined(CONFIG_CPM2)
Prabhakar Kushwahad1698082013-08-16 14:52:26 +0530638 gd->arch.vco_out = 2*sys_info.freq_systembus;
Simon Glass44ea8512012-12-13 20:48:46 +0000639 gd->arch.cpm_clk = gd->arch.vco_out / 2;
640 gd->arch.scc_clk = gd->arch.vco_out / 4;
641 gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1)));
wdenk9c53f402003-10-15 23:53:47 +0000642#endif
643
644 if(gd->cpu_clk != 0) return (0);
645 else return (1);
646}
647
648
649/********************************************
650 * get_bus_freq
651 * return system bus freq in Hz
652 *********************************************/
Simon Glass85d65312019-12-28 10:44:58 -0700653ulong get_bus_freq(ulong dummy)
wdenk9c53f402003-10-15 23:53:47 +0000654{
James Yangd1d51ad2008-02-08 18:05:08 -0600655 return gd->bus_clk;
wdenk9c53f402003-10-15 23:53:47 +0000656}
Kumar Gala07db1702007-12-07 04:59:26 -0600657
658/********************************************
659 * get_ddr_freq
660 * return ddr bus freq in Hz
661 *********************************************/
662ulong get_ddr_freq (ulong dummy)
663{
James Yangd1d51ad2008-02-08 18:05:08 -0600664 return gd->mem_clk;
Kumar Gala07db1702007-12-07 04:59:26 -0600665}