2 * Copyright 2004 Freescale Semiconductor.
4 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
6 * (C) Copyright 2000-2002
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * SPDX-License-Identifier: GPL-2.0+
14 #include <asm/processor.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 /* used in some defintiions of CONFIG_SYS_CLK_FREQ */
20 extern unsigned long get_board_sys_clk(unsigned long dummy);
22 void get_sys_info(sys_info_t *sysInfo)
24 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
25 volatile ccsr_gur_t *gur = &immap->im_gur;
26 uint plat_ratio, e600_ratio;
29 plat_ratio = (gur->porpllsr) & 0x0000003e;
34 sysInfo->freqSystemBus = 16 * CONFIG_SYS_CLK_FREQ;
46 sysInfo->freqSystemBus = plat_ratio * CONFIG_SYS_CLK_FREQ;
49 sysInfo->freqSystemBus = 0;
53 e600_ratio = (gur->porpllsr) & 0x003f0000;
58 sysInfo->freqProcessor = 2 * sysInfo->freqSystemBus;
61 sysInfo->freqProcessor = 5 * sysInfo->freqSystemBus / 2;
64 sysInfo->freqProcessor = 3 * sysInfo->freqSystemBus;
67 sysInfo->freqProcessor = 7 * sysInfo->freqSystemBus / 2;
70 sysInfo->freqProcessor = 4 * sysInfo->freqSystemBus;
73 sysInfo->freqProcessor = 9 * sysInfo->freqSystemBus / 2;
76 sysInfo->freqProcessor = e600_ratio + sysInfo->freqSystemBus;
80 #if defined(CONFIG_SYS_LBC_LCRR)
81 /* We will program LCRR to this value later */
82 lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV;
84 lcrr_div = in_be32(&immap->im_lbc.lcrr) & LCRR_CLKDIV;
86 if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) {
87 sysInfo->freqLocalBus = sysInfo->freqSystemBus / (lcrr_div * 2);
89 /* In case anyone cares what the unknown value is */
90 sysInfo->freqLocalBus = lcrr_div;
96 * Measure CPU clock speed (core clock GCLK1, GCLK2)
97 * (Approx. GCLK frequency in Hz)
104 get_sys_info(&sys_info);
105 gd->cpu_clk = sys_info.freqProcessor;
106 gd->bus_clk = sys_info.freqSystemBus;
107 gd->arch.lbc_clk = sys_info.freqLocalBus;
110 * The base clock for I2C depends on the actual SOC. Unfortunately,
111 * there is no pattern that can be used to determine the frequency, so
112 * the only choice is to look up the actual SOC number and use the value
113 * for that SOC. This information is taken from application note
116 #ifdef CONFIG_MPC8610
117 gd->arch.i2c1_clk = sys_info.freqSystemBus;
119 gd->arch.i2c1_clk = sys_info.freqSystemBus / 2;
121 gd->arch.i2c2_clk = gd->arch.i2c1_clk;
123 if (gd->cpu_clk != 0)
132 * Return system bus freq in Hz
135 ulong get_bus_freq(ulong dummy)
140 get_sys_info(&sys_info);
141 val = sys_info.freqSystemBus;