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