blob: 5a9cd281617b4c54386341d228d387add0de8b06 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk42d1f032003-10-15 23:53:47 +00002/*
Dipen Dudhatbeba93e2011-01-19 12:46:27 +05303 * Copyright 2004, 2007-2011 Freescale Semiconductor, Inc.
Kumar Gala39aaca12009-03-19 02:46:19 -05004 *
wdenk42d1f032003-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.
wdenk42d1f032003-10-15 23:53:47 +000010 */
11
12#include <common.h>
Simon Glassb5981472019-11-14 12:57:32 -070013#include <cpu_func.h>
Tom Riniefb5dab72021-08-21 13:50:17 -040014#include <clock_legacy.h>
wdenk42d1f032003-10-15 23:53:47 +000015#include <ppc_asm.tmpl>
Simon Glass401d1c42020-10-30 21:38:53 -060016#include <asm/global_data.h>
Haiying Wanga52d2f82011-02-11 01:25:30 -060017#include <linux/compiler.h>
wdenk42d1f032003-10-15 23:53:47 +000018#include <asm/processor.h>
Trent Piephoada591d2008-12-03 15:16:37 -080019#include <asm/io.h>
wdenk42d1f032003-10-15 23:53:47 +000020
Wolfgang Denkd87080b2006-03-31 18:32:53 +020021DECLARE_GLOBAL_DATA_PTR;
22
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +053023
24#ifndef CONFIG_SYS_FSL_NUM_CC_PLLS
25#define CONFIG_SYS_FSL_NUM_CC_PLLS 6
26#endif
wdenk42d1f032003-10-15 23:53:47 +000027/* --------------------------------------------------------------- */
28
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +053029void get_sys_info(sys_info_t *sys_info)
wdenk42d1f032003-10-15 23:53:47 +000030{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020031 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Kumar Gala39aaca12009-03-19 02:46:19 -050032#ifdef CONFIG_FSL_CORENET
33 volatile ccsr_clk_t *clk = (void *)(CONFIG_SYS_FSL_CORENET_CLK_ADDR);
Timur Tabifbb9ecf2011-08-05 16:15:24 -050034 unsigned int cpu;
Shaveta Leekhab8bf0ad2015-01-19 12:46:54 +053035#ifdef CONFIG_HETROGENOUS_CLUSTERS
36 unsigned int dsp_cpu;
37 uint rcw_tmp1, rcw_tmp2;
38#endif
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +053039#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
40 int cc_group[12] = CONFIG_SYS_FSL_CLUSTER_CLOCKS;
41#endif
York Sun14109c72014-10-27 11:31:33 -070042 __maybe_unused u32 svr;
Kumar Gala39aaca12009-03-19 02:46:19 -050043
44 const u8 core_cplx_PLL[16] = {
45 [ 0] = 0, /* CC1 PPL / 1 */
46 [ 1] = 0, /* CC1 PPL / 2 */
47 [ 2] = 0, /* CC1 PPL / 4 */
48 [ 4] = 1, /* CC2 PPL / 1 */
49 [ 5] = 1, /* CC2 PPL / 2 */
50 [ 6] = 1, /* CC2 PPL / 4 */
51 [ 8] = 2, /* CC3 PPL / 1 */
52 [ 9] = 2, /* CC3 PPL / 2 */
53 [10] = 2, /* CC3 PPL / 4 */
54 [12] = 3, /* CC4 PPL / 1 */
55 [13] = 3, /* CC4 PPL / 2 */
56 [14] = 3, /* CC4 PPL / 4 */
57 };
58
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +053059 const u8 core_cplx_pll_div[16] = {
Kumar Gala39aaca12009-03-19 02:46:19 -050060 [ 0] = 1, /* CC1 PPL / 1 */
61 [ 1] = 2, /* CC1 PPL / 2 */
62 [ 2] = 4, /* CC1 PPL / 4 */
63 [ 4] = 1, /* CC2 PPL / 1 */
64 [ 5] = 2, /* CC2 PPL / 2 */
65 [ 6] = 4, /* CC2 PPL / 4 */
66 [ 8] = 1, /* CC3 PPL / 1 */
67 [ 9] = 2, /* CC3 PPL / 2 */
68 [10] = 4, /* CC3 PPL / 4 */
69 [12] = 1, /* CC4 PPL / 1 */
70 [13] = 2, /* CC4 PPL / 2 */
71 [14] = 4, /* CC4 PPL / 4 */
72 };
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +053073 uint i, freq_c_pll[CONFIG_SYS_FSL_NUM_CC_PLLS];
Yangbo Luc2a8b4f2019-12-19 18:59:27 +080074#if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV)
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +053075 uint rcw_tmp;
76#endif
77 uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS];
Tom Rini2f8a6db2021-12-14 13:36:40 -050078 unsigned long sysclk = get_board_sys_clk();
Srikanth Srinivasanab48ca12010-02-10 17:32:43 +080079 uint mem_pll_rat;
Kumar Gala39aaca12009-03-19 02:46:19 -050080
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +053081 sys_info->freq_systembus = sysclk;
Priyanka Jainb1359912013-12-17 14:25:52 +053082#ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
vijay rai0c12a152014-04-15 11:34:12 +053083 uint ddr_refclk_sel;
84 unsigned int porsr1_sys_clk;
85 porsr1_sys_clk = in_be32(&gur->porsr1) >> FSL_DCFG_PORSR1_SYSCLK_SHIFT
86 & FSL_DCFG_PORSR1_SYSCLK_MASK;
87 if (porsr1_sys_clk == FSL_DCFG_PORSR1_SYSCLK_DIFF)
88 sys_info->diff_sysclk = 1;
89 else
90 sys_info->diff_sysclk = 0;
91
Priyanka Jainb1359912013-12-17 14:25:52 +053092 /*
93 * DDR_REFCLK_SEL rcw bit is used to determine if DDR PLLS
94 * are driven by separate DDR Refclock or single source
95 * differential clock.
96 */
vijay rai0c12a152014-04-15 11:34:12 +053097 ddr_refclk_sel = (in_be32(&gur->rcwsr[5]) >>
Priyanka Jainb1359912013-12-17 14:25:52 +053098 FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT) &
99 FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK;
100 /*
vijay rai0c12a152014-04-15 11:34:12 +0530101 * For single source clocking, both ddrclock and sysclock
Priyanka Jainb1359912013-12-17 14:25:52 +0530102 * are driven by differential sysclock.
103 */
vijay rai0c12a152014-04-15 11:34:12 +0530104 if (ddr_refclk_sel == FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK)
Tom Rini2f8a6db2021-12-14 13:36:40 -0500105 sys_info->freq_ddrbus = get_board_sys_clk();
vijay rai0c12a152014-04-15 11:34:12 +0530106 else
Priyanka Jainb1359912013-12-17 14:25:52 +0530107#endif
Tom Riniefb5dab72021-08-21 13:50:17 -0400108#if defined(CONFIG_DYNAMIC_DDR_CLK_FREQ) || defined(CONFIG_STATIC_DDR_CLK_FREQ)
109 sys_info->freq_ddrbus = get_board_ddr_clk();
York Sun98ffa192012-10-08 07:44:31 +0000110#else
Priyanka Jainb1359912013-12-17 14:25:52 +0530111 sys_info->freq_ddrbus = sysclk;
York Sun98ffa192012-10-08 07:44:31 +0000112#endif
Kumar Gala39aaca12009-03-19 02:46:19 -0500113
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530114 sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
York Sunf77329c2012-10-08 07:44:09 +0000115 mem_pll_rat = (in_be32(&gur->rcwsr[0]) >>
116 FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT)
117 & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK;
York Sunc3678b02014-03-28 15:07:27 -0700118#ifdef CONFIG_SYS_FSL_ERRATUM_A007212
119 if (mem_pll_rat == 0) {
120 mem_pll_rat = (in_be32(&gur->rcwsr[0]) >>
121 FSL_CORENET_RCWSR0_MEM_PLL_RAT_RESV_SHIFT) &
122 FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK;
123 }
124#endif
Zang Roy-R61911e88f4212013-11-28 13:23:37 +0800125 /* T4240/T4160 Rev2.0 MEM_PLL_RAT uses a value which is half of
126 * T4240/T4160 Rev1.0. eg. It's 12 in Rev1.0, however, for Rev2.0
127 * it uses 6.
York Sun14109c72014-10-27 11:31:33 -0700128 * T2080 rev 1.1 and later also use half mem_pll comparing with rev 1.0
Zang Roy-R61911e88f4212013-11-28 13:23:37 +0800129 */
Tom Riniec6b37c2021-05-23 10:58:05 -0400130#if defined(CONFIG_ARCH_T4240) || defined(CONFIG_ARCH_T2080)
York Sun14109c72014-10-27 11:31:33 -0700131 svr = get_svr();
132 switch (SVR_SOC_VER(svr)) {
133 case SVR_T4240:
134 case SVR_T4160:
135 case SVR_T4120:
136 case SVR_T4080:
137 if (SVR_MAJ(svr) >= 2)
138 mem_pll_rat *= 2;
139 break;
140 case SVR_T2080:
141 case SVR_T2081:
142 if ((SVR_MAJ(svr) > 1) || (SVR_MIN(svr) >= 1))
143 mem_pll_rat *= 2;
144 break;
145 default:
146 break;
147 }
Zang Roy-R61911e88f4212013-11-28 13:23:37 +0800148#endif
Srikanth Srinivasanab48ca12010-02-10 17:32:43 +0800149 if (mem_pll_rat > 2)
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530150 sys_info->freq_ddrbus *= mem_pll_rat;
Srikanth Srinivasanab48ca12010-02-10 17:32:43 +0800151 else
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530152 sys_info->freq_ddrbus = sys_info->freq_systembus * mem_pll_rat;
Kumar Gala39aaca12009-03-19 02:46:19 -0500153
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530154 for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) {
155 ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0x3f;
Srikanth Srinivasanab48ca12010-02-10 17:32:43 +0800156 if (ratio[i] > 4)
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530157 freq_c_pll[i] = sysclk * ratio[i];
Srikanth Srinivasanab48ca12010-02-10 17:32:43 +0800158 else
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530159 freq_c_pll[i] = sys_info->freq_systembus * ratio[i];
Srikanth Srinivasanab48ca12010-02-10 17:32:43 +0800160 }
Shaveta Leekhab8bf0ad2015-01-19 12:46:54 +0530161
York Sun9a653a92012-10-08 07:44:11 +0000162#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
163 /*
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530164 * As per CHASSIS2 architeture total 12 clusters are posible and
York Sun9a653a92012-10-08 07:44:11 +0000165 * Each cluster has up to 4 cores, sharing the same PLL selection.
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530166 * The cluster clock assignment is SoC defined.
167 *
168 * Total 4 clock groups are possible with 3 PLLs each.
169 * as per array indices, clock group A has 0, 1, 2 numbered PLLs &
170 * clock group B has 3, 4, 6 and so on.
171 *
172 * Clock group A having PLL1, PLL2, PLL3, feeding cores of any cluster
173 * depends upon the SoC architeture. Same applies to other
174 * clock groups and clusters.
175 *
York Sun9a653a92012-10-08 07:44:11 +0000176 */
177 for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) {
York Sunf6981432013-03-25 07:40:07 +0000178 int cluster = fsl_qoriq_core_to_cluster(cpu);
179 u32 c_pll_sel = (in_be32(&clk->clkcsr[cluster].clkcncsr) >> 27)
York Sun9a653a92012-10-08 07:44:11 +0000180 & 0xf;
181 u32 cplx_pll = core_cplx_PLL[c_pll_sel];
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530182 cplx_pll += cc_group[cluster] - 1;
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530183 sys_info->freq_processor[cpu] =
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530184 freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel];
York Sun9a653a92012-10-08 07:44:11 +0000185 }
Shaveta Leekhab8bf0ad2015-01-19 12:46:54 +0530186
187#ifdef CONFIG_HETROGENOUS_CLUSTERS
188 for_each_cpu(i, dsp_cpu, cpu_num_dspcores(), cpu_dsp_mask()) {
189 int dsp_cluster = fsl_qoriq_dsp_core_to_cluster(dsp_cpu);
190 u32 c_pll_sel = (in_be32
191 (&clk->clkcsr[dsp_cluster].clkcncsr) >> 27)
192 & 0xf;
193 u32 cplx_pll = core_cplx_PLL[c_pll_sel];
194 cplx_pll += cc_group[dsp_cluster] - 1;
195 sys_info->freq_processor_dsp[dsp_cpu] =
196 freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel];
197 }
198#endif
199
York Sunb41f1922016-11-18 11:56:57 -0800200#if defined(CONFIG_ARCH_B4860) || defined(CONFIG_ARCH_B4420) || \
Tom Rini2322b952021-02-20 20:06:21 -0500201 defined(CONFIG_ARCH_T2080)
Sandeep Singh0cb33252013-03-25 07:33:09 +0000202#define FM1_CLK_SEL 0xe0000000
203#define FM1_CLK_SHIFT 29
Tom Rini6c3d9932021-05-14 21:34:22 -0400204#elif defined(CONFIG_ARCH_T1024)
Shengzhou Liuf6050792014-11-24 17:11:54 +0800205#define FM1_CLK_SEL 0x00000007
206#define FM1_CLK_SHIFT 0
Sandeep Singh0cb33252013-03-25 07:33:09 +0000207#else
York Sun9a653a92012-10-08 07:44:11 +0000208#define PME_CLK_SEL 0xe0000000
209#define PME_CLK_SHIFT 29
210#define FM1_CLK_SEL 0x1c000000
211#define FM1_CLK_SHIFT 26
Sandeep Singh0cb33252013-03-25 07:33:09 +0000212#endif
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530213#if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV)
Tom Rini6c3d9932021-05-14 21:34:22 -0400214#if defined(CONFIG_ARCH_T1024)
Shengzhou Liuf6050792014-11-24 17:11:54 +0800215 rcw_tmp = in_be32(&gur->rcwsr[15]) - 4;
216#else
York Sun9a653a92012-10-08 07:44:11 +0000217 rcw_tmp = in_be32(&gur->rcwsr[7]);
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530218#endif
Shengzhou Liuf6050792014-11-24 17:11:54 +0800219#endif
York Sun9a653a92012-10-08 07:44:11 +0000220
221#ifdef CONFIG_SYS_DPAA_PME
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530222#ifndef CONFIG_PME_PLAT_CLK_DIV
York Sun9a653a92012-10-08 07:44:11 +0000223 switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) {
224 case 1:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530225 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK];
York Sun9a653a92012-10-08 07:44:11 +0000226 break;
227 case 2:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530228 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2;
York Sun9a653a92012-10-08 07:44:11 +0000229 break;
230 case 3:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530231 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3;
York Sun9a653a92012-10-08 07:44:11 +0000232 break;
233 case 4:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530234 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4;
York Sun9a653a92012-10-08 07:44:11 +0000235 break;
236 case 6:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530237 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 2;
York Sun9a653a92012-10-08 07:44:11 +0000238 break;
239 case 7:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530240 sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 3;
York Sun9a653a92012-10-08 07:44:11 +0000241 break;
242 default:
243 printf("Error: Unknown PME clock select!\n");
244 case 0:
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530245 sys_info->freq_pme = sys_info->freq_systembus / 2;
York Sun9a653a92012-10-08 07:44:11 +0000246 break;
247
248 }
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530249#else
250 sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK;
251
252#endif
York Sun9a653a92012-10-08 07:44:11 +0000253#endif
254
Haiying Wang990e1a82012-10-11 07:13:39 +0000255#ifdef CONFIG_SYS_DPAA_QBMAN
Shengzhou Liuf6050792014-11-24 17:11:54 +0800256#ifndef CONFIG_QBMAN_CLK_DIV
257#define CONFIG_QBMAN_CLK_DIV 2
258#endif
259 sys_info->freq_qman = sys_info->freq_systembus / CONFIG_QBMAN_CLK_DIV;
Haiying Wang990e1a82012-10-11 07:13:39 +0000260#endif
261
Shaveta Leekhab8bf0ad2015-01-19 12:46:54 +0530262#if defined(CONFIG_SYS_MAPLE)
263#define CPRI_CLK_SEL 0x1C000000
264#define CPRI_CLK_SHIFT 26
265#define CPRI_ALT_CLK_SEL 0x00007000
266#define CPRI_ALT_CLK_SHIFT 12
267
268 rcw_tmp1 = in_be32(&gur->rcwsr[7]); /* Reading RCW bits: 224-255*/
269 rcw_tmp2 = in_be32(&gur->rcwsr[15]); /* Reading RCW bits: 480-511*/
270 /* For MAPLE and CPRI frequency */
271 switch ((rcw_tmp1 & CPRI_CLK_SEL) >> CPRI_CLK_SHIFT) {
272 case 1:
273 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK];
274 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK];
275 break;
276 case 2:
277 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 2;
278 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 2;
279 break;
280 case 3:
281 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 3;
282 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 3;
283 break;
284 case 4:
285 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 4;
286 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 4;
287 break;
288 case 5:
289 if (((rcw_tmp2 & CPRI_ALT_CLK_SEL)
290 >> CPRI_ALT_CLK_SHIFT) == 6) {
291 sys_info->freq_maple =
292 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 2;
293 sys_info->freq_cpri =
294 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 2;
295 }
296 if (((rcw_tmp2 & CPRI_ALT_CLK_SEL)
297 >> CPRI_ALT_CLK_SHIFT) == 7) {
298 sys_info->freq_maple =
299 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 3;
300 sys_info->freq_cpri =
301 freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 3;
302 }
303 break;
304 case 6:
305 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 2;
306 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 2;
307 break;
308 case 7:
309 sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 3;
310 sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 3;
311 break;
312 default:
313 printf("Error: Unknown MAPLE/CPRI clock select!\n");
314 }
315
316 /* For MAPLE ULB and eTVPE frequencies */
317#define ULB_CLK_SEL 0x00000038
318#define ULB_CLK_SHIFT 3
319#define ETVPE_CLK_SEL 0x00000007
320#define ETVPE_CLK_SHIFT 0
321
322 switch ((rcw_tmp2 & ULB_CLK_SEL) >> ULB_CLK_SHIFT) {
323 case 1:
324 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK];
325 break;
326 case 2:
327 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 2;
328 break;
329 case 3:
330 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 3;
331 break;
332 case 4:
333 sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 4;
334 break;
335 case 5:
336 sys_info->freq_maple_ulb = sys_info->freq_systembus;
337 break;
338 case 6:
339 sys_info->freq_maple_ulb =
340 freq_c_pll[CONFIG_SYS_ULB_CLK - 1] / 2;
341 break;
342 case 7:
343 sys_info->freq_maple_ulb =
344 freq_c_pll[CONFIG_SYS_ULB_CLK - 1] / 3;
345 break;
346 default:
347 printf("Error: Unknown MAPLE ULB clock select!\n");
348 }
349
350 switch ((rcw_tmp2 & ETVPE_CLK_SEL) >> ETVPE_CLK_SHIFT) {
351 case 1:
352 sys_info->freq_maple_etvpe = freq_c_pll[CONFIG_SYS_ETVPE_CLK];
353 break;
354 case 2:
355 sys_info->freq_maple_etvpe =
356 freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 2;
357 break;
358 case 3:
359 sys_info->freq_maple_etvpe =
360 freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 3;
361 break;
362 case 4:
363 sys_info->freq_maple_etvpe =
364 freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 4;
365 break;
366 case 5:
367 sys_info->freq_maple_etvpe = sys_info->freq_systembus;
368 break;
369 case 6:
370 sys_info->freq_maple_etvpe =
371 freq_c_pll[CONFIG_SYS_ETVPE_CLK - 1] / 2;
372 break;
373 case 7:
374 sys_info->freq_maple_etvpe =
375 freq_c_pll[CONFIG_SYS_ETVPE_CLK - 1] / 3;
376 break;
377 default:
378 printf("Error: Unknown MAPLE eTVPE clock select!\n");
379 }
380
381#endif
382
York Sun9a653a92012-10-08 07:44:11 +0000383#ifdef CONFIG_SYS_DPAA_FMAN
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530384#ifndef CONFIG_FM_PLAT_CLK_DIV
York Sun9a653a92012-10-08 07:44:11 +0000385 switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) {
386 case 1:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530387 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK];
York Sun9a653a92012-10-08 07:44:11 +0000388 break;
389 case 2:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530390 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 2;
York Sun9a653a92012-10-08 07:44:11 +0000391 break;
392 case 3:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530393 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 3;
York Sun9a653a92012-10-08 07:44:11 +0000394 break;
395 case 4:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530396 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 4;
York Sun9a653a92012-10-08 07:44:11 +0000397 break;
Sandeep Singh0cb33252013-03-25 07:33:09 +0000398 case 5:
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530399 sys_info->freq_fman[0] = sys_info->freq_systembus;
Sandeep Singh0cb33252013-03-25 07:33:09 +0000400 break;
York Sun9a653a92012-10-08 07:44:11 +0000401 case 6:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530402 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 2;
York Sun9a653a92012-10-08 07:44:11 +0000403 break;
404 case 7:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530405 sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 3;
York Sun9a653a92012-10-08 07:44:11 +0000406 break;
407 default:
408 printf("Error: Unknown FMan1 clock select!\n");
409 case 0:
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530410 sys_info->freq_fman[0] = sys_info->freq_systembus / 2;
York Sun9a653a92012-10-08 07:44:11 +0000411 break;
412 }
413#if (CONFIG_SYS_NUM_FMAN) == 2
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530414#ifdef CONFIG_SYS_FM2_CLK
York Sun9a653a92012-10-08 07:44:11 +0000415#define FM2_CLK_SEL 0x00000038
416#define FM2_CLK_SHIFT 3
417 rcw_tmp = in_be32(&gur->rcwsr[15]);
418 switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) {
419 case 1:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530420 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1];
York Sun9a653a92012-10-08 07:44:11 +0000421 break;
422 case 2:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530423 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 2;
York Sun9a653a92012-10-08 07:44:11 +0000424 break;
425 case 3:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530426 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 3;
York Sun9a653a92012-10-08 07:44:11 +0000427 break;
428 case 4:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530429 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 4;
York Sun9a653a92012-10-08 07:44:11 +0000430 break;
Shaohui Xiec1015c62013-11-28 13:52:51 +0800431 case 5:
432 sys_info->freq_fman[1] = sys_info->freq_systembus;
433 break;
York Sun9a653a92012-10-08 07:44:11 +0000434 case 6:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530435 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 2;
York Sun9a653a92012-10-08 07:44:11 +0000436 break;
437 case 7:
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530438 sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 3;
York Sun9a653a92012-10-08 07:44:11 +0000439 break;
440 default:
441 printf("Error: Unknown FMan2 clock select!\n");
442 case 0:
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530443 sys_info->freq_fman[1] = sys_info->freq_systembus / 2;
York Sun9a653a92012-10-08 07:44:11 +0000444 break;
445 }
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530446#endif
York Sun9a653a92012-10-08 07:44:11 +0000447#endif /* CONFIG_SYS_NUM_FMAN == 2 */
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530448#else
449 sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK;
450#endif
451#endif
York Sun9a653a92012-10-08 07:44:11 +0000452
453#else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
454
Timur Tabifbb9ecf2011-08-05 16:15:24 -0500455 for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) {
York Sunf6981432013-03-25 07:40:07 +0000456 u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27)
457 & 0xf;
Kumar Gala39aaca12009-03-19 02:46:19 -0500458 u32 cplx_pll = core_cplx_PLL[c_pll_sel];
459
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530460 sys_info->freq_processor[cpu] =
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530461 freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel];
Kumar Gala39aaca12009-03-19 02:46:19 -0500462 }
Kumar Gala39aaca12009-03-19 02:46:19 -0500463#define PME_CLK_SEL 0x80000000
464#define FM1_CLK_SEL 0x40000000
465#define FM2_CLK_SEL 0x20000000
Kumar Galab5c87532011-02-16 02:03:29 -0600466#define HWA_ASYNC_DIV 0x04000000
467#if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2)
468#define HWA_CC_PLL 1
Timur Tabi49054432012-10-05 11:09:19 +0000469#elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3)
470#define HWA_CC_PLL 2
Kumar Galab5c87532011-02-16 02:03:29 -0600471#elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4)
Wolfgang Denkcd6881b2011-05-19 22:21:41 +0200472#define HWA_CC_PLL 2
Kumar Galab5c87532011-02-16 02:03:29 -0600473#else
474#error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case
475#endif
Kumar Gala39aaca12009-03-19 02:46:19 -0500476 rcw_tmp = in_be32(&gur->rcwsr[7]);
477
478#ifdef CONFIG_SYS_DPAA_PME
Kumar Galab5c87532011-02-16 02:03:29 -0600479 if (rcw_tmp & PME_CLK_SEL) {
480 if (rcw_tmp & HWA_ASYNC_DIV)
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530481 sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4;
Kumar Galab5c87532011-02-16 02:03:29 -0600482 else
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530483 sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2;
Kumar Galab5c87532011-02-16 02:03:29 -0600484 } else {
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530485 sys_info->freq_pme = sys_info->freq_systembus / 2;
Kumar Galab5c87532011-02-16 02:03:29 -0600486 }
Kumar Gala39aaca12009-03-19 02:46:19 -0500487#endif
488
489#ifdef CONFIG_SYS_DPAA_FMAN
Kumar Galab5c87532011-02-16 02:03:29 -0600490 if (rcw_tmp & FM1_CLK_SEL) {
491 if (rcw_tmp & HWA_ASYNC_DIV)
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530492 sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4;
Kumar Galab5c87532011-02-16 02:03:29 -0600493 else
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530494 sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2;
Kumar Galab5c87532011-02-16 02:03:29 -0600495 } else {
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530496 sys_info->freq_fman[0] = sys_info->freq_systembus / 2;
Kumar Galab5c87532011-02-16 02:03:29 -0600497 }
Kumar Gala39aaca12009-03-19 02:46:19 -0500498#if (CONFIG_SYS_NUM_FMAN) == 2
Kumar Galab5c87532011-02-16 02:03:29 -0600499 if (rcw_tmp & FM2_CLK_SEL) {
500 if (rcw_tmp & HWA_ASYNC_DIV)
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530501 sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4;
Kumar Galab5c87532011-02-16 02:03:29 -0600502 else
Prabhakar Kushwahace746fe2013-09-03 11:20:15 +0530503 sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2;
Kumar Galab5c87532011-02-16 02:03:29 -0600504 } else {
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530505 sys_info->freq_fman[1] = sys_info->freq_systembus / 2;
Kumar Galab5c87532011-02-16 02:03:29 -0600506 }
Kumar Gala39aaca12009-03-19 02:46:19 -0500507#endif
508#endif
509
Shaohui Xie3e83fc92013-03-25 07:33:25 +0000510#ifdef CONFIG_SYS_DPAA_QBMAN
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530511 sys_info->freq_qman = sys_info->freq_systembus / 2;
Shaohui Xie3e83fc92013-03-25 07:33:25 +0000512#endif
513
York Sun9a653a92012-10-08 07:44:11 +0000514#endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
515
Zhao Qiang2a44efe2014-03-21 16:21:45 +0800516#ifdef CONFIG_U_QE
517 sys_info->freq_qe = sys_info->freq_systembus / 2;
518#endif
519
York Sun9a653a92012-10-08 07:44:11 +0000520#else /* CONFIG_FSL_CORENET */
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530521 uint plat_ratio, e500_ratio, half_freq_systembus;
Haiying Wang2fc7eb02009-01-15 11:58:35 -0500522 int i;
Haiying Wangb3d7f202009-05-20 12:30:29 -0400523#ifdef CONFIG_QE
Haiying Wanga52d2f82011-02-11 01:25:30 -0600524 __maybe_unused u32 qe_ratio;
Haiying Wangb3d7f202009-05-20 12:30:29 -0400525#endif
wdenk42d1f032003-10-15 23:53:47 +0000526
527 plat_ratio = (gur->porpllsr) & 0x0000003e;
528 plat_ratio >>= 1;
Tom Rini2f8a6db2021-12-14 13:36:40 -0500529 sys_info->freq_systembus = plat_ratio * get_board_sys_clk();
Andy Fleming66ed6cc2007-04-23 02:37:47 -0500530
531 /* Divide before multiply to avoid integer
532 * overflow for processor speeds above 2GHz */
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530533 half_freq_systembus = sys_info->freq_systembus/2;
Poonam Aggrwal0e870982009-07-31 12:08:14 +0530534 for (i = 0; i < cpu_numcores(); i++) {
Haiying Wang2fc7eb02009-01-15 11:58:35 -0500535 e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f;
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530536 sys_info->freq_processor[i] = e500_ratio * half_freq_systembus;
Haiying Wang2fc7eb02009-01-15 11:58:35 -0500537 }
James Yanga3e77fa2008-02-08 18:05:08 -0600538
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530539 /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */
540 sys_info->freq_ddrbus = sys_info->freq_systembus;
Kumar Galad4357932007-12-07 04:59:26 -0600541
Tom Riniefb5dab72021-08-21 13:50:17 -0400542#if defined(CONFIG_DYNAMIC_DDR_CLK_FREQ) || defined(CONFIG_STATIC_DDR_CLK_FREQ)
Kumar Galad4357932007-12-07 04:59:26 -0600543 {
Jason Jinc0391112008-09-27 14:40:57 +0800544 u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO)
545 >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
Kumar Galad4357932007-12-07 04:59:26 -0600546 if (ddr_ratio != 0x7)
Tom Riniefb5dab72021-08-21 13:50:17 -0400547 sys_info->freq_ddrbus = ddr_ratio * get_board_ddr_clk();
Kumar Galad4357932007-12-07 04:59:26 -0600548 }
549#endif
Trent Piephoada591d2008-12-03 15:16:37 -0800550
Haiying Wangb3d7f202009-05-20 12:30:29 -0400551#ifdef CONFIG_QE
York Sun4167a672016-11-18 11:05:38 -0800552#if defined(CONFIG_ARCH_P1021) || defined(CONFIG_ARCH_P1025)
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530553 sys_info->freq_qe = sys_info->freq_systembus;
Haiying Wanga52d2f82011-02-11 01:25:30 -0600554#else
Haiying Wangb3d7f202009-05-20 12:30:29 -0400555 qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO)
556 >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT;
Tom Rini2f8a6db2021-12-14 13:36:40 -0500557 sys_info->freq_qe = qe_ratio * get_board_sys_clk();
Haiying Wangb3d7f202009-05-20 12:30:29 -0400558#endif
Haiying Wanga52d2f82011-02-11 01:25:30 -0600559#endif
Haiying Wangb3d7f202009-05-20 12:30:29 -0400560
Haiying Wang24995d82011-01-20 22:26:31 +0000561#ifdef CONFIG_SYS_DPAA_FMAN
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530562 sys_info->freq_fman[0] = sys_info->freq_systembus;
Haiying Wang24995d82011-01-20 22:26:31 +0000563#endif
564
565#endif /* CONFIG_FSL_CORENET */
566
Dipen Dudhatbeba93e2011-01-19 12:46:27 +0530567#if defined(CONFIG_FSL_LBC)
Prabhakar Kushwahaadd63f92017-02-02 15:02:00 +0530568 sys_info->freq_localbus = sys_info->freq_systembus /
569 CONFIG_SYS_FSL_LBC_CLK_DIV;
Dipen Dudhatbeba93e2011-01-19 12:46:27 +0530570#endif
Kumar Gala800c73c2012-10-08 07:44:06 +0000571
572#if defined(CONFIG_FSL_IFC)
Prabhakar Kushwaha1c407072017-02-02 15:01:26 +0530573 sys_info->freq_localbus = sys_info->freq_systembus /
574 CONFIG_SYS_FSL_IFC_CLK_DIV;
Kumar Gala800c73c2012-10-08 07:44:06 +0000575#endif
wdenk42d1f032003-10-15 23:53:47 +0000576}
577
Simon Glassd96c2602019-12-28 10:44:58 -0700578int get_clocks(void)
wdenk42d1f032003-10-15 23:53:47 +0000579{
wdenk42d1f032003-10-15 23:53:47 +0000580 sys_info_t sys_info;
York Sun25cb74b2016-11-15 13:57:15 -0800581#ifdef CONFIG_ARCH_MPC8544
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200582 volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR;
Timur Tabi88353a92008-04-04 11:15:58 -0500583#endif
Jon Loeliger9c4c5ae2005-07-23 10:37:35 -0500584#if defined(CONFIG_CPM2)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200585 volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR;
wdenk42d1f032003-10-15 23:53:47 +0000586 uint sccr, dfbrg;
587
588 /* set VCO = 4 * BRG */
Kumar Galaaafeefb2007-11-28 00:36:33 -0600589 cpm->im_cpm_intctl.sccr &= 0xfffffffc;
590 sccr = cpm->im_cpm_intctl.sccr;
wdenk42d1f032003-10-15 23:53:47 +0000591 dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
592#endif
593 get_sys_info (&sys_info);
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530594 gd->cpu_clk = sys_info.freq_processor[0];
595 gd->bus_clk = sys_info.freq_systembus;
596 gd->mem_clk = sys_info.freq_ddrbus;
597 gd->arch.lbc_clk = sys_info.freq_localbus;
Timur Tabi88353a92008-04-04 11:15:58 -0500598
Haiying Wangb3d7f202009-05-20 12:30:29 -0400599#ifdef CONFIG_QE
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530600 gd->arch.qe_clk = sys_info.freq_qe;
Simon Glass45bae2e2012-12-13 20:48:50 +0000601 gd->arch.brg_clk = gd->arch.qe_clk / 2;
Haiying Wangb3d7f202009-05-20 12:30:29 -0400602#endif
Timur Tabi88353a92008-04-04 11:15:58 -0500603 /*
604 * The base clock for I2C depends on the actual SOC. Unfortunately,
605 * there is no pattern that can be used to determine the frequency, so
606 * the only choice is to look up the actual SOC number and use the value
607 * for that SOC. This information is taken from application note
608 * AN2919.
609 */
Tom Rini98898602021-05-14 21:34:21 -0400610#if defined(CONFIG_ARCH_MPC8540) || defined(CONFIG_ARCH_MPC8560)
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530611 gd->arch.i2c1_clk = sys_info.freq_systembus;
York Sun25cb74b2016-11-15 13:57:15 -0800612#elif defined(CONFIG_ARCH_MPC8544)
Timur Tabi88353a92008-04-04 11:15:58 -0500613 /*
614 * On the 8544, the I2C clock is the same as the SEC clock. This can be
615 * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See
616 * 4.4.3.3 of the 8544 RM. Note that this might actually work for all
617 * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the
618 * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544.
619 */
620 if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG)
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530621 gd->arch.i2c1_clk = sys_info.freq_systembus / 3;
Kumar Gala42653b82008-10-16 21:58:49 -0500622 else
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530623 gd->arch.i2c1_clk = sys_info.freq_systembus / 2;
Timur Tabi88353a92008-04-04 11:15:58 -0500624#else
625 /* Most 85xx SOCs use CCB/2, so this is the default behavior. */
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530626 gd->arch.i2c1_clk = sys_info.freq_systembus / 2;
Timur Tabi88353a92008-04-04 11:15:58 -0500627#endif
Simon Glass609e6ec2012-12-13 20:48:49 +0000628 gd->arch.i2c2_clk = gd->arch.i2c1_clk;
Timur Tabi943afa22008-01-09 14:35:26 -0600629
Dipen Dudhat6b9ea082009-09-01 17:27:00 +0530630#if defined(CONFIG_FSL_ESDHC)
Tom Rini2cc60712021-02-20 20:06:29 -0500631#if defined(CONFIG_ARCH_P1010)
Simon Glasse9adeca2012-12-13 20:49:05 +0000632 gd->arch.sdhc_clk = gd->bus_clk;
Anton Vorontsov7f52ed52009-10-15 17:47:06 +0400633#else
Simon Glasse9adeca2012-12-13 20:49:05 +0000634 gd->arch.sdhc_clk = gd->bus_clk / 2;
Kumar Galaef50d6c2008-08-12 11:14:19 -0500635#endif
Anton Vorontsov7f52ed52009-10-15 17:47:06 +0400636#endif /* defined(CONFIG_FSL_ESDHC) */
Kumar Galaef50d6c2008-08-12 11:14:19 -0500637
Jon Loeliger9c4c5ae2005-07-23 10:37:35 -0500638#if defined(CONFIG_CPM2)
Prabhakar Kushwaha997399f2013-08-16 14:52:26 +0530639 gd->arch.vco_out = 2*sys_info.freq_systembus;
Simon Glass748cd052012-12-13 20:48:46 +0000640 gd->arch.cpm_clk = gd->arch.vco_out / 2;
641 gd->arch.scc_clk = gd->arch.vco_out / 4;
642 gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1)));
wdenk42d1f032003-10-15 23:53:47 +0000643#endif
644
645 if(gd->cpu_clk != 0) return (0);
646 else return (1);
647}
648
649
650/********************************************
651 * get_bus_freq
652 * return system bus freq in Hz
653 *********************************************/
Simon Glassd96c2602019-12-28 10:44:58 -0700654ulong get_bus_freq(ulong dummy)
wdenk42d1f032003-10-15 23:53:47 +0000655{
James Yanga3e77fa2008-02-08 18:05:08 -0600656 return gd->bus_clk;
wdenk42d1f032003-10-15 23:53:47 +0000657}
Kumar Galad4357932007-12-07 04:59:26 -0600658
659/********************************************
660 * get_ddr_freq
661 * return ddr bus freq in Hz
662 *********************************************/
663ulong get_ddr_freq (ulong dummy)
664{
James Yanga3e77fa2008-02-08 18:05:08 -0600665 return gd->mem_clk;
Kumar Galad4357932007-12-07 04:59:26 -0600666}