diff options
Diffstat (limited to 'firmware/target/arm/as3525/system-as3525.c')
-rw-r--r-- | firmware/target/arm/as3525/system-as3525.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index 0451cb36d2..82a0a01795 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "panic.h" | 25 | #include "panic.h" |
26 | #include "ascodec-target.h" | 26 | #include "ascodec-target.h" |
27 | #include "dma-target.h" | 27 | #include "dma-target.h" |
28 | #include "clock-target.h" | ||
28 | 29 | ||
29 | #define default_interrupt(name) \ | 30 | #define default_interrupt(name) \ |
30 | extern __attribute__((weak,alias("UIRQ"))) void name (void) | 31 | extern __attribute__((weak,alias("UIRQ"))) void name (void) |
@@ -135,9 +136,6 @@ static void sdram_delay(void) | |||
135 | /* Use the same initialization than OF */ | 136 | /* Use the same initialization than OF */ |
136 | static void sdram_init(void) | 137 | static void sdram_init(void) |
137 | { | 138 | { |
138 | CGU_PERI &= ~(0xf<<2); /* clear div0 (memclock) */ | ||
139 | CGU_PERI |= (1<<2); /* divider = 2 */ | ||
140 | |||
141 | CGU_PERI |= (1<<26)|(1<<27); /* extmem & extmem intf clocks */ | 139 | CGU_PERI |= (1<<26)|(1<<27); /* extmem & extmem intf clocks */ |
142 | 140 | ||
143 | MPMC_CONTROL = 0x1; /* enable MPMC */ | 141 | MPMC_CONTROL = 0x1; /* enable MPMC */ |
@@ -201,11 +199,8 @@ static void sdram_init(void) | |||
201 | 199 | ||
202 | void system_init(void) | 200 | void system_init(void) |
203 | { | 201 | { |
204 | #ifdef BOOTLOADER | ||
205 | #if 0 /* the GPIO clock is already enabled by the dualboot function */ | ||
206 | CGU_PERI |= CGU_GPIO_CLOCK_ENABLE; | ||
207 | #endif | ||
208 | 202 | ||
203 | #ifdef BOOTLOADER /* TODO: makes this work in the main build */ | ||
209 | CGU_PROC = 0; /* fclk 24 MHz */ | 204 | CGU_PROC = 0; /* fclk 24 MHz */ |
210 | CGU_PERI &= ~0x7f; /* pclk 24 MHz */ | 205 | CGU_PERI &= ~0x7f; /* pclk 24 MHz */ |
211 | 206 | ||
@@ -215,10 +210,13 @@ void system_init(void) | |||
215 | "mcr p15, 0, r0, c1, c0 \n" | 210 | "mcr p15, 0, r0, c1, c0 \n" |
216 | : : : "r0" ); | 211 | : : : "r0" ); |
217 | 212 | ||
218 | CGU_PLLA = 0x261F; /* PLLA 248 MHz */ | 213 | CGU_PLLA = AS3525_PLLA_SETTING; |
219 | while(!(CGU_INTCTRL & (1<<0))); /* wait until PLLA is locked */ | 214 | while(!(CGU_INTCTRL & (1<<0))); /* wait until PLLA is locked */ |
220 | 215 | ||
221 | CGU_PROC = 1; /* fclk = PLLA = 248 MHz */ | 216 | CGU_PROC = (AS3525_CPU_PREDIV << 2) | 1; |
217 | |||
218 | CGU_PERI |= ((CLK_DIV(AS3525_PLLA_FREQ, AS3525_PCLK_FREQ) - 1) << 2) | ||
219 | | 1; /* clk_in = PLLA */ | ||
222 | 220 | ||
223 | asm volatile( | 221 | asm volatile( |
224 | "mov r0, #0 \n" | 222 | "mov r0, #0 \n" |
@@ -230,26 +228,32 @@ void system_init(void) | |||
230 | : : : "r0" ); | 228 | : : : "r0" ); |
231 | 229 | ||
232 | sdram_init(); | 230 | sdram_init(); |
231 | #endif /* BOOTLOADER */ | ||
232 | |||
233 | #if 0 /* the GPIO clock is already enabled by the dualboot function */ | ||
234 | CGU_PERI |= CGU_GPIO_CLOCK_ENABLE; | ||
235 | #endif | ||
233 | 236 | ||
234 | /* enable timer interface for TIMER1 & TIMER2 */ | 237 | /* enable timer interface for TIMER1 & TIMER2 */ |
235 | CGU_PERI |= CGU_TIMERIF_CLOCK_ENABLE; | 238 | CGU_PERI |= CGU_TIMERIF_CLOCK_ENABLE; |
236 | 239 | ||
237 | /* enable VIC */ | 240 | /* enable VIC */ |
238 | VIC_INT_ENABLE = 0; /* disable all interrupt lines */ | 241 | VIC_INT_EN_CLEAR = 0xffffffff; /* disable all interrupt lines */ |
239 | CGU_PERI |= CGU_VIC_CLOCK_ENABLE; | 242 | CGU_PERI |= CGU_VIC_CLOCK_ENABLE; |
240 | VIC_INT_SELECT = 0; /* only IRQ, no FIQ */ | 243 | VIC_INT_SELECT = 0; /* only IRQ, no FIQ */ |
241 | #else | 244 | |
245 | dma_init(); | ||
246 | |||
247 | #ifndef BOOTLOADER | ||
242 | /* Disable fast hardware power-off, to use power button normally | 248 | /* Disable fast hardware power-off, to use power button normally |
243 | * We don't need the power button in the bootloader. */ | 249 | * We don't need the power button in the bootloader. */ |
244 | ascodec_init(); | 250 | ascodec_init(); |
245 | ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) & (1<<2)); | 251 | ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) & (1<<2)); |
246 | #endif /* BOOTLOADER */ | 252 | #endif /* !BOOTLOADER */ |
247 | 253 | ||
248 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 254 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
249 | set_cpu_frequency(CPUFREQ_DEFAULT); | 255 | set_cpu_frequency(CPUFREQ_DEFAULT); |
250 | #endif | 256 | #endif |
251 | |||
252 | dma_init(); | ||
253 | } | 257 | } |
254 | 258 | ||
255 | void system_reboot(void) | 259 | void system_reboot(void) |