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