blob: e102b0cfc3866233d6c6c77e8ef6f210e93001ab [file] [log] [blame]
Peter Tyser1c2b3292008-12-17 16:36:23 -06001/*
2 * Copyright 2008 Extreme Engineering Solutions, Inc.
3 *
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +02004 * SPDX-License-Identifier: GPL-2.0+
Peter Tyser1c2b3292008-12-17 16:36:23 -06005 */
6
7#include <common.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 */
13unsigned long get_board_sys_clk(ulong dummy)
14{
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 */
37unsigned long get_board_ddr_clk(ulong dummy)
38{
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)
43 return get_board_sys_clk(dummy);
44
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