summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/system-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 20:08:49 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-17 00:29:24 +0200
commitf5ac658d160d11880c2affa9c5b669404c4fe207 (patch)
tree120f5e132430ea032d12d765fc6f407c020a908e /firmware/target/arm/imx233/system-imx233.c
parent84fc327aeb7be91e611520bb058a6c8d318401c3 (diff)
downloadrockbox-f5ac658d160d11880c2affa9c5b669404c4fe207.tar.gz
rockbox-f5ac658d160d11880c2affa9c5b669404c4fe207.zip
imx233: normalise clkctrl
The clkctrl functions were becoming a mess. Normalise the names, get rid of the xtal derived as special case and use the same interface. Change-Id: Ib954a8d30a6bd691914b5e0d97774ec9fc560c50
Diffstat (limited to 'firmware/target/arm/imx233/system-imx233.c')
-rw-r--r--firmware/target/arm/imx233/system-imx233.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c
index 8d705264bd..dcf3b82408 100644
--- a/firmware/target/arm/imx233/system-imx233.c
+++ b/firmware/target/arm/imx233/system-imx233.c
@@ -105,8 +105,12 @@ void system_init(void)
105 /* NOTE: don't use anything here that might require tick task ! 105 /* NOTE: don't use anything here that might require tick task !
106 * It is initialized by kernel_init *after* system_init(). 106 * It is initialized by kernel_init *after* system_init().
107 * The main() will naturally set cpu speed to normal after kernel_init() 107 * The main() will naturally set cpu speed to normal after kernel_init()
108 * so don't bother if the cpu is running at 24MHz here. */ 108 * so don't bother if the cpu is running at 24MHz here.
109 imx233_clkctrl_enable_clock(CLK_PLL, true); 109 * Make sure IO clock is running at expected speed */
110 imx233_clkctrl_init();
111 imx233_clkctrl_enable(CLK_PLL, true);
112 imx233_clkctrl_set_frac_div(CLK_IO, 18); // clk_io@clk_pll
113
110 imx233_rtc_init(); 114 imx233_rtc_init();
111 imx233_icoll_init(); 115 imx233_icoll_init();
112 imx233_pinctrl_init(); 116 imx233_pinctrl_init();
@@ -119,19 +123,14 @@ void system_init(void)
119 imx233_power_init(); 123 imx233_power_init();
120 imx233_i2c_init(); 124 imx233_i2c_init();
121 125
122 imx233_clkctrl_enable_auto_slow_monitor(AS_CPU_INSTR, true); 126 /* make sure auto-slow is disable now, we don't know at which frequency we
123 imx233_clkctrl_enable_auto_slow_monitor(AS_CPU_DATA, true); 127 * are running and auto-slow could violate constraints on {xbus,hbus} */
124 imx233_clkctrl_enable_auto_slow_monitor(AS_TRAFFIC, true); 128 imx233_clkctrl_enable_auto_slow(false);
125 imx233_clkctrl_enable_auto_slow_monitor(AS_TRAFFIC_JAM, true); 129 imx233_clkctrl_set_auto_slow_div(BV_CLKCTRL_HBUS_SLOW_DIV__BY8);
126 imx233_clkctrl_enable_auto_slow_monitor(AS_APBXDMA, true);
127 imx233_clkctrl_enable_auto_slow_monitor(AS_APBHDMA, true);
128 imx233_clkctrl_set_auto_slow_divisor(AS_DIV_8);
129 imx233_clkctrl_enable_auto_slow(true);
130 130
131 cpu_frequency = imx233_clkctrl_get_clock_freq(CLK_CPU); 131 cpu_frequency = imx233_clkctrl_get_freq(CLK_CPU);
132 132
133#if !defined(BOOTLOADER) &&(defined(SANSA_FUZEPLUS) || \ 133#if CONFIG_TUNER
134 defined(CREATIVE_ZENXFI3) || defined(CREATIVE_ZENXFI2))
135 fmradio_i2c_init(); 134 fmradio_i2c_init();
136#endif 135#endif
137} 136}
@@ -210,7 +209,6 @@ void set_cpu_frequency(long frequency)
210 if(prof->cpu_freq == 0) 209 if(prof->cpu_freq == 0)
211 return; 210 return;
212 /* disable auto-slow (enable back afterwards) */ 211 /* disable auto-slow (enable back afterwards) */
213 bool as = imx233_clkctrl_is_auto_slow_enabled();
214 imx233_clkctrl_enable_auto_slow(false); 212 imx233_clkctrl_enable_auto_slow(false);
215 213
216 /* WARNING watch out the order ! */ 214 /* WARNING watch out the order ! */
@@ -221,28 +219,28 @@ void set_cpu_frequency(long frequency)
221 /* Change ARM cache timings */ 219 /* Change ARM cache timings */
222 imx233_digctl_set_arm_cache_timings(prof->arm_cache_timings); 220 imx233_digctl_set_arm_cache_timings(prof->arm_cache_timings);
223 /* Switch CPU to crystal at 24MHz */ 221 /* Switch CPU to crystal at 24MHz */
224 imx233_clkctrl_set_bypass_pll(CLK_CPU, true); 222 imx233_clkctrl_set_bypass(CLK_CPU, true);
225 /* Program CPU divider for PLL */ 223 /* Program CPU divider for PLL */
226 imx233_clkctrl_set_fractional_divisor(CLK_CPU, prof->cpu_fdiv); 224 imx233_clkctrl_set_frac_div(CLK_CPU, prof->cpu_fdiv);
227 imx233_clkctrl_set_clock_divisor(CLK_CPU, prof->cpu_idiv); 225 imx233_clkctrl_set_div(CLK_CPU, prof->cpu_idiv);
228 /* Change the HBUS divider to its final value */ 226 /* Change the HBUS divider to its final value */
229 imx233_clkctrl_set_clock_divisor(CLK_HBUS, prof->hbus_div); 227 imx233_clkctrl_set_div(CLK_HBUS, prof->hbus_div);
230 /* Switch back CPU to PLL */ 228 /* Switch back CPU to PLL */
231 imx233_clkctrl_set_bypass_pll(CLK_CPU, false); 229 imx233_clkctrl_set_bypass(CLK_CPU, false);
232 /* Set the new EMI frequency */ 230 /* Set the new EMI frequency */
233 imx233_emi_set_frequency(prof->emi_freq); 231 imx233_emi_set_frequency(prof->emi_freq);
234 } 232 }
235 else 233 else
236 { 234 {
237 /* Switch CPU to crystal at 24MHz */ 235 /* Switch CPU to crystal at 24MHz */
238 imx233_clkctrl_set_bypass_pll(CLK_CPU, true); 236 imx233_clkctrl_set_bypass(CLK_CPU, true);
239 /* Program HBUS divider to its final value */ 237 /* Program HBUS divider to its final value */
240 imx233_clkctrl_set_clock_divisor(CLK_HBUS, prof->hbus_div); 238 imx233_clkctrl_set_div(CLK_HBUS, prof->hbus_div);
241 /* Program CPU divider for PLL */ 239 /* Program CPU divider for PLL */
242 imx233_clkctrl_set_fractional_divisor(CLK_CPU, prof->cpu_fdiv); 240 imx233_clkctrl_set_frac_div(CLK_CPU, prof->cpu_fdiv);
243 imx233_clkctrl_set_clock_divisor(CLK_CPU, prof->cpu_idiv); 241 imx233_clkctrl_set_div(CLK_CPU, prof->cpu_idiv);
244 /* Switch back CPU to PLL */ 242 /* Switch back CPU to PLL */
245 imx233_clkctrl_set_bypass_pll(CLK_CPU, false); 243 imx233_clkctrl_set_bypass(CLK_CPU, false);
246 /* Set the new EMI frequency */ 244 /* Set the new EMI frequency */
247 imx233_emi_set_frequency(prof->emi_freq); 245 imx233_emi_set_frequency(prof->emi_freq);
248 /* Change ARM cache timings */ 246 /* Change ARM cache timings */
@@ -251,7 +249,7 @@ void set_cpu_frequency(long frequency)
251 imx233_power_set_regulator(REGULATOR_VDDD, prof->vddd, prof->vddd_bo); 249 imx233_power_set_regulator(REGULATOR_VDDD, prof->vddd, prof->vddd_bo);
252 } 250 }
253 /* enable auto slow again */ 251 /* enable auto slow again */
254 imx233_clkctrl_enable_auto_slow(as); 252 imx233_clkctrl_enable_auto_slow(true);
255 /* update frequency */ 253 /* update frequency */
256 cpu_frequency = frequency; 254 cpu_frequency = frequency;
257} 255}