Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2000-2002 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 6 | * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
Mario Six | 7cab147 | 2018-08-06 10:23:36 +0200 | [diff] [blame] | 9 | #ifndef CONFIG_CLK_MPC83XX |
| 10 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 11 | #include <common.h> |
Simon Glass | 85d6531 | 2019-12-28 10:44:58 -0700 | [diff] [blame^] | 12 | #include <clock_legacy.h> |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 13 | #include <mpc83xx.h> |
Kim Phillips | d82b077 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 14 | #include <command.h> |
Simon Glass | f5c208d | 2019-11-14 12:57:20 -0700 | [diff] [blame] | 15 | #include <vsprintf.h> |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 16 | #include <asm/processor.h> |
| 17 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 20 | /* ----------------------------------------------------------------- */ |
| 21 | |
| 22 | typedef enum { |
| 23 | _unk, |
| 24 | _off, |
| 25 | _byp, |
| 26 | _x8, |
| 27 | _x4, |
| 28 | _x2, |
| 29 | _x1, |
| 30 | _1x, |
| 31 | _1_5x, |
| 32 | _2x, |
| 33 | _2_5x, |
| 34 | _3x |
| 35 | } mult_t; |
| 36 | |
| 37 | typedef struct { |
| 38 | mult_t core_csb_ratio; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 39 | mult_t vco_divider; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 40 | } corecnf_t; |
| 41 | |
Kim Phillips | b5c312a | 2012-10-29 13:34:39 +0000 | [diff] [blame] | 42 | static corecnf_t corecnf_tab[] = { |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 43 | {_byp, _byp}, /* 0x00 */ |
| 44 | {_byp, _byp}, /* 0x01 */ |
| 45 | {_byp, _byp}, /* 0x02 */ |
| 46 | {_byp, _byp}, /* 0x03 */ |
| 47 | {_byp, _byp}, /* 0x04 */ |
| 48 | {_byp, _byp}, /* 0x05 */ |
| 49 | {_byp, _byp}, /* 0x06 */ |
| 50 | {_byp, _byp}, /* 0x07 */ |
| 51 | {_1x, _x2}, /* 0x08 */ |
| 52 | {_1x, _x4}, /* 0x09 */ |
| 53 | {_1x, _x8}, /* 0x0A */ |
| 54 | {_1x, _x8}, /* 0x0B */ |
| 55 | {_1_5x, _x2}, /* 0x0C */ |
| 56 | {_1_5x, _x4}, /* 0x0D */ |
| 57 | {_1_5x, _x8}, /* 0x0E */ |
| 58 | {_1_5x, _x8}, /* 0x0F */ |
| 59 | {_2x, _x2}, /* 0x10 */ |
| 60 | {_2x, _x4}, /* 0x11 */ |
| 61 | {_2x, _x8}, /* 0x12 */ |
| 62 | {_2x, _x8}, /* 0x13 */ |
| 63 | {_2_5x, _x2}, /* 0x14 */ |
| 64 | {_2_5x, _x4}, /* 0x15 */ |
| 65 | {_2_5x, _x8}, /* 0x16 */ |
| 66 | {_2_5x, _x8}, /* 0x17 */ |
| 67 | {_3x, _x2}, /* 0x18 */ |
| 68 | {_3x, _x4}, /* 0x19 */ |
| 69 | {_3x, _x8}, /* 0x1A */ |
| 70 | {_3x, _x8}, /* 0x1B */ |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /* ----------------------------------------------------------------- */ |
| 74 | |
| 75 | /* |
| 76 | * |
| 77 | */ |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 78 | int get_clocks(void) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 79 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 80 | volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 81 | u32 pci_sync_in; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 82 | u8 spmf; |
| 83 | u8 clkin_div; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 84 | u32 sccr; |
| 85 | u32 corecnf_tab_index; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 86 | u8 corepll; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 87 | u32 lcrr; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 88 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 89 | u32 csb_clk; |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 90 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 91 | defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC837X) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 92 | u32 tsec1_clk; |
| 93 | u32 tsec2_clk; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 94 | u32 usbdr_clk; |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 95 | #elif defined(CONFIG_ARCH_MPC8309) |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 96 | u32 usbdr_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 97 | #endif |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 98 | #ifdef CONFIG_ARCH_MPC834X |
Scott Wood | c036fc9 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 99 | u32 usbmph_clk; |
| 100 | #endif |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 101 | u32 core_clk; |
| 102 | u32 i2c1_clk; |
Mario Six | be07e55 | 2019-01-21 09:17:26 +0100 | [diff] [blame] | 103 | #if !defined(CONFIG_ARCH_MPC832X) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 104 | u32 i2c2_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 105 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 106 | #if defined(CONFIG_ARCH_MPC8315) |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 107 | u32 tdm_clk; |
| 108 | #endif |
Rini van Zetten | a249617 | 2010-04-15 16:03:05 +0200 | [diff] [blame] | 109 | #if defined(CONFIG_FSL_ESDHC) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 110 | u32 sdhc_clk; |
| 111 | #endif |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 112 | #if !defined(CONFIG_ARCH_MPC8309) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 113 | u32 enc_clk; |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 114 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 115 | u32 lbiu_clk; |
| 116 | u32 lclk_clk; |
Kim Phillips | c02cf1e | 2008-03-28 10:18:40 -0500 | [diff] [blame] | 117 | u32 mem_clk; |
Mario Six | 84eb431 | 2019-01-21 09:17:28 +0100 | [diff] [blame] | 118 | #if defined(CONFIG_ARCH_MPC8360) |
Kim Phillips | c02cf1e | 2008-03-28 10:18:40 -0500 | [diff] [blame] | 119 | u32 mem_sec_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 120 | #endif |
Gerlando Falauto | 77cf283 | 2012-10-10 22:13:06 +0000 | [diff] [blame] | 121 | #if defined(CONFIG_QE) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 122 | u32 qepmf; |
| 123 | u32 qepdf; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 124 | u32 qe_clk; |
| 125 | u32 brg_clk; |
| 126 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 127 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 128 | defined(CONFIG_ARCH_MPC837X) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 129 | u32 pciexp1_clk; |
| 130 | u32 pciexp2_clk; |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 131 | #endif |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 132 | #if defined(CONFIG_ARCH_MPC837X) || defined(CONFIG_ARCH_MPC8315) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 133 | u32 sata_clk; |
| 134 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 135 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 136 | if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 137 | return -1; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 138 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 139 | clkin_div = ((im->clk.spmr & SPMR_CKID) >> SPMR_CKID_SHIFT); |
Marian Balakowicz | 513b4a1 | 2005-10-11 19:09:42 +0200 | [diff] [blame] | 140 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 141 | if (im->reset.rcwh & HRCWH_PCI_HOST) { |
Mario Six | d10f318 | 2019-01-21 09:17:53 +0100 | [diff] [blame] | 142 | #if defined(CONFIG_SYS_CLK_FREQ) |
| 143 | pci_sync_in = CONFIG_SYS_CLK_FREQ / (1 + clkin_div); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 144 | #else |
| 145 | pci_sync_in = 0xDEADBEEF; |
| 146 | #endif |
| 147 | } else { |
| 148 | #if defined(CONFIG_83XX_PCICLK) |
| 149 | pci_sync_in = CONFIG_83XX_PCICLK; |
| 150 | #else |
| 151 | pci_sync_in = 0xDEADBEEF; |
| 152 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 153 | } |
Marian Balakowicz | 513b4a1 | 2005-10-11 19:09:42 +0200 | [diff] [blame] | 154 | |
Joakim Tjernlund | f2af1bb | 2011-01-27 16:30:54 +0100 | [diff] [blame] | 155 | spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 156 | csb_clk = pci_sync_in * (1 + clkin_div) * spmf; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 157 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 158 | sccr = im->clk.sccr; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 159 | |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 160 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 161 | defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC837X) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 162 | switch ((sccr & SCCR_TSEC1CM) >> SCCR_TSEC1CM_SHIFT) { |
| 163 | case 0: |
| 164 | tsec1_clk = 0; |
| 165 | break; |
| 166 | case 1: |
| 167 | tsec1_clk = csb_clk; |
| 168 | break; |
| 169 | case 2: |
| 170 | tsec1_clk = csb_clk / 2; |
| 171 | break; |
| 172 | case 3: |
| 173 | tsec1_clk = csb_clk / 3; |
| 174 | break; |
| 175 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 176 | /* unknown SCCR_TSEC1CM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 177 | return -2; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 178 | } |
Gerlando Falauto | 7473555 | 2012-10-10 22:13:07 +0000 | [diff] [blame] | 179 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 180 | |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 181 | #if defined(CONFIG_ARCH_MPC830X) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 182 | defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC837X) |
Scott Wood | c036fc9 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 183 | switch ((sccr & SCCR_USBDRCM) >> SCCR_USBDRCM_SHIFT) { |
| 184 | case 0: |
| 185 | usbdr_clk = 0; |
| 186 | break; |
| 187 | case 1: |
| 188 | usbdr_clk = csb_clk; |
| 189 | break; |
| 190 | case 2: |
| 191 | usbdr_clk = csb_clk / 2; |
| 192 | break; |
| 193 | case 3: |
| 194 | usbdr_clk = csb_clk / 3; |
| 195 | break; |
| 196 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 197 | /* unknown SCCR_USBDRCM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 198 | return -3; |
Scott Wood | c036fc9 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 199 | } |
| 200 | #endif |
| 201 | |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 202 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC8315) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 203 | defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC837X) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 204 | switch ((sccr & SCCR_TSEC2CM) >> SCCR_TSEC2CM_SHIFT) { |
| 205 | case 0: |
| 206 | tsec2_clk = 0; |
| 207 | break; |
| 208 | case 1: |
| 209 | tsec2_clk = csb_clk; |
| 210 | break; |
| 211 | case 2: |
| 212 | tsec2_clk = csb_clk / 2; |
| 213 | break; |
| 214 | case 3: |
| 215 | tsec2_clk = csb_clk / 3; |
| 216 | break; |
| 217 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 218 | /* unknown SCCR_TSEC2CM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 219 | return -4; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 220 | } |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 221 | #elif defined(CONFIG_ARCH_MPC8313) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 222 | tsec2_clk = tsec1_clk; |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 223 | |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 224 | if (!(sccr & SCCR_TSEC1ON)) |
| 225 | tsec1_clk = 0; |
| 226 | if (!(sccr & SCCR_TSEC2ON)) |
| 227 | tsec2_clk = 0; |
| 228 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 229 | |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 230 | #if defined(CONFIG_ARCH_MPC834X) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 231 | switch ((sccr & SCCR_USBMPHCM) >> SCCR_USBMPHCM_SHIFT) { |
| 232 | case 0: |
| 233 | usbmph_clk = 0; |
| 234 | break; |
| 235 | case 1: |
| 236 | usbmph_clk = csb_clk; |
| 237 | break; |
| 238 | case 2: |
| 239 | usbmph_clk = csb_clk / 2; |
| 240 | break; |
| 241 | case 3: |
| 242 | usbmph_clk = csb_clk / 3; |
| 243 | break; |
| 244 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 245 | /* unknown SCCR_USBMPHCM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 246 | return -5; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 247 | } |
| 248 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 249 | if (usbmph_clk != 0 && usbdr_clk != 0 && usbmph_clk != usbdr_clk) { |
| 250 | /* if USB MPH clock is not disabled and |
| 251 | * USB DR clock is not disabled then |
| 252 | * USB MPH & USB DR must have the same rate |
| 253 | */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 254 | return -6; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 255 | } |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 256 | #endif |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 257 | #if !defined(CONFIG_ARCH_MPC8309) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 258 | switch ((sccr & SCCR_ENCCM) >> SCCR_ENCCM_SHIFT) { |
| 259 | case 0: |
| 260 | enc_clk = 0; |
| 261 | break; |
| 262 | case 1: |
| 263 | enc_clk = csb_clk; |
| 264 | break; |
| 265 | case 2: |
| 266 | enc_clk = csb_clk / 2; |
| 267 | break; |
| 268 | case 3: |
| 269 | enc_clk = csb_clk / 3; |
| 270 | break; |
| 271 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 272 | /* unknown SCCR_ENCCM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 273 | return -7; |
| 274 | } |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 275 | #endif |
Scott Wood | c036fc9 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 276 | |
Rini van Zetten | a249617 | 2010-04-15 16:03:05 +0200 | [diff] [blame] | 277 | #if defined(CONFIG_FSL_ESDHC) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 278 | switch ((sccr & SCCR_SDHCCM) >> SCCR_SDHCCM_SHIFT) { |
| 279 | case 0: |
| 280 | sdhc_clk = 0; |
| 281 | break; |
| 282 | case 1: |
| 283 | sdhc_clk = csb_clk; |
| 284 | break; |
| 285 | case 2: |
| 286 | sdhc_clk = csb_clk / 2; |
| 287 | break; |
| 288 | case 3: |
| 289 | sdhc_clk = csb_clk / 3; |
| 290 | break; |
| 291 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 292 | /* unknown SCCR_SDHCCM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 293 | return -8; |
| 294 | } |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 295 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 296 | #if defined(CONFIG_ARCH_MPC8315) |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 297 | switch ((sccr & SCCR_TDMCM) >> SCCR_TDMCM_SHIFT) { |
| 298 | case 0: |
| 299 | tdm_clk = 0; |
| 300 | break; |
| 301 | case 1: |
| 302 | tdm_clk = csb_clk; |
| 303 | break; |
| 304 | case 2: |
| 305 | tdm_clk = csb_clk / 2; |
| 306 | break; |
| 307 | case 3: |
| 308 | tdm_clk = csb_clk / 3; |
| 309 | break; |
| 310 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 311 | /* unknown SCCR_TDMCM value */ |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 312 | return -8; |
| 313 | } |
| 314 | #endif |
Scott Wood | c036fc9 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 315 | |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 316 | #if defined(CONFIG_ARCH_MPC834X) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 317 | i2c1_clk = tsec2_clk; |
Mario Six | 84eb431 | 2019-01-21 09:17:28 +0100 | [diff] [blame] | 318 | #elif defined(CONFIG_ARCH_MPC8360) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 319 | i2c1_clk = csb_clk; |
Mario Six | be07e55 | 2019-01-21 09:17:26 +0100 | [diff] [blame] | 320 | #elif defined(CONFIG_ARCH_MPC832X) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 321 | i2c1_clk = enc_clk; |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 322 | #elif defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 323 | i2c1_clk = enc_clk; |
Rini van Zetten | a249617 | 2010-04-15 16:03:05 +0200 | [diff] [blame] | 324 | #elif defined(CONFIG_FSL_ESDHC) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 325 | i2c1_clk = sdhc_clk; |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 326 | #elif defined(CONFIG_ARCH_MPC837X) |
Andre Schwarz | a76cc61 | 2011-04-14 14:57:40 +0200 | [diff] [blame] | 327 | i2c1_clk = enc_clk; |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 328 | #elif defined(CONFIG_ARCH_MPC8309) |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 329 | i2c1_clk = csb_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 330 | #endif |
Mario Six | be07e55 | 2019-01-21 09:17:26 +0100 | [diff] [blame] | 331 | #if !defined(CONFIG_ARCH_MPC832X) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 332 | i2c2_clk = csb_clk; /* i2c-2 clk is equal to csb clk */ |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 333 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 334 | |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 335 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 336 | defined(CONFIG_ARCH_MPC837X) |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 337 | switch ((sccr & SCCR_PCIEXP1CM) >> SCCR_PCIEXP1CM_SHIFT) { |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 338 | case 0: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 339 | pciexp1_clk = 0; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 340 | break; |
| 341 | case 1: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 342 | pciexp1_clk = csb_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 343 | break; |
| 344 | case 2: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 345 | pciexp1_clk = csb_clk / 2; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 346 | break; |
| 347 | case 3: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 348 | pciexp1_clk = csb_clk / 3; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 349 | break; |
| 350 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 351 | /* unknown SCCR_PCIEXP1CM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 352 | return -9; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 353 | } |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 354 | |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 355 | switch ((sccr & SCCR_PCIEXP2CM) >> SCCR_PCIEXP2CM_SHIFT) { |
| 356 | case 0: |
| 357 | pciexp2_clk = 0; |
| 358 | break; |
| 359 | case 1: |
| 360 | pciexp2_clk = csb_clk; |
| 361 | break; |
| 362 | case 2: |
| 363 | pciexp2_clk = csb_clk / 2; |
| 364 | break; |
| 365 | case 3: |
| 366 | pciexp2_clk = csb_clk / 3; |
| 367 | break; |
| 368 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 369 | /* unknown SCCR_PCIEXP2CM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 370 | return -10; |
| 371 | } |
| 372 | #endif |
| 373 | |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 374 | #if defined(CONFIG_ARCH_MPC837X) || defined(CONFIG_ARCH_MPC8315) |
Dave Liu | b7896ad | 2008-01-17 18:23:19 +0800 | [diff] [blame] | 375 | switch ((sccr & SCCR_SATA1CM) >> SCCR_SATA1CM_SHIFT) { |
| 376 | case 0: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 377 | sata_clk = 0; |
| 378 | break; |
Dave Liu | b7896ad | 2008-01-17 18:23:19 +0800 | [diff] [blame] | 379 | case 1: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 380 | sata_clk = csb_clk; |
| 381 | break; |
Dave Liu | b7896ad | 2008-01-17 18:23:19 +0800 | [diff] [blame] | 382 | case 2: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 383 | sata_clk = csb_clk / 2; |
| 384 | break; |
Dave Liu | b7896ad | 2008-01-17 18:23:19 +0800 | [diff] [blame] | 385 | case 3: |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 386 | sata_clk = csb_clk / 3; |
| 387 | break; |
| 388 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 389 | /* unknown SCCR_SATA1CM value */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 390 | return -11; |
| 391 | } |
| 392 | #endif |
| 393 | |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 394 | lbiu_clk = csb_clk * |
Joakim Tjernlund | f2af1bb | 2011-01-27 16:30:54 +0100 | [diff] [blame] | 395 | (1 + ((im->clk.spmr & SPMR_LBIUCM) >> SPMR_LBIUCM_SHIFT)); |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 396 | lcrr = (im->im_lbc.lcrr & LCRR_CLKDIV) >> LCRR_CLKDIV_SHIFT; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 397 | switch (lcrr) { |
| 398 | case 2: |
| 399 | case 4: |
| 400 | case 8: |
| 401 | lclk_clk = lbiu_clk / lcrr; |
| 402 | break; |
| 403 | default: |
| 404 | /* unknown lcrr */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 405 | return -12; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 406 | } |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 407 | |
Kim Phillips | c02cf1e | 2008-03-28 10:18:40 -0500 | [diff] [blame] | 408 | mem_clk = csb_clk * |
Joakim Tjernlund | f2af1bb | 2011-01-27 16:30:54 +0100 | [diff] [blame] | 409 | (1 + ((im->clk.spmr & SPMR_DDRCM) >> SPMR_DDRCM_SHIFT)); |
| 410 | corepll = (im->clk.spmr & SPMR_COREPLL) >> SPMR_COREPLL_SHIFT; |
| 411 | |
Mario Six | 84eb431 | 2019-01-21 09:17:28 +0100 | [diff] [blame] | 412 | #if defined(CONFIG_ARCH_MPC8360) |
Kim Phillips | c02cf1e | 2008-03-28 10:18:40 -0500 | [diff] [blame] | 413 | mem_sec_clk = csb_clk * (1 + |
Joakim Tjernlund | f2af1bb | 2011-01-27 16:30:54 +0100 | [diff] [blame] | 414 | ((im->clk.spmr & SPMR_LBIUCM) >> SPMR_LBIUCM_SHIFT)); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 415 | #endif |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 416 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 417 | corecnf_tab_index = ((corepll & 0x1F) << 2) | ((corepll & 0x60) >> 5); |
Robert P. J. Day | 0c91159 | 2016-05-23 06:49:21 -0400 | [diff] [blame] | 418 | if (corecnf_tab_index > (ARRAY_SIZE(corecnf_tab))) { |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 419 | /* corecnf_tab_index is too high, possibly wrong value */ |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 420 | return -11; |
| 421 | } |
| 422 | switch (corecnf_tab[corecnf_tab_index].core_csb_ratio) { |
| 423 | case _byp: |
| 424 | case _x1: |
| 425 | case _1x: |
| 426 | core_clk = csb_clk; |
| 427 | break; |
| 428 | case _1_5x: |
| 429 | core_clk = (3 * csb_clk) / 2; |
| 430 | break; |
| 431 | case _2x: |
| 432 | core_clk = 2 * csb_clk; |
| 433 | break; |
| 434 | case _2_5x: |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 435 | core_clk = (5 * csb_clk) / 2; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 436 | break; |
| 437 | case _3x: |
| 438 | core_clk = 3 * csb_clk; |
| 439 | break; |
| 440 | default: |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 441 | /* unknown core to csb ratio */ |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 442 | return -13; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 443 | } |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 444 | |
Gerlando Falauto | 77cf283 | 2012-10-10 22:13:06 +0000 | [diff] [blame] | 445 | #if defined(CONFIG_QE) |
Joakim Tjernlund | f2af1bb | 2011-01-27 16:30:54 +0100 | [diff] [blame] | 446 | qepmf = (im->clk.spmr & SPMR_CEPMF) >> SPMR_CEPMF_SHIFT; |
| 447 | qepdf = (im->clk.spmr & SPMR_CEPDF) >> SPMR_CEPDF_SHIFT; |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 448 | qe_clk = (pci_sync_in * qepmf) / (1 + qepdf); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 449 | brg_clk = qe_clk / 2; |
| 450 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 451 | |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 452 | gd->arch.csb_clk = csb_clk; |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 453 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 454 | defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC837X) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 455 | gd->arch.tsec1_clk = tsec1_clk; |
| 456 | gd->arch.tsec2_clk = tsec2_clk; |
| 457 | gd->arch.usbdr_clk = usbdr_clk; |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 458 | #elif defined(CONFIG_ARCH_MPC8309) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 459 | gd->arch.usbdr_clk = usbdr_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 460 | #endif |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 461 | #if defined(CONFIG_ARCH_MPC834X) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 462 | gd->arch.usbmph_clk = usbmph_clk; |
Scott Wood | c036fc9 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 463 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 464 | #if defined(CONFIG_ARCH_MPC8315) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 465 | gd->arch.tdm_clk = tdm_clk; |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 466 | #endif |
Rini van Zetten | a249617 | 2010-04-15 16:03:05 +0200 | [diff] [blame] | 467 | #if defined(CONFIG_FSL_ESDHC) |
Simon Glass | 9e247d1 | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 468 | gd->arch.sdhc_clk = sdhc_clk; |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 469 | #endif |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 470 | gd->arch.core_clk = core_clk; |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 471 | gd->arch.i2c1_clk = i2c1_clk; |
Mario Six | be07e55 | 2019-01-21 09:17:26 +0100 | [diff] [blame] | 472 | #if !defined(CONFIG_ARCH_MPC832X) |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 473 | gd->arch.i2c2_clk = i2c2_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 474 | #endif |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 475 | #if !defined(CONFIG_ARCH_MPC8309) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 476 | gd->arch.enc_clk = enc_clk; |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 477 | #endif |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 478 | gd->arch.lbiu_clk = lbiu_clk; |
| 479 | gd->arch.lclk_clk = lclk_clk; |
Kim Phillips | c02cf1e | 2008-03-28 10:18:40 -0500 | [diff] [blame] | 480 | gd->mem_clk = mem_clk; |
Mario Six | 84eb431 | 2019-01-21 09:17:28 +0100 | [diff] [blame] | 481 | #if defined(CONFIG_ARCH_MPC8360) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 482 | gd->arch.mem_sec_clk = mem_sec_clk; |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 483 | #endif |
Gerlando Falauto | 77cf283 | 2012-10-10 22:13:06 +0000 | [diff] [blame] | 484 | #if defined(CONFIG_QE) |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 485 | gd->arch.qe_clk = qe_clk; |
Simon Glass | 34a194f | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 486 | gd->arch.brg_clk = brg_clk; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 487 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 488 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 489 | defined(CONFIG_ARCH_MPC837X) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 490 | gd->arch.pciexp1_clk = pciexp1_clk; |
| 491 | gd->arch.pciexp2_clk = pciexp2_clk; |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 492 | #endif |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 493 | #if defined(CONFIG_ARCH_MPC837X) || defined(CONFIG_ARCH_MPC8315) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 494 | gd->arch.sata_clk = sata_clk; |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 495 | #endif |
Kim Phillips | cd9fd70 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 496 | gd->pci_clk = pci_sync_in; |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 497 | gd->cpu_clk = gd->arch.core_clk; |
| 498 | gd->bus_clk = gd->arch.csb_clk; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 499 | return 0; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 500 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | /******************************************** |
| 504 | * get_bus_freq |
| 505 | * return system bus freq in Hz |
| 506 | *********************************************/ |
Kim Phillips | bae2479 | 2006-11-02 19:47:11 -0600 | [diff] [blame] | 507 | ulong get_bus_freq(ulong dummy) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 508 | { |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 509 | return gd->arch.csb_clk; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 510 | } |
| 511 | |
York Sun | e12ce98 | 2011-08-26 11:32:44 -0700 | [diff] [blame] | 512 | /******************************************** |
| 513 | * get_ddr_freq |
| 514 | * return ddr bus freq in Hz |
| 515 | *********************************************/ |
| 516 | ulong get_ddr_freq(ulong dummy) |
| 517 | { |
| 518 | return gd->mem_clk; |
| 519 | } |
| 520 | |
Mario Six | 2fc5227 | 2019-01-21 09:18:05 +0100 | [diff] [blame] | 521 | int get_serial_clock(void) |
| 522 | { |
| 523 | return get_bus_freq(0); |
| 524 | } |
| 525 | |
Kim Phillips | b5c312a | 2012-10-29 13:34:39 +0000 | [diff] [blame] | 526 | static int do_clocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 527 | { |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 528 | char buf[32]; |
| 529 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 530 | printf("Clock configuration:\n"); |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 531 | printf(" Core: %-4s MHz\n", |
| 532 | strmhz(buf, gd->arch.core_clk)); |
| 533 | printf(" Coherent System Bus: %-4s MHz\n", |
| 534 | strmhz(buf, gd->arch.csb_clk)); |
Gerlando Falauto | 77cf283 | 2012-10-10 22:13:06 +0000 | [diff] [blame] | 535 | #if defined(CONFIG_QE) |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 536 | printf(" QE: %-4s MHz\n", |
| 537 | strmhz(buf, gd->arch.qe_clk)); |
Simon Glass | 34a194f | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 538 | printf(" BRG: %-4s MHz\n", |
| 539 | strmhz(buf, gd->arch.brg_clk)); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 540 | #endif |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 541 | printf(" Local Bus Controller:%-4s MHz\n", |
| 542 | strmhz(buf, gd->arch.lbiu_clk)); |
| 543 | printf(" Local Bus: %-4s MHz\n", |
| 544 | strmhz(buf, gd->arch.lclk_clk)); |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 545 | printf(" DDR: %-4s MHz\n", strmhz(buf, gd->mem_clk)); |
Mario Six | 84eb431 | 2019-01-21 09:17:28 +0100 | [diff] [blame] | 546 | #if defined(CONFIG_ARCH_MPC8360) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 547 | printf(" DDR Secondary: %-4s MHz\n", |
| 548 | strmhz(buf, gd->arch.mem_sec_clk)); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 549 | #endif |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 550 | #if !defined(CONFIG_ARCH_MPC8309) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 551 | printf(" SEC: %-4s MHz\n", |
| 552 | strmhz(buf, gd->arch.enc_clk)); |
Gerlando Falauto | fe201cb | 2012-10-10 22:13:08 +0000 | [diff] [blame] | 553 | #endif |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 554 | printf(" I2C1: %-4s MHz\n", |
| 555 | strmhz(buf, gd->arch.i2c1_clk)); |
Mario Six | be07e55 | 2019-01-21 09:17:26 +0100 | [diff] [blame] | 556 | #if !defined(CONFIG_ARCH_MPC832X) |
Simon Glass | c2baaec | 2012-12-13 20:48:49 +0000 | [diff] [blame] | 557 | printf(" I2C2: %-4s MHz\n", |
| 558 | strmhz(buf, gd->arch.i2c2_clk)); |
Dave Liu | e740c46 | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 559 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 560 | #if defined(CONFIG_ARCH_MPC8315) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 561 | printf(" TDM: %-4s MHz\n", |
| 562 | strmhz(buf, gd->arch.tdm_clk)); |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 563 | #endif |
Rini van Zetten | a249617 | 2010-04-15 16:03:05 +0200 | [diff] [blame] | 564 | #if defined(CONFIG_FSL_ESDHC) |
Simon Glass | 9e247d1 | 2012-12-13 20:49:05 +0000 | [diff] [blame] | 565 | printf(" SDHC: %-4s MHz\n", |
| 566 | strmhz(buf, gd->arch.sdhc_clk)); |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 567 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 568 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 569 | defined(CONFIG_ARCH_MPC834X) || defined(CONFIG_ARCH_MPC837X) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 570 | printf(" TSEC1: %-4s MHz\n", |
| 571 | strmhz(buf, gd->arch.tsec1_clk)); |
| 572 | printf(" TSEC2: %-4s MHz\n", |
| 573 | strmhz(buf, gd->arch.tsec2_clk)); |
| 574 | printf(" USB DR: %-4s MHz\n", |
| 575 | strmhz(buf, gd->arch.usbdr_clk)); |
Mario Six | b2e701c | 2019-01-21 09:17:24 +0100 | [diff] [blame] | 576 | #elif defined(CONFIG_ARCH_MPC8309) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 577 | printf(" USB DR: %-4s MHz\n", |
| 578 | strmhz(buf, gd->arch.usbdr_clk)); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 579 | #endif |
Mario Six | 0344f5e | 2019-01-21 09:17:27 +0100 | [diff] [blame] | 580 | #if defined(CONFIG_ARCH_MPC834X) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 581 | printf(" USB MPH: %-4s MHz\n", |
| 582 | strmhz(buf, gd->arch.usbmph_clk)); |
Scott Wood | c036fc9 | 2007-04-16 14:34:19 -0500 | [diff] [blame] | 583 | #endif |
Mario Six | 9164bdd | 2019-01-21 09:17:25 +0100 | [diff] [blame] | 584 | #if defined(CONFIG_ARCH_MPC8308) || defined(CONFIG_ARCH_MPC831X) || \ |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 585 | defined(CONFIG_ARCH_MPC837X) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 586 | printf(" PCIEXP1: %-4s MHz\n", |
| 587 | strmhz(buf, gd->arch.pciexp1_clk)); |
| 588 | printf(" PCIEXP2: %-4s MHz\n", |
| 589 | strmhz(buf, gd->arch.pciexp2_clk)); |
Dave Liu | e0cfec8 | 2007-09-18 12:36:58 +0800 | [diff] [blame] | 590 | #endif |
Mario Six | 60b1123 | 2019-01-21 09:17:29 +0100 | [diff] [blame] | 591 | #if defined(CONFIG_ARCH_MPC837X) || defined(CONFIG_ARCH_MPC8315) |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 592 | printf(" SATA: %-4s MHz\n", |
| 593 | strmhz(buf, gd->arch.sata_clk)); |
Dave Liu | 5245ff5 | 2007-09-18 12:36:11 +0800 | [diff] [blame] | 594 | #endif |
Jon Loeliger | ebc7224 | 2005-08-01 13:20:47 -0500 | [diff] [blame] | 595 | return 0; |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 596 | } |
Kim Phillips | d82b077 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 597 | |
| 598 | U_BOOT_CMD(clocks, 1, 0, do_clocks, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 599 | "print clock configuration", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 600 | " clocks" |
Kim Phillips | d82b077 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 601 | ); |
Mario Six | 7cab147 | 2018-08-06 10:23:36 +0200 | [diff] [blame] | 602 | |
| 603 | #endif |