Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 2 | /* |
| 3 | * |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 4 | * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 5 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/processor.h> |
| 10 | |
| 11 | #include <asm/immap.h> |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 12 | #include <asm/io.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | /* |
| 17 | * Low Power Divider specifications |
| 18 | */ |
| 19 | #define CLOCK_LPD_MIN (1 << 0) /* Divider (decoded) */ |
| 20 | #define CLOCK_LPD_MAX (1 << 15) /* Divider (decoded) */ |
| 21 | |
| 22 | #define CLOCK_PLL_FVCO_MAX 540000000 |
| 23 | #define CLOCK_PLL_FVCO_MIN 300000000 |
| 24 | |
| 25 | #define CLOCK_PLL_FSYS_MAX 266666666 |
| 26 | #define CLOCK_PLL_FSYS_MIN 100000000 |
| 27 | #define MHZ 1000000 |
| 28 | |
| 29 | void clock_enter_limp(int lpdiv) |
| 30 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 31 | ccm_t *ccm = (ccm_t *)MMAP_CCM; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 32 | int i, j; |
| 33 | |
| 34 | /* Check bounds of divider */ |
| 35 | if (lpdiv < CLOCK_LPD_MIN) |
| 36 | lpdiv = CLOCK_LPD_MIN; |
| 37 | if (lpdiv > CLOCK_LPD_MAX) |
| 38 | lpdiv = CLOCK_LPD_MAX; |
| 39 | |
| 40 | /* Round divider down to nearest power of two */ |
| 41 | for (i = 0, j = lpdiv; j != 1; j >>= 1, i++) ; |
| 42 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 43 | #ifdef CONFIG_MCF5445x |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 44 | /* Apply the divider to the system clock */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 45 | clrsetbits_be16(&ccm->cdr, 0x0f00, CCM_CDR_LPDIV(i)); |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 46 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 47 | |
| 48 | /* Enable Limp Mode */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 49 | setbits_be16(&ccm->misccr, CCM_MISCCR_LIMP); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | /* |
| 53 | * brief Exit Limp mode |
| 54 | * warning The PLL should be set and locked prior to exiting Limp mode |
| 55 | */ |
| 56 | void clock_exit_limp(void) |
| 57 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 58 | ccm_t *ccm = (ccm_t *)MMAP_CCM; |
| 59 | pll_t *pll = (pll_t *)MMAP_PLL; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 60 | |
| 61 | /* Exit Limp mode */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 62 | clrbits_be16(&ccm->misccr, CCM_MISCCR_LIMP); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 63 | |
| 64 | /* Wait for the PLL to lock */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 65 | while (!(in_be32(&pll->psr) & PLL_PSR_LOCK)) |
| 66 | ; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 69 | #ifdef CONFIG_MCF5441x |
| 70 | void setup_5441x_clocks(void) |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 71 | { |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 72 | ccm_t *ccm = (ccm_t *)MMAP_CCM; |
| 73 | pll_t *pll = (pll_t *)MMAP_PLL; |
| 74 | int temp, vco = 0, bootmod_ccr, pdr; |
| 75 | |
| 76 | bootmod_ccr = (in_be16(&ccm->ccr) & CCM_CCR_BOOTMOD) >> 14; |
| 77 | |
| 78 | switch (bootmod_ccr) { |
| 79 | case 0: |
| 80 | out_be32(&pll->pcr, 0x00000013); |
| 81 | out_be32(&pll->pdr, 0x00e70c61); |
| 82 | clock_exit_limp(); |
| 83 | break; |
| 84 | case 2: |
| 85 | break; |
| 86 | case 3: |
| 87 | break; |
| 88 | } |
| 89 | |
| 90 | /*Change frequency for Modelo SER1 USB host*/ |
| 91 | #ifdef CONFIG_LOW_MCFCLK |
| 92 | temp = in_be32(&pll->pcr); |
| 93 | temp &= ~0x3f; |
| 94 | temp |= 5; |
| 95 | out_be32(&pll->pcr, temp); |
| 96 | |
| 97 | temp = in_be32(&pll->pdr); |
| 98 | temp &= ~0x001f0000; |
| 99 | temp |= 0x00040000; |
| 100 | out_be32(&pll->pdr, temp); |
| 101 | __asm__("tpf"); |
| 102 | #endif |
| 103 | |
| 104 | setbits_be16(&ccm->misccr2, 0x02); |
| 105 | |
| 106 | vco = ((in_be32(&pll->pcr) & PLL_CR_FBKDIV_BITS) + 1) * |
| 107 | CONFIG_SYS_INPUT_CLKSRC; |
Jason Jin | 2ecfc78 | 2013-06-26 10:21:31 +0800 | [diff] [blame] | 108 | gd->arch.vco_clk = vco; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 109 | |
Jason Jin | 2ecfc78 | 2013-06-26 10:21:31 +0800 | [diff] [blame] | 110 | gd->arch.inp_clk = CONFIG_SYS_INPUT_CLKSRC; /* Input clock */ |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 111 | |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 112 | pdr = in_be32(&pll->pdr); |
| 113 | temp = (pdr & PLL_DR_OUTDIV1_BITS) + 1; |
| 114 | gd->cpu_clk = vco / temp; /* cpu clock */ |
Jason Jin | 2ecfc78 | 2013-06-26 10:21:31 +0800 | [diff] [blame] | 115 | gd->arch.flb_clk = vco / temp; /* FlexBus clock */ |
| 116 | gd->arch.flb_clk >>= 1; |
Vasili Galka | 24f413b | 2014-06-30 12:59:06 +0300 | [diff] [blame] | 117 | if (in_be16(&ccm->misccr2) & 2) /* fsys/4 */ |
Jason Jin | 2ecfc78 | 2013-06-26 10:21:31 +0800 | [diff] [blame] | 118 | gd->arch.flb_clk >>= 1; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 119 | |
| 120 | temp = ((pdr & PLL_DR_OUTDIV2_BITS) >> 5) + 1; |
| 121 | gd->bus_clk = vco / temp; /* bus clock */ |
| 122 | |
Angelo Dureghello | 95a6998 | 2018-01-25 22:42:52 +0100 | [diff] [blame] | 123 | temp = ((pdr & PLL_DR_OUTDIV3_BITS) >> 10) + 1; |
| 124 | gd->arch.sdhc_clk = vco / temp; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 125 | } |
| 126 | #endif |
| 127 | |
| 128 | #ifdef CONFIG_MCF5445x |
| 129 | void setup_5445x_clocks(void) |
| 130 | { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 131 | ccm_t *ccm = (ccm_t *)MMAP_CCM; |
| 132 | pll_t *pll = (pll_t *)MMAP_PLL; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 133 | int pllmult_nopci[] = { 20, 10, 24, 18, 12, 6, 16, 8 }; |
| 134 | int pllmult_pci[] = { 12, 6, 16, 8 }; |
Marek Vasut | e946a88 | 2012-10-03 13:28:45 +0000 | [diff] [blame] | 135 | int vco = 0, temp, fbtemp, pcrvalue; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 136 | int *pPllmult = NULL; |
| 137 | u16 fbpll_mask; |
Marek Vasut | e946a88 | 2012-10-03 13:28:45 +0000 | [diff] [blame] | 138 | #ifdef CONFIG_PCI |
| 139 | int bPci; |
| 140 | #endif |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 141 | |
| 142 | #ifdef CONFIG_M54455EVB |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 143 | u8 *cpld = (u8 *)(CONFIG_SYS_CS2_BASE + 3); |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 144 | #endif |
| 145 | u8 bootmode; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 146 | |
| 147 | /* To determine PCI is present or not */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 148 | if (((in_be16(&ccm->ccr) & CCM_CCR_360_FBCONFIG_MASK) == 0x00e0) || |
| 149 | ((in_be16(&ccm->ccr) & CCM_CCR_360_FBCONFIG_MASK) == 0x0060)) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 150 | pPllmult = &pllmult_pci[0]; |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 151 | fbpll_mask = 3; /* 11b */ |
Marek Vasut | e946a88 | 2012-10-03 13:28:45 +0000 | [diff] [blame] | 152 | #ifdef CONFIG_PCI |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 153 | bPci = 1; |
Marek Vasut | e946a88 | 2012-10-03 13:28:45 +0000 | [diff] [blame] | 154 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 155 | } else { |
| 156 | pPllmult = &pllmult_nopci[0]; |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 157 | fbpll_mask = 7; /* 111b */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 158 | #ifdef CONFIG_PCI |
| 159 | gd->pci_clk = 0; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 160 | bPci = 0; |
Marek Vasut | e946a88 | 2012-10-03 13:28:45 +0000 | [diff] [blame] | 161 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | #ifdef CONFIG_M54455EVB |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 165 | bootmode = (in_8(cpld) & 0x03); |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 166 | |
| 167 | if (bootmode != 3) { |
| 168 | /* Temporary read from CCR- fixed fb issue, must be the same clock |
| 169 | as pci or input clock, causing cpld/fpga read inconsistancy */ |
| 170 | fbtemp = pPllmult[ccm->ccr & fbpll_mask]; |
| 171 | |
| 172 | /* Break down into small pieces, code still in flex bus */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 173 | pcrvalue = in_be32(&pll->pcr) & 0xFFFFF0FF; |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 174 | temp = fbtemp - 1; |
| 175 | pcrvalue |= PLL_PCR_OUTDIV3(temp); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 176 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 177 | out_be32(&pll->pcr, pcrvalue); |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 178 | } |
| 179 | #endif |
| 180 | #ifdef CONFIG_M54451EVB |
| 181 | /* No external logic to read the bootmode, hard coded from built */ |
| 182 | #ifdef CONFIG_CF_SBF |
| 183 | bootmode = 3; |
| 184 | #else |
| 185 | bootmode = 2; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 186 | |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 187 | /* default value is 16 mul, set to 20 mul */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 188 | pcrvalue = (in_be32(&pll->pcr) & 0x00FFFFFF) | 0x14000000; |
| 189 | out_be32(&pll->pcr, pcrvalue); |
| 190 | while ((in_be32(&pll->psr) & PLL_PSR_LOCK) != PLL_PSR_LOCK) |
| 191 | ; |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 192 | #endif |
| 193 | #endif |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 194 | |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 195 | if (bootmode == 0) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 196 | /* RCON mode */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 197 | vco = pPllmult[ccm->rcon & fbpll_mask] * CONFIG_SYS_INPUT_CLKSRC; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 198 | |
| 199 | if ((vco < CLOCK_PLL_FVCO_MIN) || (vco > CLOCK_PLL_FVCO_MAX)) { |
| 200 | /* invaild range, re-set in PCR */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 201 | int temp = ((in_be32(&pll->pcr) & PLL_PCR_OUTDIV2_MASK) >> 4) + 1; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 202 | int i, j, bus; |
| 203 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 204 | j = (in_be32(&pll->pcr) & 0xFF000000) >> 24; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 205 | for (i = j; i < 0xFF; i++) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 206 | vco = i * CONFIG_SYS_INPUT_CLKSRC; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 207 | if (vco >= CLOCK_PLL_FVCO_MIN) { |
| 208 | bus = vco / temp; |
| 209 | if (bus <= CLOCK_PLL_FSYS_MIN - MHZ) |
| 210 | continue; |
| 211 | else |
| 212 | break; |
| 213 | } |
| 214 | } |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 215 | pcrvalue = in_be32(&pll->pcr) & 0x00FF00FF; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 216 | fbtemp = ((i - 1) << 8) | ((i - 1) << 12); |
| 217 | pcrvalue |= ((i << 24) | fbtemp); |
| 218 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 219 | out_be32(&pll->pcr, pcrvalue); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 220 | } |
Simon Glass | 568a7b6 | 2012-12-13 20:49:07 +0000 | [diff] [blame] | 221 | gd->arch.vco_clk = vco; /* Vco clock */ |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 222 | } else if (bootmode == 2) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 223 | /* Normal mode */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 224 | vco = ((in_be32(&pll->pcr) & 0xFF000000) >> 24) * CONFIG_SYS_INPUT_CLKSRC; |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 225 | if ((vco < CLOCK_PLL_FVCO_MIN) || (vco > CLOCK_PLL_FVCO_MAX)) { |
| 226 | /* Default value */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 227 | pcrvalue = (in_be32(&pll->pcr) & 0x00FFFFFF); |
| 228 | pcrvalue |= pPllmult[in_be16(&ccm->ccr) & fbpll_mask] << 24; |
| 229 | out_be32(&pll->pcr, pcrvalue); |
| 230 | vco = ((in_be32(&pll->pcr) & 0xFF000000) >> 24) * CONFIG_SYS_INPUT_CLKSRC; |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 231 | } |
Simon Glass | 568a7b6 | 2012-12-13 20:49:07 +0000 | [diff] [blame] | 232 | gd->arch.vco_clk = vco; /* Vco clock */ |
TsiChung Liew | 23cf8fd | 2008-07-23 20:38:53 -0500 | [diff] [blame] | 233 | } else if (bootmode == 3) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 234 | /* serial mode */ |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 235 | vco = ((in_be32(&pll->pcr) & 0xFF000000) >> 24) * CONFIG_SYS_INPUT_CLKSRC; |
Simon Glass | 568a7b6 | 2012-12-13 20:49:07 +0000 | [diff] [blame] | 236 | gd->arch.vco_clk = vco; /* Vco clock */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 237 | } |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 238 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 239 | if ((in_be16(&ccm->ccr) & CCM_MISCCR_LIMP) == CCM_MISCCR_LIMP) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 240 | /* Limp mode */ |
| 241 | } else { |
Simon Glass | 568a7b6 | 2012-12-13 20:49:07 +0000 | [diff] [blame] | 242 | gd->arch.inp_clk = CONFIG_SYS_INPUT_CLKSRC; /* Input clock */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 243 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 244 | temp = (in_be32(&pll->pcr) & PLL_PCR_OUTDIV1_MASK) + 1; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 245 | gd->cpu_clk = vco / temp; /* cpu clock */ |
| 246 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 247 | temp = ((in_be32(&pll->pcr) & PLL_PCR_OUTDIV2_MASK) >> 4) + 1; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 248 | gd->bus_clk = vco / temp; /* bus clock */ |
| 249 | |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 250 | temp = ((in_be32(&pll->pcr) & PLL_PCR_OUTDIV3_MASK) >> 8) + 1; |
Simon Glass | 568a7b6 | 2012-12-13 20:49:07 +0000 | [diff] [blame] | 251 | gd->arch.flb_clk = vco / temp; /* FlexBus clock */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 252 | |
| 253 | #ifdef CONFIG_PCI |
| 254 | if (bPci) { |
Alison Wang | 8d8dac9 | 2012-03-26 21:49:08 +0000 | [diff] [blame] | 255 | temp = ((in_be32(&pll->pcr) & PLL_PCR_OUTDIV4_MASK) >> 12) + 1; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 256 | gd->pci_clk = vco / temp; /* PCI clock */ |
| 257 | } |
| 258 | #endif |
| 259 | } |
| 260 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 261 | #ifdef CONFIG_SYS_I2C_FSL |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 262 | gd->arch.i2c1_clk = gd->bus_clk; |
TsiChung Liew | 0c1e325 | 2008-08-19 03:01:19 +0600 | [diff] [blame] | 263 | #endif |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 264 | } |
| 265 | #endif |
| 266 | |
| 267 | /* get_clocks() fills in gd->cpu_clock and gd->bus_clk */ |
| 268 | int get_clocks(void) |
| 269 | { |
| 270 | #ifdef CONFIG_MCF5441x |
| 271 | setup_5441x_clocks(); |
| 272 | #endif |
| 273 | #ifdef CONFIG_MCF5445x |
| 274 | setup_5445x_clocks(); |
| 275 | #endif |
| 276 | |
Heiko Schocher | f285074 | 2012-10-24 13:48:22 +0200 | [diff] [blame] | 277 | #ifdef CONFIG_SYS_FSL_I2C |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 278 | gd->arch.i2c1_clk = gd->bus_clk; |
Alison Wang | fdc2fb1 | 2012-10-18 19:25:51 +0000 | [diff] [blame] | 279 | #endif |
TsiChung Liew | 0c1e325 | 2008-08-19 03:01:19 +0600 | [diff] [blame] | 280 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 281 | return (0); |
| 282 | } |