wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
Dipen Dudhat | 5d51bf9 | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 2 | * Copyright 2004, 2007-2011 Freescale Semiconductor, Inc. |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 3 | * |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 4 | * (C) Copyright 2003 Motorola Inc. |
| 5 | * Xianghua Xiao, (X.Xiao@motorola.com) |
| 6 | * |
| 7 | * (C) Copyright 2000 |
| 8 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 9 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
| 14 | #include <ppc_asm.tmpl> |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 15 | #include <linux/compiler.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 16 | #include <asm/processor.h> |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 17 | #include <asm/io.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 18 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 21 | |
| 22 | #ifndef CONFIG_SYS_FSL_NUM_CC_PLLS |
| 23 | #define CONFIG_SYS_FSL_NUM_CC_PLLS 6 |
| 24 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 25 | /* --------------------------------------------------------------- */ |
| 26 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 27 | void get_sys_info(sys_info_t *sys_info) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 28 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 29 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 17ec6fa | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 30 | #ifdef CONFIG_FSL_IFC |
| 31 | struct fsl_ifc *ifc_regs = (void *)CONFIG_SYS_IFC_ADDR; |
| 32 | u32 ccr; |
| 33 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 34 | #ifdef CONFIG_FSL_CORENET |
| 35 | volatile ccsr_clk_t *clk = (void *)(CONFIG_SYS_FSL_CORENET_CLK_ADDR); |
Timur Tabi | 4728942 | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 36 | unsigned int cpu; |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 37 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 38 | int cc_group[12] = CONFIG_SYS_FSL_CLUSTER_CLOCKS; |
| 39 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 40 | |
| 41 | const u8 core_cplx_PLL[16] = { |
| 42 | [ 0] = 0, /* CC1 PPL / 1 */ |
| 43 | [ 1] = 0, /* CC1 PPL / 2 */ |
| 44 | [ 2] = 0, /* CC1 PPL / 4 */ |
| 45 | [ 4] = 1, /* CC2 PPL / 1 */ |
| 46 | [ 5] = 1, /* CC2 PPL / 2 */ |
| 47 | [ 6] = 1, /* CC2 PPL / 4 */ |
| 48 | [ 8] = 2, /* CC3 PPL / 1 */ |
| 49 | [ 9] = 2, /* CC3 PPL / 2 */ |
| 50 | [10] = 2, /* CC3 PPL / 4 */ |
| 51 | [12] = 3, /* CC4 PPL / 1 */ |
| 52 | [13] = 3, /* CC4 PPL / 2 */ |
| 53 | [14] = 3, /* CC4 PPL / 4 */ |
| 54 | }; |
| 55 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 56 | const u8 core_cplx_pll_div[16] = { |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 57 | [ 0] = 1, /* CC1 PPL / 1 */ |
| 58 | [ 1] = 2, /* CC1 PPL / 2 */ |
| 59 | [ 2] = 4, /* CC1 PPL / 4 */ |
| 60 | [ 4] = 1, /* CC2 PPL / 1 */ |
| 61 | [ 5] = 2, /* CC2 PPL / 2 */ |
| 62 | [ 6] = 4, /* CC2 PPL / 4 */ |
| 63 | [ 8] = 1, /* CC3 PPL / 1 */ |
| 64 | [ 9] = 2, /* CC3 PPL / 2 */ |
| 65 | [10] = 4, /* CC3 PPL / 4 */ |
| 66 | [12] = 1, /* CC4 PPL / 1 */ |
| 67 | [13] = 2, /* CC4 PPL / 2 */ |
| 68 | [14] = 4, /* CC4 PPL / 4 */ |
| 69 | }; |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 70 | uint i, freq_c_pll[CONFIG_SYS_FSL_NUM_CC_PLLS]; |
| 71 | #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) |
| 72 | uint rcw_tmp; |
| 73 | #endif |
| 74 | uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS]; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 75 | unsigned long sysclk = CONFIG_SYS_CLK_FREQ; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 76 | uint mem_pll_rat; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 77 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 78 | sys_info->freq_systembus = sysclk; |
York Sun | 3b5179f | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 79 | #ifdef CONFIG_DDR_CLK_FREQ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 80 | sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ; |
York Sun | 3b5179f | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 81 | #else |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 82 | sys_info->freq_ddrbus = sysclk; |
York Sun | 3b5179f | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 83 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 84 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 85 | sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; |
York Sun | b8a076b | 2012-10-08 07:44:09 +0000 | [diff] [blame] | 86 | mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> |
| 87 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT) |
| 88 | & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 89 | if (mem_pll_rat > 2) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 90 | sys_info->freq_ddrbus *= mem_pll_rat; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 91 | else |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 92 | sys_info->freq_ddrbus = sys_info->freq_systembus * mem_pll_rat; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 93 | |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 94 | for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) { |
| 95 | ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0x3f; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 96 | if (ratio[i] > 4) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 97 | freq_c_pll[i] = sysclk * ratio[i]; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 98 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 99 | freq_c_pll[i] = sys_info->freq_systembus * ratio[i]; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 100 | } |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 101 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 102 | /* |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 103 | * As per CHASSIS2 architeture total 12 clusters are posible and |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 104 | * Each cluster has up to 4 cores, sharing the same PLL selection. |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 105 | * The cluster clock assignment is SoC defined. |
| 106 | * |
| 107 | * Total 4 clock groups are possible with 3 PLLs each. |
| 108 | * as per array indices, clock group A has 0, 1, 2 numbered PLLs & |
| 109 | * clock group B has 3, 4, 6 and so on. |
| 110 | * |
| 111 | * Clock group A having PLL1, PLL2, PLL3, feeding cores of any cluster |
| 112 | * depends upon the SoC architeture. Same applies to other |
| 113 | * clock groups and clusters. |
| 114 | * |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 115 | */ |
Timur Tabi | 4728942 | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 116 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | aa150bb | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 117 | int cluster = fsl_qoriq_core_to_cluster(cpu); |
| 118 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cluster].clkcncsr) >> 27) |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 119 | & 0xf; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 120 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 121 | cplx_pll += cc_group[cluster] - 1; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 122 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 123 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 124 | } |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 125 | #ifdef CONFIG_PPC_B4860 |
| 126 | #define FM1_CLK_SEL 0xe0000000 |
| 127 | #define FM1_CLK_SHIFT 29 |
| 128 | #else |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 129 | #define PME_CLK_SEL 0xe0000000 |
| 130 | #define PME_CLK_SHIFT 29 |
| 131 | #define FM1_CLK_SEL 0x1c000000 |
| 132 | #define FM1_CLK_SHIFT 26 |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 133 | #endif |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 134 | #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 135 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 136 | #endif |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 137 | |
| 138 | #ifdef CONFIG_SYS_DPAA_PME |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 139 | #ifndef CONFIG_PME_PLAT_CLK_DIV |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 140 | switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) { |
| 141 | case 1: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 142 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 143 | break; |
| 144 | case 2: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 145 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 146 | break; |
| 147 | case 3: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 148 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 149 | break; |
| 150 | case 4: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 151 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 152 | break; |
| 153 | case 6: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 154 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 155 | break; |
| 156 | case 7: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 157 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 158 | break; |
| 159 | default: |
| 160 | printf("Error: Unknown PME clock select!\n"); |
| 161 | case 0: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 162 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 163 | break; |
| 164 | |
| 165 | } |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 166 | #else |
| 167 | sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK; |
| 168 | |
| 169 | #endif |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 170 | #endif |
| 171 | |
Haiying Wang | 09d0aa9 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 172 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 173 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Haiying Wang | 09d0aa9 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 174 | #endif |
| 175 | |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 176 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 177 | #ifndef CONFIG_FM_PLAT_CLK_DIV |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 178 | switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) { |
| 179 | case 1: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 180 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 181 | break; |
| 182 | case 2: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 183 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 184 | break; |
| 185 | case 3: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 186 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 187 | break; |
| 188 | case 4: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 189 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 4; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 190 | break; |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 191 | case 5: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 192 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 193 | break; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 194 | case 6: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 195 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 196 | break; |
| 197 | case 7: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 198 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 199 | break; |
| 200 | default: |
| 201 | printf("Error: Unknown FMan1 clock select!\n"); |
| 202 | case 0: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 203 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 204 | break; |
| 205 | } |
| 206 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 207 | #ifdef CONFIG_SYS_FM2_CLK |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 208 | #define FM2_CLK_SEL 0x00000038 |
| 209 | #define FM2_CLK_SHIFT 3 |
| 210 | rcw_tmp = in_be32(&gur->rcwsr[15]); |
| 211 | switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) { |
| 212 | case 1: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 213 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 214 | break; |
| 215 | case 2: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 216 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 217 | break; |
| 218 | case 3: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 219 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 220 | break; |
| 221 | case 4: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 222 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 4; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 223 | break; |
| 224 | case 6: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 225 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 226 | break; |
| 227 | case 7: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 228 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 229 | break; |
| 230 | default: |
| 231 | printf("Error: Unknown FMan2 clock select!\n"); |
| 232 | case 0: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 233 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 234 | break; |
| 235 | } |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 236 | #endif |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 237 | #endif /* CONFIG_SYS_NUM_FMAN == 2 */ |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 238 | #else |
| 239 | sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK; |
| 240 | #endif |
| 241 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 242 | |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 243 | #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 244 | |
| 245 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | aa150bb | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 246 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27) |
| 247 | & 0xf; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 248 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
| 249 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 250 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 251 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 252 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 253 | #define PME_CLK_SEL 0x80000000 |
| 254 | #define FM1_CLK_SEL 0x40000000 |
| 255 | #define FM2_CLK_SEL 0x20000000 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 256 | #define HWA_ASYNC_DIV 0x04000000 |
| 257 | #if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2) |
| 258 | #define HWA_CC_PLL 1 |
Timur Tabi | d5e1388 | 2012-10-05 11:09:19 +0000 | [diff] [blame] | 259 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3) |
| 260 | #define HWA_CC_PLL 2 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 261 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4) |
Wolfgang Denk | 80f7021 | 2011-05-19 22:21:41 +0200 | [diff] [blame] | 262 | #define HWA_CC_PLL 2 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 263 | #else |
| 264 | #error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case |
| 265 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 266 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
| 267 | |
| 268 | #ifdef CONFIG_SYS_DPAA_PME |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 269 | if (rcw_tmp & PME_CLK_SEL) { |
| 270 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 271 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 272 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 273 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 274 | } else { |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 275 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 276 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 277 | #endif |
| 278 | |
| 279 | #ifdef CONFIG_SYS_DPAA_FMAN |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 280 | if (rcw_tmp & FM1_CLK_SEL) { |
| 281 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 282 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 283 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 284 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 285 | } else { |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 286 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 287 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 288 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 289 | if (rcw_tmp & FM2_CLK_SEL) { |
| 290 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 291 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 292 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 293 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 294 | } else { |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 295 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 296 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 297 | #endif |
| 298 | #endif |
| 299 | |
Shaohui Xie | 835c9ad | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 300 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 301 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Shaohui Xie | 835c9ad | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 302 | #endif |
| 303 | |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 304 | #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 305 | |
| 306 | #else /* CONFIG_FSL_CORENET */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 307 | uint plat_ratio, e500_ratio, half_freq_systembus; |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 308 | int i; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 309 | #ifdef CONFIG_QE |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 310 | __maybe_unused u32 qe_ratio; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 311 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 312 | |
| 313 | plat_ratio = (gur->porpllsr) & 0x0000003e; |
| 314 | plat_ratio >>= 1; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 315 | sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ; |
Andy Fleming | 6d97276 | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 316 | |
| 317 | /* Divide before multiply to avoid integer |
| 318 | * overflow for processor speeds above 2GHz */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 319 | half_freq_systembus = sys_info->freq_systembus/2; |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 320 | for (i = 0; i < cpu_numcores(); i++) { |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 321 | e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 322 | sys_info->freq_processor[i] = e500_ratio * half_freq_systembus; |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 323 | } |
James Yang | d1d51ad | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 324 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 325 | /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */ |
| 326 | sys_info->freq_ddrbus = sys_info->freq_systembus; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 327 | |
| 328 | #ifdef CONFIG_DDR_CLK_FREQ |
| 329 | { |
Jason Jin | bfcd6c3 | 2008-09-27 14:40:57 +0800 | [diff] [blame] | 330 | u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) |
| 331 | >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 332 | if (ddr_ratio != 0x7) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 333 | sys_info->freq_ddrbus = ddr_ratio * CONFIG_DDR_CLK_FREQ; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 334 | } |
| 335 | #endif |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 336 | |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 337 | #ifdef CONFIG_QE |
York Sun | 6bf020a | 2012-08-10 11:07:26 +0000 | [diff] [blame] | 338 | #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 339 | sys_info->freq_qe = sys_info->freq_systembus; |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 340 | #else |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 341 | qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO) |
| 342 | >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 343 | sys_info->freq_qe = qe_ratio * CONFIG_SYS_CLK_FREQ; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 344 | #endif |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 345 | #endif |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 346 | |
| 347 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 348 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 349 | #endif |
| 350 | |
| 351 | #endif /* CONFIG_FSL_CORENET */ |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 352 | |
Dipen Dudhat | 5d51bf9 | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 353 | #if defined(CONFIG_FSL_LBC) |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 354 | uint lcrr_div; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 355 | #if defined(CONFIG_SYS_LBC_LCRR) |
| 356 | /* We will program LCRR to this value later */ |
| 357 | lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV; |
| 358 | #else |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 359 | lcrr_div = in_be32(&(LBC_BASE_ADDR)->lcrr) & LCRR_CLKDIV; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 360 | #endif |
| 361 | if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) { |
Dave Liu | d8cb9e4 | 2009-11-17 20:49:05 +0800 | [diff] [blame] | 362 | #if defined(CONFIG_FSL_CORENET) |
| 363 | /* If this is corenet based SoC, bit-representation |
| 364 | * for four times the clock divider values. |
| 365 | */ |
| 366 | lcrr_div *= 4; |
| 367 | #elif !defined(CONFIG_MPC8540) && !defined(CONFIG_MPC8541) && \ |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 368 | !defined(CONFIG_MPC8555) && !defined(CONFIG_MPC8560) |
| 369 | /* |
| 370 | * Yes, the entire PQ38 family use the same |
| 371 | * bit-representation for twice the clock divider values. |
| 372 | */ |
| 373 | lcrr_div *= 2; |
| 374 | #endif |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 375 | sys_info->freq_localbus = sys_info->freq_systembus / lcrr_div; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 376 | } else { |
| 377 | /* In case anyone cares what the unknown value is */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 378 | sys_info->freq_localbus = lcrr_div; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 379 | } |
Dipen Dudhat | 5d51bf9 | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 380 | #endif |
Kumar Gala | 17ec6fa | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 381 | |
| 382 | #if defined(CONFIG_FSL_IFC) |
| 383 | ccr = in_be32(&ifc_regs->ifc_ccr); |
| 384 | ccr = ((ccr & IFC_CCR_CLK_DIV_MASK) >> IFC_CCR_CLK_DIV_SHIFT) + 1; |
| 385 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 386 | sys_info->freq_localbus = sys_info->freq_systembus / ccr; |
Kumar Gala | 17ec6fa | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 387 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 388 | } |
| 389 | |
Andy Fleming | 6d97276 | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 390 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 391 | int get_clocks (void) |
| 392 | { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 393 | sys_info_t sys_info; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 394 | #ifdef CONFIG_MPC8544 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 395 | volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 396 | #endif |
Jon Loeliger | f5ad378 | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 397 | #if defined(CONFIG_CPM2) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 398 | volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 399 | uint sccr, dfbrg; |
| 400 | |
| 401 | /* set VCO = 4 * BRG */ |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 402 | cpm->im_cpm_intctl.sccr &= 0xfffffffc; |
| 403 | sccr = cpm->im_cpm_intctl.sccr; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 404 | dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT; |
| 405 | #endif |
| 406 | get_sys_info (&sys_info); |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 407 | gd->cpu_clk = sys_info.freq_processor[0]; |
| 408 | gd->bus_clk = sys_info.freq_systembus; |
| 409 | gd->mem_clk = sys_info.freq_ddrbus; |
| 410 | gd->arch.lbc_clk = sys_info.freq_localbus; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 411 | |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 412 | #ifdef CONFIG_QE |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 413 | gd->arch.qe_clk = sys_info.freq_qe; |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 414 | gd->arch.brg_clk = gd->arch.qe_clk / 2; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 415 | #endif |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 416 | /* |
| 417 | * The base clock for I2C depends on the actual SOC. Unfortunately, |
| 418 | * there is no pattern that can be used to determine the frequency, so |
| 419 | * the only choice is to look up the actual SOC number and use the value |
| 420 | * for that SOC. This information is taken from application note |
| 421 | * AN2919. |
| 422 | */ |
| 423 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ |
Tang Yuantian | a2f7262 | 2013-09-06 10:45:40 +0800 | [diff] [blame] | 424 | defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555) || \ |
| 425 | defined(CONFIG_P1022) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 426 | gd->arch.i2c1_clk = sys_info.freq_systembus; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 427 | #elif defined(CONFIG_MPC8544) |
| 428 | /* |
| 429 | * On the 8544, the I2C clock is the same as the SEC clock. This can be |
| 430 | * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See |
| 431 | * 4.4.3.3 of the 8544 RM. Note that this might actually work for all |
| 432 | * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the |
| 433 | * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544. |
| 434 | */ |
| 435 | if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 436 | gd->arch.i2c1_clk = sys_info.freq_systembus / 3; |
Kumar Gala | 9632f66 | 2008-10-16 21:58:49 -0500 | [diff] [blame] | 437 | else |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 438 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 439 | #else |
| 440 | /* Most 85xx SOCs use CCB/2, so this is the default behavior. */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 441 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 442 | #endif |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 443 | gd->arch.i2c2_clk = gd->arch.i2c1_clk; |
Timur Tabi | c1499f48 | 2008-01-09 14:35:26 -0600 | [diff] [blame] | 444 | |
Dipen Dudhat | 9af188d | 2009-09-01 17:27:00 +0530 | [diff] [blame] | 445 | #if defined(CONFIG_FSL_ESDHC) |
Priyanka Jain | ce0397b | 2011-02-08 15:45:25 +0530 | [diff] [blame] | 446 | #if defined(CONFIG_MPC8569) || defined(CONFIG_P1010) ||\ |
| 447 | defined(CONFIG_P1014) |
Simon Glass | 9e247d1 | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 448 | gd->arch.sdhc_clk = gd->bus_clk; |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 449 | #else |
Simon Glass | 9e247d1 | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 450 | gd->arch.sdhc_clk = gd->bus_clk / 2; |
Kumar Gala | cd77728 | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 451 | #endif |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 452 | #endif /* defined(CONFIG_FSL_ESDHC) */ |
Kumar Gala | cd77728 | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 453 | |
Jon Loeliger | f5ad378 | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 454 | #if defined(CONFIG_CPM2) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 455 | gd->arch.vco_out = 2*sys_info.freq_systembus; |
Simon Glass | 44ea851 | 2012-12-13 20:48:46 +0000 | [diff] [blame] | 456 | gd->arch.cpm_clk = gd->arch.vco_out / 2; |
| 457 | gd->arch.scc_clk = gd->arch.vco_out / 4; |
| 458 | gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1))); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 459 | #endif |
| 460 | |
| 461 | if(gd->cpu_clk != 0) return (0); |
| 462 | else return (1); |
| 463 | } |
| 464 | |
| 465 | |
| 466 | /******************************************** |
| 467 | * get_bus_freq |
| 468 | * return system bus freq in Hz |
| 469 | *********************************************/ |
| 470 | ulong get_bus_freq (ulong dummy) |
| 471 | { |
James Yang | d1d51ad | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 472 | return gd->bus_clk; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 473 | } |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 474 | |
| 475 | /******************************************** |
| 476 | * get_ddr_freq |
| 477 | * return ddr bus freq in Hz |
| 478 | *********************************************/ |
| 479 | ulong get_ddr_freq (ulong dummy) |
| 480 | { |
James Yang | d1d51ad | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 481 | return gd->mem_clk; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 482 | } |