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; |
Shaveta Leekha | b8bf0ad | 2015-01-19 12:46:54 +0530 | [diff] [blame^] | 37 | #ifdef CONFIG_HETROGENOUS_CLUSTERS |
| 38 | unsigned int dsp_cpu; |
| 39 | uint rcw_tmp1, rcw_tmp2; |
| 40 | #endif |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 41 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 42 | int cc_group[12] = CONFIG_SYS_FSL_CLUSTER_CLOCKS; |
| 43 | #endif |
York Sun | 14109c7 | 2014-10-27 11:31:33 -0700 | [diff] [blame] | 44 | __maybe_unused u32 svr; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 45 | |
| 46 | const u8 core_cplx_PLL[16] = { |
| 47 | [ 0] = 0, /* CC1 PPL / 1 */ |
| 48 | [ 1] = 0, /* CC1 PPL / 2 */ |
| 49 | [ 2] = 0, /* CC1 PPL / 4 */ |
| 50 | [ 4] = 1, /* CC2 PPL / 1 */ |
| 51 | [ 5] = 1, /* CC2 PPL / 2 */ |
| 52 | [ 6] = 1, /* CC2 PPL / 4 */ |
| 53 | [ 8] = 2, /* CC3 PPL / 1 */ |
| 54 | [ 9] = 2, /* CC3 PPL / 2 */ |
| 55 | [10] = 2, /* CC3 PPL / 4 */ |
| 56 | [12] = 3, /* CC4 PPL / 1 */ |
| 57 | [13] = 3, /* CC4 PPL / 2 */ |
| 58 | [14] = 3, /* CC4 PPL / 4 */ |
| 59 | }; |
| 60 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 61 | const u8 core_cplx_pll_div[16] = { |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 62 | [ 0] = 1, /* CC1 PPL / 1 */ |
| 63 | [ 1] = 2, /* CC1 PPL / 2 */ |
| 64 | [ 2] = 4, /* CC1 PPL / 4 */ |
| 65 | [ 4] = 1, /* CC2 PPL / 1 */ |
| 66 | [ 5] = 2, /* CC2 PPL / 2 */ |
| 67 | [ 6] = 4, /* CC2 PPL / 4 */ |
| 68 | [ 8] = 1, /* CC3 PPL / 1 */ |
| 69 | [ 9] = 2, /* CC3 PPL / 2 */ |
| 70 | [10] = 4, /* CC3 PPL / 4 */ |
| 71 | [12] = 1, /* CC4 PPL / 1 */ |
| 72 | [13] = 2, /* CC4 PPL / 2 */ |
| 73 | [14] = 4, /* CC4 PPL / 4 */ |
| 74 | }; |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 75 | uint i, freq_c_pll[CONFIG_SYS_FSL_NUM_CC_PLLS]; |
| 76 | #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) |
| 77 | uint rcw_tmp; |
| 78 | #endif |
| 79 | uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS]; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 80 | unsigned long sysclk = CONFIG_SYS_CLK_FREQ; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 81 | uint mem_pll_rat; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 82 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 83 | sys_info->freq_systembus = sysclk; |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 84 | #ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK |
vijay rai | 0c12a15 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 85 | uint ddr_refclk_sel; |
| 86 | unsigned int porsr1_sys_clk; |
| 87 | porsr1_sys_clk = in_be32(&gur->porsr1) >> FSL_DCFG_PORSR1_SYSCLK_SHIFT |
| 88 | & FSL_DCFG_PORSR1_SYSCLK_MASK; |
| 89 | if (porsr1_sys_clk == FSL_DCFG_PORSR1_SYSCLK_DIFF) |
| 90 | sys_info->diff_sysclk = 1; |
| 91 | else |
| 92 | sys_info->diff_sysclk = 0; |
| 93 | |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 94 | /* |
| 95 | * DDR_REFCLK_SEL rcw bit is used to determine if DDR PLLS |
| 96 | * are driven by separate DDR Refclock or single source |
| 97 | * differential clock. |
| 98 | */ |
vijay rai | 0c12a15 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 99 | ddr_refclk_sel = (in_be32(&gur->rcwsr[5]) >> |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 100 | FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT) & |
| 101 | FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK; |
| 102 | /* |
vijay rai | 0c12a15 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 103 | * For single source clocking, both ddrclock and sysclock |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 104 | * are driven by differential sysclock. |
| 105 | */ |
vijay rai | 0c12a15 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 106 | if (ddr_refclk_sel == FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK) |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 107 | sys_info->freq_ddrbus = CONFIG_SYS_CLK_FREQ; |
vijay rai | 0c12a15 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 108 | else |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 109 | #endif |
York Sun | 98ffa19 | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 110 | #ifdef CONFIG_DDR_CLK_FREQ |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 111 | sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ; |
York Sun | 98ffa19 | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 112 | #else |
Priyanka Jain | b135991 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 113 | sys_info->freq_ddrbus = sysclk; |
York Sun | 98ffa19 | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 114 | #endif |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 115 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 116 | sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; |
York Sun | f77329c | 2012-10-08 07:44:09 +0000 | [diff] [blame] | 117 | mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> |
| 118 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT) |
| 119 | & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; |
York Sun | c3678b0 | 2014-03-28 15:07:27 -0700 | [diff] [blame] | 120 | #ifdef CONFIG_SYS_FSL_ERRATUM_A007212 |
| 121 | if (mem_pll_rat == 0) { |
| 122 | mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> |
| 123 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_RESV_SHIFT) & |
| 124 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; |
| 125 | } |
| 126 | #endif |
Zang Roy-R61911 | e88f421 | 2013-11-28 13:23:37 +0800 | [diff] [blame] | 127 | /* T4240/T4160 Rev2.0 MEM_PLL_RAT uses a value which is half of |
| 128 | * T4240/T4160 Rev1.0. eg. It's 12 in Rev1.0, however, for Rev2.0 |
| 129 | * it uses 6. |
York Sun | 14109c7 | 2014-10-27 11:31:33 -0700 | [diff] [blame] | 130 | * T2080 rev 1.1 and later also use half mem_pll comparing with rev 1.0 |
Zang Roy-R61911 | e88f421 | 2013-11-28 13:23:37 +0800 | [diff] [blame] | 131 | */ |
Shengzhou Liu | 5122dfa | 2014-04-25 16:31:22 +0800 | [diff] [blame] | 132 | #if defined(CONFIG_PPC_T4240) || defined(CONFIG_PPC_T4160) || \ |
York Sun | 14109c7 | 2014-10-27 11:31:33 -0700 | [diff] [blame] | 133 | defined(CONFIG_PPC_T4080) || defined(CONFIG_PPC_T2080) |
| 134 | svr = get_svr(); |
| 135 | switch (SVR_SOC_VER(svr)) { |
| 136 | case SVR_T4240: |
| 137 | case SVR_T4160: |
| 138 | case SVR_T4120: |
| 139 | case SVR_T4080: |
| 140 | if (SVR_MAJ(svr) >= 2) |
| 141 | mem_pll_rat *= 2; |
| 142 | break; |
| 143 | case SVR_T2080: |
| 144 | case SVR_T2081: |
| 145 | if ((SVR_MAJ(svr) > 1) || (SVR_MIN(svr) >= 1)) |
| 146 | mem_pll_rat *= 2; |
| 147 | break; |
| 148 | default: |
| 149 | break; |
| 150 | } |
Zang Roy-R61911 | e88f421 | 2013-11-28 13:23:37 +0800 | [diff] [blame] | 151 | #endif |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 152 | if (mem_pll_rat > 2) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 153 | sys_info->freq_ddrbus *= mem_pll_rat; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 154 | else |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 155 | sys_info->freq_ddrbus = sys_info->freq_systembus * mem_pll_rat; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 156 | |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 157 | for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) { |
| 158 | ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0x3f; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 159 | if (ratio[i] > 4) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 160 | freq_c_pll[i] = sysclk * ratio[i]; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 161 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 162 | freq_c_pll[i] = sys_info->freq_systembus * ratio[i]; |
Srikanth Srinivasan | ab48ca1 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 163 | } |
Shaveta Leekha | b8bf0ad | 2015-01-19 12:46:54 +0530 | [diff] [blame^] | 164 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 165 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 166 | /* |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 167 | * As per CHASSIS2 architeture total 12 clusters are posible and |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 168 | * Each cluster has up to 4 cores, sharing the same PLL selection. |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 169 | * The cluster clock assignment is SoC defined. |
| 170 | * |
| 171 | * Total 4 clock groups are possible with 3 PLLs each. |
| 172 | * as per array indices, clock group A has 0, 1, 2 numbered PLLs & |
| 173 | * clock group B has 3, 4, 6 and so on. |
| 174 | * |
| 175 | * Clock group A having PLL1, PLL2, PLL3, feeding cores of any cluster |
| 176 | * depends upon the SoC architeture. Same applies to other |
| 177 | * clock groups and clusters. |
| 178 | * |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 179 | */ |
| 180 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | f698143 | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 181 | int cluster = fsl_qoriq_core_to_cluster(cpu); |
| 182 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cluster].clkcncsr) >> 27) |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 183 | & 0xf; |
| 184 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 185 | cplx_pll += cc_group[cluster] - 1; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 186 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 187 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 188 | } |
Shaveta Leekha | b8bf0ad | 2015-01-19 12:46:54 +0530 | [diff] [blame^] | 189 | |
| 190 | #ifdef CONFIG_HETROGENOUS_CLUSTERS |
| 191 | for_each_cpu(i, dsp_cpu, cpu_num_dspcores(), cpu_dsp_mask()) { |
| 192 | int dsp_cluster = fsl_qoriq_dsp_core_to_cluster(dsp_cpu); |
| 193 | u32 c_pll_sel = (in_be32 |
| 194 | (&clk->clkcsr[dsp_cluster].clkcncsr) >> 27) |
| 195 | & 0xf; |
| 196 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
| 197 | cplx_pll += cc_group[dsp_cluster] - 1; |
| 198 | sys_info->freq_processor_dsp[dsp_cpu] = |
| 199 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
| 200 | } |
| 201 | #endif |
| 202 | |
Prabhakar Kushwaha | b33bd8c | 2014-04-21 10:47:41 +0530 | [diff] [blame] | 203 | #if defined(CONFIG_PPC_B4860) || defined(CONFIG_PPC_B4420) || \ |
| 204 | defined(CONFIG_PPC_T2080) || defined(CONFIG_PPC_T2081) |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 205 | #define FM1_CLK_SEL 0xe0000000 |
| 206 | #define FM1_CLK_SHIFT 29 |
Shengzhou Liu | f605079 | 2014-11-24 17:11:54 +0800 | [diff] [blame] | 207 | #elif defined(CONFIG_PPC_T1024) || defined(CONFIG_PPC_T1023) |
| 208 | #define FM1_CLK_SEL 0x00000007 |
| 209 | #define FM1_CLK_SHIFT 0 |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 210 | #else |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 211 | #define PME_CLK_SEL 0xe0000000 |
| 212 | #define PME_CLK_SHIFT 29 |
| 213 | #define FM1_CLK_SEL 0x1c000000 |
| 214 | #define FM1_CLK_SHIFT 26 |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 215 | #endif |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 216 | #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) |
Shengzhou Liu | f605079 | 2014-11-24 17:11:54 +0800 | [diff] [blame] | 217 | #if defined(CONFIG_PPC_T1024) || defined(CONFIG_PPC_T1023) |
| 218 | rcw_tmp = in_be32(&gur->rcwsr[15]) - 4; |
| 219 | #else |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 220 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 221 | #endif |
Shengzhou Liu | f605079 | 2014-11-24 17:11:54 +0800 | [diff] [blame] | 222 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 223 | |
| 224 | #ifdef CONFIG_SYS_DPAA_PME |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 225 | #ifndef CONFIG_PME_PLAT_CLK_DIV |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 226 | switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) { |
| 227 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 228 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 229 | break; |
| 230 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 231 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 232 | break; |
| 233 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 234 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 235 | break; |
| 236 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 237 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 238 | break; |
| 239 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 240 | 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] | 241 | break; |
| 242 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 243 | 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] | 244 | break; |
| 245 | default: |
| 246 | printf("Error: Unknown PME clock select!\n"); |
| 247 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 248 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 249 | break; |
| 250 | |
| 251 | } |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 252 | #else |
| 253 | sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK; |
| 254 | |
| 255 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 256 | #endif |
| 257 | |
Haiying Wang | 990e1a8 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 258 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Shengzhou Liu | f605079 | 2014-11-24 17:11:54 +0800 | [diff] [blame] | 259 | #ifndef CONFIG_QBMAN_CLK_DIV |
| 260 | #define CONFIG_QBMAN_CLK_DIV 2 |
| 261 | #endif |
| 262 | sys_info->freq_qman = sys_info->freq_systembus / CONFIG_QBMAN_CLK_DIV; |
Haiying Wang | 990e1a8 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 263 | #endif |
| 264 | |
Shaveta Leekha | b8bf0ad | 2015-01-19 12:46:54 +0530 | [diff] [blame^] | 265 | #if defined(CONFIG_SYS_MAPLE) |
| 266 | #define CPRI_CLK_SEL 0x1C000000 |
| 267 | #define CPRI_CLK_SHIFT 26 |
| 268 | #define CPRI_ALT_CLK_SEL 0x00007000 |
| 269 | #define CPRI_ALT_CLK_SHIFT 12 |
| 270 | |
| 271 | rcw_tmp1 = in_be32(&gur->rcwsr[7]); /* Reading RCW bits: 224-255*/ |
| 272 | rcw_tmp2 = in_be32(&gur->rcwsr[15]); /* Reading RCW bits: 480-511*/ |
| 273 | /* For MAPLE and CPRI frequency */ |
| 274 | switch ((rcw_tmp1 & CPRI_CLK_SEL) >> CPRI_CLK_SHIFT) { |
| 275 | case 1: |
| 276 | sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK]; |
| 277 | sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK]; |
| 278 | break; |
| 279 | case 2: |
| 280 | sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 2; |
| 281 | sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 2; |
| 282 | break; |
| 283 | case 3: |
| 284 | sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 3; |
| 285 | sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 3; |
| 286 | break; |
| 287 | case 4: |
| 288 | sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 4; |
| 289 | sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK] / 4; |
| 290 | break; |
| 291 | case 5: |
| 292 | if (((rcw_tmp2 & CPRI_ALT_CLK_SEL) |
| 293 | >> CPRI_ALT_CLK_SHIFT) == 6) { |
| 294 | sys_info->freq_maple = |
| 295 | freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 2; |
| 296 | sys_info->freq_cpri = |
| 297 | freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 2; |
| 298 | } |
| 299 | if (((rcw_tmp2 & CPRI_ALT_CLK_SEL) |
| 300 | >> CPRI_ALT_CLK_SHIFT) == 7) { |
| 301 | sys_info->freq_maple = |
| 302 | freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 3; |
| 303 | sys_info->freq_cpri = |
| 304 | freq_c_pll[CONFIG_SYS_CPRI_CLK - 2] / 3; |
| 305 | } |
| 306 | break; |
| 307 | case 6: |
| 308 | sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 2; |
| 309 | sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 2; |
| 310 | break; |
| 311 | case 7: |
| 312 | sys_info->freq_maple = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 3; |
| 313 | sys_info->freq_cpri = freq_c_pll[CONFIG_SYS_CPRI_CLK + 1] / 3; |
| 314 | break; |
| 315 | default: |
| 316 | printf("Error: Unknown MAPLE/CPRI clock select!\n"); |
| 317 | } |
| 318 | |
| 319 | /* For MAPLE ULB and eTVPE frequencies */ |
| 320 | #define ULB_CLK_SEL 0x00000038 |
| 321 | #define ULB_CLK_SHIFT 3 |
| 322 | #define ETVPE_CLK_SEL 0x00000007 |
| 323 | #define ETVPE_CLK_SHIFT 0 |
| 324 | |
| 325 | switch ((rcw_tmp2 & ULB_CLK_SEL) >> ULB_CLK_SHIFT) { |
| 326 | case 1: |
| 327 | sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK]; |
| 328 | break; |
| 329 | case 2: |
| 330 | sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 2; |
| 331 | break; |
| 332 | case 3: |
| 333 | sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 3; |
| 334 | break; |
| 335 | case 4: |
| 336 | sys_info->freq_maple_ulb = freq_c_pll[CONFIG_SYS_ULB_CLK] / 4; |
| 337 | break; |
| 338 | case 5: |
| 339 | sys_info->freq_maple_ulb = sys_info->freq_systembus; |
| 340 | break; |
| 341 | case 6: |
| 342 | sys_info->freq_maple_ulb = |
| 343 | freq_c_pll[CONFIG_SYS_ULB_CLK - 1] / 2; |
| 344 | break; |
| 345 | case 7: |
| 346 | sys_info->freq_maple_ulb = |
| 347 | freq_c_pll[CONFIG_SYS_ULB_CLK - 1] / 3; |
| 348 | break; |
| 349 | default: |
| 350 | printf("Error: Unknown MAPLE ULB clock select!\n"); |
| 351 | } |
| 352 | |
| 353 | switch ((rcw_tmp2 & ETVPE_CLK_SEL) >> ETVPE_CLK_SHIFT) { |
| 354 | case 1: |
| 355 | sys_info->freq_maple_etvpe = freq_c_pll[CONFIG_SYS_ETVPE_CLK]; |
| 356 | break; |
| 357 | case 2: |
| 358 | sys_info->freq_maple_etvpe = |
| 359 | freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 2; |
| 360 | break; |
| 361 | case 3: |
| 362 | sys_info->freq_maple_etvpe = |
| 363 | freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 3; |
| 364 | break; |
| 365 | case 4: |
| 366 | sys_info->freq_maple_etvpe = |
| 367 | freq_c_pll[CONFIG_SYS_ETVPE_CLK] / 4; |
| 368 | break; |
| 369 | case 5: |
| 370 | sys_info->freq_maple_etvpe = sys_info->freq_systembus; |
| 371 | break; |
| 372 | case 6: |
| 373 | sys_info->freq_maple_etvpe = |
| 374 | freq_c_pll[CONFIG_SYS_ETVPE_CLK - 1] / 2; |
| 375 | break; |
| 376 | case 7: |
| 377 | sys_info->freq_maple_etvpe = |
| 378 | freq_c_pll[CONFIG_SYS_ETVPE_CLK - 1] / 3; |
| 379 | break; |
| 380 | default: |
| 381 | printf("Error: Unknown MAPLE eTVPE clock select!\n"); |
| 382 | } |
| 383 | |
| 384 | #endif |
| 385 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 386 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 387 | #ifndef CONFIG_FM_PLAT_CLK_DIV |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 388 | switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) { |
| 389 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 390 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK]; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 391 | break; |
| 392 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 393 | 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] | 394 | break; |
| 395 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 396 | 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] | 397 | break; |
| 398 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 399 | 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] | 400 | break; |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 401 | case 5: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 402 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Sandeep Singh | 0cb3325 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 403 | break; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 404 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 405 | 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] | 406 | break; |
| 407 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 408 | 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] | 409 | break; |
| 410 | default: |
| 411 | printf("Error: Unknown FMan1 clock select!\n"); |
| 412 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 413 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 414 | break; |
| 415 | } |
| 416 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 417 | #ifdef CONFIG_SYS_FM2_CLK |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 418 | #define FM2_CLK_SEL 0x00000038 |
| 419 | #define FM2_CLK_SHIFT 3 |
| 420 | rcw_tmp = in_be32(&gur->rcwsr[15]); |
| 421 | switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) { |
| 422 | case 1: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 423 | 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] | 424 | break; |
| 425 | case 2: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 426 | 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] | 427 | break; |
| 428 | case 3: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 429 | 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] | 430 | break; |
| 431 | case 4: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 432 | 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] | 433 | break; |
Shaohui Xie | c1015c6 | 2013-11-28 13:52:51 +0800 | [diff] [blame] | 434 | case 5: |
| 435 | sys_info->freq_fman[1] = sys_info->freq_systembus; |
| 436 | break; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 437 | case 6: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 438 | 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] | 439 | break; |
| 440 | case 7: |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 441 | 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] | 442 | break; |
| 443 | default: |
| 444 | printf("Error: Unknown FMan2 clock select!\n"); |
| 445 | case 0: |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 446 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 447 | break; |
| 448 | } |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 449 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 450 | #endif /* CONFIG_SYS_NUM_FMAN == 2 */ |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 451 | #else |
| 452 | sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK; |
| 453 | #endif |
| 454 | #endif |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 455 | |
| 456 | #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 457 | |
Timur Tabi | fbb9ecf | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 458 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | f698143 | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 459 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27) |
| 460 | & 0xf; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 461 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
| 462 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 463 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 464 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 465 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 466 | #define PME_CLK_SEL 0x80000000 |
| 467 | #define FM1_CLK_SEL 0x40000000 |
| 468 | #define FM2_CLK_SEL 0x20000000 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 469 | #define HWA_ASYNC_DIV 0x04000000 |
| 470 | #if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2) |
| 471 | #define HWA_CC_PLL 1 |
Timur Tabi | 4905443 | 2012-10-05 11:09:19 +0000 | [diff] [blame] | 472 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3) |
| 473 | #define HWA_CC_PLL 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 474 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4) |
Wolfgang Denk | cd6881b | 2011-05-19 22:21:41 +0200 | [diff] [blame] | 475 | #define HWA_CC_PLL 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 476 | #else |
| 477 | #error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case |
| 478 | #endif |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 479 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
| 480 | |
| 481 | #ifdef CONFIG_SYS_DPAA_PME |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 482 | if (rcw_tmp & PME_CLK_SEL) { |
| 483 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 484 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 485 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 486 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 487 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 488 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 489 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 490 | #endif |
| 491 | |
| 492 | #ifdef CONFIG_SYS_DPAA_FMAN |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 493 | if (rcw_tmp & FM1_CLK_SEL) { |
| 494 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 495 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 496 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 497 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 498 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 499 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 500 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 501 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 502 | if (rcw_tmp & FM2_CLK_SEL) { |
| 503 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 504 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 505 | else |
Prabhakar Kushwaha | ce746fe | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 506 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 507 | } else { |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 508 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
Kumar Gala | b5c8753 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 509 | } |
Kumar Gala | 39aaca1 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 510 | #endif |
| 511 | #endif |
| 512 | |
Shaohui Xie | 3e83fc9 | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 513 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 514 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Shaohui Xie | 3e83fc9 | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 515 | #endif |
| 516 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 517 | #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 518 | |
Zhao Qiang | 2a44efe | 2014-03-21 16:21:45 +0800 | [diff] [blame] | 519 | #ifdef CONFIG_U_QE |
| 520 | sys_info->freq_qe = sys_info->freq_systembus / 2; |
| 521 | #endif |
| 522 | |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 523 | #else /* CONFIG_FSL_CORENET */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 524 | uint plat_ratio, e500_ratio, half_freq_systembus; |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 525 | int i; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 526 | #ifdef CONFIG_QE |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 527 | __maybe_unused u32 qe_ratio; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 528 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 529 | |
| 530 | plat_ratio = (gur->porpllsr) & 0x0000003e; |
| 531 | plat_ratio >>= 1; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 532 | sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ; |
Andy Fleming | 66ed6cc | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 533 | |
| 534 | /* Divide before multiply to avoid integer |
| 535 | * overflow for processor speeds above 2GHz */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 536 | half_freq_systembus = sys_info->freq_systembus/2; |
Poonam Aggrwal | 0e87098 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 537 | for (i = 0; i < cpu_numcores(); i++) { |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 538 | e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 539 | sys_info->freq_processor[i] = e500_ratio * half_freq_systembus; |
Haiying Wang | 2fc7eb0 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 540 | } |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 541 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 542 | /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */ |
| 543 | sys_info->freq_ddrbus = sys_info->freq_systembus; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 544 | |
| 545 | #ifdef CONFIG_DDR_CLK_FREQ |
| 546 | { |
Jason Jin | c039111 | 2008-09-27 14:40:57 +0800 | [diff] [blame] | 547 | u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) |
| 548 | >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 549 | if (ddr_ratio != 0x7) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 550 | sys_info->freq_ddrbus = ddr_ratio * CONFIG_DDR_CLK_FREQ; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 551 | } |
| 552 | #endif |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 553 | |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 554 | #ifdef CONFIG_QE |
York Sun | be7bebe | 2012-08-10 11:07:26 +0000 | [diff] [blame] | 555 | #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 556 | sys_info->freq_qe = sys_info->freq_systembus; |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 557 | #else |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 558 | qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO) |
| 559 | >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 560 | sys_info->freq_qe = qe_ratio * CONFIG_SYS_CLK_FREQ; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 561 | #endif |
Haiying Wang | a52d2f8 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 562 | #endif |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 563 | |
Haiying Wang | 24995d8 | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 564 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 565 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Haiying Wang | 24995d8 | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 566 | #endif |
| 567 | |
| 568 | #endif /* CONFIG_FSL_CORENET */ |
| 569 | |
Dipen Dudhat | beba93e | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 570 | #if defined(CONFIG_FSL_LBC) |
York Sun | 9a653a9 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 571 | uint lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 572 | #if defined(CONFIG_SYS_LBC_LCRR) |
| 573 | /* We will program LCRR to this value later */ |
| 574 | lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV; |
| 575 | #else |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 576 | lcrr_div = in_be32(&(LBC_BASE_ADDR)->lcrr) & LCRR_CLKDIV; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 577 | #endif |
| 578 | if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) { |
Dave Liu | 0fd2fa6 | 2009-11-17 20:49:05 +0800 | [diff] [blame] | 579 | #if defined(CONFIG_FSL_CORENET) |
| 580 | /* If this is corenet based SoC, bit-representation |
| 581 | * for four times the clock divider values. |
| 582 | */ |
| 583 | lcrr_div *= 4; |
| 584 | #elif !defined(CONFIG_MPC8540) && !defined(CONFIG_MPC8541) && \ |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 585 | !defined(CONFIG_MPC8555) && !defined(CONFIG_MPC8560) |
| 586 | /* |
| 587 | * Yes, the entire PQ38 family use the same |
| 588 | * bit-representation for twice the clock divider values. |
| 589 | */ |
| 590 | lcrr_div *= 2; |
| 591 | #endif |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 592 | sys_info->freq_localbus = sys_info->freq_systembus / lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 593 | } else { |
| 594 | /* In case anyone cares what the unknown value is */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 595 | sys_info->freq_localbus = lcrr_div; |
Trent Piepho | ada591d | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 596 | } |
Dipen Dudhat | beba93e | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 597 | #endif |
Kumar Gala | 800c73c | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 598 | |
| 599 | #if defined(CONFIG_FSL_IFC) |
Prabhakar Kushwaha | aa5a3d8 | 2014-09-23 10:57:12 +0530 | [diff] [blame] | 600 | ccr = ifc_in32(&ifc_regs->ifc_ccr); |
Kumar Gala | 800c73c | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 601 | ccr = ((ccr & IFC_CCR_CLK_DIV_MASK) >> IFC_CCR_CLK_DIV_SHIFT) + 1; |
| 602 | |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 603 | sys_info->freq_localbus = sys_info->freq_systembus / ccr; |
Kumar Gala | 800c73c | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 604 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Andy Fleming | 66ed6cc | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 607 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 608 | int get_clocks (void) |
| 609 | { |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 610 | sys_info_t sys_info; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 611 | #ifdef CONFIG_MPC8544 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 612 | volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 613 | #endif |
Jon Loeliger | 9c4c5ae | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 614 | #if defined(CONFIG_CPM2) |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 615 | volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 616 | uint sccr, dfbrg; |
| 617 | |
| 618 | /* set VCO = 4 * BRG */ |
Kumar Gala | aafeefb | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 619 | cpm->im_cpm_intctl.sccr &= 0xfffffffc; |
| 620 | sccr = cpm->im_cpm_intctl.sccr; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 621 | dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT; |
| 622 | #endif |
| 623 | get_sys_info (&sys_info); |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 624 | gd->cpu_clk = sys_info.freq_processor[0]; |
| 625 | gd->bus_clk = sys_info.freq_systembus; |
| 626 | gd->mem_clk = sys_info.freq_ddrbus; |
| 627 | gd->arch.lbc_clk = sys_info.freq_localbus; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 628 | |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 629 | #ifdef CONFIG_QE |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 630 | gd->arch.qe_clk = sys_info.freq_qe; |
Simon Glass | 45bae2e | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 631 | gd->arch.brg_clk = gd->arch.qe_clk / 2; |
Haiying Wang | b3d7f20 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 632 | #endif |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 633 | /* |
| 634 | * The base clock for I2C depends on the actual SOC. Unfortunately, |
| 635 | * there is no pattern that can be used to determine the frequency, so |
| 636 | * the only choice is to look up the actual SOC number and use the value |
| 637 | * for that SOC. This information is taken from application note |
| 638 | * AN2919. |
| 639 | */ |
| 640 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ |
Tang Yuantian | f62b123 | 2013-09-06 10:45:40 +0800 | [diff] [blame] | 641 | defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555) || \ |
| 642 | defined(CONFIG_P1022) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 643 | gd->arch.i2c1_clk = sys_info.freq_systembus; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 644 | #elif defined(CONFIG_MPC8544) |
| 645 | /* |
| 646 | * On the 8544, the I2C clock is the same as the SEC clock. This can be |
| 647 | * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See |
| 648 | * 4.4.3.3 of the 8544 RM. Note that this might actually work for all |
| 649 | * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the |
| 650 | * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544. |
| 651 | */ |
| 652 | if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 653 | gd->arch.i2c1_clk = sys_info.freq_systembus / 3; |
Kumar Gala | 42653b8 | 2008-10-16 21:58:49 -0500 | [diff] [blame] | 654 | else |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 655 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 656 | #else |
| 657 | /* Most 85xx SOCs use CCB/2, so this is the default behavior. */ |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 658 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 88353a9 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 659 | #endif |
Simon Glass | 609e6ec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 660 | gd->arch.i2c2_clk = gd->arch.i2c1_clk; |
Timur Tabi | 943afa2 | 2008-01-09 14:35:26 -0600 | [diff] [blame] | 661 | |
Dipen Dudhat | 6b9ea08 | 2009-09-01 17:27:00 +0530 | [diff] [blame] | 662 | #if defined(CONFIG_FSL_ESDHC) |
Priyanka Jain | 7d640e9 | 2011-02-08 15:45:25 +0530 | [diff] [blame] | 663 | #if defined(CONFIG_MPC8569) || defined(CONFIG_P1010) ||\ |
| 664 | defined(CONFIG_P1014) |
Simon Glass | e9adeca | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 665 | gd->arch.sdhc_clk = gd->bus_clk; |
Anton Vorontsov | 7f52ed5 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 666 | #else |
Simon Glass | e9adeca | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 667 | gd->arch.sdhc_clk = gd->bus_clk / 2; |
Kumar Gala | ef50d6c | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 668 | #endif |
Anton Vorontsov | 7f52ed5 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 669 | #endif /* defined(CONFIG_FSL_ESDHC) */ |
Kumar Gala | ef50d6c | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 670 | |
Jon Loeliger | 9c4c5ae | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 671 | #if defined(CONFIG_CPM2) |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 672 | gd->arch.vco_out = 2*sys_info.freq_systembus; |
Simon Glass | 748cd05 | 2012-12-13 20:48:46 +0000 | [diff] [blame] | 673 | gd->arch.cpm_clk = gd->arch.vco_out / 2; |
| 674 | gd->arch.scc_clk = gd->arch.vco_out / 4; |
| 675 | gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1))); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 676 | #endif |
| 677 | |
| 678 | if(gd->cpu_clk != 0) return (0); |
| 679 | else return (1); |
| 680 | } |
| 681 | |
| 682 | |
| 683 | /******************************************** |
| 684 | * get_bus_freq |
| 685 | * return system bus freq in Hz |
| 686 | *********************************************/ |
| 687 | ulong get_bus_freq (ulong dummy) |
| 688 | { |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 689 | return gd->bus_clk; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 690 | } |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 691 | |
| 692 | /******************************************** |
| 693 | * get_ddr_freq |
| 694 | * return ddr bus freq in Hz |
| 695 | *********************************************/ |
| 696 | ulong get_ddr_freq (ulong dummy) |
| 697 | { |
James Yang | a3e77fa | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 698 | return gd->mem_clk; |
Kumar Gala | d435793 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 699 | } |