blob: 20e88d43604fff7df8857e4c6ffa4b1f7b884a55 [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>
Tom Rini8c70baa2021-12-14 13:36:40 -05007#include <clock_legacy.h>
Peter Tyser2b1a48d2009-08-07 13:16:34 -05008#include <asm/io.h>
Peter Tyser1c2b3292008-12-17 16:36:23 -06009
10/*
11 * Return SYSCLK input frequency - 50 MHz or 66 MHz depending on POR config
12 */
Tom Riniaea2a992021-12-14 13:36:39 -050013unsigned long get_board_sys_clk(void)
Peter Tyser1c2b3292008-12-17 16:36:23 -060014{
Peter Tyser281e41d2009-05-22 10:26:37 -050015#if defined(CONFIG_MPC85xx)
Peter Tyser1c2b3292008-12-17 16:36:23 -060016 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser281e41d2009-05-22 10:26:37 -050017#elif defined(CONFIG_MPC86xx)
18 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
19 volatile ccsr_gur_t *gur = &immap->im_gur;
20#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060021
Peter Tyser2b1a48d2009-08-07 13:16:34 -050022 if (in_be32(&gur->gpporcr) & 0x10000)
Peter Tyser1c2b3292008-12-17 16:36:23 -060023 return 66666666;
24 else
York Sun4b08dd72016-11-18 11:08:43 -080025#ifdef CONFIG_ARCH_P2020
John Schmoller9a0709d2010-10-22 00:20:34 -050026 return 100000000;
27#else
Peter Tyser1c2b3292008-12-17 16:36:23 -060028 return 50000000;
John Schmoller9a0709d2010-10-22 00:20:34 -050029#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060030}
31
Peter Tyser281e41d2009-05-22 10:26:37 -050032#ifdef CONFIG_MPC85xx
Peter Tyser1c2b3292008-12-17 16:36:23 -060033/*
34 * Return DDR input clock - synchronous with SYSCLK or 66 MHz
Peter Tyser281e41d2009-05-22 10:26:37 -050035 * Note: 86xx doesn't support asynchronous DDR clk
Peter Tyser1c2b3292008-12-17 16:36:23 -060036 */
Tom Riniaea2a992021-12-14 13:36:39 -050037unsigned long get_board_ddr_clk(void)
Peter Tyser1c2b3292008-12-17 16:36:23 -060038{
39 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser2b1a48d2009-08-07 13:16:34 -050040 u32 ddr_ratio = (in_be32(&gur->porpllsr) & 0x00003e00) >> 9;
Peter Tyser1c2b3292008-12-17 16:36:23 -060041
42 if (ddr_ratio == 0x7)
Tom Riniaea2a992021-12-14 13:36:39 -050043 return get_board_sys_clk();
Peter Tyser1c2b3292008-12-17 16:36:23 -060044
York Sun4b08dd72016-11-18 11:08:43 -080045#ifdef CONFIG_ARCH_P2020
John Schmoller9a0709d2010-10-22 00:20:34 -050046 if (in_be32(&gur->gpporcr) & 0x20000)
47 return 66666666;
48 else
49 return 100000000;
50#else
Peter Tyser1c2b3292008-12-17 16:36:23 -060051 return 66666666;
John Schmoller9a0709d2010-10-22 00:20:34 -050052#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060053}
Peter Tyser281e41d2009-05-22 10:26:37 -050054#endif