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