diff options
Diffstat (limited to 'firmware/target/arm/as3525')
-rw-r--r-- | firmware/target/arm/as3525/system-as3525.c | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index 2df8eee7e5..e83e5150ae 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2007 by Rob Purchase | 10 | * Copyright (C) 2007 by Rob Purchase |
11 | * Copyright © 2008 Rafaël Carré | ||
11 | * | 12 | * |
12 | * This program is free software; you can redistribute it and/or | 13 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 14 | * modify it under the terms of the GNU General Public License |
@@ -124,10 +125,83 @@ void fiq_handler(void) | |||
124 | ); | 125 | ); |
125 | } | 126 | } |
126 | 127 | ||
128 | static void sdram_delay(void) | ||
129 | { | ||
130 | int delay = 1024; /* arbitrary */ | ||
131 | while (delay--) ; | ||
132 | } | ||
133 | |||
134 | /* Use the same initialization than OF */ | ||
135 | static void sdram_init(void) | ||
136 | { | ||
137 | CGU_PERI &= ~(0xf<<2); /* clear div0 (memclock) */ | ||
138 | CGU_PERI |= (1<<2); /* divider = 2 */ | ||
139 | |||
140 | CGU_PERI |= (1<<26)|(1<<27); /* extmem & extmem intf clocks */ | ||
141 | |||
142 | MPMC_CONTROL = 0x1; /* enable MPMC */ | ||
143 | |||
144 | MPMC_DYNAMIC_CONTROL = 0x183; /* SDRAM NOP, all clocks high */ | ||
145 | sdram_delay(); | ||
146 | |||
147 | MPMC_DYNAMIC_CONTROL = 0x103; /* SDRAM PALL, all clocks high */ | ||
148 | sdram_delay(); | ||
149 | |||
150 | MPMC_DYNAMIC_REFRESH = 0x138; /* 0x138 * 16 HCLK ticks between SDRAM refresh cycles */ | ||
151 | |||
152 | MPMC_CONFIG = 0; /* little endian, HCLK:MPMCCLKOUT[3:0] ratio = 1:1 */ | ||
153 | |||
154 | if(MPMC_PERIPH_ID2 & 0xf0) | ||
155 | MPMC_DYNAMIC_READ_CONFIG = 0x1; /* command delayed, clock out not delayed */ | ||
156 | |||
157 | /* timings */ | ||
158 | MPMC_DYNAMIC_tRP = 2; | ||
159 | MPMC_DYNAMIC_tRAS = 4; | ||
160 | MPMC_DYNAMIC_tSREX = 5; | ||
161 | MPMC_DYNAMIC_tAPR = 0; | ||
162 | MPMC_DYNAMIC_tDAL = 4; | ||
163 | MPMC_DYNAMIC_tWR = 2; | ||
164 | MPMC_DYNAMIC_tRC = 5; | ||
165 | MPMC_DYNAMIC_tRFC = 5; | ||
166 | MPMC_DYNAMIC_tXSR = 5; | ||
167 | MPMC_DYNAMIC_tRRD = 2; | ||
168 | MPMC_DYNAMIC_tMRD = 2; | ||
169 | |||
170 | #if defined(SANSA_CLIP) || defined(SANSA_M200V2) | ||
171 | # define MEMORY_MODEL 0x21 | ||
172 | /* 16 bits external bus, low power SDRAM, 16 Mbits = 2 Mbytes */ | ||
173 | #elif defined(SANSA_E200V2) | ||
174 | # define MEMORY_MODEL 0x5 | ||
175 | /* 16 bits external bus, high performance SDRAM, 64 Mbits = 8 Mbytes */ | ||
176 | #else | ||
177 | # error "The external memory in your player is unknown" | ||
178 | #endif | ||
179 | |||
180 | MPMC_DYNAMIC_RASCAS_0 = (2<<8)|2; /* CAS & RAS latency = 2 clock cycles */ | ||
181 | MPMC_DYNAMIC_CONFIG_0 = (MEMORY_MODEL << 7); | ||
182 | |||
183 | MPMC_DYNAMIC_RASCAS_1 = MPMC_DYNAMIC_CONFIG_1 = | ||
184 | MPMC_DYNAMIC_RASCAS_2 = MPMC_DYNAMIC_CONFIG_2 = | ||
185 | MPMC_DYNAMIC_RASCAS_3 = MPMC_DYNAMIC_CONFIG_3 = 0; | ||
186 | |||
187 | MPMC_DYNAMIC_CONTROL = 0x82; /* SDRAM MODE, MPMCCLKOUT runs continuously */ | ||
188 | |||
189 | /* this part is required, if you know why please explain */ | ||
190 | unsigned int tmp = *(volatile unsigned int*)(0x30000000+0x2300*MEM); | ||
191 | (void)tmp; /* we just need to read from this location */ | ||
192 | |||
193 | MPMC_DYNAMIC_CONTROL = 0x2; /* SDRAM NORMAL, MPMCCLKOUT runs continuously */ | ||
194 | |||
195 | MPMC_DYNAMIC_CONFIG_0 |= (1<<19); /* buffer enable */ | ||
196 | } | ||
127 | 197 | ||
128 | void system_init(void) | 198 | void system_init(void) |
129 | { | 199 | { |
130 | /* CGU_PERI |= CGU_GPIO_CLOCK_ENABLE; */ | 200 | #if 0 /* the GPIO clock is already enabled by the dualboot function */ |
201 | CGU_PERI |= CGU_GPIO_CLOCK_ENABLE; | ||
202 | #endif | ||
203 | |||
204 | sdram_init(); | ||
131 | } | 205 | } |
132 | 206 | ||
133 | void system_reboot(void) | 207 | void system_reboot(void) |