Commit a832ddba55f79801b6f75b79e96c3f5e1469335a
Committed by
Marek Vasut
1 parent
0911af00b0
Exists in
v2017.01-smarct4x
and in
37 other branches
arm: socfpga: clock: Add code to read clock configuration
Add the entire bulk of code to read out clock configuration from the SoCFPGA CPU registers. This is important for MMC, QSPI and UART drivers as otherwise they cannot determine the frequency of their upstream clock. Signed-off-by: Pavel Machek <pavel@denx.de> Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chin Liang See <clsee@altera.com> Cc: Dinh Nguyen <dinguyen@altera.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net> Cc: Tom Rini <trini@ti.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Pavel Machek <pavel@denx.de> V2: Fixed the L4 MP clock divider and synced the clock code with latest rocketboards codebase (thanks Dinh for pointing this out)
Showing 3 changed files with 267 additions and 3 deletions Inline Diff
arch/arm/cpu/armv7/socfpga/clock_manager.c
1 | /* | 1 | /* |
2 | * Copyright (C) 2013 Altera Corporation <www.altera.com> | 2 | * Copyright (C) 2013 Altera Corporation <www.altera.com> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <common.h> | 7 | #include <common.h> |
8 | #include <asm/io.h> | 8 | #include <asm/io.h> |
9 | #include <asm/arch/clock_manager.h> | 9 | #include <asm/arch/clock_manager.h> |
10 | 10 | ||
11 | DECLARE_GLOBAL_DATA_PTR; | ||
12 | |||
11 | static const struct socfpga_clock_manager *clock_manager_base = | 13 | static const struct socfpga_clock_manager *clock_manager_base = |
12 | (void *)SOCFPGA_CLKMGR_ADDRESS; | 14 | (struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS; |
13 | 15 | ||
14 | #define CLKMGR_BYPASS_ENABLE 1 | 16 | #define CLKMGR_BYPASS_ENABLE 1 |
15 | #define CLKMGR_BYPASS_DISABLE 0 | 17 | #define CLKMGR_BYPASS_DISABLE 0 |
16 | #define CLKMGR_STAT_IDLE 0 | 18 | #define CLKMGR_STAT_IDLE 0 |
17 | #define CLKMGR_STAT_BUSY 1 | 19 | #define CLKMGR_STAT_BUSY 1 |
18 | #define CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1 0 | 20 | #define CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1 0 |
19 | #define CLKMGR_BYPASS_PERPLLSRC_SELECT_INPUT_MUX 1 | 21 | #define CLKMGR_BYPASS_PERPLLSRC_SELECT_INPUT_MUX 1 |
20 | #define CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1 0 | 22 | #define CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1 0 |
21 | #define CLKMGR_BYPASS_SDRPLLSRC_SELECT_INPUT_MUX 1 | 23 | #define CLKMGR_BYPASS_SDRPLLSRC_SELECT_INPUT_MUX 1 |
22 | 24 | ||
23 | #define CLEAR_BGP_EN_PWRDN \ | 25 | #define CLEAR_BGP_EN_PWRDN \ |
24 | (CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(0)| \ | 26 | (CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(0)| \ |
25 | CLKMGR_MAINPLLGRP_VCO_EN_SET(0)| \ | 27 | CLKMGR_MAINPLLGRP_VCO_EN_SET(0)| \ |
26 | CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(0)) | 28 | CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(0)) |
27 | 29 | ||
28 | #define VCO_EN_BASE \ | 30 | #define VCO_EN_BASE \ |
29 | (CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(0)| \ | 31 | (CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(0)| \ |
30 | CLKMGR_MAINPLLGRP_VCO_EN_SET(1)| \ | 32 | CLKMGR_MAINPLLGRP_VCO_EN_SET(1)| \ |
31 | CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(0)) | 33 | CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(0)) |
32 | 34 | ||
33 | static void cm_wait_for_lock(uint32_t mask) | 35 | static void cm_wait_for_lock(uint32_t mask) |
34 | { | 36 | { |
35 | register uint32_t inter_val; | 37 | register uint32_t inter_val; |
36 | do { | 38 | do { |
37 | inter_val = readl(&clock_manager_base->inter) & mask; | 39 | inter_val = readl(&clock_manager_base->inter) & mask; |
38 | } while (inter_val != mask); | 40 | } while (inter_val != mask); |
39 | } | 41 | } |
40 | 42 | ||
41 | /* function to poll in the fsm busy bit */ | 43 | /* function to poll in the fsm busy bit */ |
42 | static void cm_wait_for_fsm(void) | 44 | static void cm_wait_for_fsm(void) |
43 | { | 45 | { |
44 | while (readl(&clock_manager_base->stat) & CLKMGR_STAT_BUSY) | 46 | while (readl(&clock_manager_base->stat) & CLKMGR_STAT_BUSY) |
45 | ; | 47 | ; |
46 | } | 48 | } |
47 | 49 | ||
48 | /* | 50 | /* |
49 | * function to write the bypass register which requires a poll of the | 51 | * function to write the bypass register which requires a poll of the |
50 | * busy bit | 52 | * busy bit |
51 | */ | 53 | */ |
52 | static void cm_write_bypass(uint32_t val) | 54 | static void cm_write_bypass(uint32_t val) |
53 | { | 55 | { |
54 | writel(val, &clock_manager_base->bypass); | 56 | writel(val, &clock_manager_base->bypass); |
55 | cm_wait_for_fsm(); | 57 | cm_wait_for_fsm(); |
56 | } | 58 | } |
57 | 59 | ||
58 | /* function to write the ctrl register which requires a poll of the busy bit */ | 60 | /* function to write the ctrl register which requires a poll of the busy bit */ |
59 | static void cm_write_ctrl(uint32_t val) | 61 | static void cm_write_ctrl(uint32_t val) |
60 | { | 62 | { |
61 | writel(val, &clock_manager_base->ctrl); | 63 | writel(val, &clock_manager_base->ctrl); |
62 | cm_wait_for_fsm(); | 64 | cm_wait_for_fsm(); |
63 | } | 65 | } |
64 | 66 | ||
65 | /* function to write a clock register that has phase information */ | 67 | /* function to write a clock register that has phase information */ |
66 | static void cm_write_with_phase(uint32_t value, | 68 | static void cm_write_with_phase(uint32_t value, |
67 | uint32_t reg_address, uint32_t mask) | 69 | uint32_t reg_address, uint32_t mask) |
68 | { | 70 | { |
69 | /* poll until phase is zero */ | 71 | /* poll until phase is zero */ |
70 | while (readl(reg_address) & mask) | 72 | while (readl(reg_address) & mask) |
71 | ; | 73 | ; |
72 | 74 | ||
73 | writel(value, reg_address); | 75 | writel(value, reg_address); |
74 | 76 | ||
75 | while (readl(reg_address) & mask) | 77 | while (readl(reg_address) & mask) |
76 | ; | 78 | ; |
77 | } | 79 | } |
78 | 80 | ||
79 | /* | 81 | /* |
80 | * Setup clocks while making no assumptions about previous state of the clocks. | 82 | * Setup clocks while making no assumptions about previous state of the clocks. |
81 | * | 83 | * |
82 | * Start by being paranoid and gate all sw managed clocks | 84 | * Start by being paranoid and gate all sw managed clocks |
83 | * Put all plls in bypass | 85 | * Put all plls in bypass |
84 | * Put all plls VCO registers back to reset value (bandgap power down). | 86 | * Put all plls VCO registers back to reset value (bandgap power down). |
85 | * Put peripheral and main pll src to reset value to avoid glitch. | 87 | * Put peripheral and main pll src to reset value to avoid glitch. |
86 | * Delay 5 us. | 88 | * Delay 5 us. |
87 | * Deassert bandgap power down and set numerator and denominator | 89 | * Deassert bandgap power down and set numerator and denominator |
88 | * Start 7 us timer. | 90 | * Start 7 us timer. |
89 | * set internal dividers | 91 | * set internal dividers |
90 | * Wait for 7 us timer. | 92 | * Wait for 7 us timer. |
91 | * Enable plls | 93 | * Enable plls |
92 | * Set external dividers while plls are locking | 94 | * Set external dividers while plls are locking |
93 | * Wait for pll lock | 95 | * Wait for pll lock |
94 | * Assert/deassert outreset all. | 96 | * Assert/deassert outreset all. |
95 | * Take all pll's out of bypass | 97 | * Take all pll's out of bypass |
96 | * Clear safe mode | 98 | * Clear safe mode |
97 | * set source main and peripheral clocks | 99 | * set source main and peripheral clocks |
98 | * Ungate clocks | 100 | * Ungate clocks |
99 | */ | 101 | */ |
100 | 102 | ||
101 | void cm_basic_init(const cm_config_t *cfg) | 103 | void cm_basic_init(const cm_config_t *cfg) |
102 | { | 104 | { |
103 | uint32_t start, timeout; | 105 | uint32_t start, timeout; |
104 | 106 | ||
105 | /* Start by being paranoid and gate all sw managed clocks */ | 107 | /* Start by being paranoid and gate all sw managed clocks */ |
106 | 108 | ||
107 | /* | 109 | /* |
108 | * We need to disable nandclk | 110 | * We need to disable nandclk |
109 | * and then do another apb access before disabling | 111 | * and then do another apb access before disabling |
110 | * gatting off the rest of the periperal clocks. | 112 | * gatting off the rest of the periperal clocks. |
111 | */ | 113 | */ |
112 | writel(~CLKMGR_PERPLLGRP_EN_NANDCLK_MASK & | 114 | writel(~CLKMGR_PERPLLGRP_EN_NANDCLK_MASK & |
113 | readl(&clock_manager_base->per_pll.en), | 115 | readl(&clock_manager_base->per_pll.en), |
114 | &clock_manager_base->per_pll.en); | 116 | &clock_manager_base->per_pll.en); |
115 | 117 | ||
116 | /* DO NOT GATE OFF DEBUG CLOCKS & BRIDGE CLOCKS */ | 118 | /* DO NOT GATE OFF DEBUG CLOCKS & BRIDGE CLOCKS */ |
117 | writel(CLKMGR_MAINPLLGRP_EN_DBGTIMERCLK_MASK | | 119 | writel(CLKMGR_MAINPLLGRP_EN_DBGTIMERCLK_MASK | |
118 | CLKMGR_MAINPLLGRP_EN_DBGTRACECLK_MASK | | 120 | CLKMGR_MAINPLLGRP_EN_DBGTRACECLK_MASK | |
119 | CLKMGR_MAINPLLGRP_EN_DBGCLK_MASK | | 121 | CLKMGR_MAINPLLGRP_EN_DBGCLK_MASK | |
120 | CLKMGR_MAINPLLGRP_EN_DBGATCLK_MASK | | 122 | CLKMGR_MAINPLLGRP_EN_DBGATCLK_MASK | |
121 | CLKMGR_MAINPLLGRP_EN_S2FUSER0CLK_MASK | | 123 | CLKMGR_MAINPLLGRP_EN_S2FUSER0CLK_MASK | |
122 | CLKMGR_MAINPLLGRP_EN_L4MPCLK_MASK, | 124 | CLKMGR_MAINPLLGRP_EN_L4MPCLK_MASK, |
123 | &clock_manager_base->main_pll.en); | 125 | &clock_manager_base->main_pll.en); |
124 | 126 | ||
125 | writel(0, &clock_manager_base->sdr_pll.en); | 127 | writel(0, &clock_manager_base->sdr_pll.en); |
126 | 128 | ||
127 | /* now we can gate off the rest of the peripheral clocks */ | 129 | /* now we can gate off the rest of the peripheral clocks */ |
128 | writel(0, &clock_manager_base->per_pll.en); | 130 | writel(0, &clock_manager_base->per_pll.en); |
129 | 131 | ||
130 | /* Put all plls in bypass */ | 132 | /* Put all plls in bypass */ |
131 | cm_write_bypass( | 133 | cm_write_bypass( |
132 | CLKMGR_BYPASS_PERPLLSRC_SET( | 134 | CLKMGR_BYPASS_PERPLLSRC_SET( |
133 | CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) | | 135 | CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) | |
134 | CLKMGR_BYPASS_SDRPLLSRC_SET( | 136 | CLKMGR_BYPASS_SDRPLLSRC_SET( |
135 | CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) | | 137 | CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) | |
136 | CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_ENABLE) | | 138 | CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_ENABLE) | |
137 | CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_ENABLE) | | 139 | CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_ENABLE) | |
138 | CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_ENABLE)); | 140 | CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_ENABLE)); |
139 | 141 | ||
140 | /* | 142 | /* |
141 | * Put all plls VCO registers back to reset value. | 143 | * Put all plls VCO registers back to reset value. |
142 | * Some code might have messed with them. | 144 | * Some code might have messed with them. |
143 | */ | 145 | */ |
144 | writel(CLKMGR_MAINPLLGRP_VCO_RESET_VALUE, | 146 | writel(CLKMGR_MAINPLLGRP_VCO_RESET_VALUE, |
145 | &clock_manager_base->main_pll.vco); | 147 | &clock_manager_base->main_pll.vco); |
146 | writel(CLKMGR_PERPLLGRP_VCO_RESET_VALUE, | 148 | writel(CLKMGR_PERPLLGRP_VCO_RESET_VALUE, |
147 | &clock_manager_base->per_pll.vco); | 149 | &clock_manager_base->per_pll.vco); |
148 | writel(CLKMGR_SDRPLLGRP_VCO_RESET_VALUE, | 150 | writel(CLKMGR_SDRPLLGRP_VCO_RESET_VALUE, |
149 | &clock_manager_base->sdr_pll.vco); | 151 | &clock_manager_base->sdr_pll.vco); |
150 | 152 | ||
151 | /* | 153 | /* |
152 | * The clocks to the flash devices and the L4_MAIN clocks can | 154 | * The clocks to the flash devices and the L4_MAIN clocks can |
153 | * glitch when coming out of safe mode if their source values | 155 | * glitch when coming out of safe mode if their source values |
154 | * are different from their reset value. So the trick it to | 156 | * are different from their reset value. So the trick it to |
155 | * put them back to their reset state, and change input | 157 | * put them back to their reset state, and change input |
156 | * after exiting safe mode but before ungating the clocks. | 158 | * after exiting safe mode but before ungating the clocks. |
157 | */ | 159 | */ |
158 | writel(CLKMGR_PERPLLGRP_SRC_RESET_VALUE, | 160 | writel(CLKMGR_PERPLLGRP_SRC_RESET_VALUE, |
159 | &clock_manager_base->per_pll.src); | 161 | &clock_manager_base->per_pll.src); |
160 | writel(CLKMGR_MAINPLLGRP_L4SRC_RESET_VALUE, | 162 | writel(CLKMGR_MAINPLLGRP_L4SRC_RESET_VALUE, |
161 | &clock_manager_base->main_pll.l4src); | 163 | &clock_manager_base->main_pll.l4src); |
162 | 164 | ||
163 | /* read back for the required 5 us delay. */ | 165 | /* read back for the required 5 us delay. */ |
164 | readl(&clock_manager_base->main_pll.vco); | 166 | readl(&clock_manager_base->main_pll.vco); |
165 | readl(&clock_manager_base->per_pll.vco); | 167 | readl(&clock_manager_base->per_pll.vco); |
166 | readl(&clock_manager_base->sdr_pll.vco); | 168 | readl(&clock_manager_base->sdr_pll.vco); |
167 | 169 | ||
168 | 170 | ||
169 | /* | 171 | /* |
170 | * We made sure bgpwr down was assert for 5 us. Now deassert BG PWR DN | 172 | * We made sure bgpwr down was assert for 5 us. Now deassert BG PWR DN |
171 | * with numerator and denominator. | 173 | * with numerator and denominator. |
172 | */ | 174 | */ |
173 | writel(cfg->main_vco_base | CLEAR_BGP_EN_PWRDN | | 175 | writel(cfg->main_vco_base | CLEAR_BGP_EN_PWRDN | |
174 | CLKMGR_MAINPLLGRP_VCO_REGEXTSEL_MASK, | 176 | CLKMGR_MAINPLLGRP_VCO_REGEXTSEL_MASK, |
175 | &clock_manager_base->main_pll.vco); | 177 | &clock_manager_base->main_pll.vco); |
176 | 178 | ||
177 | writel(cfg->peri_vco_base | CLEAR_BGP_EN_PWRDN | | 179 | writel(cfg->peri_vco_base | CLEAR_BGP_EN_PWRDN | |
178 | CLKMGR_PERPLLGRP_VCO_REGEXTSEL_MASK, | 180 | CLKMGR_PERPLLGRP_VCO_REGEXTSEL_MASK, |
179 | &clock_manager_base->per_pll.vco); | 181 | &clock_manager_base->per_pll.vco); |
180 | 182 | ||
181 | writel(CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(0) | | 183 | writel(CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(0) | |
182 | CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(0) | | 184 | CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(0) | |
183 | cfg->sdram_vco_base | CLEAR_BGP_EN_PWRDN | | 185 | cfg->sdram_vco_base | CLEAR_BGP_EN_PWRDN | |
184 | CLKMGR_SDRPLLGRP_VCO_REGEXTSEL_MASK, | 186 | CLKMGR_SDRPLLGRP_VCO_REGEXTSEL_MASK, |
185 | &clock_manager_base->sdr_pll.vco); | 187 | &clock_manager_base->sdr_pll.vco); |
186 | 188 | ||
187 | /* | 189 | /* |
188 | * Time starts here | 190 | * Time starts here |
189 | * must wait 7 us from BGPWRDN_SET(0) to VCO_ENABLE_SET(1) | 191 | * must wait 7 us from BGPWRDN_SET(0) to VCO_ENABLE_SET(1) |
190 | */ | 192 | */ |
191 | start = get_timer(0); | 193 | start = get_timer(0); |
192 | /* timeout in unit of us as CONFIG_SYS_HZ = 1000*1000 */ | 194 | /* timeout in unit of us as CONFIG_SYS_HZ = 1000*1000 */ |
193 | timeout = 7; | 195 | timeout = 7; |
194 | 196 | ||
195 | /* main mpu */ | 197 | /* main mpu */ |
196 | writel(cfg->mpuclk, &clock_manager_base->main_pll.mpuclk); | 198 | writel(cfg->mpuclk, &clock_manager_base->main_pll.mpuclk); |
197 | 199 | ||
198 | /* main main clock */ | 200 | /* main main clock */ |
199 | writel(cfg->mainclk, &clock_manager_base->main_pll.mainclk); | 201 | writel(cfg->mainclk, &clock_manager_base->main_pll.mainclk); |
200 | 202 | ||
201 | /* main for dbg */ | 203 | /* main for dbg */ |
202 | writel(cfg->dbgatclk, &clock_manager_base->main_pll.dbgatclk); | 204 | writel(cfg->dbgatclk, &clock_manager_base->main_pll.dbgatclk); |
203 | 205 | ||
204 | /* main for cfgs2fuser0clk */ | 206 | /* main for cfgs2fuser0clk */ |
205 | writel(cfg->cfg2fuser0clk, | 207 | writel(cfg->cfg2fuser0clk, |
206 | &clock_manager_base->main_pll.cfgs2fuser0clk); | 208 | &clock_manager_base->main_pll.cfgs2fuser0clk); |
207 | 209 | ||
208 | /* Peri emac0 50 MHz default to RMII */ | 210 | /* Peri emac0 50 MHz default to RMII */ |
209 | writel(cfg->emac0clk, &clock_manager_base->per_pll.emac0clk); | 211 | writel(cfg->emac0clk, &clock_manager_base->per_pll.emac0clk); |
210 | 212 | ||
211 | /* Peri emac1 50 MHz default to RMII */ | 213 | /* Peri emac1 50 MHz default to RMII */ |
212 | writel(cfg->emac1clk, &clock_manager_base->per_pll.emac1clk); | 214 | writel(cfg->emac1clk, &clock_manager_base->per_pll.emac1clk); |
213 | 215 | ||
214 | /* Peri QSPI */ | 216 | /* Peri QSPI */ |
215 | writel(cfg->mainqspiclk, &clock_manager_base->main_pll.mainqspiclk); | 217 | writel(cfg->mainqspiclk, &clock_manager_base->main_pll.mainqspiclk); |
216 | 218 | ||
217 | writel(cfg->perqspiclk, &clock_manager_base->per_pll.perqspiclk); | 219 | writel(cfg->perqspiclk, &clock_manager_base->per_pll.perqspiclk); |
218 | 220 | ||
219 | /* Peri pernandsdmmcclk */ | 221 | /* Peri pernandsdmmcclk */ |
220 | writel(cfg->pernandsdmmcclk, | 222 | writel(cfg->pernandsdmmcclk, |
221 | &clock_manager_base->per_pll.pernandsdmmcclk); | 223 | &clock_manager_base->per_pll.pernandsdmmcclk); |
222 | 224 | ||
223 | /* Peri perbaseclk */ | 225 | /* Peri perbaseclk */ |
224 | writel(cfg->perbaseclk, &clock_manager_base->per_pll.perbaseclk); | 226 | writel(cfg->perbaseclk, &clock_manager_base->per_pll.perbaseclk); |
225 | 227 | ||
226 | /* Peri s2fuser1clk */ | 228 | /* Peri s2fuser1clk */ |
227 | writel(cfg->s2fuser1clk, &clock_manager_base->per_pll.s2fuser1clk); | 229 | writel(cfg->s2fuser1clk, &clock_manager_base->per_pll.s2fuser1clk); |
228 | 230 | ||
229 | /* 7 us must have elapsed before we can enable the VCO */ | 231 | /* 7 us must have elapsed before we can enable the VCO */ |
230 | while (get_timer(start) < timeout) | 232 | while (get_timer(start) < timeout) |
231 | ; | 233 | ; |
232 | 234 | ||
233 | /* Enable vco */ | 235 | /* Enable vco */ |
234 | /* main pll vco */ | 236 | /* main pll vco */ |
235 | writel(cfg->main_vco_base | VCO_EN_BASE, | 237 | writel(cfg->main_vco_base | VCO_EN_BASE, |
236 | &clock_manager_base->main_pll.vco); | 238 | &clock_manager_base->main_pll.vco); |
237 | 239 | ||
238 | /* periferal pll */ | 240 | /* periferal pll */ |
239 | writel(cfg->peri_vco_base | VCO_EN_BASE, | 241 | writel(cfg->peri_vco_base | VCO_EN_BASE, |
240 | &clock_manager_base->per_pll.vco); | 242 | &clock_manager_base->per_pll.vco); |
241 | 243 | ||
242 | /* sdram pll vco */ | 244 | /* sdram pll vco */ |
243 | writel(CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(0) | | 245 | writel(CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(0) | |
244 | CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(0) | | 246 | CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(0) | |
245 | cfg->sdram_vco_base | VCO_EN_BASE, | 247 | cfg->sdram_vco_base | VCO_EN_BASE, |
246 | &clock_manager_base->sdr_pll.vco); | 248 | &clock_manager_base->sdr_pll.vco); |
247 | 249 | ||
248 | /* L3 MP and L3 SP */ | 250 | /* L3 MP and L3 SP */ |
249 | writel(cfg->maindiv, &clock_manager_base->main_pll.maindiv); | 251 | writel(cfg->maindiv, &clock_manager_base->main_pll.maindiv); |
250 | 252 | ||
251 | writel(cfg->dbgdiv, &clock_manager_base->main_pll.dbgdiv); | 253 | writel(cfg->dbgdiv, &clock_manager_base->main_pll.dbgdiv); |
252 | 254 | ||
253 | writel(cfg->tracediv, &clock_manager_base->main_pll.tracediv); | 255 | writel(cfg->tracediv, &clock_manager_base->main_pll.tracediv); |
254 | 256 | ||
255 | /* L4 MP, L4 SP, can0, and can1 */ | 257 | /* L4 MP, L4 SP, can0, and can1 */ |
256 | writel(cfg->perdiv, &clock_manager_base->per_pll.div); | 258 | writel(cfg->perdiv, &clock_manager_base->per_pll.div); |
257 | 259 | ||
258 | writel(cfg->gpiodiv, &clock_manager_base->per_pll.gpiodiv); | 260 | writel(cfg->gpiodiv, &clock_manager_base->per_pll.gpiodiv); |
259 | 261 | ||
260 | #define LOCKED_MASK \ | 262 | #define LOCKED_MASK \ |
261 | (CLKMGR_INTER_SDRPLLLOCKED_MASK | \ | 263 | (CLKMGR_INTER_SDRPLLLOCKED_MASK | \ |
262 | CLKMGR_INTER_PERPLLLOCKED_MASK | \ | 264 | CLKMGR_INTER_PERPLLLOCKED_MASK | \ |
263 | CLKMGR_INTER_MAINPLLLOCKED_MASK) | 265 | CLKMGR_INTER_MAINPLLLOCKED_MASK) |
264 | 266 | ||
265 | cm_wait_for_lock(LOCKED_MASK); | 267 | cm_wait_for_lock(LOCKED_MASK); |
266 | 268 | ||
267 | /* write the sdram clock counters before toggling outreset all */ | 269 | /* write the sdram clock counters before toggling outreset all */ |
268 | writel(cfg->ddrdqsclk & CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_MASK, | 270 | writel(cfg->ddrdqsclk & CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_MASK, |
269 | &clock_manager_base->sdr_pll.ddrdqsclk); | 271 | &clock_manager_base->sdr_pll.ddrdqsclk); |
270 | 272 | ||
271 | writel(cfg->ddr2xdqsclk & CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_MASK, | 273 | writel(cfg->ddr2xdqsclk & CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_MASK, |
272 | &clock_manager_base->sdr_pll.ddr2xdqsclk); | 274 | &clock_manager_base->sdr_pll.ddr2xdqsclk); |
273 | 275 | ||
274 | writel(cfg->ddrdqclk & CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_MASK, | 276 | writel(cfg->ddrdqclk & CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_MASK, |
275 | &clock_manager_base->sdr_pll.ddrdqclk); | 277 | &clock_manager_base->sdr_pll.ddrdqclk); |
276 | 278 | ||
277 | writel(cfg->s2fuser2clk & CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_MASK, | 279 | writel(cfg->s2fuser2clk & CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_MASK, |
278 | &clock_manager_base->sdr_pll.s2fuser2clk); | 280 | &clock_manager_base->sdr_pll.s2fuser2clk); |
279 | 281 | ||
280 | /* | 282 | /* |
281 | * after locking, but before taking out of bypass | 283 | * after locking, but before taking out of bypass |
282 | * assert/deassert outresetall | 284 | * assert/deassert outresetall |
283 | */ | 285 | */ |
284 | uint32_t mainvco = readl(&clock_manager_base->main_pll.vco); | 286 | uint32_t mainvco = readl(&clock_manager_base->main_pll.vco); |
285 | 287 | ||
286 | /* assert main outresetall */ | 288 | /* assert main outresetall */ |
287 | writel(mainvco | CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK, | 289 | writel(mainvco | CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK, |
288 | &clock_manager_base->main_pll.vco); | 290 | &clock_manager_base->main_pll.vco); |
289 | 291 | ||
290 | uint32_t periphvco = readl(&clock_manager_base->per_pll.vco); | 292 | uint32_t periphvco = readl(&clock_manager_base->per_pll.vco); |
291 | 293 | ||
292 | /* assert pheriph outresetall */ | 294 | /* assert pheriph outresetall */ |
293 | writel(periphvco | CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK, | 295 | writel(periphvco | CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK, |
294 | &clock_manager_base->per_pll.vco); | 296 | &clock_manager_base->per_pll.vco); |
295 | 297 | ||
296 | /* assert sdram outresetall */ | 298 | /* assert sdram outresetall */ |
297 | writel(cfg->sdram_vco_base | VCO_EN_BASE| | 299 | writel(cfg->sdram_vco_base | VCO_EN_BASE| |
298 | CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(1), | 300 | CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(1), |
299 | &clock_manager_base->sdr_pll.vco); | 301 | &clock_manager_base->sdr_pll.vco); |
300 | 302 | ||
301 | /* deassert main outresetall */ | 303 | /* deassert main outresetall */ |
302 | writel(mainvco & ~CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK, | 304 | writel(mainvco & ~CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK, |
303 | &clock_manager_base->main_pll.vco); | 305 | &clock_manager_base->main_pll.vco); |
304 | 306 | ||
305 | /* deassert pheriph outresetall */ | 307 | /* deassert pheriph outresetall */ |
306 | writel(periphvco & ~CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK, | 308 | writel(periphvco & ~CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK, |
307 | &clock_manager_base->per_pll.vco); | 309 | &clock_manager_base->per_pll.vco); |
308 | 310 | ||
309 | /* deassert sdram outresetall */ | 311 | /* deassert sdram outresetall */ |
310 | writel(CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(0) | | 312 | writel(CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(0) | |
311 | cfg->sdram_vco_base | VCO_EN_BASE, | 313 | cfg->sdram_vco_base | VCO_EN_BASE, |
312 | &clock_manager_base->sdr_pll.vco); | 314 | &clock_manager_base->sdr_pll.vco); |
313 | 315 | ||
314 | /* | 316 | /* |
315 | * now that we've toggled outreset all, all the clocks | 317 | * now that we've toggled outreset all, all the clocks |
316 | * are aligned nicely; so we can change any phase. | 318 | * are aligned nicely; so we can change any phase. |
317 | */ | 319 | */ |
318 | cm_write_with_phase(cfg->ddrdqsclk, | 320 | cm_write_with_phase(cfg->ddrdqsclk, |
319 | (uint32_t)&clock_manager_base->sdr_pll.ddrdqsclk, | 321 | (uint32_t)&clock_manager_base->sdr_pll.ddrdqsclk, |
320 | CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_MASK); | 322 | CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_MASK); |
321 | 323 | ||
322 | /* SDRAM DDR2XDQSCLK */ | 324 | /* SDRAM DDR2XDQSCLK */ |
323 | cm_write_with_phase(cfg->ddr2xdqsclk, | 325 | cm_write_with_phase(cfg->ddr2xdqsclk, |
324 | (uint32_t)&clock_manager_base->sdr_pll.ddr2xdqsclk, | 326 | (uint32_t)&clock_manager_base->sdr_pll.ddr2xdqsclk, |
325 | CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_MASK); | 327 | CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_MASK); |
326 | 328 | ||
327 | cm_write_with_phase(cfg->ddrdqclk, | 329 | cm_write_with_phase(cfg->ddrdqclk, |
328 | (uint32_t)&clock_manager_base->sdr_pll.ddrdqclk, | 330 | (uint32_t)&clock_manager_base->sdr_pll.ddrdqclk, |
329 | CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_MASK); | 331 | CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_MASK); |
330 | 332 | ||
331 | cm_write_with_phase(cfg->s2fuser2clk, | 333 | cm_write_with_phase(cfg->s2fuser2clk, |
332 | (uint32_t)&clock_manager_base->sdr_pll.s2fuser2clk, | 334 | (uint32_t)&clock_manager_base->sdr_pll.s2fuser2clk, |
333 | CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_MASK); | 335 | CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_MASK); |
334 | 336 | ||
335 | /* Take all three PLLs out of bypass when safe mode is cleared. */ | 337 | /* Take all three PLLs out of bypass when safe mode is cleared. */ |
336 | cm_write_bypass( | 338 | cm_write_bypass( |
337 | CLKMGR_BYPASS_PERPLLSRC_SET( | 339 | CLKMGR_BYPASS_PERPLLSRC_SET( |
338 | CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) | | 340 | CLKMGR_BYPASS_PERPLLSRC_SELECT_EOSC1) | |
339 | CLKMGR_BYPASS_SDRPLLSRC_SET( | 341 | CLKMGR_BYPASS_SDRPLLSRC_SET( |
340 | CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) | | 342 | CLKMGR_BYPASS_SDRPLLSRC_SELECT_EOSC1) | |
341 | CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_DISABLE) | | 343 | CLKMGR_BYPASS_PERPLL_SET(CLKMGR_BYPASS_DISABLE) | |
342 | CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_DISABLE) | | 344 | CLKMGR_BYPASS_SDRPLL_SET(CLKMGR_BYPASS_DISABLE) | |
343 | CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_DISABLE)); | 345 | CLKMGR_BYPASS_MAINPLL_SET(CLKMGR_BYPASS_DISABLE)); |
344 | 346 | ||
345 | /* clear safe mode */ | 347 | /* clear safe mode */ |
346 | cm_write_ctrl(readl(&clock_manager_base->ctrl) | | 348 | cm_write_ctrl(readl(&clock_manager_base->ctrl) | |
347 | CLKMGR_CTRL_SAFEMODE_SET(CLKMGR_CTRL_SAFEMODE_MASK)); | 349 | CLKMGR_CTRL_SAFEMODE_SET(CLKMGR_CTRL_SAFEMODE_MASK)); |
348 | 350 | ||
349 | /* | 351 | /* |
350 | * now that safe mode is clear with clocks gated | 352 | * now that safe mode is clear with clocks gated |
351 | * it safe to change the source mux for the flashes the the L4_MAIN | 353 | * it safe to change the source mux for the flashes the the L4_MAIN |
352 | */ | 354 | */ |
353 | writel(cfg->persrc, &clock_manager_base->per_pll.src); | 355 | writel(cfg->persrc, &clock_manager_base->per_pll.src); |
354 | writel(cfg->l4src, &clock_manager_base->main_pll.l4src); | 356 | writel(cfg->l4src, &clock_manager_base->main_pll.l4src); |
355 | 357 | ||
356 | /* Now ungate non-hw-managed clocks */ | 358 | /* Now ungate non-hw-managed clocks */ |
357 | writel(~0, &clock_manager_base->main_pll.en); | 359 | writel(~0, &clock_manager_base->main_pll.en); |
358 | writel(~0, &clock_manager_base->per_pll.en); | 360 | writel(~0, &clock_manager_base->per_pll.en); |
359 | writel(~0, &clock_manager_base->sdr_pll.en); | 361 | writel(~0, &clock_manager_base->sdr_pll.en); |
360 | } | 362 | } |
363 | |||
364 | unsigned long cm_get_mpu_clk_hz(void) | ||
365 | { | ||
366 | uint32_t reg, clock; | ||
367 | |||
368 | /* get the main VCO clock */ | ||
369 | reg = readl(&clock_manager_base->main_pll.vco); | ||
370 | clock = CONFIG_HPS_CLK_OSC1_HZ / | ||
371 | (CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
372 | clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
373 | |||
374 | /* get the MPU clock */ | ||
375 | reg = readl(&clock_manager_base->altera.mpuclk); | ||
376 | clock /= (reg + 1); | ||
377 | reg = readl(&clock_manager_base->main_pll.mpuclk); | ||
378 | clock /= (reg + 1); | ||
379 | return clock; | ||
380 | } | ||
381 | |||
382 | unsigned long cm_get_sdram_clk_hz(void) | ||
383 | { | ||
384 | uint32_t reg, clock = 0; | ||
385 | |||
386 | /* identify SDRAM PLL clock source */ | ||
387 | reg = readl(&clock_manager_base->sdr_pll.vco); | ||
388 | reg = CLKMGR_SDRPLLGRP_VCO_SSRC_GET(reg); | ||
389 | if (reg == CLKMGR_VCO_SSRC_EOSC1) | ||
390 | clock = CONFIG_HPS_CLK_OSC1_HZ; | ||
391 | else if (reg == CLKMGR_VCO_SSRC_EOSC2) | ||
392 | clock = CONFIG_HPS_CLK_OSC2_HZ; | ||
393 | else if (reg == CLKMGR_VCO_SSRC_F2S) | ||
394 | clock = CONFIG_HPS_CLK_F2S_SDR_REF_HZ; | ||
395 | |||
396 | /* get the SDRAM VCO clock */ | ||
397 | reg = readl(&clock_manager_base->sdr_pll.vco); | ||
398 | clock /= (CLKMGR_SDRPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
399 | clock *= (CLKMGR_SDRPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
400 | |||
401 | /* get the SDRAM (DDR_DQS) clock */ | ||
402 | reg = readl(&clock_manager_base->sdr_pll.ddrdqsclk); | ||
403 | reg = CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_GET(reg); | ||
404 | clock /= (reg + 1); | ||
405 | |||
406 | return clock; | ||
407 | } | ||
408 | |||
409 | unsigned int cm_get_l4_sp_clk_hz(void) | ||
410 | { | ||
411 | uint32_t reg, clock = 0; | ||
412 | |||
413 | /* identify the source of L4 SP clock */ | ||
414 | reg = readl(&clock_manager_base->main_pll.l4src); | ||
415 | reg = CLKMGR_MAINPLLGRP_L4SRC_L4SP_GET(reg); | ||
416 | |||
417 | if (reg == CLKMGR_L4_SP_CLK_SRC_MAINPLL) { | ||
418 | /* get the main VCO clock */ | ||
419 | reg = readl(&clock_manager_base->main_pll.vco); | ||
420 | clock = CONFIG_HPS_CLK_OSC1_HZ / | ||
421 | (CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
422 | clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
423 | |||
424 | /* get the clock prior L4 SP divider (main clk) */ | ||
425 | reg = readl(&clock_manager_base->altera.mainclk); | ||
426 | clock /= (reg + 1); | ||
427 | reg = readl(&clock_manager_base->main_pll.mainclk); | ||
428 | clock /= (reg + 1); | ||
429 | } else if (reg == CLKMGR_L4_SP_CLK_SRC_PERPLL) { | ||
430 | /* identify PER PLL clock source */ | ||
431 | reg = readl(&clock_manager_base->per_pll.vco); | ||
432 | reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg); | ||
433 | if (reg == CLKMGR_VCO_SSRC_EOSC1) | ||
434 | clock = CONFIG_HPS_CLK_OSC1_HZ; | ||
435 | else if (reg == CLKMGR_VCO_SSRC_EOSC2) | ||
436 | clock = CONFIG_HPS_CLK_OSC2_HZ; | ||
437 | else if (reg == CLKMGR_VCO_SSRC_F2S) | ||
438 | clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ; | ||
439 | |||
440 | /* get the PER VCO clock */ | ||
441 | reg = readl(&clock_manager_base->per_pll.vco); | ||
442 | clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
443 | clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
444 | |||
445 | /* get the clock prior L4 SP divider (periph_base_clk) */ | ||
446 | reg = readl(&clock_manager_base->per_pll.perbaseclk); | ||
447 | clock /= (reg + 1); | ||
448 | } | ||
449 | |||
450 | /* get the L4 SP clock which supplied to UART */ | ||
451 | reg = readl(&clock_manager_base->main_pll.maindiv); | ||
452 | reg = CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_GET(reg); | ||
453 | clock = clock / (1 << reg); | ||
454 | |||
455 | return clock; | ||
456 | } | ||
457 | |||
458 | unsigned int cm_get_mmc_controller_clk_hz(void) | ||
459 | { | ||
460 | uint32_t reg, clock = 0; | ||
461 | |||
462 | /* identify the source of MMC clock */ | ||
463 | reg = readl(&clock_manager_base->per_pll.src); | ||
464 | reg = CLKMGR_PERPLLGRP_SRC_SDMMC_GET(reg); | ||
465 | |||
466 | if (reg == CLKMGR_SDMMC_CLK_SRC_F2S) { | ||
467 | clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ; | ||
468 | } else if (reg == CLKMGR_SDMMC_CLK_SRC_MAIN) { | ||
469 | /* get the main VCO clock */ | ||
470 | reg = readl(&clock_manager_base->main_pll.vco); | ||
471 | clock = CONFIG_HPS_CLK_OSC1_HZ / | ||
472 | (CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
473 | clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
474 | |||
475 | /* get the SDMMC clock */ | ||
476 | reg = readl(&clock_manager_base->main_pll.mainnandsdmmcclk); | ||
477 | clock /= (reg + 1); | ||
478 | } else if (reg == CLKMGR_SDMMC_CLK_SRC_PER) { | ||
479 | /* identify PER PLL clock source */ | ||
480 | reg = readl(&clock_manager_base->per_pll.vco); | ||
481 | reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg); | ||
482 | if (reg == CLKMGR_VCO_SSRC_EOSC1) | ||
483 | clock = CONFIG_HPS_CLK_OSC1_HZ; | ||
484 | else if (reg == CLKMGR_VCO_SSRC_EOSC2) | ||
485 | clock = CONFIG_HPS_CLK_OSC2_HZ; | ||
486 | else if (reg == CLKMGR_VCO_SSRC_F2S) | ||
487 | clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ; | ||
488 | |||
489 | /* get the PER VCO clock */ | ||
490 | reg = readl(&clock_manager_base->per_pll.vco); | ||
491 | clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
492 | clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
493 | |||
494 | /* get the SDMMC clock */ | ||
495 | reg = readl(&clock_manager_base->per_pll.pernandsdmmcclk); | ||
496 | clock /= (reg + 1); | ||
497 | } | ||
498 | |||
499 | /* further divide by 4 as we have fixed divider at wrapper */ | ||
500 | clock /= 4; | ||
501 | return clock; | ||
502 | } | ||
503 | |||
504 | unsigned int cm_get_qspi_controller_clk_hz(void) | ||
505 | { | ||
506 | uint32_t reg, clock = 0; | ||
507 | |||
508 | /* identify the source of QSPI clock */ | ||
509 | reg = readl(&clock_manager_base->per_pll.src); | ||
510 | reg = CLKMGR_PERPLLGRP_SRC_QSPI_GET(reg); | ||
511 | |||
512 | if (reg == CLKMGR_QSPI_CLK_SRC_F2S) { | ||
513 | clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ; | ||
514 | } else if (reg == CLKMGR_QSPI_CLK_SRC_MAIN) { | ||
515 | /* get the main VCO clock */ | ||
516 | reg = readl(&clock_manager_base->main_pll.vco); | ||
517 | clock = CONFIG_HPS_CLK_OSC1_HZ / | ||
518 | (CLKMGR_MAINPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
519 | clock *= (CLKMGR_MAINPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
520 | |||
521 | /* get the qspi clock */ | ||
522 | reg = readl(&clock_manager_base->main_pll.mainqspiclk); | ||
523 | clock /= (reg + 1); | ||
524 | } else if (reg == CLKMGR_QSPI_CLK_SRC_PER) { | ||
525 | /* identify PER PLL clock source */ | ||
526 | reg = readl(&clock_manager_base->per_pll.vco); | ||
527 | reg = CLKMGR_PERPLLGRP_VCO_SSRC_GET(reg); | ||
528 | if (reg == CLKMGR_VCO_SSRC_EOSC1) | ||
529 | clock = CONFIG_HPS_CLK_OSC1_HZ; | ||
530 | else if (reg == CLKMGR_VCO_SSRC_EOSC2) | ||
531 | clock = CONFIG_HPS_CLK_OSC2_HZ; | ||
532 | else if (reg == CLKMGR_VCO_SSRC_F2S) | ||
533 | clock = CONFIG_HPS_CLK_F2S_PER_REF_HZ; | ||
534 | |||
535 | /* get the PER VCO clock */ | ||
536 | reg = readl(&clock_manager_base->per_pll.vco); | ||
537 | clock /= (CLKMGR_PERPLLGRP_VCO_DENOM_GET(reg) + 1); | ||
538 | clock *= (CLKMGR_PERPLLGRP_VCO_NUMER_GET(reg) + 1); | ||
539 | |||
540 | /* get the qspi clock */ | ||
541 | reg = readl(&clock_manager_base->per_pll.perqspiclk); | ||
542 | clock /= (reg + 1); | ||
543 | } | ||
544 | |||
545 | return clock; | ||
546 | } | ||
547 | |||
548 | static void cm_print_clock_quick_summary(void) | ||
549 | { | ||
550 | printf("MPU %10ld kHz\n", cm_get_mpu_clk_hz() / 1000); | ||
551 | printf("DDR %10ld kHz\n", cm_get_sdram_clk_hz() / 1000); | ||
552 | printf("EOSC1 %8d kHz\n", CONFIG_HPS_CLK_OSC1_HZ / 1000); | ||
553 | printf("EOSC2 %8d kHz\n", CONFIG_HPS_CLK_OSC2_HZ / 1000); | ||
554 | printf("F2S_SDR_REF %8d kHz\n", CONFIG_HPS_CLK_F2S_SDR_REF_HZ / 1000); | ||
555 | printf("F2S_PER_REF %8d kHz\n", CONFIG_HPS_CLK_F2S_PER_REF_HZ / 1000); | ||
556 | printf("MMC %8d kHz\n", cm_get_mmc_controller_clk_hz() / 1000); | ||
557 | printf("QSPI %8d kHz\n", cm_get_qspi_controller_clk_hz() / 1000); | ||
558 | printf("UART %8d kHz\n", cm_get_l4_sp_clk_hz() / 1000); | ||
559 | } | ||
560 | |||
561 | int set_cpu_clk_info(void) | ||
562 | { | ||
563 | /* Calculate the clock frequencies required for drivers */ | ||
564 | cm_get_l4_sp_clk_hz(); | ||
565 | cm_get_mmc_controller_clk_hz(); | ||
566 | |||
567 | gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000; | ||
568 | gd->bd->bi_dsp_freq = 0; | ||
569 | gd->bd->bi_ddr_freq = cm_get_sdram_clk_hz() / 1000000; | ||
570 | |||
571 | return 0; | ||
572 | } | ||
573 | |||
574 | int do_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | ||
575 | { | ||
576 | cm_print_clock_quick_summary(); | ||
577 | return 0; | ||
578 | } | ||
579 | |||
580 | U_BOOT_CMD( | ||
581 | clocks, CONFIG_SYS_MAXARGS, 1, do_showclocks, | ||
582 | "display clocks", | ||
583 | "" | ||
584 | ); | ||
361 | 585 |
arch/arm/include/asm/arch-socfpga/clock_manager.h
1 | /* | 1 | /* |
2 | * Copyright (C) 2013 Altera Corporation <www.altera.com> | 2 | * Copyright (C) 2013 Altera Corporation <www.altera.com> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef _CLOCK_MANAGER_H_ | 7 | #ifndef _CLOCK_MANAGER_H_ |
8 | #define _CLOCK_MANAGER_H_ | 8 | #define _CLOCK_MANAGER_H_ |
9 | 9 | ||
10 | #ifndef __ASSEMBLER__ | ||
11 | /* Clock speed accessors */ | ||
12 | unsigned long cm_get_mpu_clk_hz(void); | ||
13 | unsigned long cm_get_sdram_clk_hz(void); | ||
14 | unsigned int cm_get_l4_sp_clk_hz(void); | ||
15 | unsigned int cm_get_mmc_controller_clk_hz(void); | ||
16 | unsigned int cm_get_qspi_controller_clk_hz(void); | ||
17 | #endif | ||
18 | |||
10 | typedef struct { | 19 | typedef struct { |
11 | /* main group */ | 20 | /* main group */ |
12 | uint32_t main_vco_base; | 21 | uint32_t main_vco_base; |
13 | uint32_t mpuclk; | 22 | uint32_t mpuclk; |
14 | uint32_t mainclk; | 23 | uint32_t mainclk; |
15 | uint32_t dbgatclk; | 24 | uint32_t dbgatclk; |
16 | uint32_t mainqspiclk; | 25 | uint32_t mainqspiclk; |
17 | uint32_t mainnandsdmmcclk; | 26 | uint32_t mainnandsdmmcclk; |
18 | uint32_t cfg2fuser0clk; | 27 | uint32_t cfg2fuser0clk; |
19 | uint32_t maindiv; | 28 | uint32_t maindiv; |
20 | uint32_t dbgdiv; | 29 | uint32_t dbgdiv; |
21 | uint32_t tracediv; | 30 | uint32_t tracediv; |
22 | uint32_t l4src; | 31 | uint32_t l4src; |
23 | 32 | ||
24 | /* peripheral group */ | 33 | /* peripheral group */ |
25 | uint32_t peri_vco_base; | 34 | uint32_t peri_vco_base; |
26 | uint32_t emac0clk; | 35 | uint32_t emac0clk; |
27 | uint32_t emac1clk; | 36 | uint32_t emac1clk; |
28 | uint32_t perqspiclk; | 37 | uint32_t perqspiclk; |
29 | uint32_t pernandsdmmcclk; | 38 | uint32_t pernandsdmmcclk; |
30 | uint32_t perbaseclk; | 39 | uint32_t perbaseclk; |
31 | uint32_t s2fuser1clk; | 40 | uint32_t s2fuser1clk; |
32 | uint32_t perdiv; | 41 | uint32_t perdiv; |
33 | uint32_t gpiodiv; | 42 | uint32_t gpiodiv; |
34 | uint32_t persrc; | 43 | uint32_t persrc; |
35 | 44 | ||
36 | /* sdram pll group */ | 45 | /* sdram pll group */ |
37 | uint32_t sdram_vco_base; | 46 | uint32_t sdram_vco_base; |
38 | uint32_t ddrdqsclk; | 47 | uint32_t ddrdqsclk; |
39 | uint32_t ddr2xdqsclk; | 48 | uint32_t ddr2xdqsclk; |
40 | uint32_t ddrdqclk; | 49 | uint32_t ddrdqclk; |
41 | uint32_t s2fuser2clk; | 50 | uint32_t s2fuser2clk; |
42 | } cm_config_t; | 51 | } cm_config_t; |
43 | 52 | ||
44 | extern void cm_basic_init(const cm_config_t *cfg); | 53 | extern void cm_basic_init(const cm_config_t *cfg); |
45 | 54 | ||
46 | struct socfpga_clock_manager_main_pll { | 55 | struct socfpga_clock_manager_main_pll { |
47 | u32 vco; | 56 | u32 vco; |
48 | u32 misc; | 57 | u32 misc; |
49 | u32 mpuclk; | 58 | u32 mpuclk; |
50 | u32 mainclk; | 59 | u32 mainclk; |
51 | u32 dbgatclk; | 60 | u32 dbgatclk; |
52 | u32 mainqspiclk; | 61 | u32 mainqspiclk; |
53 | u32 mainnandsdmmcclk; | 62 | u32 mainnandsdmmcclk; |
54 | u32 cfgs2fuser0clk; | 63 | u32 cfgs2fuser0clk; |
55 | u32 en; | 64 | u32 en; |
56 | u32 maindiv; | 65 | u32 maindiv; |
57 | u32 dbgdiv; | 66 | u32 dbgdiv; |
58 | u32 tracediv; | 67 | u32 tracediv; |
59 | u32 l4src; | 68 | u32 l4src; |
60 | u32 stat; | 69 | u32 stat; |
61 | u32 _pad_0x38_0x40[2]; | 70 | u32 _pad_0x38_0x40[2]; |
62 | }; | 71 | }; |
63 | 72 | ||
64 | struct socfpga_clock_manager_per_pll { | 73 | struct socfpga_clock_manager_per_pll { |
65 | u32 vco; | 74 | u32 vco; |
66 | u32 misc; | 75 | u32 misc; |
67 | u32 emac0clk; | 76 | u32 emac0clk; |
68 | u32 emac1clk; | 77 | u32 emac1clk; |
69 | u32 perqspiclk; | 78 | u32 perqspiclk; |
70 | u32 pernandsdmmcclk; | 79 | u32 pernandsdmmcclk; |
71 | u32 perbaseclk; | 80 | u32 perbaseclk; |
72 | u32 s2fuser1clk; | 81 | u32 s2fuser1clk; |
73 | u32 en; | 82 | u32 en; |
74 | u32 div; | 83 | u32 div; |
75 | u32 gpiodiv; | 84 | u32 gpiodiv; |
76 | u32 src; | 85 | u32 src; |
77 | u32 stat; | 86 | u32 stat; |
78 | u32 _pad_0x34_0x40[3]; | 87 | u32 _pad_0x34_0x40[3]; |
79 | }; | 88 | }; |
80 | 89 | ||
81 | struct socfpga_clock_manager_sdr_pll { | 90 | struct socfpga_clock_manager_sdr_pll { |
82 | u32 vco; | 91 | u32 vco; |
83 | u32 ctrl; | 92 | u32 ctrl; |
84 | u32 ddrdqsclk; | 93 | u32 ddrdqsclk; |
85 | u32 ddr2xdqsclk; | 94 | u32 ddr2xdqsclk; |
86 | u32 ddrdqclk; | 95 | u32 ddrdqclk; |
87 | u32 s2fuser2clk; | 96 | u32 s2fuser2clk; |
88 | u32 en; | 97 | u32 en; |
89 | u32 stat; | 98 | u32 stat; |
90 | }; | 99 | }; |
91 | 100 | ||
101 | struct socfpga_clock_manager_altera { | ||
102 | u32 mpuclk; | ||
103 | u32 mainclk; | ||
104 | }; | ||
105 | |||
92 | struct socfpga_clock_manager { | 106 | struct socfpga_clock_manager { |
93 | u32 ctrl; | 107 | u32 ctrl; |
94 | u32 bypass; | 108 | u32 bypass; |
95 | u32 inter; | 109 | u32 inter; |
96 | u32 intren; | 110 | u32 intren; |
97 | u32 dbctrl; | 111 | u32 dbctrl; |
98 | u32 stat; | 112 | u32 stat; |
99 | u32 _pad_0x18_0x3f[10]; | 113 | u32 _pad_0x18_0x3f[10]; |
100 | struct socfpga_clock_manager_main_pll main_pll; | 114 | struct socfpga_clock_manager_main_pll main_pll; |
101 | struct socfpga_clock_manager_per_pll per_pll; | 115 | struct socfpga_clock_manager_per_pll per_pll; |
102 | struct socfpga_clock_manager_sdr_pll sdr_pll; | 116 | struct socfpga_clock_manager_sdr_pll sdr_pll; |
103 | u32 _pad_0xe0_0x200[72]; | 117 | struct socfpga_clock_manager_altera altera; |
118 | u32 _pad_0xe8_0x200[70]; | ||
104 | }; | 119 | }; |
105 | 120 | ||
106 | #define CLKMGR_CTRL_SAFEMODE_MASK 0x00000001 | 121 | #define CLKMGR_CTRL_SAFEMODE_MASK 0x00000001 |
107 | #define CLKMGR_CTRL_SAFEMODE_SET(x) (((x) << 0) & 0x00000001) | 122 | #define CLKMGR_CTRL_SAFEMODE_SET(x) (((x) << 0) & 0x00000001) |
108 | 123 | ||
109 | #define CLKMGR_BYPASS_MAINPLL_SET(x) (((x) << 0) & 0x00000001) | 124 | #define CLKMGR_BYPASS_MAINPLL_SET(x) (((x) << 0) & 0x00000001) |
110 | #define CLKMGR_BYPASS_PERPLLSRC_SET(x) (((x) << 4) & 0x00000010) | 125 | #define CLKMGR_BYPASS_PERPLLSRC_SET(x) (((x) << 4) & 0x00000010) |
111 | #define CLKMGR_BYPASS_PERPLL_SET(x) (((x) << 3) & 0x00000008) | 126 | #define CLKMGR_BYPASS_PERPLL_SET(x) (((x) << 3) & 0x00000008) |
112 | #define CLKMGR_BYPASS_SDRPLLSRC_SET(x) (((x) << 2) & 0x00000004) | 127 | #define CLKMGR_BYPASS_SDRPLLSRC_SET(x) (((x) << 2) & 0x00000004) |
113 | #define CLKMGR_BYPASS_SDRPLL_SET(x) (((x) << 1) & 0x00000002) | 128 | #define CLKMGR_BYPASS_SDRPLL_SET(x) (((x) << 1) & 0x00000002) |
114 | 129 | ||
115 | #define CLKMGR_INTER_MAINPLLLOCKED_MASK 0x00000040 | 130 | #define CLKMGR_INTER_MAINPLLLOCKED_MASK 0x00000040 |
116 | #define CLKMGR_INTER_PERPLLLOCKED_MASK 0x00000080 | 131 | #define CLKMGR_INTER_PERPLLLOCKED_MASK 0x00000080 |
117 | #define CLKMGR_INTER_SDRPLLLOCKED_MASK 0x00000100 | 132 | #define CLKMGR_INTER_SDRPLLLOCKED_MASK 0x00000100 |
118 | 133 | ||
119 | /* Main PLL */ | 134 | /* Main PLL */ |
120 | #define CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(x) (((x) << 0) & 0x00000001) | 135 | #define CLKMGR_MAINPLLGRP_VCO_BGPWRDN_SET(x) (((x) << 0) & 0x00000001) |
136 | #define CLKMGR_MAINPLLGRP_VCO_DENOM_GET(x) (((x) & 0x003f0000) >> 16) | ||
121 | #define CLKMGR_MAINPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000) | 137 | #define CLKMGR_MAINPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000) |
122 | #define CLKMGR_MAINPLLGRP_VCO_EN_SET(x) (((x) << 1) & 0x00000002) | 138 | #define CLKMGR_MAINPLLGRP_VCO_EN_SET(x) (((x) << 1) & 0x00000002) |
139 | #define CLKMGR_MAINPLLGRP_VCO_NUMER_GET(x) (((x) & 0x0000fff8) >> 3) | ||
123 | #define CLKMGR_MAINPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8) | 140 | #define CLKMGR_MAINPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8) |
124 | #define CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK 0x01000000 | 141 | #define CLKMGR_MAINPLLGRP_VCO_OUTRESETALL_MASK 0x01000000 |
125 | #define CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(x) (((x) << 2) & 0x00000004) | 142 | #define CLKMGR_MAINPLLGRP_VCO_PWRDN_SET(x) (((x) << 2) & 0x00000004) |
126 | #define CLKMGR_MAINPLLGRP_VCO_REGEXTSEL_MASK 0x80000000 | 143 | #define CLKMGR_MAINPLLGRP_VCO_REGEXTSEL_MASK 0x80000000 |
127 | #define CLKMGR_MAINPLLGRP_VCO_RESET_VALUE 0x8001000d | 144 | #define CLKMGR_MAINPLLGRP_VCO_RESET_VALUE 0x8001000d |
128 | 145 | ||
129 | #define CLKMGR_MAINPLLGRP_MPUCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 146 | #define CLKMGR_MAINPLLGRP_MPUCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
130 | 147 | ||
131 | #define CLKMGR_MAINPLLGRP_MAINCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 148 | #define CLKMGR_MAINPLLGRP_MAINCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
132 | 149 | ||
133 | #define CLKMGR_MAINPLLGRP_DBGATCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 150 | #define CLKMGR_MAINPLLGRP_DBGATCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
134 | 151 | ||
135 | #define CLKMGR_MAINPLLGRP_MAINQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 152 | #define CLKMGR_MAINPLLGRP_MAINQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
136 | 153 | ||
137 | #define CLKMGR_MAINPLLGRP_MAINNANDSDMMCCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 154 | #define CLKMGR_MAINPLLGRP_MAINNANDSDMMCCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
138 | 155 | ||
139 | #define CLKMGR_MAINPLLGRP_CFGS2FUSER0CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 156 | #define CLKMGR_MAINPLLGRP_CFGS2FUSER0CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
140 | 157 | ||
141 | #define CLKMGR_MAINPLLGRP_EN_DBGATCLK_MASK 0x00000010 | 158 | #define CLKMGR_MAINPLLGRP_EN_DBGATCLK_MASK 0x00000010 |
142 | #define CLKMGR_MAINPLLGRP_EN_DBGCLK_MASK 0x00000020 | 159 | #define CLKMGR_MAINPLLGRP_EN_DBGCLK_MASK 0x00000020 |
143 | #define CLKMGR_MAINPLLGRP_EN_DBGTIMERCLK_MASK 0x00000080 | 160 | #define CLKMGR_MAINPLLGRP_EN_DBGTIMERCLK_MASK 0x00000080 |
144 | #define CLKMGR_MAINPLLGRP_EN_DBGTRACECLK_MASK 0x00000040 | 161 | #define CLKMGR_MAINPLLGRP_EN_DBGTRACECLK_MASK 0x00000040 |
145 | #define CLKMGR_MAINPLLGRP_EN_L4MPCLK_MASK 0x00000004 | 162 | #define CLKMGR_MAINPLLGRP_EN_L4MPCLK_MASK 0x00000004 |
146 | #define CLKMGR_MAINPLLGRP_EN_S2FUSER0CLK_MASK 0x00000200 | 163 | #define CLKMGR_MAINPLLGRP_EN_S2FUSER0CLK_MASK 0x00000200 |
147 | 164 | ||
148 | #define CLKMGR_MAINPLLGRP_MAINDIV_L3MPCLK_SET(x) (((x) << 0) & 0x00000003) | 165 | #define CLKMGR_MAINPLLGRP_MAINDIV_L3MPCLK_SET(x) (((x) << 0) & 0x00000003) |
149 | #define CLKMGR_MAINPLLGRP_MAINDIV_L3SPCLK_SET(x) (((x) << 2) & 0x0000000c) | 166 | #define CLKMGR_MAINPLLGRP_MAINDIV_L3SPCLK_SET(x) (((x) << 2) & 0x0000000c) |
150 | #define CLKMGR_MAINPLLGRP_MAINDIV_L4MPCLK_SET(x) (((x) << 4) & 0x00000070) | 167 | #define CLKMGR_MAINPLLGRP_MAINDIV_L4MPCLK_SET(x) (((x) << 4) & 0x00000070) |
151 | #define CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_SET(x) (((x) << 7) & 0x00000380) | 168 | #define CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_GET(x) (((x) & 0x00000380) >> 7) |
169 | #define CLKMGR_MAINPLLGRP_MAINDIV_L4SPCLK_SET(x) (((x) << 7) & 0x00000380) | ||
152 | 170 | ||
153 | #define CLKMGR_MAINPLLGRP_DBGDIV_DBGATCLK_SET(x) (((x) << 0) & 0x00000003) | 171 | #define CLKMGR_MAINPLLGRP_DBGDIV_DBGATCLK_SET(x) (((x) << 0) & 0x00000003) |
154 | #define CLKMGR_MAINPLLGRP_DBGDIV_DBGCLK_SET(x) (((x) << 2) & 0x0000000c) | 172 | #define CLKMGR_MAINPLLGRP_DBGDIV_DBGCLK_SET(x) (((x) << 2) & 0x0000000c) |
155 | 173 | ||
156 | #define CLKMGR_MAINPLLGRP_TRACEDIV_TRACECLK_SET(x) (((x) << 0) & 0x00000007) | 174 | #define CLKMGR_MAINPLLGRP_TRACEDIV_TRACECLK_SET(x) (((x) << 0) & 0x00000007) |
157 | 175 | ||
158 | #define CLKMGR_MAINPLLGRP_L4SRC_L4MP_SET(x) (((x) << 0) & 0x00000001) | 176 | #define CLKMGR_MAINPLLGRP_L4SRC_L4MP_SET(x) (((x) << 0) & 0x00000001) |
177 | #define CLKMGR_MAINPLLGRP_L4SRC_L4SP_GET(x) (((x) & 0x00000002) >> 1) | ||
159 | #define CLKMGR_MAINPLLGRP_L4SRC_L4SP_SET(x) (((x) << 1) & 0x00000002) | 178 | #define CLKMGR_MAINPLLGRP_L4SRC_L4SP_SET(x) (((x) << 1) & 0x00000002) |
160 | #define CLKMGR_MAINPLLGRP_L4SRC_RESET_VALUE 0x00000000 | 179 | #define CLKMGR_MAINPLLGRP_L4SRC_RESET_VALUE 0x00000000 |
180 | #define CLKMGR_L4_SP_CLK_SRC_MAINPLL 0x0 | ||
181 | #define CLKMGR_L4_SP_CLK_SRC_PERPLL 0x1 | ||
161 | 182 | ||
162 | /* Per PLL */ | 183 | /* Per PLL */ |
184 | #define CLKMGR_PERPLLGRP_VCO_DENOM_GET(x) (((x) & 0x003f0000) >> 16) | ||
163 | #define CLKMGR_PERPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000) | 185 | #define CLKMGR_PERPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000) |
186 | #define CLKMGR_PERPLLGRP_VCO_NUMER_GET(x) (((x) & 0x0000fff8) >> 3) | ||
164 | #define CLKMGR_PERPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8) | 187 | #define CLKMGR_PERPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8) |
165 | #define CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK 0x01000000 | 188 | #define CLKMGR_PERPLLGRP_VCO_OUTRESETALL_MASK 0x01000000 |
166 | #define CLKMGR_PERPLLGRP_VCO_PSRC_SET(x) (((x) << 22) & 0x00c00000) | 189 | #define CLKMGR_PERPLLGRP_VCO_PSRC_SET(x) (((x) << 22) & 0x00c00000) |
167 | #define CLKMGR_PERPLLGRP_VCO_REGEXTSEL_MASK 0x80000000 | 190 | #define CLKMGR_PERPLLGRP_VCO_REGEXTSEL_MASK 0x80000000 |
168 | #define CLKMGR_PERPLLGRP_VCO_RESET_VALUE 0x8001000d | 191 | #define CLKMGR_PERPLLGRP_VCO_RESET_VALUE 0x8001000d |
192 | #define CLKMGR_PERPLLGRP_VCO_SSRC_GET(x) (((x) & 0x00c00000) >> 22) | ||
193 | #define CLKMGR_VCO_SSRC_EOSC1 0x0 | ||
194 | #define CLKMGR_VCO_SSRC_EOSC2 0x1 | ||
195 | #define CLKMGR_VCO_SSRC_F2S 0x2 | ||
169 | 196 | ||
170 | #define CLKMGR_PERPLLGRP_EMAC0CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 197 | #define CLKMGR_PERPLLGRP_EMAC0CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
171 | 198 | ||
172 | #define CLKMGR_PERPLLGRP_EMAC1CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 199 | #define CLKMGR_PERPLLGRP_EMAC1CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
173 | 200 | ||
174 | #define CLKMGR_PERPLLGRP_PERQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 201 | #define CLKMGR_PERPLLGRP_PERQSPICLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
175 | 202 | ||
176 | #define CLKMGR_PERPLLGRP_PERNANDSDMMCCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 203 | #define CLKMGR_PERPLLGRP_PERNANDSDMMCCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
177 | 204 | ||
178 | #define CLKMGR_PERPLLGRP_PERBASECLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 205 | #define CLKMGR_PERPLLGRP_PERBASECLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
179 | 206 | ||
180 | #define CLKMGR_PERPLLGRP_S2FUSER1CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 207 | #define CLKMGR_PERPLLGRP_S2FUSER1CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
181 | 208 | ||
182 | #define CLKMGR_PERPLLGRP_EN_NANDCLK_MASK 0x00000400 | 209 | #define CLKMGR_PERPLLGRP_EN_NANDCLK_MASK 0x00000400 |
183 | #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK 0x00000100 | 210 | #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK 0x00000100 |
184 | 211 | ||
185 | #define CLKMGR_PERPLLGRP_DIV_CAN0CLK_SET(x) (((x) << 6) & 0x000001c0) | 212 | #define CLKMGR_PERPLLGRP_DIV_CAN0CLK_SET(x) (((x) << 6) & 0x000001c0) |
186 | #define CLKMGR_PERPLLGRP_DIV_CAN1CLK_SET(x) (((x) << 9) & 0x00000e00) | 213 | #define CLKMGR_PERPLLGRP_DIV_CAN1CLK_SET(x) (((x) << 9) & 0x00000e00) |
187 | #define CLKMGR_PERPLLGRP_DIV_SPIMCLK_SET(x) (((x) << 3) & 0x00000038) | 214 | #define CLKMGR_PERPLLGRP_DIV_SPIMCLK_SET(x) (((x) << 3) & 0x00000038) |
188 | #define CLKMGR_PERPLLGRP_DIV_SPIMCLK_SET(x) (((x) << 3) & 0x00000038) | 215 | #define CLKMGR_PERPLLGRP_DIV_SPIMCLK_SET(x) (((x) << 3) & 0x00000038) |
189 | #define CLKMGR_PERPLLGRP_DIV_USBCLK_SET(x) (((x) << 0) & 0x00000007) | 216 | #define CLKMGR_PERPLLGRP_DIV_USBCLK_SET(x) (((x) << 0) & 0x00000007) |
190 | 217 | ||
191 | #define CLKMGR_PERPLLGRP_GPIODIV_GPIODBCLK_SET(x) (((x) << 0) & 0x00ffffff) | 218 | #define CLKMGR_PERPLLGRP_GPIODIV_GPIODBCLK_SET(x) (((x) << 0) & 0x00ffffff) |
192 | 219 | ||
193 | #define CLKMGR_PERPLLGRP_SRC_NAND_SET(x) (((x) << 2) & 0x0000000c) | 220 | #define CLKMGR_PERPLLGRP_SRC_NAND_SET(x) (((x) << 2) & 0x0000000c) |
221 | #define CLKMGR_PERPLLGRP_SRC_QSPI_GET(x) (((x) & 0x00000030) >> 4) | ||
194 | #define CLKMGR_PERPLLGRP_SRC_QSPI_SET(x) (((x) << 4) & 0x00000030) | 222 | #define CLKMGR_PERPLLGRP_SRC_QSPI_SET(x) (((x) << 4) & 0x00000030) |
195 | #define CLKMGR_PERPLLGRP_SRC_RESET_VALUE 0x00000015 | 223 | #define CLKMGR_PERPLLGRP_SRC_RESET_VALUE 0x00000015 |
224 | #define CLKMGR_PERPLLGRP_SRC_SDMMC_GET(x) (((x) & 0x00000003) >> 0) | ||
196 | #define CLKMGR_PERPLLGRP_SRC_SDMMC_SET(x) (((x) << 0) & 0x00000003) | 225 | #define CLKMGR_PERPLLGRP_SRC_SDMMC_SET(x) (((x) << 0) & 0x00000003) |
226 | #define CLKMGR_SDMMC_CLK_SRC_F2S 0x0 | ||
227 | #define CLKMGR_SDMMC_CLK_SRC_MAIN 0x1 | ||
228 | #define CLKMGR_SDMMC_CLK_SRC_PER 0x2 | ||
229 | #define CLKMGR_QSPI_CLK_SRC_F2S 0x0 | ||
230 | #define CLKMGR_QSPI_CLK_SRC_MAIN 0x1 | ||
231 | #define CLKMGR_QSPI_CLK_SRC_PER 0x2 | ||
197 | 232 | ||
198 | /* SDR PLL */ | 233 | /* SDR PLL */ |
234 | #define CLKMGR_SDRPLLGRP_VCO_DENOM_GET(x) (((x) & 0x003f0000) >> 16) | ||
199 | #define CLKMGR_SDRPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000) | 235 | #define CLKMGR_SDRPLLGRP_VCO_DENOM_SET(x) (((x) << 16) & 0x003f0000) |
236 | #define CLKMGR_SDRPLLGRP_VCO_NUMER_GET(x) (((x) & 0x0000fff8) >> 3) | ||
200 | #define CLKMGR_SDRPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8) | 237 | #define CLKMGR_SDRPLLGRP_VCO_NUMER_SET(x) (((x) << 3) & 0x0000fff8) |
201 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000) | 238 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000) |
202 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000) | 239 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESETALL_SET(x) (((x) << 24) & 0x01000000) |
203 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESET_MASK 0x7e000000 | 240 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESET_MASK 0x7e000000 |
204 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(x) (((x) << 25) & 0x7e000000) | 241 | #define CLKMGR_SDRPLLGRP_VCO_OUTRESET_SET(x) (((x) << 25) & 0x7e000000) |
205 | #define CLKMGR_SDRPLLGRP_VCO_REGEXTSEL_MASK 0x80000000 | 242 | #define CLKMGR_SDRPLLGRP_VCO_REGEXTSEL_MASK 0x80000000 |
206 | #define CLKMGR_SDRPLLGRP_VCO_RESET_VALUE 0x8001000d | 243 | #define CLKMGR_SDRPLLGRP_VCO_RESET_VALUE 0x8001000d |
244 | #define CLKMGR_SDRPLLGRP_VCO_SSRC_GET(x) (((x) & 0x00c00000) >> 22) | ||
207 | #define CLKMGR_SDRPLLGRP_VCO_SSRC_SET(x) (((x) << 22) & 0x00c00000) | 245 | #define CLKMGR_SDRPLLGRP_VCO_SSRC_SET(x) (((x) << 22) & 0x00c00000) |
208 | 246 | ||
247 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_GET(x) (((x) & 0x000001ff) >> 0) | ||
209 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_MASK 0x000001ff | 248 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_MASK 0x000001ff |
210 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 249 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
211 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_MASK 0x001ffe00 | 250 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_MASK 0x001ffe00 |
212 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) | 251 | #define CLKMGR_SDRPLLGRP_DDRDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) |
213 | 252 | ||
214 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_MASK 0x000001ff | 253 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_MASK 0x000001ff |
215 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 254 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
216 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_MASK 0x001ffe00 | 255 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_MASK 0x001ffe00 |
217 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) | 256 | #define CLKMGR_SDRPLLGRP_DDR2XDQSCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) |
218 | 257 | ||
219 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_MASK 0x000001ff | 258 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_MASK 0x000001ff |
220 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 259 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
221 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_MASK 0x001ffe00 | 260 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_MASK 0x001ffe00 |
222 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) | 261 | #define CLKMGR_SDRPLLGRP_DDRDQCLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) |
223 | 262 | ||
224 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_MASK 0x000001ff | 263 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_MASK 0x000001ff |
225 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) | 264 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_CNT_SET(x) (((x) << 0) & 0x000001ff) |
226 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_MASK 0x001ffe00 | 265 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_MASK 0x001ffe00 |
227 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) | 266 | #define CLKMGR_SDRPLLGRP_S2FUSER2CLK_PHASE_SET(x) (((x) << 9) & 0x00000e00) |
228 | 267 | ||
229 | #define MAIN_VCO_BASE \ | 268 | #define MAIN_VCO_BASE \ |
230 | (CLKMGR_MAINPLLGRP_VCO_DENOM_SET(CONFIG_HPS_MAINPLLGRP_VCO_DENOM) | \ | 269 | (CLKMGR_MAINPLLGRP_VCO_DENOM_SET(CONFIG_HPS_MAINPLLGRP_VCO_DENOM) | \ |
231 | CLKMGR_MAINPLLGRP_VCO_NUMER_SET(CONFIG_HPS_MAINPLLGRP_VCO_NUMER)) | 270 | CLKMGR_MAINPLLGRP_VCO_NUMER_SET(CONFIG_HPS_MAINPLLGRP_VCO_NUMER)) |
232 | 271 | ||
233 | #define PERI_VCO_BASE \ | 272 | #define PERI_VCO_BASE \ |
234 | (CLKMGR_PERPLLGRP_VCO_PSRC_SET(CONFIG_HPS_PERPLLGRP_VCO_PSRC) | \ | 273 | (CLKMGR_PERPLLGRP_VCO_PSRC_SET(CONFIG_HPS_PERPLLGRP_VCO_PSRC) | \ |
235 | CLKMGR_PERPLLGRP_VCO_DENOM_SET(CONFIG_HPS_PERPLLGRP_VCO_DENOM) | \ | 274 | CLKMGR_PERPLLGRP_VCO_DENOM_SET(CONFIG_HPS_PERPLLGRP_VCO_DENOM) | \ |
236 | CLKMGR_PERPLLGRP_VCO_NUMER_SET(CONFIG_HPS_PERPLLGRP_VCO_NUMER)) | 275 | CLKMGR_PERPLLGRP_VCO_NUMER_SET(CONFIG_HPS_PERPLLGRP_VCO_NUMER)) |
237 | 276 | ||
238 | #define SDR_VCO_BASE \ | 277 | #define SDR_VCO_BASE \ |
239 | (CLKMGR_SDRPLLGRP_VCO_SSRC_SET(CONFIG_HPS_SDRPLLGRP_VCO_SSRC) | \ | 278 | (CLKMGR_SDRPLLGRP_VCO_SSRC_SET(CONFIG_HPS_SDRPLLGRP_VCO_SSRC) | \ |
240 | CLKMGR_SDRPLLGRP_VCO_DENOM_SET(CONFIG_HPS_SDRPLLGRP_VCO_DENOM) | \ | 279 | CLKMGR_SDRPLLGRP_VCO_DENOM_SET(CONFIG_HPS_SDRPLLGRP_VCO_DENOM) | \ |
241 | CLKMGR_SDRPLLGRP_VCO_NUMER_SET(CONFIG_HPS_SDRPLLGRP_VCO_NUMER)) | 280 | CLKMGR_SDRPLLGRP_VCO_NUMER_SET(CONFIG_HPS_SDRPLLGRP_VCO_NUMER)) |
242 | 281 | ||
243 | #endif /* _CLOCK_MANAGER_H_ */ | 282 | #endif /* _CLOCK_MANAGER_H_ */ |
244 | 283 |
include/configs/socfpga_cyclone5.h
1 | /* | 1 | /* |
2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> | 2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | #ifndef __CONFIG_H | 6 | #ifndef __CONFIG_H |
7 | #define __CONFIG_H | 7 | #define __CONFIG_H |
8 | 8 | ||
9 | #include <asm/arch/socfpga_base_addrs.h> | 9 | #include <asm/arch/socfpga_base_addrs.h> |
10 | #include "../../board/altera/socfpga/pinmux_config.h" | 10 | #include "../../board/altera/socfpga/pinmux_config.h" |
11 | #include "../../board/altera/socfpga/iocsr_config.h" | 11 | #include "../../board/altera/socfpga/iocsr_config.h" |
12 | #include "../../board/altera/socfpga/pll_config.h" | 12 | #include "../../board/altera/socfpga/pll_config.h" |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * High level configuration | 15 | * High level configuration |
16 | */ | 16 | */ |
17 | /* Virtual target or real hardware */ | 17 | /* Virtual target or real hardware */ |
18 | #undef CONFIG_SOCFPGA_VIRTUAL_TARGET | 18 | #undef CONFIG_SOCFPGA_VIRTUAL_TARGET |
19 | 19 | ||
20 | #define CONFIG_ARMV7 | 20 | #define CONFIG_ARMV7 |
21 | #define CONFIG_SYS_DCACHE_OFF | 21 | #define CONFIG_SYS_DCACHE_OFF |
22 | #undef CONFIG_USE_IRQ | 22 | #undef CONFIG_USE_IRQ |
23 | 23 | ||
24 | #define CONFIG_MISC_INIT_R | 24 | #define CONFIG_MISC_INIT_R |
25 | #define CONFIG_SINGLE_BOOTLOADER | 25 | #define CONFIG_SINGLE_BOOTLOADER |
26 | #define CONFIG_SOCFPGA | 26 | #define CONFIG_SOCFPGA |
27 | #define CONFIG_CLOCKS | ||
27 | 28 | ||
28 | /* base address for .text section */ | 29 | /* base address for .text section */ |
29 | #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET | 30 | #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET |
30 | #define CONFIG_SYS_TEXT_BASE 0x08000040 | 31 | #define CONFIG_SYS_TEXT_BASE 0x08000040 |
31 | #else | 32 | #else |
32 | #define CONFIG_SYS_TEXT_BASE 0x01000040 | 33 | #define CONFIG_SYS_TEXT_BASE 0x01000040 |
33 | #endif | 34 | #endif |
34 | #define CONFIG_SYS_LOAD_ADDR 0x7fc0 | 35 | #define CONFIG_SYS_LOAD_ADDR 0x7fc0 |
35 | 36 | ||
36 | /* Console I/O Buffer Size */ | 37 | /* Console I/O Buffer Size */ |
37 | #define CONFIG_SYS_CBSIZE 256 | 38 | #define CONFIG_SYS_CBSIZE 256 |
38 | /* Monitor Command Prompt */ | 39 | /* Monitor Command Prompt */ |
39 | #define CONFIG_SYS_PROMPT "SOCFPGA_CYCLONE5 # " | 40 | #define CONFIG_SYS_PROMPT "SOCFPGA_CYCLONE5 # " |
40 | #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ | 41 | #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ |
41 | sizeof(CONFIG_SYS_PROMPT) + 16) | 42 | sizeof(CONFIG_SYS_PROMPT) + 16) |
42 | 43 | ||
43 | /* | 44 | /* |
44 | * Display CPU and Board Info | 45 | * Display CPU and Board Info |
45 | */ | 46 | */ |
46 | #define CONFIG_DISPLAY_CPUINFO | 47 | #define CONFIG_DISPLAY_CPUINFO |
47 | #define CONFIG_DISPLAY_BOARDINFO | 48 | #define CONFIG_DISPLAY_BOARDINFO |
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Enable early stage initialization at C environment | 51 | * Enable early stage initialization at C environment |
51 | */ | 52 | */ |
52 | #define CONFIG_BOARD_EARLY_INIT_F | 53 | #define CONFIG_BOARD_EARLY_INIT_F |
53 | 54 | ||
54 | /* flat device tree */ | 55 | /* flat device tree */ |
55 | #define CONFIG_OF_LIBFDT | 56 | #define CONFIG_OF_LIBFDT |
56 | /* skip updating the FDT blob */ | 57 | /* skip updating the FDT blob */ |
57 | #define CONFIG_FDT_BLOB_SKIP_UPDATE | 58 | #define CONFIG_FDT_BLOB_SKIP_UPDATE |
58 | /* Initial Memory map size for Linux, minus 4k alignment for DFT blob */ | 59 | /* Initial Memory map size for Linux, minus 4k alignment for DFT blob */ |
59 | #define CONFIG_SYS_BOOTMAPSZ ((256*1024*1024) - (4*1024)) | 60 | #define CONFIG_SYS_BOOTMAPSZ ((256*1024*1024) - (4*1024)) |
60 | 61 | ||
61 | #define CONFIG_SPL_RAM_DEVICE | 62 | #define CONFIG_SPL_RAM_DEVICE |
62 | #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR | 63 | #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR |
63 | #define CONFIG_SYS_SPL_MALLOC_START ((unsigned long) (&__malloc_start)) | 64 | #define CONFIG_SYS_SPL_MALLOC_START ((unsigned long) (&__malloc_start)) |
64 | #define CONFIG_SYS_SPL_MALLOC_SIZE (&__malloc_end - &__malloc_start) | 65 | #define CONFIG_SYS_SPL_MALLOC_SIZE (&__malloc_end - &__malloc_start) |
65 | 66 | ||
66 | /* | 67 | /* |
67 | * Memory allocation (MALLOC) | 68 | * Memory allocation (MALLOC) |
68 | */ | 69 | */ |
69 | /* Room required on the stack for the environment data */ | 70 | /* Room required on the stack for the environment data */ |
70 | #define CONFIG_ENV_SIZE 1024 | 71 | #define CONFIG_ENV_SIZE 1024 |
71 | /* Size of DRAM reserved for malloc() use */ | 72 | /* Size of DRAM reserved for malloc() use */ |
72 | #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) | 73 | #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) |
73 | 74 | ||
74 | /* SP location before relocation, must use scratch RAM */ | 75 | /* SP location before relocation, must use scratch RAM */ |
75 | #define CONFIG_SYS_INIT_RAM_ADDR 0xFFFF0000 | 76 | #define CONFIG_SYS_INIT_RAM_ADDR 0xFFFF0000 |
76 | /* Reserving 0x100 space at back of scratch RAM for debug info */ | 77 | /* Reserving 0x100 space at back of scratch RAM for debug info */ |
77 | #define CONFIG_SYS_INIT_RAM_SIZE (0x10000 - 0x100) | 78 | #define CONFIG_SYS_INIT_RAM_SIZE (0x10000 - 0x100) |
78 | /* Stack pointer prior relocation, must situated at on-chip RAM */ | 79 | /* Stack pointer prior relocation, must situated at on-chip RAM */ |
79 | #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \ | 80 | #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + \ |
80 | CONFIG_SYS_INIT_RAM_SIZE - \ | 81 | CONFIG_SYS_INIT_RAM_SIZE - \ |
81 | GENERATED_GBL_DATA_SIZE) | 82 | GENERATED_GBL_DATA_SIZE) |
82 | 83 | ||
83 | 84 | ||
84 | /* | 85 | /* |
85 | * Command line configuration. | 86 | * Command line configuration. |
86 | */ | 87 | */ |
87 | #define CONFIG_SYS_NO_FLASH | 88 | #define CONFIG_SYS_NO_FLASH |
88 | #include <config_cmd_default.h> | 89 | #include <config_cmd_default.h> |
89 | /* FAT file system support */ | 90 | /* FAT file system support */ |
90 | #define CONFIG_CMD_FAT | 91 | #define CONFIG_CMD_FAT |
91 | 92 | ||
92 | 93 | ||
93 | /* | 94 | /* |
94 | * Misc | 95 | * Misc |
95 | */ | 96 | */ |
96 | #define CONFIG_DOS_PARTITION 1 | 97 | #define CONFIG_DOS_PARTITION 1 |
97 | 98 | ||
98 | #ifdef CONFIG_SPL_BUILD | 99 | #ifdef CONFIG_SPL_BUILD |
99 | #undef CONFIG_PARTITIONS | 100 | #undef CONFIG_PARTITIONS |
100 | #endif | 101 | #endif |
101 | 102 | ||
102 | /* | 103 | /* |
103 | * Environment setup | 104 | * Environment setup |
104 | */ | 105 | */ |
105 | 106 | ||
106 | /* Delay before automatically booting the default image */ | 107 | /* Delay before automatically booting the default image */ |
107 | #define CONFIG_BOOTDELAY 3 | 108 | #define CONFIG_BOOTDELAY 3 |
108 | /* Enable auto completion of commands using TAB */ | 109 | /* Enable auto completion of commands using TAB */ |
109 | #define CONFIG_AUTO_COMPLETE | 110 | #define CONFIG_AUTO_COMPLETE |
110 | /* use "hush" command parser */ | 111 | /* use "hush" command parser */ |
111 | #define CONFIG_SYS_HUSH_PARSER | 112 | #define CONFIG_SYS_HUSH_PARSER |
112 | #define CONFIG_SYS_PROMPT_HUSH_PS2 "> " | 113 | #define CONFIG_SYS_PROMPT_HUSH_PS2 "> " |
113 | #define CONFIG_CMD_RUN | 114 | #define CONFIG_CMD_RUN |
114 | 115 | ||
115 | #define CONFIG_BOOTCOMMAND "run ramboot" | 116 | #define CONFIG_BOOTCOMMAND "run ramboot" |
116 | 117 | ||
117 | /* | 118 | /* |
118 | * arguments passed to the bootm command. The value of | 119 | * arguments passed to the bootm command. The value of |
119 | * CONFIG_BOOTARGS goes into the environment value "bootargs". | 120 | * CONFIG_BOOTARGS goes into the environment value "bootargs". |
120 | * Do note the value will overide also the chosen node in FDT blob. | 121 | * Do note the value will overide also the chosen node in FDT blob. |
121 | */ | 122 | */ |
122 | #define CONFIG_BOOTARGS "console=ttyS0,57600,mem=256M@0x0" | 123 | #define CONFIG_BOOTARGS "console=ttyS0,57600,mem=256M@0x0" |
123 | 124 | ||
124 | #define CONFIG_EXTRA_ENV_SETTINGS \ | 125 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
125 | "verify=n\0" \ | 126 | "verify=n\0" \ |
126 | "loadaddr= " __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ | 127 | "loadaddr= " __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ |
127 | "ramboot=setenv bootargs " CONFIG_BOOTARGS ";" \ | 128 | "ramboot=setenv bootargs " CONFIG_BOOTARGS ";" \ |
128 | "bootm ${loadaddr} - ${fdt_addr}\0" \ | 129 | "bootm ${loadaddr} - ${fdt_addr}\0" \ |
129 | "bootimage=uImage\0" \ | 130 | "bootimage=uImage\0" \ |
130 | "fdt_addr=100\0" \ | 131 | "fdt_addr=100\0" \ |
131 | "fsloadcmd=ext2load\0" \ | 132 | "fsloadcmd=ext2load\0" \ |
132 | "bootm ${loadaddr} - ${fdt_addr}\0" \ | 133 | "bootm ${loadaddr} - ${fdt_addr}\0" \ |
133 | "qspiroot=/dev/mtdblock0\0" \ | 134 | "qspiroot=/dev/mtdblock0\0" \ |
134 | "qspirootfstype=jffs2\0" \ | 135 | "qspirootfstype=jffs2\0" \ |
135 | "qspiboot=setenv bootargs " CONFIG_BOOTARGS \ | 136 | "qspiboot=setenv bootargs " CONFIG_BOOTARGS \ |
136 | " root=${qspiroot} rw rootfstype=${qspirootfstype};"\ | 137 | " root=${qspiroot} rw rootfstype=${qspirootfstype};"\ |
137 | "bootm ${loadaddr} - ${fdt_addr}\0" | 138 | "bootm ${loadaddr} - ${fdt_addr}\0" |
138 | 139 | ||
139 | /* using environment setting for stdin, stdout, stderr */ | 140 | /* using environment setting for stdin, stdout, stderr */ |
140 | #define CONFIG_SYS_CONSOLE_IS_IN_ENV | 141 | #define CONFIG_SYS_CONSOLE_IS_IN_ENV |
141 | /* Enable the call to overwrite_console() */ | 142 | /* Enable the call to overwrite_console() */ |
142 | #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE | 143 | #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE |
143 | /* Enable overwrite of previous console environment settings */ | 144 | /* Enable overwrite of previous console environment settings */ |
144 | #define CONFIG_SYS_CONSOLE_ENV_OVERWRITE | 145 | #define CONFIG_SYS_CONSOLE_ENV_OVERWRITE |
145 | 146 | ||
146 | /* max number of command args */ | 147 | /* max number of command args */ |
147 | #define CONFIG_SYS_MAXARGS 16 | 148 | #define CONFIG_SYS_MAXARGS 16 |
148 | 149 | ||
149 | 150 | ||
150 | /* | 151 | /* |
151 | * Hardware drivers | 152 | * Hardware drivers |
152 | */ | 153 | */ |
153 | 154 | ||
154 | /* | 155 | /* |
155 | * SDRAM Memory Map | 156 | * SDRAM Memory Map |
156 | */ | 157 | */ |
157 | /* We have 1 bank of DRAM */ | 158 | /* We have 1 bank of DRAM */ |
158 | #define CONFIG_NR_DRAM_BANKS 1 | 159 | #define CONFIG_NR_DRAM_BANKS 1 |
159 | /* SDRAM Bank #1 */ | 160 | /* SDRAM Bank #1 */ |
160 | #define CONFIG_SYS_SDRAM_BASE 0x00000000 | 161 | #define CONFIG_SYS_SDRAM_BASE 0x00000000 |
161 | /* SDRAM memory size */ | 162 | /* SDRAM memory size */ |
162 | #define PHYS_SDRAM_1_SIZE 0x40000000 | 163 | #define PHYS_SDRAM_1_SIZE 0x40000000 |
163 | 164 | ||
164 | #define PHYS_SDRAM_1 CONFIG_SYS_SDRAM_BASE | 165 | #define PHYS_SDRAM_1 CONFIG_SYS_SDRAM_BASE |
165 | #define CONFIG_SYS_MEMTEST_START 0x00000000 | 166 | #define CONFIG_SYS_MEMTEST_START 0x00000000 |
166 | #define CONFIG_SYS_MEMTEST_END PHYS_SDRAM_1_SIZE | 167 | #define CONFIG_SYS_MEMTEST_END PHYS_SDRAM_1_SIZE |
167 | 168 | ||
168 | /* | 169 | /* |
169 | * NS16550 Configuration | 170 | * NS16550 Configuration |
170 | */ | 171 | */ |
171 | #define UART0_BASE SOCFPGA_UART0_ADDRESS | 172 | #define UART0_BASE SOCFPGA_UART0_ADDRESS |
172 | #define CONFIG_SYS_NS16550 | 173 | #define CONFIG_SYS_NS16550 |
173 | #define CONFIG_SYS_NS16550_SERIAL | 174 | #define CONFIG_SYS_NS16550_SERIAL |
174 | #define CONFIG_SYS_NS16550_REG_SIZE -4 | 175 | #define CONFIG_SYS_NS16550_REG_SIZE -4 |
175 | #define CONFIG_SYS_NS16550_CLK V_NS16550_CLK | 176 | #define CONFIG_SYS_NS16550_CLK V_NS16550_CLK |
176 | #define CONFIG_CONS_INDEX 1 | 177 | #define CONFIG_CONS_INDEX 1 |
177 | #define CONFIG_SYS_NS16550_COM1 UART0_BASE | 178 | #define CONFIG_SYS_NS16550_COM1 UART0_BASE |
178 | #define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, 115200} | 179 | #define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, 115200} |
179 | #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET | 180 | #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET |
180 | #define V_NS16550_CLK 1000000 | 181 | #define V_NS16550_CLK 1000000 |
181 | #else | 182 | #else |
182 | #define V_NS16550_CLK 100000000 | 183 | #define V_NS16550_CLK 100000000 |
183 | #endif | 184 | #endif |
184 | #define CONFIG_BAUDRATE 115200 | 185 | #define CONFIG_BAUDRATE 115200 |
185 | 186 | ||
186 | /* | 187 | /* |
187 | * FLASH | 188 | * FLASH |
188 | */ | 189 | */ |
189 | #define CONFIG_SYS_NO_FLASH | 190 | #define CONFIG_SYS_NO_FLASH |
190 | 191 | ||
191 | /* | 192 | /* |
192 | * L4 OSC1 Timer 0 | 193 | * L4 OSC1 Timer 0 |
193 | */ | 194 | */ |
194 | /* This timer use eosc1 where the clock frequency is fixed | 195 | /* This timer use eosc1 where the clock frequency is fixed |
195 | * throughout any condition */ | 196 | * throughout any condition */ |
196 | #define CONFIG_SYS_TIMERBASE SOCFPGA_OSC1TIMER0_ADDRESS | 197 | #define CONFIG_SYS_TIMERBASE SOCFPGA_OSC1TIMER0_ADDRESS |
197 | /* reload value when timer count to zero */ | 198 | /* reload value when timer count to zero */ |
198 | #define TIMER_LOAD_VAL 0xFFFFFFFF | 199 | #define TIMER_LOAD_VAL 0xFFFFFFFF |
199 | /* Timer info */ | 200 | /* Timer info */ |
200 | #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET | 201 | #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET |
201 | #define CONFIG_SYS_TIMER_RATE 2400000 | 202 | #define CONFIG_SYS_TIMER_RATE 2400000 |
202 | #else | 203 | #else |
203 | #define CONFIG_SYS_TIMER_RATE 25000000 | 204 | #define CONFIG_SYS_TIMER_RATE 25000000 |
204 | #endif | 205 | #endif |
205 | #define CONFIG_SYS_TIMER_COUNTS_DOWN | 206 | #define CONFIG_SYS_TIMER_COUNTS_DOWN |
206 | #define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMERBASE + 0x4) | 207 | #define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMERBASE + 0x4) |
207 | 208 | ||
208 | #define CONFIG_ENV_IS_NOWHERE | 209 | #define CONFIG_ENV_IS_NOWHERE |
209 | 210 | ||
210 | /* | 211 | /* |
211 | * network support | 212 | * network support |
212 | */ | 213 | */ |
213 | #ifndef CONFIG_SOCFPGA_VIRTUAL_TARGET | 214 | #ifndef CONFIG_SOCFPGA_VIRTUAL_TARGET |
214 | #define CONFIG_DESIGNWARE_ETH 1 | 215 | #define CONFIG_DESIGNWARE_ETH 1 |
215 | #endif | 216 | #endif |
216 | 217 | ||
217 | #ifdef CONFIG_DESIGNWARE_ETH | 218 | #ifdef CONFIG_DESIGNWARE_ETH |
218 | #define CONFIG_EMAC0_BASE SOCFPGA_EMAC0_ADDRESS | 219 | #define CONFIG_EMAC0_BASE SOCFPGA_EMAC0_ADDRESS |
219 | #define CONFIG_EMAC1_BASE SOCFPGA_EMAC1_ADDRESS | 220 | #define CONFIG_EMAC1_BASE SOCFPGA_EMAC1_ADDRESS |
220 | /* console support for network */ | 221 | /* console support for network */ |
221 | #define CONFIG_CMD_DHCP | 222 | #define CONFIG_CMD_DHCP |
222 | #define CONFIG_CMD_MII | 223 | #define CONFIG_CMD_MII |
223 | #define CONFIG_CMD_NET | 224 | #define CONFIG_CMD_NET |
224 | #define CONFIG_CMD_PING | 225 | #define CONFIG_CMD_PING |
225 | /* designware */ | 226 | /* designware */ |
226 | #define CONFIG_NET_MULTI | 227 | #define CONFIG_NET_MULTI |
227 | #define CONFIG_DW_ALTDESCRIPTOR | 228 | #define CONFIG_DW_ALTDESCRIPTOR |
228 | #define CONFIG_MII | 229 | #define CONFIG_MII |
229 | #define CONFIG_PHY_GIGE | 230 | #define CONFIG_PHY_GIGE |
230 | #define CONFIG_DW_AUTONEG | 231 | #define CONFIG_DW_AUTONEG |
231 | #define CONFIG_AUTONEG_TIMEOUT (15 * CONFIG_SYS_HZ) | 232 | #define CONFIG_AUTONEG_TIMEOUT (15 * CONFIG_SYS_HZ) |
232 | #define CONFIG_PHYLIB | 233 | #define CONFIG_PHYLIB |
233 | #define CONFIG_PHY_MICREL | 234 | #define CONFIG_PHY_MICREL |
234 | #define CONFIG_PHY_MICREL_KSZ9021 | 235 | #define CONFIG_PHY_MICREL_KSZ9021 |
235 | /* EMAC controller and PHY used */ | 236 | /* EMAC controller and PHY used */ |
236 | #define CONFIG_EMAC_BASE CONFIG_EMAC1_BASE | 237 | #define CONFIG_EMAC_BASE CONFIG_EMAC1_BASE |
237 | #define CONFIG_EPHY_PHY_ADDR CONFIG_EPHY1_PHY_ADDR | 238 | #define CONFIG_EPHY_PHY_ADDR CONFIG_EPHY1_PHY_ADDR |
238 | #define CONFIG_PHY_INTERFACE_MODE PHY_INTERFACE_MODE_RGMII | 239 | #define CONFIG_PHY_INTERFACE_MODE PHY_INTERFACE_MODE_RGMII |
239 | #endif /* CONFIG_DESIGNWARE_ETH */ | 240 | #endif /* CONFIG_DESIGNWARE_ETH */ |
240 | 241 | ||
241 | /* | 242 | /* |
242 | * L4 Watchdog | 243 | * L4 Watchdog |
243 | */ | 244 | */ |
244 | #define CONFIG_HW_WATCHDOG | 245 | #define CONFIG_HW_WATCHDOG |
245 | #define CONFIG_HW_WATCHDOG_TIMEOUT_MS 2000 | 246 | #define CONFIG_HW_WATCHDOG_TIMEOUT_MS 2000 |
246 | #define CONFIG_DESIGNWARE_WATCHDOG | 247 | #define CONFIG_DESIGNWARE_WATCHDOG |
247 | #define CONFIG_DW_WDT_BASE SOCFPGA_L4WD0_ADDRESS | 248 | #define CONFIG_DW_WDT_BASE SOCFPGA_L4WD0_ADDRESS |
248 | /* Clocks source frequency to watchdog timer */ | 249 | /* Clocks source frequency to watchdog timer */ |
249 | #define CONFIG_DW_WDT_CLOCK_KHZ 25000 | 250 | #define CONFIG_DW_WDT_CLOCK_KHZ 25000 |
250 | 251 | ||
251 | 252 | ||
252 | /* | 253 | /* |
253 | * SPL "Second Program Loader" aka Initial Software | 254 | * SPL "Second Program Loader" aka Initial Software |
254 | */ | 255 | */ |
255 | 256 | ||
256 | /* Enable building of SPL globally */ | 257 | /* Enable building of SPL globally */ |
257 | #define CONFIG_SPL_FRAMEWORK | 258 | #define CONFIG_SPL_FRAMEWORK |
258 | 259 | ||
259 | /* TEXT_BASE for linking the SPL binary */ | 260 | /* TEXT_BASE for linking the SPL binary */ |
260 | #define CONFIG_SPL_TEXT_BASE 0xFFFF0000 | 261 | #define CONFIG_SPL_TEXT_BASE 0xFFFF0000 |
261 | 262 | ||
262 | /* Stack size for SPL */ | 263 | /* Stack size for SPL */ |
263 | #define CONFIG_SPL_STACK_SIZE (4 * 1024) | 264 | #define CONFIG_SPL_STACK_SIZE (4 * 1024) |
264 | 265 | ||
265 | /* MALLOC size for SPL */ | 266 | /* MALLOC size for SPL */ |
266 | #define CONFIG_SPL_MALLOC_SIZE (5 * 1024) | 267 | #define CONFIG_SPL_MALLOC_SIZE (5 * 1024) |
267 | 268 | ||
268 | #define CONFIG_SPL_SERIAL_SUPPORT | 269 | #define CONFIG_SPL_SERIAL_SUPPORT |
269 | #define CONFIG_SPL_BOARD_INIT | 270 | #define CONFIG_SPL_BOARD_INIT |
270 | 271 | ||
271 | #define CHUNKSZ_CRC32 (1 * 1024) | 272 | #define CHUNKSZ_CRC32 (1 * 1024) |
272 | 273 | ||
273 | #define CONFIG_CRC32_VERIFY | 274 | #define CONFIG_CRC32_VERIFY |
274 | 275 | ||
275 | /* Linker script for SPL */ | 276 | /* Linker script for SPL */ |
276 | #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/socfpga/u-boot-spl.lds" | 277 | #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/socfpga/u-boot-spl.lds" |
277 | 278 | ||
278 | /* Support for common/libcommon.o in SPL binary */ | 279 | /* Support for common/libcommon.o in SPL binary */ |
279 | #define CONFIG_SPL_LIBCOMMON_SUPPORT | 280 | #define CONFIG_SPL_LIBCOMMON_SUPPORT |
280 | /* Support for lib/libgeneric.o in SPL binary */ | 281 | /* Support for lib/libgeneric.o in SPL binary */ |
281 | #define CONFIG_SPL_LIBGENERIC_SUPPORT | 282 | #define CONFIG_SPL_LIBGENERIC_SUPPORT |
282 | 283 | ||
283 | /* Support for watchdog */ | 284 | /* Support for watchdog */ |
284 | #define CONFIG_SPL_WATCHDOG_SUPPORT | 285 | #define CONFIG_SPL_WATCHDOG_SUPPORT |
285 | 286 | ||
286 | #endif /* __CONFIG_H */ | 287 | #endif /* __CONFIG_H */ |
287 | 288 |