Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2008 Extreme Engineering Solutions, Inc. |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 7 | #include <asm/io.h> |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 8 | |
| 9 | /* |
| 10 | * Return SYSCLK input frequency - 50 MHz or 66 MHz depending on POR config |
| 11 | */ |
| 12 | unsigned long get_board_sys_clk(ulong dummy) |
| 13 | { |
Peter Tyser | 281e41d | 2009-05-22 10:26:37 -0500 | [diff] [blame] | 14 | #if defined(CONFIG_MPC85xx) |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 15 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Peter Tyser | 281e41d | 2009-05-22 10:26:37 -0500 | [diff] [blame] | 16 | #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 Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 20 | |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 21 | if (in_be32(&gur->gpporcr) & 0x10000) |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 22 | return 66666666; |
| 23 | else |
York Sun | 4b08dd7 | 2016-11-18 11:08:43 -0800 | [diff] [blame] | 24 | #ifdef CONFIG_ARCH_P2020 |
John Schmoller | 9a0709d | 2010-10-22 00:20:34 -0500 | [diff] [blame] | 25 | return 100000000; |
| 26 | #else |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 27 | return 50000000; |
John Schmoller | 9a0709d | 2010-10-22 00:20:34 -0500 | [diff] [blame] | 28 | #endif |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 29 | } |
| 30 | |
Peter Tyser | 281e41d | 2009-05-22 10:26:37 -0500 | [diff] [blame] | 31 | #ifdef CONFIG_MPC85xx |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 32 | /* |
| 33 | * Return DDR input clock - synchronous with SYSCLK or 66 MHz |
Peter Tyser | 281e41d | 2009-05-22 10:26:37 -0500 | [diff] [blame] | 34 | * Note: 86xx doesn't support asynchronous DDR clk |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 35 | */ |
| 36 | unsigned long get_board_ddr_clk(ulong dummy) |
| 37 | { |
| 38 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Peter Tyser | 2b1a48d | 2009-08-07 13:16:34 -0500 | [diff] [blame] | 39 | u32 ddr_ratio = (in_be32(&gur->porpllsr) & 0x00003e00) >> 9; |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 40 | |
| 41 | if (ddr_ratio == 0x7) |
| 42 | return get_board_sys_clk(dummy); |
| 43 | |
York Sun | 4b08dd7 | 2016-11-18 11:08:43 -0800 | [diff] [blame] | 44 | #ifdef CONFIG_ARCH_P2020 |
John Schmoller | 9a0709d | 2010-10-22 00:20:34 -0500 | [diff] [blame] | 45 | if (in_be32(&gur->gpporcr) & 0x20000) |
| 46 | return 66666666; |
| 47 | else |
| 48 | return 100000000; |
| 49 | #else |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 50 | return 66666666; |
John Schmoller | 9a0709d | 2010-10-22 00:20:34 -0500 | [diff] [blame] | 51 | #endif |
Peter Tyser | 1c2b329 | 2008-12-17 16:36:23 -0600 | [diff] [blame] | 52 | } |
Peter Tyser | 281e41d | 2009-05-22 10:26:37 -0500 | [diff] [blame] | 53 | #endif |