1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
Index: apps/plugins/SOURCES
===================================================================
--- apps/plugins/SOURCES	(revision 21022)
+++ apps/plugins/SOURCES	(working copy)
@@ -1,4 +1,9 @@
 /* plugins common to all models */
+
+test_codec.c
+test_disk.c
+test_fps.c
+
 chessclock.c
 credits.c
 cube.c
Index: firmware/SOURCES
===================================================================
--- firmware/SOURCES	(revision 21022)
+++ firmware/SOURCES	(working copy)
@@ -362,6 +362,7 @@
 target/arm/as3525/dma-pl081.c
 target/arm/as3525/ascodec-as3525.c
 #ifndef BOOTLOADER
+target/arm/mmu-arm.S
 drivers/generic_i2c.c
 target/arm/adc-as3514.c
 target/arm/as3525/audio-as3525.c
Index: firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c
===================================================================
--- firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c	(revision 21022)
+++ firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c	(working copy)
@@ -98,7 +98,7 @@
 /* DBOP initialisation, do what OF does */
 static void ams3525_dbop_init(void)
 {
-    CGU_DBOP = (1<<3) | (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1);
+    CGU_DBOP = (1<<3) | AS3525_DBOP_DIV;

     DBOP_TIMPOL_01 = 0xe167e167;
     DBOP_TIMPOL_23 = 0xe167006e;
Index: firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
===================================================================
--- firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c	(revision 21022)
+++ firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c	(working copy)
@@ -108,7 +108,7 @@
 /* DBOP initialisation, do what OF does */
 static void ams3525_dbop_init(void)
 {
-    CGU_DBOP = (1<<3) | (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1);
+    CGU_DBOP = (1<<3) | AS3525_DBOP_DIV;

     DBOP_TIMPOL_01 = 0xe167e167;
     DBOP_TIMPOL_23 = 0xe167006e;
Index: firmware/target/arm/as3525/system-as3525.c
===================================================================
--- firmware/target/arm/as3525/system-as3525.c	(revision 21022)
+++ firmware/target/arm/as3525/system-as3525.c	(working copy)
@@ -28,6 +28,7 @@
 #include "clock-target.h"
 #include "fmradio_i2c.h"
 #include "button-target.h"
+#include "mmu-arm.h"

 #define default_interrupt(name) \
   extern __attribute__((weak,alias("UIRQ"))) void name (void)
@@ -229,29 +230,26 @@
     CGU_PROC = 0;           /* fclk 24 MHz */
     CGU_PERI &= ~0x7f;      /* pclk 24 MHz */

-    asm volatile(
-        "mrc p15, 0, r0, c1, c0  \n"
-        "orr r0, r0, #0xC0000000 \n" /* asynchronous clocking */
-        "mcr p15, 0, r0, c1, c0  \n"
-        : : : "r0" );
+    CGU_PLLA = AS3525_PLLA_SETTING;           /*  PLLA =     384 Mhz */
+    while(!(CGU_INTCTRL & (1<<0)));           /* wait until PLLA is locked */

-    CGU_PLLA = AS3525_PLLA_SETTING;
-    while(!(CGU_INTCTRL & (1<<0))); /* wait until PLLA is locked */
+    /*  Set FCLK frequency */
+    CGU_PROC = ((AS3525_FCLK_POSTDIV << 4) |  /* Div=   1/1      */
+                (AS3525_FCLK_PREDIV  << 2) |  /* Div=   5/8      */
+                 AS3525_FCLK_SEL);            /* source=PLLA FCLK 240MHz*/
+    /*  Set PCLK frequency */
+    CGU_PERI = ((CGU_PERI & 0xffffff80)  |    /* reset divider bits 0:6 */
+                 (AS3525_PCLK_DIV0 << 2) |    /* div =     */
+                 (AS3525_PCLK_DIV1 << 6) |    /* div =     */
+                  AS3525_PCLK_SEL);           /* source = Fclk  PCLK=  Mhz*/

-    CGU_PROC = (AS3525_CPU_PREDIV << 2) | 1;
-
-    CGU_PERI |= ((CLK_DIV(AS3525_PLLA_FREQ, AS3525_PCLK_FREQ) - 1) << 2)
-                | 1; /* clk_in = PLLA */
-
-
-    /* FIXME: dcache will not be active, since the mmu is not running
-     * See arm922t datasheet */
     asm volatile(
         "mov r0, #0               \n"
-        "mcr p15, 0, r0, c7, c7   \n" /* invalidate icache & dcache */
-        "mrc p15, 0, r0, c1, c0   \n" /* control register */
-        "orr r0, r0, #0x1000      \n" /* enable icache */
-        "orr r0, r0, #4           \n" /* enable dcache */
+        "mcr p15, 0, r0, c7, c7   \n"      /* invalidate icache & dcache */
+        "mrc p15, 0, r0, c1, c0   \n"      /* control register */
+        "bic r0, r0, #3<<30       \n"      /* clears bus bits & sets fastbus */
+        "orr r0, r0, #1<<14       \n"      /* round robin cache replacement */
+        "orr r0, r0, #1<<12       \n"      /* enable icache */
         "mcr p15, 0, r0, c1, c0   \n"
         : : : "r0" );

@@ -281,10 +279,6 @@
     fmradio_i2c_init();
 #endif
 #endif /* !BOOTLOADER */
-
-#ifdef HAVE_ADJUSTABLE_CPU_FREQ
-    set_cpu_frequency(CPUFREQ_DEFAULT);
-#endif
 }

 void system_reboot(void)
@@ -311,16 +305,35 @@
 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
 void set_cpu_frequency(long frequency)
 {
-    int divider = frequency ? (CPUFREQ_MAX / frequency) : 16 /* minimal */ ;
+    if(frequency == CPUFREQ_MAX)
+    {

-    if(divider > 16)
-        divider = 16;
-    else if(divider < 1)
-        divider = 1;
+        asm volatile(                       /* 922CLK = FCLK = (4)PCLK = 248MHz*/
+            "mrc p15, 0, r0, c1, c0  \n"

-    cpu_frequency = CPUFREQ_MAX / divider;
+#ifdef ASYNCHRONOUS_BUS
+            "orr r0, r0, #3<<30      \n"   /* asynchronous bus clocking */
+#else
+            "bic r0, r0, #3<<30      \n"   /* clear bus bits */
+            "orr r0, r0, #1<<30      \n"   /* synchronous bus clocking */
+#endif /*ASYNCHRONOUS_BUS */

-    CGU_PROC = (CGU_PROC & 0x0f) | ((divider-1) << 4);
+            "mcr p15, 0, r0, c1, c0  \n"
+            : : : "r0" );
+
+        cpu_frequency = CPUFREQ_MAX;
+    }
+    else
+    {
+//        set_bus_mode(fastbus);             /* 922CLK = PCLK = 62MHz)*/
+        asm volatile(
+            "mrc p15, 0, r0, c1, c0  \n"
+            "bic r0, r0, #3<<30      \n"   /* fastbus clocking */
+            "mcr p15, 0, r0, c1, c0  \n"
+            : : : "r0" );
+
+        cpu_frequency = CPUFREQ_NORMAL;
+    }
 }
 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
-#endif /* BOOTLOADER */
+#endif /* !BOOTLOADER */
Index: firmware/target/arm/as3525/debug-as3525.c
===================================================================
--- firmware/target/arm/as3525/debug-as3525.c	(revision 21022)
+++ firmware/target/arm/as3525/debug-as3525.c	(working copy)
@@ -120,39 +120,39 @@
             switch(CGU_PROC & 3) {
                 case 0:
                     return CLK_MAIN/
-                    ((8/(8-((CGU_PROC & 0xc)>>2)))*(((CGU_PROC & 0xf0)>>4) + 1));
+                    ((8/(8-((CGU_PROC>>2)& 0x3)))*(((CGU_PROC>>4)& 0xf) + 1));
                 case 1:
                     return calc_freq(CLK_PLLA)/
-                    ((8/(8-((CGU_PROC & 0xc)>>2)))*(((CGU_PROC & 0xf0)>>4) + 1));
+                    ((8/(8-((CGU_PROC>>2)& 0x3)))*(((CGU_PROC>>4)& 0xf) + 1));
                 case 2:
                     return calc_freq(CLK_PLLB)/
-                    ((8/(8-((CGU_PROC & 0xc)>>2)))*(((CGU_PROC & 0xf0)>>4) + 1));
+                    ((8/(8-((CGU_PROC>>2)& 0x3)))*(((CGU_PROC>>4)& 0xf) + 1));
                 default:
                     return 0;
             }
         case CLK_EXTMEM:
             switch(CGU_PERI & 3) {
                 case 0:
-                    return CLK_MAIN/(((CGU_PERI & 0x3c)>>2)+1);
+                    return CLK_MAIN/(((CGU_PERI>>2)& 0xf)+1);
                 case 1:
-                    return calc_freq(CLK_PLLA)/(((CGU_PERI & 0x3c)>>2)+1);
+                    return calc_freq(CLK_PLLA)/(((CGU_PERI>>2)& 0xf)+1);
                 case 2:
-                    return calc_freq(CLK_PLLB)/(((CGU_PERI & 0x3c)>>2)+1);
+                    return calc_freq(CLK_PLLB)/(((CGU_PERI>>2)& 0xf)+1);
                 case 3:
-                    return calc_freq(CLK_FCLK)/(((CGU_PERI & 0x3c)>>2)+1);
+                    return calc_freq(CLK_FCLK)/(((CGU_PERI>>2)& 0xf)+1);
                 default:
                     return 0;
             }
         case CLK_PCLK:
-            return calc_freq(CLK_EXTMEM)/(((CGU_PERI & 0x40)>>6)+1);
+            return calc_freq(CLK_EXTMEM)/(((CGU_PERI>>6)& 0x1)+1);
         case CLK_IDE:
             switch(CGU_IDE & 3) {
                 case 0:
-                    return CLK_MAIN/(((CGU_IDE & 0x3c)>>2)+1);
+                    return CLK_MAIN/(((CGU_IDE>>2)& 0xf)+1);
                 case 1:
-                    return calc_freq(CLK_PLLA)/(((CGU_IDE & 0x3c)>>2)+1);;
+                    return calc_freq(CLK_PLLA)/(((CGU_IDE>>2)& 0xf)+1);
                 case 2:
-                    return calc_freq(CLK_PLLB)/(((CGU_IDE & 0x3c)>>2)+1);
+                    return calc_freq(CLK_PLLB)/(((CGU_IDE>>2)& 0xf)+1);
                 default:
                     return 0;
             }
Index: firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c
===================================================================
--- firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c	(revision 21022)
+++ firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c	(working copy)
@@ -70,7 +70,7 @@
 /* DBOP initialisation, do what OF does */
 static void ams3525_dbop_init(void)
 {
-    CGU_DBOP = (1<<3) | (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1);
+    CGU_DBOP = (1<<3) | AS3525_DBOP_DIV;

     GPIOB_AFSEL = 0x08; /* DBOP on pin 3 */
     GPIOC_AFSEL = 0x0f; /* DBOP on pins 3:0 */
Index: firmware/target/arm/as3525/ascodec-as3525.c
===================================================================
--- firmware/target/arm/as3525/ascodec-as3525.c	(revision 21022)
+++ firmware/target/arm/as3525/ascodec-as3525.c	(working copy)
@@ -78,7 +78,7 @@
     CGU_PERI |= CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE;

     /* prescaler for i2c clock */
-    prescaler = CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ);
+    prescaler = AS3525_I2C_PRESCALER;
     I2C2_CPSR0 = prescaler & 0xFF;          /* 8 lsb */
     I2C2_CPSR1 = (prescaler >> 8) & 0x3;    /* 2 msb */

Index: firmware/target/arm/as3525/clock-target.h
===================================================================
--- firmware/target/arm/as3525/clock-target.h	(revision 21022)
+++ firmware/target/arm/as3525/clock-target.h	(working copy)
@@ -24,47 +24,112 @@
 /* returns clock divider, given maximal target frequency and clock reference */
 #define CLK_DIV(ref, target) ((ref + target - 1) / target)

-/* PLL */

-#define AS3525_PLLA_FREQ        248000000
-#define AS3525_PLLA_SETTING     0x261F
+/*  Frequency and Bus Settings
+ *  These bus settings work on the assumption that unboosted performance will be
+ *  based on fastbus mode(FCLK == PCLK) at a frequency configured with this file.
+ *  Boosted performance defaults to synchronous bus but may be
+ *  changed to asynchronous by uncommenting the #define ASYNCHRONOUS_BUS line.
+ *  The player starts up in fastbus mode and synchronous or asynchronous mode is
+ *  implemented in the set_cpu_frequency() function in system-as3525.c.  There 
+ *  are limitations on both frequencies and frequency relationships listed in 7.3.14
+ *  of the as3525 datasheet that need to be observed.  If you are determined to
+ *  use a frequency that is not "legal" you can do that. There are no checks for 
+ *  legal frequency values, only some validity checks to make sure the divider 
+ *  value fits into the number of bits allotted to it.
+ *
+ *  The CLOCK_DIV macro does a pretty good job at selecting divider values but
+ *  you can always overide it by choosing your own value and commenting out the
+ *  macro.  I have include I2SO, I2SI, & USB but commented them out for now.
+ */

-/* CPU */
+/* Clock Sources  */
+#define AS3525_CLK_MAIN           0
+#define AS3525_CLK_PLLA           1
+#define AS3525_CLK_PLLB           2
+#define AS3525_CLK_FCLK           3

-/* ensure that PLLA_FREQ * prediv == CPUFREQ_MAX */
-#define AS3525_CPU_PREDIV       0 /* div = 1/1 */
+/* PLL  frequencies and settings*/

-#define CPUFREQ_MAX             248000000
+//#define AS3525_PLLA_FREQ        248000000
+//#define AS3525_PLLA_SETTING     0x261F

-#define CPUFREQ_DEFAULT         24800000
+#define AS3525_PLLA_FREQ        384000000
+#define AS3525_PLLA_SETTING     0x2630

-#define CPUFREQ_NORMAL          31000000

-/* peripherals */
+/** ************ Change these to reconfigure clocking scheme *******************/

-#define AS3525_PCLK_FREQ        62000000
-#if (CLK_DIV(AS3525_PLLA_FREQ, AS3525_PCLK_FREQ) - 1) >= (1<<4) /* 4 bits */
-#error PCLK frequency is too low : clock divider will not fit !
+//#define ASYNCHRONOUS_BUS                          /* Boosted mode asynchronous */
+
+#define AS3525_FCLK_FREQ         192000000          /* Boosted FCLK frequency  */
+#define AS3525_PCLK_FREQ         64000000           /* Initial PCLK frequency  */
+#define AS3525_DBOP_FREQ         AS3525_PCLK_FREQ   /* Initial PCLK frequency  */
+
+/** ****************************************************************************/
+
+
+
+/* Tell the software what frequencies we're running */
+#define CPUFREQ_MAX              AS3525_FCLK_FREQ
+#define CPUFREQ_DEFAULT          AS3525_PCLK_FREQ
+#define CPUFREQ_NORMAL           AS3525_PCLK_FREQ
+
+/* FCLK */
+#define AS3525_FCLK_SEL          AS3525_CLK_PLLA
+#define AS3525_FCLK_PREDIV       0   /* div = (8-n)/8 = 5/8 acts strange when used!*/
+#define AS3525_FCLK_POSTDIV      (CLK_DIV(AS3525_PLLA_FREQ, AS3525_FCLK_FREQ) - 1) /*div=1/(n+1)*/
+
+/* PCLK */
+#ifdef ASYNCHRONOUS_BUS
+#define AS3525_PCLK_SEL          AS3525_CLK_PLLA    /* PLLA input for asynchronous */
+#define AS3525_PCLK_DIV0         (CLK_DIV(AS3525_PLLA_FREQ, AS3525_PCLK_FREQ) - 1)/*div=1/(n+1)*/
+#else
+#define AS3525_PCLK_SEL          AS3525_CLK_FCLK    /* Fclk input for synchronous */
+#define AS3525_PCLK_DIV0         (CLK_DIV(AS3525_FCLK_FREQ, AS3525_PCLK_FREQ) - 1) /*div=1/(n+1)*/
 #endif
+#define AS3525_PCLK_DIV1         0 /* div = 1/(n+1) unable to use successfuly so far*/

-#define AS3525_IDE_FREQ         90000000    /* The OF uses 66MHz maximal freq
+   /* PCLK as Source */
+  #define AS3525_DBOP_DIV        (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1) /*div=1/(n+1)*/
+  #define AS3525_I2C_PRESCALER   CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ)
+  #define AS3525_I2C_FREQ        400000
+  #define AS3525_SD_IDENT_DIV    ((CLK_DIV(AS3525_PCLK_FREQ, AS3525_SD_IDENT_FREQ) / 2) - 1)
+  #define AS3525_SD_IDENT_FREQ   400000      /* must be between 100 & 400 kHz */
+
+#define AS3525_IDE_SEL           AS3525_CLK_PLLA           /* Input Source   */
+#define AS3525_IDE_DIV           (CLK_DIV(AS3525_PLLA_FREQ, AS3525_IDE_FREQ) - 1)/*div=1/(n+1)*/
+#define AS3525_IDE_FREQ          90000000    /* The OF uses 66MHz maximal freq
                                                but sd transfers fail on some
                                                players with this limit */
+
+//#define AS3525_I2SO_MCLK_SEL     AS3525_CLK_PLLA            /* Input Source   */
+//#define AS3525_I2SO_MCLK_DIV     /* div = 1/(n+1)*/
+//#define AS3525_I2SI_MCLK_SEL     AS3525_CLK_PLLA            /* Input Source   */
+//#define AS3525_I2SI_MCLK_DIV     /* div = 1/(n+1)*/
+//#define AS3525_USB_SEL           AS3525_CLK_PLLA            /* Input Source   */
+//#define AS3525_USB_DIV           /* div = 1/(n=0?1:2n)*/
+
+
+/* Validity Checks */
+
+/* AS3525_PCLK_FREQ  */
+#if (CLK_DIV(AS3525_PLLA_FREQ, AS3525_PCLK_FREQ) - 1) >= (1<<4) /* 4 bits */
+#error PCLK frequency is too low : clock divider will not fit !
+#endif
+/*  AS3525_DBOP_FREQ */
+#if (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1) >= (1<<3) /* 3 bits */
+#error DBOP frequency is too low : clock divider will not fit !
+#endif
+/* AS3525_IDE_FREQ */
 #if (CLK_DIV(AS3525_PLLA_FREQ, AS3525_IDE_FREQ) - 1) >= (1<<4) /* 4 bits */
 #error IDE frequency is too low : clock divider will not fit !
 #endif
-
-#define AS3525_I2C_FREQ         400000
+/* AS3525_I2C_FREQ */
 #if (CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ)) >= (1<<10) /* 2+8 bits */
 #error I2C frequency is too low : clock divider will not fit !
 #endif
-
-#define AS3525_DBOP_FREQ        32000000
-#if (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1) >= (1<<3) /* 3 bits */
-#error DBOP frequency is too low : clock divider will not fit !
-#endif
-
-#define AS3525_SD_IDENT_FREQ    400000      /* must be between 100 & 400 kHz */
+/* AS3525_SD_IDENT_FREQ */
 #if ((CLK_DIV(AS3525_PCLK_FREQ, AS3525_SD_IDENT_FREQ) / 2) - 1) >= (1<<8) /* 8 bits */
 #error SD IDENTIFICATION frequency is too low : clock divider will not fit !
 #endif
Index: firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
===================================================================
--- firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c	(revision 21022)
+++ firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c	(working copy)
@@ -50,7 +50,7 @@

 static void as3525_dbop_init(void)
 {
-    CGU_DBOP = (1<<3) | (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1);
+    CGU_DBOP = (1<<3) | AS3525_DBOP_DIV;

     DBOP_TIMPOL_01 = 0xe167e167;
     DBOP_TIMPOL_23 = 0xe167006e;
Index: firmware/target/arm/as3525/ata_sd_as3525.c
===================================================================
--- firmware/target/arm/as3525/ata_sd_as3525.c	(revision 21022)
+++ firmware/target/arm/as3525/ata_sd_as3525.c	(working copy)
@@ -41,6 +41,7 @@
 #include "stdbool.h"
 #include "ata_idle_notify.h"
 #include "sd.h"
+#include "mmu-arm.h"

 #ifdef HAVE_HOTSWAP
 #include "disk.h"
@@ -456,8 +457,7 @@

     MCI_SELECT(drive) = 0;

-    MCI_CLOCK(drive) = MCI_CLOCK_ENABLE |
-                (((CLK_DIV(AS3525_PCLK_FREQ, AS3525_SD_IDENT_FREQ)) / 2) - 1);
+    MCI_CLOCK(drive) = MCI_CLOCK_ENABLE | AS3525_SD_IDENT_DIV;
     mci_delay();
 }

@@ -466,8 +466,8 @@
     int ret;
     CGU_IDE =   (1<<7)  /* AHB interface enable */  |
                 (1<<6)  /* interface enable */      |
-                ((CLK_DIV(AS3525_PLLA_FREQ, AS3525_IDE_FREQ) - 1) << 2) |
-                1;       /* clock source = PLLA */
+                (AS3525_IDE_DIV << 2)               |
+                AS3525_CLK_PLLA;  /* clock source = PLLA */


     CGU_PERI |= CGU_NAF_CLOCK_ENABLE;