xref: /openbmc/u-boot/arch/m68k/cpu/mcf523x/speed.c (revision d9b23e26)
1 /*
2  *
3  * (C) Copyright 2000-2003
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  *
6  * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
7  * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
8  *
9  * SPDX-License-Identifier:	GPL-2.0+
10  */
11 
12 #include <common.h>
13 #include <asm/processor.h>
14 
15 #include <asm/immap.h>
16 #include <asm/io.h>
17 
18 DECLARE_GLOBAL_DATA_PTR;
19 /*
20  * get_clocks() fills in gd->cpu_clock and gd->bus_clk
21  */
22 int get_clocks(void)
23 {
24 	pll_t *pll = (pll_t *)(MMAP_PLL);
25 
26 	out_be32(&pll->syncr, PLL_SYNCR_MFD(1));
27 
28 	while (!(in_be32(&pll->synsr) & PLL_SYNSR_LOCK))
29 		;
30 
31 	gd->bus_clk = CONFIG_SYS_CLK;
32 	gd->cpu_clk = (gd->bus_clk * 2);
33 
34 #ifdef CONFIG_SYS_I2C_FSL
35 	gd->arch.i2c1_clk = gd->bus_clk;
36 #endif
37 
38 	return (0);
39 }
40