wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
Dipen Dudhat | 5d51bf9 | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 2 | * Copyright 2004, 2007-2011 Freescale Semiconductor, Inc. |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 3 | * |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 4 | * (C) Copyright 2003 Motorola Inc. |
| 5 | * Xianghua Xiao, (X.Xiao@motorola.com) |
| 6 | * |
| 7 | * (C) Copyright 2000 |
| 8 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 9 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
| 14 | #include <ppc_asm.tmpl> |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 15 | #include <linux/compiler.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 16 | #include <asm/processor.h> |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 17 | #include <asm/io.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 18 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 21 | |
| 22 | #ifndef CONFIG_SYS_FSL_NUM_CC_PLLS |
| 23 | #define CONFIG_SYS_FSL_NUM_CC_PLLS 6 |
| 24 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 25 | /* --------------------------------------------------------------- */ |
| 26 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 27 | void get_sys_info(sys_info_t *sys_info) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 28 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 29 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 17ec6fa | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 30 | #ifdef CONFIG_FSL_IFC |
| 31 | struct fsl_ifc *ifc_regs = (void *)CONFIG_SYS_IFC_ADDR; |
| 32 | u32 ccr; |
| 33 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 34 | #ifdef CONFIG_FSL_CORENET |
| 35 | volatile ccsr_clk_t *clk = (void *)(CONFIG_SYS_FSL_CORENET_CLK_ADDR); |
Timur Tabi | 4728942 | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 36 | unsigned int cpu; |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 37 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 38 | int cc_group[12] = CONFIG_SYS_FSL_CLUSTER_CLOCKS; |
| 39 | #endif |
York Sun | 7c355f5 | 2014-10-27 11:31:33 -0700 | [diff] [blame] | 40 | __maybe_unused u32 svr; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 41 | |
| 42 | const u8 core_cplx_PLL[16] = { |
| 43 | [ 0] = 0, /* CC1 PPL / 1 */ |
| 44 | [ 1] = 0, /* CC1 PPL / 2 */ |
| 45 | [ 2] = 0, /* CC1 PPL / 4 */ |
| 46 | [ 4] = 1, /* CC2 PPL / 1 */ |
| 47 | [ 5] = 1, /* CC2 PPL / 2 */ |
| 48 | [ 6] = 1, /* CC2 PPL / 4 */ |
| 49 | [ 8] = 2, /* CC3 PPL / 1 */ |
| 50 | [ 9] = 2, /* CC3 PPL / 2 */ |
| 51 | [10] = 2, /* CC3 PPL / 4 */ |
| 52 | [12] = 3, /* CC4 PPL / 1 */ |
| 53 | [13] = 3, /* CC4 PPL / 2 */ |
| 54 | [14] = 3, /* CC4 PPL / 4 */ |
| 55 | }; |
| 56 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 57 | const u8 core_cplx_pll_div[16] = { |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 58 | [ 0] = 1, /* CC1 PPL / 1 */ |
| 59 | [ 1] = 2, /* CC1 PPL / 2 */ |
| 60 | [ 2] = 4, /* CC1 PPL / 4 */ |
| 61 | [ 4] = 1, /* CC2 PPL / 1 */ |
| 62 | [ 5] = 2, /* CC2 PPL / 2 */ |
| 63 | [ 6] = 4, /* CC2 PPL / 4 */ |
| 64 | [ 8] = 1, /* CC3 PPL / 1 */ |
| 65 | [ 9] = 2, /* CC3 PPL / 2 */ |
| 66 | [10] = 4, /* CC3 PPL / 4 */ |
| 67 | [12] = 1, /* CC4 PPL / 1 */ |
| 68 | [13] = 2, /* CC4 PPL / 2 */ |
| 69 | [14] = 4, /* CC4 PPL / 4 */ |
| 70 | }; |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 71 | uint i, freq_c_pll[CONFIG_SYS_FSL_NUM_CC_PLLS]; |
| 72 | #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) |
| 73 | uint rcw_tmp; |
| 74 | #endif |
| 75 | uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS]; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 76 | unsigned long sysclk = CONFIG_SYS_CLK_FREQ; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 77 | uint mem_pll_rat; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 78 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 79 | sys_info->freq_systembus = sysclk; |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 80 | #ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK |
vijay rai | d84fd50 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 81 | uint ddr_refclk_sel; |
| 82 | unsigned int porsr1_sys_clk; |
| 83 | porsr1_sys_clk = in_be32(&gur->porsr1) >> FSL_DCFG_PORSR1_SYSCLK_SHIFT |
| 84 | & FSL_DCFG_PORSR1_SYSCLK_MASK; |
| 85 | if (porsr1_sys_clk == FSL_DCFG_PORSR1_SYSCLK_DIFF) |
| 86 | sys_info->diff_sysclk = 1; |
| 87 | else |
| 88 | sys_info->diff_sysclk = 0; |
| 89 | |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 90 | /* |
| 91 | * DDR_REFCLK_SEL rcw bit is used to determine if DDR PLLS |
| 92 | * are driven by separate DDR Refclock or single source |
| 93 | * differential clock. |
| 94 | */ |
vijay rai | d84fd50 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 95 | ddr_refclk_sel = (in_be32(&gur->rcwsr[5]) >> |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 96 | FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT) & |
| 97 | FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK; |
| 98 | /* |
vijay rai | d84fd50 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 99 | * For single source clocking, both ddrclock and sysclock |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 100 | * are driven by differential sysclock. |
| 101 | */ |
vijay rai | d84fd50 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 102 | if (ddr_refclk_sel == FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK) |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 103 | sys_info->freq_ddrbus = CONFIG_SYS_CLK_FREQ; |
vijay rai | d84fd50 | 2014-04-15 11:34:12 +0530 | [diff] [blame] | 104 | else |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 105 | #endif |
York Sun | 3b5179f | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 106 | #ifdef CONFIG_DDR_CLK_FREQ |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 107 | sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ; |
York Sun | 3b5179f | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 108 | #else |
Priyanka Jain | e9dcaa8 | 2013-12-17 14:25:52 +0530 | [diff] [blame] | 109 | sys_info->freq_ddrbus = sysclk; |
York Sun | 3b5179f | 2012-10-08 07:44:31 +0000 | [diff] [blame] | 110 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 111 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 112 | sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; |
York Sun | b8a076b | 2012-10-08 07:44:09 +0000 | [diff] [blame] | 113 | mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> |
| 114 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT) |
| 115 | & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; |
York Sun | 7b083df | 2014-03-28 15:07:27 -0700 | [diff] [blame] | 116 | #ifdef CONFIG_SYS_FSL_ERRATUM_A007212 |
| 117 | if (mem_pll_rat == 0) { |
| 118 | mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> |
| 119 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_RESV_SHIFT) & |
| 120 | FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; |
| 121 | } |
| 122 | #endif |
Zang Roy-R61911 | 1b1e5cf | 2013-11-28 13:23:37 +0800 | [diff] [blame] | 123 | /* T4240/T4160 Rev2.0 MEM_PLL_RAT uses a value which is half of |
| 124 | * T4240/T4160 Rev1.0. eg. It's 12 in Rev1.0, however, for Rev2.0 |
| 125 | * it uses 6. |
York Sun | 7c355f5 | 2014-10-27 11:31:33 -0700 | [diff] [blame] | 126 | * 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] | 127 | */ |
Shengzhou Liu | 26ed2d0 | 2014-04-25 16:31:22 +0800 | [diff] [blame] | 128 | #if defined(CONFIG_PPC_T4240) || defined(CONFIG_PPC_T4160) || \ |
York Sun | 7c355f5 | 2014-10-27 11:31:33 -0700 | [diff] [blame] | 129 | defined(CONFIG_PPC_T4080) || defined(CONFIG_PPC_T2080) |
| 130 | svr = get_svr(); |
| 131 | switch (SVR_SOC_VER(svr)) { |
| 132 | case SVR_T4240: |
| 133 | case SVR_T4160: |
| 134 | case SVR_T4120: |
| 135 | case SVR_T4080: |
| 136 | if (SVR_MAJ(svr) >= 2) |
| 137 | mem_pll_rat *= 2; |
| 138 | break; |
| 139 | case SVR_T2080: |
| 140 | case SVR_T2081: |
| 141 | if ((SVR_MAJ(svr) > 1) || (SVR_MIN(svr) >= 1)) |
| 142 | mem_pll_rat *= 2; |
| 143 | break; |
| 144 | default: |
| 145 | break; |
| 146 | } |
Zang Roy-R61911 | 1b1e5cf | 2013-11-28 13:23:37 +0800 | [diff] [blame] | 147 | #endif |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 148 | if (mem_pll_rat > 2) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 149 | sys_info->freq_ddrbus *= mem_pll_rat; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 150 | else |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 151 | sys_info->freq_ddrbus = sys_info->freq_systembus * mem_pll_rat; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 152 | |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 153 | for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) { |
| 154 | ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0x3f; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 155 | if (ratio[i] > 4) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 156 | freq_c_pll[i] = sysclk * ratio[i]; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 157 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 158 | freq_c_pll[i] = sys_info->freq_systembus * ratio[i]; |
Srikanth Srinivasan | f58c2a4 | 2010-02-10 17:32:43 +0800 | [diff] [blame] | 159 | } |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 160 | #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 |
| 161 | /* |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 162 | * As per CHASSIS2 architeture total 12 clusters are posible and |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 163 | * Each cluster has up to 4 cores, sharing the same PLL selection. |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 164 | * The cluster clock assignment is SoC defined. |
| 165 | * |
| 166 | * Total 4 clock groups are possible with 3 PLLs each. |
| 167 | * as per array indices, clock group A has 0, 1, 2 numbered PLLs & |
| 168 | * clock group B has 3, 4, 6 and so on. |
| 169 | * |
| 170 | * Clock group A having PLL1, PLL2, PLL3, feeding cores of any cluster |
| 171 | * depends upon the SoC architeture. Same applies to other |
| 172 | * clock groups and clusters. |
| 173 | * |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 174 | */ |
Timur Tabi | 4728942 | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 175 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | aa150bb | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 176 | int cluster = fsl_qoriq_core_to_cluster(cpu); |
| 177 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cluster].clkcncsr) >> 27) |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 178 | & 0xf; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 179 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 180 | cplx_pll += cc_group[cluster] - 1; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 181 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 182 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 183 | } |
Prabhakar Kushwaha | 1229c22 | 2014-04-21 10:47:41 +0530 | [diff] [blame] | 184 | #if defined(CONFIG_PPC_B4860) || defined(CONFIG_PPC_B4420) || \ |
| 185 | defined(CONFIG_PPC_T2080) || defined(CONFIG_PPC_T2081) |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 186 | #define FM1_CLK_SEL 0xe0000000 |
| 187 | #define FM1_CLK_SHIFT 29 |
| 188 | #else |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 189 | #define PME_CLK_SEL 0xe0000000 |
| 190 | #define PME_CLK_SHIFT 29 |
| 191 | #define FM1_CLK_SEL 0x1c000000 |
| 192 | #define FM1_CLK_SHIFT 26 |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 193 | #endif |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 194 | #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 195 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 196 | #endif |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 197 | |
| 198 | #ifdef CONFIG_SYS_DPAA_PME |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 199 | #ifndef CONFIG_PME_PLAT_CLK_DIV |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 200 | switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) { |
| 201 | case 1: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 202 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 203 | break; |
| 204 | case 2: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 205 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 206 | break; |
| 207 | case 3: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 208 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 209 | break; |
| 210 | case 4: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 211 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 212 | break; |
| 213 | case 6: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 214 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 215 | break; |
| 216 | case 7: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 217 | sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 218 | break; |
| 219 | default: |
| 220 | printf("Error: Unknown PME clock select!\n"); |
| 221 | case 0: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 222 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 223 | break; |
| 224 | |
| 225 | } |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 226 | #else |
| 227 | sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK; |
| 228 | |
| 229 | #endif |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 230 | #endif |
| 231 | |
Haiying Wang | 09d0aa9 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 232 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 233 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Haiying Wang | 09d0aa9 | 2012-10-11 07:13:39 +0000 | [diff] [blame] | 234 | #endif |
| 235 | |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 236 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 237 | #ifndef CONFIG_FM_PLAT_CLK_DIV |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 238 | switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) { |
| 239 | case 1: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 240 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 241 | break; |
| 242 | case 2: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 243 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 244 | break; |
| 245 | case 3: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 246 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 247 | break; |
| 248 | case 4: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 249 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 4; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 250 | break; |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 251 | case 5: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 252 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Sandeep Singh | f7dfe25 | 2013-03-25 07:33:09 +0000 | [diff] [blame] | 253 | break; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 254 | case 6: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 255 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 256 | break; |
| 257 | case 7: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 258 | sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 259 | break; |
| 260 | default: |
| 261 | printf("Error: Unknown FMan1 clock select!\n"); |
| 262 | case 0: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 263 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 264 | break; |
| 265 | } |
| 266 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 267 | #ifdef CONFIG_SYS_FM2_CLK |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 268 | #define FM2_CLK_SEL 0x00000038 |
| 269 | #define FM2_CLK_SHIFT 3 |
| 270 | rcw_tmp = in_be32(&gur->rcwsr[15]); |
| 271 | switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) { |
| 272 | case 1: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 273 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 274 | break; |
| 275 | case 2: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 276 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 277 | break; |
| 278 | case 3: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 279 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 280 | break; |
| 281 | case 4: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 282 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 4; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 283 | break; |
Shaohui Xie | 45359a3 | 2013-11-28 13:52:51 +0800 | [diff] [blame] | 284 | case 5: |
| 285 | sys_info->freq_fman[1] = sys_info->freq_systembus; |
| 286 | break; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 287 | case 6: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 288 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 289 | break; |
| 290 | case 7: |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 291 | sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 3; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 292 | break; |
| 293 | default: |
| 294 | printf("Error: Unknown FMan2 clock select!\n"); |
| 295 | case 0: |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 296 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 297 | break; |
| 298 | } |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 299 | #endif |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 300 | #endif /* CONFIG_SYS_NUM_FMAN == 2 */ |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 301 | #else |
| 302 | sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK; |
| 303 | #endif |
| 304 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 305 | |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 306 | #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 307 | |
| 308 | for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { |
York Sun | aa150bb | 2013-03-25 07:40:07 +0000 | [diff] [blame] | 309 | u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27) |
| 310 | & 0xf; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 311 | u32 cplx_pll = core_cplx_PLL[c_pll_sel]; |
| 312 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 313 | sys_info->freq_processor[cpu] = |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 314 | freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 315 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 316 | #define PME_CLK_SEL 0x80000000 |
| 317 | #define FM1_CLK_SEL 0x40000000 |
| 318 | #define FM2_CLK_SEL 0x20000000 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 319 | #define HWA_ASYNC_DIV 0x04000000 |
| 320 | #if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2) |
| 321 | #define HWA_CC_PLL 1 |
Timur Tabi | d5e1388 | 2012-10-05 11:09:19 +0000 | [diff] [blame] | 322 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3) |
| 323 | #define HWA_CC_PLL 2 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 324 | #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4) |
Wolfgang Denk | 80f7021 | 2011-05-19 22:21:41 +0200 | [diff] [blame] | 325 | #define HWA_CC_PLL 2 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 326 | #else |
| 327 | #error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case |
| 328 | #endif |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 329 | rcw_tmp = in_be32(&gur->rcwsr[7]); |
| 330 | |
| 331 | #ifdef CONFIG_SYS_DPAA_PME |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 332 | if (rcw_tmp & PME_CLK_SEL) { |
| 333 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 334 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 335 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 336 | sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 337 | } else { |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 338 | sys_info->freq_pme = sys_info->freq_systembus / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 339 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 340 | #endif |
| 341 | |
| 342 | #ifdef CONFIG_SYS_DPAA_FMAN |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 343 | if (rcw_tmp & FM1_CLK_SEL) { |
| 344 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 345 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 346 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 347 | sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 348 | } else { |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 349 | sys_info->freq_fman[0] = sys_info->freq_systembus / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 350 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 351 | #if (CONFIG_SYS_NUM_FMAN) == 2 |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 352 | if (rcw_tmp & FM2_CLK_SEL) { |
| 353 | if (rcw_tmp & HWA_ASYNC_DIV) |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 354 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 355 | else |
Prabhakar Kushwaha | 7e8382f | 2013-09-03 11:20:15 +0530 | [diff] [blame] | 356 | sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 357 | } else { |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 358 | sys_info->freq_fman[1] = sys_info->freq_systembus / 2; |
Kumar Gala | 3842bb5 | 2011-02-16 02:03:29 -0600 | [diff] [blame] | 359 | } |
Kumar Gala | dccd9e3 | 2009-03-19 02:46:19 -0500 | [diff] [blame] | 360 | #endif |
| 361 | #endif |
| 362 | |
Shaohui Xie | 835c9ad | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 363 | #ifdef CONFIG_SYS_DPAA_QBMAN |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 364 | sys_info->freq_qman = sys_info->freq_systembus / 2; |
Shaohui Xie | 835c9ad | 2013-03-25 07:33:25 +0000 | [diff] [blame] | 365 | #endif |
| 366 | |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 367 | #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ |
| 368 | |
Zhao Qiang | b818ba2 | 2014-03-21 16:21:45 +0800 | [diff] [blame] | 369 | #ifdef CONFIG_U_QE |
| 370 | sys_info->freq_qe = sys_info->freq_systembus / 2; |
| 371 | #endif |
| 372 | |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 373 | #else /* CONFIG_FSL_CORENET */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 374 | uint plat_ratio, e500_ratio, half_freq_systembus; |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 375 | int i; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 376 | #ifdef CONFIG_QE |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 377 | __maybe_unused u32 qe_ratio; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 378 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 379 | |
| 380 | plat_ratio = (gur->porpllsr) & 0x0000003e; |
| 381 | plat_ratio >>= 1; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 382 | sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ; |
Andy Fleming | 6d97276 | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 383 | |
| 384 | /* Divide before multiply to avoid integer |
| 385 | * overflow for processor speeds above 2GHz */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 386 | half_freq_systembus = sys_info->freq_systembus/2; |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 387 | for (i = 0; i < cpu_numcores(); i++) { |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 388 | e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 389 | sys_info->freq_processor[i] = e500_ratio * half_freq_systembus; |
Haiying Wang | bb8aea7 | 2009-01-15 11:58:35 -0500 | [diff] [blame] | 390 | } |
James Yang | d1d51ad | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 391 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 392 | /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */ |
| 393 | sys_info->freq_ddrbus = sys_info->freq_systembus; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 394 | |
| 395 | #ifdef CONFIG_DDR_CLK_FREQ |
| 396 | { |
Jason Jin | bfcd6c3 | 2008-09-27 14:40:57 +0800 | [diff] [blame] | 397 | u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) |
| 398 | >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 399 | if (ddr_ratio != 0x7) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 400 | sys_info->freq_ddrbus = ddr_ratio * CONFIG_DDR_CLK_FREQ; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 401 | } |
| 402 | #endif |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 403 | |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 404 | #ifdef CONFIG_QE |
York Sun | 6bf020a | 2012-08-10 11:07:26 +0000 | [diff] [blame] | 405 | #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 406 | sys_info->freq_qe = sys_info->freq_systembus; |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 407 | #else |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 408 | qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO) |
| 409 | >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT; |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 410 | sys_info->freq_qe = qe_ratio * CONFIG_SYS_CLK_FREQ; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 411 | #endif |
Haiying Wang | 8cb2af7 | 2011-02-11 01:25:30 -0600 | [diff] [blame] | 412 | #endif |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 413 | |
| 414 | #ifdef CONFIG_SYS_DPAA_FMAN |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 415 | sys_info->freq_fman[0] = sys_info->freq_systembus; |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 416 | #endif |
| 417 | |
| 418 | #endif /* CONFIG_FSL_CORENET */ |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 419 | |
Dipen Dudhat | 5d51bf9 | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 420 | #if defined(CONFIG_FSL_LBC) |
York Sun | d7778f7 | 2012-10-08 07:44:11 +0000 | [diff] [blame] | 421 | uint lcrr_div; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 422 | #if defined(CONFIG_SYS_LBC_LCRR) |
| 423 | /* We will program LCRR to this value later */ |
| 424 | lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV; |
| 425 | #else |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 426 | lcrr_div = in_be32(&(LBC_BASE_ADDR)->lcrr) & LCRR_CLKDIV; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 427 | #endif |
| 428 | if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) { |
Dave Liu | d8cb9e4 | 2009-11-17 20:49:05 +0800 | [diff] [blame] | 429 | #if defined(CONFIG_FSL_CORENET) |
| 430 | /* If this is corenet based SoC, bit-representation |
| 431 | * for four times the clock divider values. |
| 432 | */ |
| 433 | lcrr_div *= 4; |
| 434 | #elif !defined(CONFIG_MPC8540) && !defined(CONFIG_MPC8541) && \ |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 435 | !defined(CONFIG_MPC8555) && !defined(CONFIG_MPC8560) |
| 436 | /* |
| 437 | * Yes, the entire PQ38 family use the same |
| 438 | * bit-representation for twice the clock divider values. |
| 439 | */ |
| 440 | lcrr_div *= 2; |
| 441 | #endif |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 442 | sys_info->freq_localbus = sys_info->freq_systembus / lcrr_div; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 443 | } else { |
| 444 | /* In case anyone cares what the unknown value is */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 445 | sys_info->freq_localbus = lcrr_div; |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 446 | } |
Dipen Dudhat | 5d51bf9 | 2011-01-19 12:46:27 +0530 | [diff] [blame] | 447 | #endif |
Kumar Gala | 17ec6fa | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 448 | |
| 449 | #if defined(CONFIG_FSL_IFC) |
Prabhakar Kushwaha | f3e12ed | 2014-09-23 10:57:12 +0530 | [diff] [blame] | 450 | ccr = ifc_in32(&ifc_regs->ifc_ccr); |
Kumar Gala | 17ec6fa | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 451 | ccr = ((ccr & IFC_CCR_CLK_DIV_MASK) >> IFC_CCR_CLK_DIV_SHIFT) + 1; |
| 452 | |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 453 | sys_info->freq_localbus = sys_info->freq_systembus / ccr; |
Kumar Gala | 17ec6fa | 2012-10-08 07:44:06 +0000 | [diff] [blame] | 454 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 455 | } |
| 456 | |
Andy Fleming | 6d97276 | 2007-04-23 02:37:47 -0500 | [diff] [blame] | 457 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 458 | int get_clocks (void) |
| 459 | { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 460 | sys_info_t sys_info; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 461 | #ifdef CONFIG_MPC8544 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 462 | volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 463 | #endif |
Jon Loeliger | f5ad378 | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 464 | #if defined(CONFIG_CPM2) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 465 | volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 466 | uint sccr, dfbrg; |
| 467 | |
| 468 | /* set VCO = 4 * BRG */ |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 469 | cpm->im_cpm_intctl.sccr &= 0xfffffffc; |
| 470 | sccr = cpm->im_cpm_intctl.sccr; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 471 | dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT; |
| 472 | #endif |
| 473 | get_sys_info (&sys_info); |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 474 | gd->cpu_clk = sys_info.freq_processor[0]; |
| 475 | gd->bus_clk = sys_info.freq_systembus; |
| 476 | gd->mem_clk = sys_info.freq_ddrbus; |
| 477 | gd->arch.lbc_clk = sys_info.freq_localbus; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 478 | |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 479 | #ifdef CONFIG_QE |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 480 | gd->arch.qe_clk = sys_info.freq_qe; |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 481 | gd->arch.brg_clk = gd->arch.qe_clk / 2; |
Haiying Wang | 6141468 | 2009-05-20 12:30:29 -0400 | [diff] [blame] | 482 | #endif |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 483 | /* |
| 484 | * The base clock for I2C depends on the actual SOC. Unfortunately, |
| 485 | * there is no pattern that can be used to determine the frequency, so |
| 486 | * the only choice is to look up the actual SOC number and use the value |
| 487 | * for that SOC. This information is taken from application note |
| 488 | * AN2919. |
| 489 | */ |
| 490 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ |
Tang Yuantian | a2f7262 | 2013-09-06 10:45:40 +0800 | [diff] [blame] | 491 | defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555) || \ |
| 492 | defined(CONFIG_P1022) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 493 | gd->arch.i2c1_clk = sys_info.freq_systembus; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 494 | #elif defined(CONFIG_MPC8544) |
| 495 | /* |
| 496 | * On the 8544, the I2C clock is the same as the SEC clock. This can be |
| 497 | * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See |
| 498 | * 4.4.3.3 of the 8544 RM. Note that this might actually work for all |
| 499 | * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the |
| 500 | * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544. |
| 501 | */ |
| 502 | if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 503 | gd->arch.i2c1_clk = sys_info.freq_systembus / 3; |
Kumar Gala | 9632f66 | 2008-10-16 21:58:49 -0500 | [diff] [blame] | 504 | else |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 505 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 506 | #else |
| 507 | /* Most 85xx SOCs use CCB/2, so this is the default behavior. */ |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 508 | gd->arch.i2c1_clk = sys_info.freq_systembus / 2; |
Timur Tabi | 44befe0 | 2008-04-04 11:15:58 -0500 | [diff] [blame] | 509 | #endif |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 510 | gd->arch.i2c2_clk = gd->arch.i2c1_clk; |
Timur Tabi | c1499f48 | 2008-01-09 14:35:26 -0600 | [diff] [blame] | 511 | |
Dipen Dudhat | 9af188d | 2009-09-01 17:27:00 +0530 | [diff] [blame] | 512 | #if defined(CONFIG_FSL_ESDHC) |
Priyanka Jain | ce0397b | 2011-02-08 15:45:25 +0530 | [diff] [blame] | 513 | #if defined(CONFIG_MPC8569) || defined(CONFIG_P1010) ||\ |
| 514 | defined(CONFIG_P1014) |
Simon Glass | 9e247d1 | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 515 | gd->arch.sdhc_clk = gd->bus_clk; |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 516 | #else |
Simon Glass | 9e247d1 | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 517 | gd->arch.sdhc_clk = gd->bus_clk / 2; |
Kumar Gala | cd77728 | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 518 | #endif |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 519 | #endif /* defined(CONFIG_FSL_ESDHC) */ |
Kumar Gala | cd77728 | 2008-08-12 11:14:19 -0500 | [diff] [blame] | 520 | |
Jon Loeliger | f5ad378 | 2005-07-23 10:37:35 -0500 | [diff] [blame] | 521 | #if defined(CONFIG_CPM2) |
Prabhakar Kushwaha | d169808 | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 522 | gd->arch.vco_out = 2*sys_info.freq_systembus; |
Simon Glass | 44ea851 | 2012-12-13 20:48:46 +0000 | [diff] [blame] | 523 | gd->arch.cpm_clk = gd->arch.vco_out / 2; |
| 524 | gd->arch.scc_clk = gd->arch.vco_out / 4; |
| 525 | gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1))); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 526 | #endif |
| 527 | |
| 528 | if(gd->cpu_clk != 0) return (0); |
| 529 | else return (1); |
| 530 | } |
| 531 | |
| 532 | |
| 533 | /******************************************** |
| 534 | * get_bus_freq |
| 535 | * return system bus freq in Hz |
| 536 | *********************************************/ |
| 537 | ulong get_bus_freq (ulong dummy) |
| 538 | { |
James Yang | d1d51ad | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 539 | return gd->bus_clk; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 540 | } |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 541 | |
| 542 | /******************************************** |
| 543 | * get_ddr_freq |
| 544 | * return ddr bus freq in Hz |
| 545 | *********************************************/ |
| 546 | ulong get_ddr_freq (ulong dummy) |
| 547 | { |
James Yang | d1d51ad | 2008-02-08 18:05:08 -0600 | [diff] [blame] | 548 | return gd->mem_clk; |
Kumar Gala | 07db170 | 2007-12-07 04:59:26 -0600 | [diff] [blame] | 549 | } |