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