blob: 6b08a12af0b69f1aa52da4cd53ddac041aa922d1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
TsiChungLiewb859ef12007-08-16 19:23:50 -05002/*
3 *
4 * (C) Copyright 2000-2003
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Alison Wangd132fe62012-03-26 21:49:06 +00007 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
TsiChungLiewb859ef12007-08-16 19:23:50 -05008 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
TsiChungLiewb859ef12007-08-16 19:23:50 -05009 */
10
11#include <common.h>
Simon Glass85d65312019-12-28 10:44:58 -070012#include <clock_legacy.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060013#include <asm/global_data.h>
TsiChungLiewb859ef12007-08-16 19:23:50 -050014#include <asm/processor.h>
15
16#include <asm/immap.h>
Alison Wangd132fe62012-03-26 21:49:06 +000017#include <asm/io.h>
TsiChungLiewb859ef12007-08-16 19:23:50 -050018
19DECLARE_GLOBAL_DATA_PTR;
20/*
21 * get_clocks() fills in gd->cpu_clock and gd->bus_clk
22 */
23int get_clocks(void)
24{
Alison Wangd132fe62012-03-26 21:49:06 +000025 pll_t *pll = (pll_t *)(MMAP_PLL);
TsiChungLiewb859ef12007-08-16 19:23:50 -050026
Alison Wangd132fe62012-03-26 21:49:06 +000027 out_be32(&pll->syncr, PLL_SYNCR_MFD(1));
TsiChungLiewb859ef12007-08-16 19:23:50 -050028
Alison Wangd132fe62012-03-26 21:49:06 +000029 while (!(in_be32(&pll->synsr) & PLL_SYNSR_LOCK))
30 ;
Stefan Roesefe9dae62007-08-18 14:33:02 +020031
Tom Rini6a5dccc2022-11-16 13:10:41 -050032 gd->bus_clk = CFG_SYS_CLK;
TsiChungLiewb859ef12007-08-16 19:23:50 -050033 gd->cpu_clk = (gd->bus_clk * 2);
Stefan Roesefe9dae62007-08-18 14:33:02 +020034
Heiko Schocherf2850742012-10-24 13:48:22 +020035#ifdef CONFIG_SYS_I2C_FSL
Simon Glassc2baaec2012-12-13 20:48:49 +000036 gd->arch.i2c1_clk = gd->bus_clk;
TsiChung Liew0c1e3252008-08-19 03:01:19 +060037#endif
38
TsiChungLiewb859ef12007-08-16 19:23:50 -050039 return (0);
40}