wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
Dipen Dudhat | beba93e | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 2 | * Copyright 2004, 2007-2011 Freescale Semiconductor, Inc. |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 3 | * |
wdenk | 42d1f03 | 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 | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
| 14 | #include <ppc_asm.tmpl> |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 15 | #include <linux/compiler.h> |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 16 | #include <asm/processor.h> |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 17 | #include <asm/io.h> |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 18 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Prabhakar Kushwaha | ce746fe | 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 | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 25 | /* --------------------------------------------------------------- */ |
| 26 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 27 | void get_sys_info(sys_info_t *sys_info) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 28 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 29 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 800c73c | 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 | 39aaca1 | 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 | fbb9ecf | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 36 | unsigned int cpu; |
Prabhakar Kushwaha | ce746fe | 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 | 39aaca1 | 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 | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 56 | const u8 core_cplx_pll_div[16] = { |
Kumar Gala | 39aaca1 | 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 | ce746fe | 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 | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 75 | unsigned long sysclk = CONFIG_SYS_CLK_FREQ; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 76 | uint mem_pll_rat; |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 77 | #ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK |
| 78 | uint single_src; |
| 79 | #endif |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 80 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 81 | sys_info->freq_systembus = sysclk; |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 82 | #ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK |
| 83 | /* |
| 84 | * DDR_REFCLK_SEL rcw bit is used to determine if DDR PLLS |
| 85 | * are driven by separate DDR Refclock or single source |
| 86 | * differential clock. |
| 87 | */ |
| 88 | single_src = (in_be32(&gur->rcwsr[5]) >> |
| 89 | FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT) & |
| 90 | FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK; |
| 91 | /* |
| 92 | * For single source clocking, both ddrclock and syclock |
| 93 | * are driven by differential sysclock. |
| 94 | */ |
| 95 | if (single_src == FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK) { |
| 96 | printf("Single Source Clock Configuration\n"); |
| 97 | sys_info->freq_ddrbus = CONFIG_SYS_CLK_FREQ; |
| 98 | } else |
| 99 | #endif |
York Sun | 98ffa19 | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 100 | #ifdef CONFIG_DDR_CLK_FREQ |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 101 | sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ; |
York Sun | 98ffa19 | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 102 | #else |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 103 | sys_info->freq_ddrbus = sysclk; |
York Sun | 98ffa19 | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 104 | #endif |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 105 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 106 | sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; |
York Sun | f77329c | 2012-10-08 07:44:09 +0000 | [diff] [blame] | 107 | mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> |
| 108 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT) |
| 109 | & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; |
Zang Roy-R61911 | e88f421 | 2013-11-28 13:23:37 +0800 | [diff] [blame] | 110 | /* T4240/T4160 Rev2.0 MEM_PLL_RAT uses a value which is half of |
| 111 | * T4240/T4160 Rev1.0. eg. It's 12 in Rev1.0, however, for Rev2.0 |
| 112 | * it uses 6. |
| 113 | */ |
| 114 | #if defined(CONFIG_PPC_T4240) || defined(CONFIG_PPC_T4160) |
| 115 | if (SVR_MAJ(get_svr()) >= 2) |
| 116 | mem_pll_rat *= 2; |
| 117 | #endif |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 118 | if (mem_pll_rat > 2) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 119 | sys_info->freq_ddrbus *= mem_pll_rat; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 120 | else |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 121 | sys_info->freq_ddrbus = sys_info->freq_systembus * mem_pll_rat; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 122 | |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 123 | for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) { |
| 124 | ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0x3f; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 125 | if (ratio[i] > 4) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 126 | freq_c_pll[i] = sysclk * ratio[i]; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 127 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 128 | freq_c_pll[i] = sys_info->freq_systembus * ratio[i]; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 129 | } |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 130 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 131 | /* |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 132 | * As per CHASSIS2 architeture total 12 clusters are posible and |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 133 | * Each cluster has up to 4 cores, sharing the same PLL selection. |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 134 | * The cluster clock assignment is SoC defined. |
| 135 | * |
| 136 | * Total 4 clock groups are possible with 3 PLLs each. |
| 137 | * as per array indices, clock group A has 0, 1, 2 numbered PLLs & |
| 138 | * clock group B has 3, 4, 6 and so on. |
| 139 | * |
| 140 | * Clock group A having PLL1, PLL2, PLL3, feeding cores of any cluster |
| 141 | * depends upon the SoC architeture. Same applies to other |
| 142 | * clock groups and clusters. |
| 143 | * |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 144 | */ |
| 145 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | f698143 | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 146 | int cluster = fsl_qoriq_core_to_cluster(cpu); |
| 147 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cluster].clkcncsr) >> 27) |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 148 | & 0xf; |
| 149 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 150 | cplx_pll += cc_group[cluster] - 1; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 151 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 152 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 153 | } |
Shengzhou Liu | 35c471e | 2014-01-21 14:11:47 +0800 | [diff] [blame^] | 154 | #if defined(CONFIG_PPC_B4860) || defined(CONFIG_PPC_T2080) || \ |
| 155 | defined(CONFIG_PPC_T2081) |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 156 | #define FM1_CLK_SEL 0xe0000000 |
| 157 | #define FM1_CLK_SHIFT 29 |
| 158 | #else |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 159 | #define PME_CLK_SEL 0xe0000000 |
| 160 | #define PME_CLK_SHIFT 29 |
| 161 | #define FM1_CLK_SEL 0x1c000000 |
| 162 | #define FM1_CLK_SHIFT 26 |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 163 | #endif |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 164 | #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 165 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 166 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 167 | |
| 168 | #ifdef CONFIG_SYS_DPAA_PME |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 169 | #ifndef CONFIG_PME_PLAT_CLK_DIV |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 170 | switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) { |
| 171 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 172 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 173 | break; |
| 174 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 175 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 176 | break; |
| 177 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 178 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 179 | break; |
| 180 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 181 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 182 | break; |
| 183 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 184 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 185 | break; |
| 186 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 187 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 188 | break; |
| 189 | default: |
| 190 | printf("Error: Unknown PME clock select!\n"); |
| 191 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 192 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 193 | break; |
| 194 | |
| 195 | } |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 196 | #else |
| 197 | sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK; |
| 198 | |
| 199 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 200 | #endif |
| 201 | |
Haiying Wang | 990e1a8 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 202 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 203 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Haiying Wang | 990e1a8 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 204 | #endif |
| 205 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 206 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 207 | #ifndef CONFIG_FM_PLAT_CLK_DIV |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 208 | switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) { |
| 209 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 210 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 211 | break; |
| 212 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 213 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 214 | break; |
| 215 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 216 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 217 | break; |
| 218 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 219 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 4; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 220 | break; |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 221 | case 5: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 222 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 223 | break; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 224 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 225 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 226 | break; |
| 227 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 228 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 229 | break; |
| 230 | default: |
| 231 | printf("Error: Unknown FMan1 clock select!\n"); |
| 232 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 233 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 234 | break; |
| 235 | } |
| 236 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 237 | #ifdef CONFIG_SYS_FM2_CLK |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 238 | #define FM2_CLK_SEL 0x00000038 |
| 239 | #define FM2_CLK_SHIFT 3 |
| 240 | rcw_tmp = in_be32(&gur->rcwsr[15]); |
| 241 | switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) { |
| 242 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 243 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 244 | break; |
| 245 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 246 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 247 | break; |
| 248 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 249 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 250 | break; |
| 251 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 252 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 4; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 253 | break; |
Shaohui Xie | c1015c6 | 2013-11-28 13:52:51 +0800 | [diff] [blame] | 254 | case 5: |
| 255 | sys_info->freq_fman[1] = sys_info->freq_systembus; |
| 256 | break; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 257 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 258 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 259 | break; |
| 260 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 261 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 262 | break; |
| 263 | default: |
| 264 | printf("Error: Unknown FMan2 clock select!\n"); |
| 265 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 266 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 267 | break; |
| 268 | } |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 269 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 270 | #endif /* CONFIG_SYS_NUM_FMAN == 2 */ |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 271 | #else |
| 272 | sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK; |
| 273 | #endif |
| 274 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 275 | |
| 276 | #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 277 | |
Timur Tabi | fbb9ecf | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 278 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | f698143 | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 279 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27) |
| 280 | & 0xf; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 281 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
| 282 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 283 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 284 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 285 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 286 | #define PME_CLK_SEL 0x80000000 |
| 287 | #define FM1_CLK_SEL 0x40000000 |
| 288 | #define FM2_CLK_SEL 0x20000000 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 289 | #define HWA_ASYNC_DIV 0x04000000 |
| 290 | #if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2) |
| 291 | #define HWA_CC_PLL 1 |
Timur Tabi | 4905443 | 2012-10-05 11:09:19 +0000 | [diff] [blame] | 292 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3) |
| 293 | #define HWA_CC_PLL 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 294 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4) |
Wolfgang Denk | cd6881b | 2011-05-19 22:21:41 +0200 | [diff] [blame] | 295 | #define HWA_CC_PLL 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 296 | #else |
| 297 | #error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case |
| 298 | #endif |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 299 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
| 300 | |
| 301 | #ifdef CONFIG_SYS_DPAA_PME |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 302 | if (rcw_tmp & PME_CLK_SEL) { |
| 303 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 304 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 305 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 306 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 307 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 308 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 309 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 310 | #endif |
| 311 | |
| 312 | #ifdef CONFIG_SYS_DPAA_FMAN |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 313 | if (rcw_tmp & FM1_CLK_SEL) { |
| 314 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 315 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 316 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 317 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 318 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 319 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 320 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 321 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 322 | if (rcw_tmp & FM2_CLK_SEL) { |
| 323 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 324 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 325 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 326 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 327 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 328 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 329 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 330 | #endif |
| 331 | #endif |
| 332 | |
Shaohui Xie | 3e83fc9 | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 333 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 334 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Shaohui Xie | 3e83fc9 | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 335 | #endif |
| 336 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 337 | #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 338 | |
| 339 | #else /* CONFIG_FSL_CORENET */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 340 | uint plat_ratio, e500_ratio, half_freq_systembus; |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 341 | int i; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 342 | #ifdef CONFIG_QE |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 343 | __maybe_unused u32 qe_ratio; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 344 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 345 | |
| 346 | plat_ratio = (gur->porpllsr) & 0x0000003e; |
| 347 | plat_ratio >>= 1; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 348 | sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ; |
Andy Fleming | 66ed6cc | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 349 | |
| 350 | /* Divide before multiply to avoid integer |
| 351 | * overflow for processor speeds above 2GHz */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 352 | half_freq_systembus = sys_info->freq_systembus/2; |
Poonam Aggrwal | 0e87098 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 353 | for (i = 0; i < cpu_numcores(); i++) { |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 354 | e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 355 | sys_info->freq_processor[i] = e500_ratio * half_freq_systembus; |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 356 | } |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 357 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 358 | /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */ |
| 359 | sys_info->freq_ddrbus = sys_info->freq_systembus; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 360 | |
| 361 | #ifdef CONFIG_DDR_CLK_FREQ |
| 362 | { |
Jason Jin | c039111 | 2008-09-27 14:40:57 +0800 | [diff] [blame] | 363 | u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) |
| 364 | >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 365 | if (ddr_ratio != 0x7) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 366 | sys_info->freq_ddrbus = ddr_ratio * CONFIG_DDR_CLK_FREQ; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 367 | } |
| 368 | #endif |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 369 | |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 370 | #ifdef CONFIG_QE |
York Sun | be7bebe | 2012-08-10 11:07:26 +0000 | [diff] [blame] | 371 | #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 372 | sys_info->freq_qe = sys_info->freq_systembus; |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 373 | #else |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 374 | qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO) |
| 375 | >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 376 | sys_info->freq_qe = qe_ratio * CONFIG_SYS_CLK_FREQ; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 377 | #endif |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 378 | #endif |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 379 | |
Haiying Wang | 24995d8 | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 380 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 381 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Haiying Wang | 24995d8 | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 382 | #endif |
| 383 | |
| 384 | #endif /* CONFIG_FSL_CORENET */ |
| 385 | |
Dipen Dudhat | beba93e | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 386 | #if defined(CONFIG_FSL_LBC) |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 387 | uint lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 388 | #if defined(CONFIG_SYS_LBC_LCRR) |
| 389 | /* We will program LCRR to this value later */ |
| 390 | lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV; |
| 391 | #else |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 392 | lcrr_div = in_be32(&(LBC_BASE_ADDR)->lcrr) & LCRR_CLKDIV; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 393 | #endif |
| 394 | if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) { |
Dave Liu | 0fd2fa6 | 2009-11-17 20:49:05 +0800 | [diff] [blame] | 395 | #if defined(CONFIG_FSL_CORENET) |
| 396 | /* If this is corenet based SoC, bit-representation |
| 397 | * for four times the clock divider values. |
| 398 | */ |
| 399 | lcrr_div *= 4; |
| 400 | #elif !defined(CONFIG_MPC8540) && !defined(CONFIG_MPC8541) && \ |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 401 | !defined(CONFIG_MPC8555) && !defined(CONFIG_MPC8560) |
| 402 | /* |
| 403 | * Yes, the entire PQ38 family use the same |
| 404 | * bit-representation for twice the clock divider values. |
| 405 | */ |
| 406 | lcrr_div *= 2; |
| 407 | #endif |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 408 | sys_info->freq_localbus = sys_info->freq_systembus / lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 409 | } else { |
| 410 | /* In case anyone cares what the unknown value is */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 411 | sys_info->freq_localbus = lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 412 | } |
Dipen Dudhat | beba93e | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 413 | #endif |
Kumar Gala | 800c73c | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 414 | |
| 415 | #if defined(CONFIG_FSL_IFC) |
| 416 | ccr = in_be32(&ifc_regs->ifc_ccr); |
| 417 | ccr = ((ccr & IFC_CCR_CLK_DIV_MASK) >> IFC_CCR_CLK_DIV_SHIFT) + 1; |
| 418 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 419 | sys_info->freq_localbus = sys_info->freq_systembus / ccr; |
Kumar Gala | 800c73c | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 420 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Andy Fleming | 66ed6cc | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 423 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 424 | int get_clocks (void) |
| 425 | { |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 426 | sys_info_t sys_info; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 427 | #ifdef CONFIG_MPC8544 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 428 | volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 429 | #endif |
Jon Loeliger | 9c4c5ae | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 430 | #if defined(CONFIG_CPM2) |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 431 | volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 432 | uint sccr, dfbrg; |
| 433 | |
| 434 | /* set VCO = 4 * BRG */ |
Kumar Gala | aafeefb | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 435 | cpm->im_cpm_intctl.sccr &= 0xfffffffc; |
| 436 | sccr = cpm->im_cpm_intctl.sccr; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 437 | dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT; |
| 438 | #endif |
| 439 | get_sys_info (&sys_info); |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 440 | gd->cpu_clk = sys_info.freq_processor[0]; |
| 441 | gd->bus_clk = sys_info.freq_systembus; |
| 442 | gd->mem_clk = sys_info.freq_ddrbus; |
| 443 | gd->arch.lbc_clk = sys_info.freq_localbus; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 444 | |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 445 | #ifdef CONFIG_QE |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 446 | gd->arch.qe_clk = sys_info.freq_qe; |
Simon Glass | 45bae2e | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 447 | gd->arch.brg_clk = gd->arch.qe_clk / 2; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 448 | #endif |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 449 | /* |
| 450 | * The base clock for I2C depends on the actual SOC. Unfortunately, |
| 451 | * there is no pattern that can be used to determine the frequency, so |
| 452 | * the only choice is to look up the actual SOC number and use the value |
| 453 | * for that SOC. This information is taken from application note |
| 454 | * AN2919. |
| 455 | */ |
| 456 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ |
Tang Yuantian | f62b123 | 2013-09-06 10:45:40 +0800 | [diff] [blame] | 457 | defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555) || \ |
| 458 | defined(CONFIG_P1022) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 459 | gd->arch.i2c1_clk = sys_info.freq_systembus; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 460 | #elif defined(CONFIG_MPC8544) |
| 461 | /* |
| 462 | * On the 8544, the I2C clock is the same as the SEC clock. This can be |
| 463 | * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See |
| 464 | * 4.4.3.3 of the 8544 RM. Note that this might actually work for all |
| 465 | * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the |
| 466 | * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544. |
| 467 | */ |
| 468 | if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 469 | gd->arch.i2c1_clk = sys_info.freq_systembus / 3; |
Kumar Gala | 42653b8 | 2008-10-16 21:58:49 -0500 | [diff] [blame] | 470 | else |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 471 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 472 | #else |
| 473 | /* Most 85xx SOCs use CCB/2, so this is the default behavior. */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 474 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 475 | #endif |
Simon Glass | 609e6ec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 476 | gd->arch.i2c2_clk = gd->arch.i2c1_clk; |
Timur Tabi | 943afa2 | 2008-01-09 14:35:26 -0600 | [diff] [blame] | 477 | |
Dipen Dudhat | 6b9ea08 | 2009-09-01 17:27:00 +0530 | [diff] [blame] | 478 | #if defined(CONFIG_FSL_ESDHC) |
Priyanka Jain | 7d640e9 | 2011-02-08 15:45:25 +0530 | [diff] [blame] | 479 | #if defined(CONFIG_MPC8569) || defined(CONFIG_P1010) ||\ |
| 480 | defined(CONFIG_P1014) |
Simon Glass | e9adeca | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 481 | gd->arch.sdhc_clk = gd->bus_clk; |
Anton Vorontsov | 7f52ed5 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 482 | #else |
Simon Glass | e9adeca | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 483 | gd->arch.sdhc_clk = gd->bus_clk / 2; |
Kumar Gala | ef50d6c | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 484 | #endif |
Anton Vorontsov | 7f52ed5 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 485 | #endif /* defined(CONFIG_FSL_ESDHC) */ |
Kumar Gala | ef50d6c | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 486 | |
Jon Loeliger | 9c4c5ae | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 487 | #if defined(CONFIG_CPM2) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 488 | gd->arch.vco_out = 2*sys_info.freq_systembus; |
Simon Glass | 748cd05 | 2012-12-13 20:48:46 +0000 | [diff] [blame] | 489 | gd->arch.cpm_clk = gd->arch.vco_out / 2; |
| 490 | gd->arch.scc_clk = gd->arch.vco_out / 4; |
| 491 | gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1))); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 492 | #endif |
| 493 | |
| 494 | if(gd->cpu_clk != 0) return (0); |
| 495 | else return (1); |
| 496 | } |
| 497 | |
| 498 | |
| 499 | /******************************************** |
| 500 | * get_bus_freq |
| 501 | * return system bus freq in Hz |
| 502 | *********************************************/ |
| 503 | ulong get_bus_freq (ulong dummy) |
| 504 | { |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 505 | return gd->bus_clk; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 506 | } |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 507 | |
| 508 | /******************************************** |
| 509 | * get_ddr_freq |
| 510 | * return ddr bus freq in Hz |
| 511 | *********************************************/ |
| 512 | ulong get_ddr_freq (ulong dummy) |
| 513 | { |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 514 | return gd->mem_clk; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 515 | } |