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 | 629d6b3 | 2013-11-22 17:39:10 +0800 | [diff] [blame] | 154 | #if defined(CONFIG_PPC_B4860) || defined(CONFIG_PPC_T2080) |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 155 | #define FM1_CLK_SEL 0xe0000000 |
| 156 | #define FM1_CLK_SHIFT 29 |
| 157 | #else |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 158 | #define PME_CLK_SEL 0xe0000000 |
| 159 | #define PME_CLK_SHIFT 29 |
| 160 | #define FM1_CLK_SEL 0x1c000000 |
| 161 | #define FM1_CLK_SHIFT 26 |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 162 | #endif |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 163 | #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] | 164 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 165 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 166 | |
| 167 | #ifdef CONFIG_SYS_DPAA_PME |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 168 | #ifndef CONFIG_PME_PLAT_CLK_DIV |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 169 | switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) { |
| 170 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 171 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 172 | break; |
| 173 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 174 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 175 | break; |
| 176 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 177 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 178 | break; |
| 179 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 180 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 181 | break; |
| 182 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 183 | 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] | 184 | break; |
| 185 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 186 | 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] | 187 | break; |
| 188 | default: |
| 189 | printf("Error: Unknown PME clock select!\n"); |
| 190 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 191 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 192 | break; |
| 193 | |
| 194 | } |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 195 | #else |
| 196 | sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK; |
| 197 | |
| 198 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 199 | #endif |
| 200 | |
Haiying Wang | 990e1a8 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 201 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 202 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Haiying Wang | 990e1a8 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 203 | #endif |
| 204 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 205 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 206 | #ifndef CONFIG_FM_PLAT_CLK_DIV |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 207 | switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) { |
| 208 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 209 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 210 | break; |
| 211 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 212 | 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] | 213 | break; |
| 214 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 215 | 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] | 216 | break; |
| 217 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 218 | 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] | 219 | break; |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 220 | case 5: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 221 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 222 | break; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 223 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 224 | 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] | 225 | break; |
| 226 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 227 | 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] | 228 | break; |
| 229 | default: |
| 230 | printf("Error: Unknown FMan1 clock select!\n"); |
| 231 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 232 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 233 | break; |
| 234 | } |
| 235 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 236 | #ifdef CONFIG_SYS_FM2_CLK |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 237 | #define FM2_CLK_SEL 0x00000038 |
| 238 | #define FM2_CLK_SHIFT 3 |
| 239 | rcw_tmp = in_be32(&gur->rcwsr[15]); |
| 240 | switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) { |
| 241 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 242 | 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] | 243 | break; |
| 244 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 245 | 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] | 246 | break; |
| 247 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 248 | 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] | 249 | break; |
| 250 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 251 | 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] | 252 | break; |
Shaohui Xie | c1015c6 | 2013-11-28 13:52:51 +0800 | [diff] [blame] | 253 | case 5: |
| 254 | sys_info->freq_fman[1] = sys_info->freq_systembus; |
| 255 | break; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 256 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 257 | 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] | 258 | break; |
| 259 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 260 | 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] | 261 | break; |
| 262 | default: |
| 263 | printf("Error: Unknown FMan2 clock select!\n"); |
| 264 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 265 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 266 | break; |
| 267 | } |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 268 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 269 | #endif /* CONFIG_SYS_NUM_FMAN == 2 */ |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 270 | #else |
| 271 | sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK; |
| 272 | #endif |
| 273 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 274 | |
| 275 | #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 276 | |
Timur Tabi | fbb9ecf | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 277 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | f698143 | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 278 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27) |
| 279 | & 0xf; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 280 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
| 281 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 282 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 283 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 284 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 285 | #define PME_CLK_SEL 0x80000000 |
| 286 | #define FM1_CLK_SEL 0x40000000 |
| 287 | #define FM2_CLK_SEL 0x20000000 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 288 | #define HWA_ASYNC_DIV 0x04000000 |
| 289 | #if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2) |
| 290 | #define HWA_CC_PLL 1 |
Timur Tabi | 4905443 | 2012-10-05 11:09:19 +0000 | [diff] [blame] | 291 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3) |
| 292 | #define HWA_CC_PLL 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 293 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4) |
Wolfgang Denk | cd6881b | 2011-05-19 22:21:41 +0200 | [diff] [blame] | 294 | #define HWA_CC_PLL 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 295 | #else |
| 296 | #error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case |
| 297 | #endif |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 298 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
| 299 | |
| 300 | #ifdef CONFIG_SYS_DPAA_PME |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 301 | if (rcw_tmp & PME_CLK_SEL) { |
| 302 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 303 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 304 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 305 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 306 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 307 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 308 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 309 | #endif |
| 310 | |
| 311 | #ifdef CONFIG_SYS_DPAA_FMAN |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 312 | if (rcw_tmp & FM1_CLK_SEL) { |
| 313 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 314 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 315 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 316 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 317 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 318 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 319 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 320 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 321 | if (rcw_tmp & FM2_CLK_SEL) { |
| 322 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 323 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 324 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 325 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 326 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 327 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 328 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 329 | #endif |
| 330 | #endif |
| 331 | |
Shaohui Xie | 3e83fc9 | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 332 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 333 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Shaohui Xie | 3e83fc9 | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 334 | #endif |
| 335 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 336 | #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 337 | |
| 338 | #else /* CONFIG_FSL_CORENET */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 339 | uint plat_ratio, e500_ratio, half_freq_systembus; |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 340 | int i; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 341 | #ifdef CONFIG_QE |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 342 | __maybe_unused u32 qe_ratio; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 343 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 344 | |
| 345 | plat_ratio = (gur->porpllsr) & 0x0000003e; |
| 346 | plat_ratio >>= 1; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 347 | sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ; |
Andy Fleming | 66ed6cc | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 348 | |
| 349 | /* Divide before multiply to avoid integer |
| 350 | * overflow for processor speeds above 2GHz */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 351 | half_freq_systembus = sys_info->freq_systembus/2; |
Poonam Aggrwal | 0e87098 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 352 | for (i = 0; i < cpu_numcores(); i++) { |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 353 | e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 354 | sys_info->freq_processor[i] = e500_ratio * half_freq_systembus; |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 355 | } |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 356 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 357 | /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */ |
| 358 | sys_info->freq_ddrbus = sys_info->freq_systembus; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 359 | |
| 360 | #ifdef CONFIG_DDR_CLK_FREQ |
| 361 | { |
Jason Jin | c039111 | 2008-09-27 14:40:57 +0800 | [diff] [blame] | 362 | u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) |
| 363 | >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 364 | if (ddr_ratio != 0x7) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 365 | sys_info->freq_ddrbus = ddr_ratio * CONFIG_DDR_CLK_FREQ; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 366 | } |
| 367 | #endif |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 368 | |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 369 | #ifdef CONFIG_QE |
York Sun | be7bebe | 2012-08-10 11:07:26 +0000 | [diff] [blame] | 370 | #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 371 | sys_info->freq_qe = sys_info->freq_systembus; |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 372 | #else |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 373 | qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO) |
| 374 | >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 375 | sys_info->freq_qe = qe_ratio * CONFIG_SYS_CLK_FREQ; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 376 | #endif |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 377 | #endif |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 378 | |
Haiying Wang | 24995d8 | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 379 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 380 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Haiying Wang | 24995d8 | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 381 | #endif |
| 382 | |
| 383 | #endif /* CONFIG_FSL_CORENET */ |
| 384 | |
Dipen Dudhat | beba93e | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 385 | #if defined(CONFIG_FSL_LBC) |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 386 | uint lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 387 | #if defined(CONFIG_SYS_LBC_LCRR) |
| 388 | /* We will program LCRR to this value later */ |
| 389 | lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV; |
| 390 | #else |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 391 | lcrr_div = in_be32(&(LBC_BASE_ADDR)->lcrr) & LCRR_CLKDIV; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 392 | #endif |
| 393 | if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) { |
Dave Liu | 0fd2fa6 | 2009-11-17 20:49:05 +0800 | [diff] [blame] | 394 | #if defined(CONFIG_FSL_CORENET) |
| 395 | /* If this is corenet based SoC, bit-representation |
| 396 | * for four times the clock divider values. |
| 397 | */ |
| 398 | lcrr_div *= 4; |
| 399 | #elif !defined(CONFIG_MPC8540) && !defined(CONFIG_MPC8541) && \ |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 400 | !defined(CONFIG_MPC8555) && !defined(CONFIG_MPC8560) |
| 401 | /* |
| 402 | * Yes, the entire PQ38 family use the same |
| 403 | * bit-representation for twice the clock divider values. |
| 404 | */ |
| 405 | lcrr_div *= 2; |
| 406 | #endif |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 407 | sys_info->freq_localbus = sys_info->freq_systembus / lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 408 | } else { |
| 409 | /* In case anyone cares what the unknown value is */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 410 | sys_info->freq_localbus = lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 411 | } |
Dipen Dudhat | beba93e | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 412 | #endif |
Kumar Gala | 800c73c | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 413 | |
| 414 | #if defined(CONFIG_FSL_IFC) |
| 415 | ccr = in_be32(&ifc_regs->ifc_ccr); |
| 416 | ccr = ((ccr & IFC_CCR_CLK_DIV_MASK) >> IFC_CCR_CLK_DIV_SHIFT) + 1; |
| 417 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 418 | sys_info->freq_localbus = sys_info->freq_systembus / ccr; |
Kumar Gala | 800c73c | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 419 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Andy Fleming | 66ed6cc | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 422 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 423 | int get_clocks (void) |
| 424 | { |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 425 | sys_info_t sys_info; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 426 | #ifdef CONFIG_MPC8544 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 427 | volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 428 | #endif |
Jon Loeliger | 9c4c5ae | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 429 | #if defined(CONFIG_CPM2) |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 430 | volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 431 | uint sccr, dfbrg; |
| 432 | |
| 433 | /* set VCO = 4 * BRG */ |
Kumar Gala | aafeefb | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 434 | cpm->im_cpm_intctl.sccr &= 0xfffffffc; |
| 435 | sccr = cpm->im_cpm_intctl.sccr; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 436 | dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT; |
| 437 | #endif |
| 438 | get_sys_info (&sys_info); |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 439 | gd->cpu_clk = sys_info.freq_processor[0]; |
| 440 | gd->bus_clk = sys_info.freq_systembus; |
| 441 | gd->mem_clk = sys_info.freq_ddrbus; |
| 442 | gd->arch.lbc_clk = sys_info.freq_localbus; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 443 | |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 444 | #ifdef CONFIG_QE |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 445 | gd->arch.qe_clk = sys_info.freq_qe; |
Simon Glass | 45bae2e | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 446 | gd->arch.brg_clk = gd->arch.qe_clk / 2; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 447 | #endif |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 448 | /* |
| 449 | * The base clock for I2C depends on the actual SOC. Unfortunately, |
| 450 | * there is no pattern that can be used to determine the frequency, so |
| 451 | * the only choice is to look up the actual SOC number and use the value |
| 452 | * for that SOC. This information is taken from application note |
| 453 | * AN2919. |
| 454 | */ |
| 455 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ |
Tang Yuantian | f62b123 | 2013-09-06 10:45:40 +0800 | [diff] [blame] | 456 | defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555) || \ |
| 457 | defined(CONFIG_P1022) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 458 | gd->arch.i2c1_clk = sys_info.freq_systembus; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 459 | #elif defined(CONFIG_MPC8544) |
| 460 | /* |
| 461 | * On the 8544, the I2C clock is the same as the SEC clock. This can be |
| 462 | * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See |
| 463 | * 4.4.3.3 of the 8544 RM. Note that this might actually work for all |
| 464 | * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the |
| 465 | * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544. |
| 466 | */ |
| 467 | if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 468 | gd->arch.i2c1_clk = sys_info.freq_systembus / 3; |
Kumar Gala | 42653b8 | 2008-10-16 21:58:49 -0500 | [diff] [blame] | 469 | else |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 470 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 471 | #else |
| 472 | /* Most 85xx SOCs use CCB/2, so this is the default behavior. */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 473 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 474 | #endif |
Simon Glass | 609e6ec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 475 | gd->arch.i2c2_clk = gd->arch.i2c1_clk; |
Timur Tabi | 943afa2 | 2008-01-09 14:35:26 -0600 | [diff] [blame] | 476 | |
Dipen Dudhat | 6b9ea08 | 2009-09-01 17:27:00 +0530 | [diff] [blame] | 477 | #if defined(CONFIG_FSL_ESDHC) |
Priyanka Jain | 7d640e9 | 2011-02-08 15:45:25 +0530 | [diff] [blame] | 478 | #if defined(CONFIG_MPC8569) || defined(CONFIG_P1010) ||\ |
| 479 | defined(CONFIG_P1014) |
Simon Glass | e9adeca | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 480 | gd->arch.sdhc_clk = gd->bus_clk; |
Anton Vorontsov | 7f52ed5 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 481 | #else |
Simon Glass | e9adeca | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 482 | gd->arch.sdhc_clk = gd->bus_clk / 2; |
Kumar Gala | ef50d6c | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 483 | #endif |
Anton Vorontsov | 7f52ed5 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 484 | #endif /* defined(CONFIG_FSL_ESDHC) */ |
Kumar Gala | ef50d6c | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 485 | |
Jon Loeliger | 9c4c5ae | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 486 | #if defined(CONFIG_CPM2) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 487 | gd->arch.vco_out = 2*sys_info.freq_systembus; |
Simon Glass | 748cd05 | 2012-12-13 20:48:46 +0000 | [diff] [blame] | 488 | gd->arch.cpm_clk = gd->arch.vco_out / 2; |
| 489 | gd->arch.scc_clk = gd->arch.vco_out / 4; |
| 490 | gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1))); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 491 | #endif |
| 492 | |
| 493 | if(gd->cpu_clk != 0) return (0); |
| 494 | else return (1); |
| 495 | } |
| 496 | |
| 497 | |
| 498 | /******************************************** |
| 499 | * get_bus_freq |
| 500 | * return system bus freq in Hz |
| 501 | *********************************************/ |
| 502 | ulong get_bus_freq (ulong dummy) |
| 503 | { |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 504 | return gd->bus_clk; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 505 | } |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 506 | |
| 507 | /******************************************** |
| 508 | * get_ddr_freq |
| 509 | * return ddr bus freq in Hz |
| 510 | *********************************************/ |
| 511 | ulong get_ddr_freq (ulong dummy) |
| 512 | { |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 513 | return gd->mem_clk; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 514 | } |