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;
28 plat_ratio = (gur->porpllsr) & 0x0000003e;
33 sys_info->freq_systembus = 16 * CONFIG_SYS_CLK_FREQ;
45 sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ;
48 sys_info->freq_systembus = 0;
52 e600_ratio = (gur->porpllsr) & 0x003f0000;
57 sys_info->freq_processor = 2 * sys_info->freq_systembus;
60 sys_info->freq_processor = 5 * sys_info->freq_systembus / 2;
63 sys_info->freq_processor = 3 * sys_info->freq_systembus;
66 sys_info->freq_processor = 7 * sys_info->freq_systembus / 2;
69 sys_info->freq_processor = 4 * sys_info->freq_systembus;
72 sys_info->freq_processor = 9 * sys_info->freq_systembus / 2;
75 sys_info->freq_processor = e600_ratio +
76 sys_info->freq_systembus;
80 sys_info->freq_localbus = sys_info->freq_systembus;
85 * Measure CPU clock speed (core clock GCLK1, GCLK2)
86 * (Approx. GCLK frequency in Hz)
93 get_sys_info(&sys_info);
94 gd->cpu_clk = sys_info.freq_processor;
95 gd->bus_clk = sys_info.freq_systembus;
96 gd->arch.lbc_clk = sys_info.freq_localbus;
99 * The base clock for I2C depends on the actual SOC. Unfortunately,
100 * there is no pattern that can be used to determine the frequency, so
101 * the only choice is to look up the actual SOC number and use the value
102 * for that SOC. This information is taken from application note
105 #ifdef CONFIG_ARCH_MPC8610
106 gd->arch.i2c1_clk = sys_info.freq_systembus;
108 gd->arch.i2c1_clk = sys_info.freq_systembus / 2;
110 gd->arch.i2c2_clk = gd->arch.i2c1_clk;
112 if (gd->cpu_clk != 0)
121 * Return system bus freq in Hz
124 ulong get_bus_freq(ulong dummy)
129 get_sys_info(&sys_info);
130 val = sys_info.freq_systembus;