1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2004 Freescale Semiconductor.
5 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
7 * (C) Copyright 2000-2002
8 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
13 #include <asm/processor.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 /* used in some defintiions of CONFIG_SYS_CLK_FREQ */
19 extern unsigned long get_board_sys_clk(unsigned long dummy);
21 void get_sys_info(sys_info_t *sys_info)
23 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
24 volatile ccsr_gur_t *gur = &immap->im_gur;
25 uint plat_ratio, e600_ratio;
27 plat_ratio = (gur->porpllsr) & 0x0000003e;
32 sys_info->freq_systembus = 16 * CONFIG_SYS_CLK_FREQ;
44 sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ;
47 sys_info->freq_systembus = 0;
51 e600_ratio = (gur->porpllsr) & 0x003f0000;
56 sys_info->freq_processor = 2 * sys_info->freq_systembus;
59 sys_info->freq_processor = 5 * sys_info->freq_systembus / 2;
62 sys_info->freq_processor = 3 * sys_info->freq_systembus;
65 sys_info->freq_processor = 7 * sys_info->freq_systembus / 2;
68 sys_info->freq_processor = 4 * sys_info->freq_systembus;
71 sys_info->freq_processor = 9 * sys_info->freq_systembus / 2;
74 sys_info->freq_processor = e600_ratio +
75 sys_info->freq_systembus;
79 sys_info->freq_localbus = sys_info->freq_systembus;
84 * Measure CPU clock speed (core clock GCLK1, GCLK2)
85 * (Approx. GCLK frequency in Hz)
92 get_sys_info(&sys_info);
93 gd->cpu_clk = sys_info.freq_processor;
94 gd->bus_clk = sys_info.freq_systembus;
95 gd->arch.lbc_clk = sys_info.freq_localbus;
98 * The base clock for I2C depends on the actual SOC. Unfortunately,
99 * there is no pattern that can be used to determine the frequency, so
100 * the only choice is to look up the actual SOC number and use the value
101 * for that SOC. This information is taken from application note
104 #ifdef CONFIG_ARCH_MPC8610
105 gd->arch.i2c1_clk = sys_info.freq_systembus;
107 gd->arch.i2c1_clk = sys_info.freq_systembus / 2;
109 gd->arch.i2c2_clk = gd->arch.i2c1_clk;
111 if (gd->cpu_clk != 0)
120 * Return system bus freq in Hz
123 ulong get_bus_freq(ulong dummy)
128 get_sys_info(&sys_info);
129 val = sys_info.freq_systembus;