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 *sys_info)
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
sys_info->freq_systembus = 16 * CONFIG_SYS_CLK_FREQ;
46
sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ;
49
sys_info->freq_systembus = 0;
53
e600_ratio = (gur->porpllsr) & 0x003f0000;
58
sys_info->freq_processor = 2 * sys_info->freq_systembus;
61
sys_info->freq_processor = 5 * sys_info->freq_systembus / 2;
64
sys_info->freq_processor = 3 * sys_info->freq_systembus;
67
sys_info->freq_processor = 7 * sys_info->freq_systembus / 2;
70
sys_info->freq_processor = 4 * sys_info->freq_systembus;
73
sys_info->freq_processor = 9 * sys_info->freq_systembus / 2;
76
sys_info->freq_processor = e600_ratio +
77
sys_info->freq_systembus;
81
#if defined(CONFIG_SYS_LBC_LCRR)
82
/* We will program LCRR to this value later */
83
lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV;
85
lcrr_div = in_be32(&immap->im_lbc.lcrr) & LCRR_CLKDIV;
87
if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) {
88
sys_info->freq_localbus = sys_info->freq_systembus
91
/* In case anyone cares what the unknown value is */
92
sys_info->freq_localbus = lcrr_div;
98
* Measure CPU clock speed (core clock GCLK1, GCLK2)
99
* (Approx. GCLK frequency in Hz)
106
get_sys_info(&sys_info);
107
gd->cpu_clk = sys_info.freq_processor;
108
gd->bus_clk = sys_info.freq_systembus;
109
gd->arch.lbc_clk = sys_info.freq_localbus;
112
* The base clock for I2C depends on the actual SOC. Unfortunately,
113
* there is no pattern that can be used to determine the frequency, so
114
* the only choice is to look up the actual SOC number and use the value
115
* for that SOC. This information is taken from application note
118
#ifdef CONFIG_MPC8610
119
gd->arch.i2c1_clk = sys_info.freq_systembus;
121
gd->arch.i2c1_clk = sys_info.freq_systembus / 2;
123
gd->arch.i2c2_clk = gd->arch.i2c1_clk;
125
if (gd->cpu_clk != 0)
134
* Return system bus freq in Hz
137
ulong get_bus_freq(ulong dummy)
142
get_sys_info(&sys_info);
143
val = sys_info.freq_systembus;