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