blob: 8ca65ca859310c251234aa698a9ae10009c31d09 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peter Tyser1c2b3292008-12-17 16:36:23 -06002/*
3 * Copyright 2008 Extreme Engineering Solutions, Inc.
Peter Tyser1c2b3292008-12-17 16:36:23 -06004 */
5
6#include <common.h>
Peter Tyser2b1a48d2009-08-07 13:16:34 -05007#include <asm/io.h>
Peter Tyser1c2b3292008-12-17 16:36:23 -06008
9/*
10 * Return SYSCLK input frequency - 50 MHz or 66 MHz depending on POR config
11 */
12unsigned long get_board_sys_clk(ulong dummy)
13{
Peter Tyser281e41d2009-05-22 10:26:37 -050014#if defined(CONFIG_MPC85xx)
Peter Tyser1c2b3292008-12-17 16:36:23 -060015 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser281e41d2009-05-22 10:26:37 -050016#elif defined(CONFIG_MPC86xx)
17 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
18 volatile ccsr_gur_t *gur = &immap->im_gur;
19#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060020
Peter Tyser2b1a48d2009-08-07 13:16:34 -050021 if (in_be32(&gur->gpporcr) & 0x10000)
Peter Tyser1c2b3292008-12-17 16:36:23 -060022 return 66666666;
23 else
York Sun4b08dd72016-11-18 11:08:43 -080024#ifdef CONFIG_ARCH_P2020
John Schmoller9a0709d2010-10-22 00:20:34 -050025 return 100000000;
26#else
Peter Tyser1c2b3292008-12-17 16:36:23 -060027 return 50000000;
John Schmoller9a0709d2010-10-22 00:20:34 -050028#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060029}
30
Peter Tyser281e41d2009-05-22 10:26:37 -050031#ifdef CONFIG_MPC85xx
Peter Tyser1c2b3292008-12-17 16:36:23 -060032/*
33 * Return DDR input clock - synchronous with SYSCLK or 66 MHz
Peter Tyser281e41d2009-05-22 10:26:37 -050034 * Note: 86xx doesn't support asynchronous DDR clk
Peter Tyser1c2b3292008-12-17 16:36:23 -060035 */
36unsigned long get_board_ddr_clk(ulong dummy)
37{
38 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser2b1a48d2009-08-07 13:16:34 -050039 u32 ddr_ratio = (in_be32(&gur->porpllsr) & 0x00003e00) >> 9;
Peter Tyser1c2b3292008-12-17 16:36:23 -060040
41 if (ddr_ratio == 0x7)
42 return get_board_sys_clk(dummy);
43
York Sun4b08dd72016-11-18 11:08:43 -080044#ifdef CONFIG_ARCH_P2020
John Schmoller9a0709d2010-10-22 00:20:34 -050045 if (in_be32(&gur->gpporcr) & 0x20000)
46 return 66666666;
47 else
48 return 100000000;
49#else
Peter Tyser1c2b3292008-12-17 16:36:23 -060050 return 66666666;
John Schmoller9a0709d2010-10-22 00:20:34 -050051#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060052}
Peter Tyser281e41d2009-05-22 10:26:37 -050053#endif