summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorFred Bauer <fred.w.bauer@gmail.com>2010-12-29 16:07:15 +0000
committerFred Bauer <fred.w.bauer@gmail.com>2010-12-29 16:07:15 +0000
commite541c98a7e19f22ab62a0adb370ea9f4c922e666 (patch)
tree74aa302fcc9e3c1ea05c9f45ad1724da8badd71e /firmware/target
parent7f31e38ac12884db251734482e0d37174c62e40b (diff)
downloadrockbox-e541c98a7e19f22ab62a0adb370ea9f4c922e666.tar.gz
rockbox-e541c98a7e19f22ab62a0adb370ea9f4c922e666.zip
revert r28834 because it causes problems with uSD
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28925 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/clock-target.h15
-rw-r--r--firmware/target/arm/as3525/debug-as3525.c11
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c42
-rw-r--r--firmware/target/arm/as3525/system-as3525.c42
4 files changed, 16 insertions, 94 deletions
diff --git a/firmware/target/arm/as3525/clock-target.h b/firmware/target/arm/as3525/clock-target.h
index 135164b25b..97d6edb3d1 100644
--- a/firmware/target/arm/as3525/clock-target.h
+++ b/firmware/target/arm/as3525/clock-target.h
@@ -114,19 +114,17 @@
114 /* *5/8 = 240MHz 120, 80, 60, 48, 40 */ 114 /* *5/8 = 240MHz 120, 80, 60, 48, 40 */
115//#define AS3525_PLLA_SETTING 0x2630 115//#define AS3525_PLLA_SETTING 0x2630
116 116
117#define AS3525_FCLK_PREDIV 2 /* div = (8-n)/8 Enter manually & postdiv will be calculated*/ 117#define AS3525_FCLK_PREDIV 0 /* div = (8-n)/8 Enter manually & postdiv will be calculated*/
118 /* 0 gives you the PLLA 1st line choices, 1 the 2nd line etc. */ 118 /* 0 gives you the PLLA 1st line choices, 1 the 2nd line etc. */
119 119
120#define AS3525_FCLK_FREQ 186000000 /* Boosted FCLK frequency - over 200MHz */ 120#define AS3525_FCLK_FREQ 248000000 /* Boosted FCLK frequency */
121 /* requires CVDDp bumped to 1.2V */ 121#define AS3525_DRAM_FREQ 62000000 /* Initial DRAM frequency */
122#define AS3525_DRAM_FREQ 31000000 /* Initial DRAM frequency */
123#define AS3525_DRAM_FREQ_BOOSTED 62000000
124/* AS3525_PCLK_FREQ != AS3525_DRAM_FREQ/1 will boot to white lcd screen */ 122/* AS3525_PCLK_FREQ != AS3525_DRAM_FREQ/1 will boot to white lcd screen */
125 123
126#endif /* CONFIG_CPU == AS3525v2 */ 124#endif /* CONFIG_CPU == AS3525v2 */
127 125
128#define AS3525_PCLK_FREQ (AS3525_DRAM_FREQ/1) /* PCLK divided from DRAM freq */ 126#define AS3525_PCLK_FREQ (AS3525_DRAM_FREQ/1) /* PCLK divided from DRAM freq */
129#define AS3525_PCLK_FREQ_BOOSTED (AS3525_DRAM_FREQ_BOOSTED/1) 127
130#define AS3525_DBOP_FREQ (AS3525_PCLK_FREQ/1) /* DBOP divided from PCLK freq */ 128#define AS3525_DBOP_FREQ (AS3525_PCLK_FREQ/1) /* DBOP divided from PCLK freq */
131 129
132/** ****************************************************************************/ 130/** ****************************************************************************/
@@ -171,9 +169,6 @@
171 /*unable to use AS3525_PCLK_DIV1 != 0 successfuly so far*/ 169 /*unable to use AS3525_PCLK_DIV1 != 0 successfuly so far*/
172#define AS3525_PCLK_DIV1 (CLK_DIV(AS3525_DRAM_FREQ, AS3525_PCLK_FREQ) - 1)/* div = 1/(n+1)*/ 170#define AS3525_PCLK_DIV1 (CLK_DIV(AS3525_DRAM_FREQ, AS3525_PCLK_FREQ) - 1)/* div = 1/(n+1)*/
173#define AS3525_PCLK_DIV0 (CLK_DIV(AS3525_PLLA_FREQ, AS3525_DRAM_FREQ) - 1) /*div=1/(n+1)*/ 171#define AS3525_PCLK_DIV0 (CLK_DIV(AS3525_PLLA_FREQ, AS3525_DRAM_FREQ) - 1) /*div=1/(n+1)*/
174#define AS3525_PCLK_DIV1_BOOSTED (CLK_DIV(AS3525_DRAM_FREQ_BOOSTED, AS3525_PCLK_FREQ_BOOSTED) - 1)
175#define AS3525_PCLK_DIV0_BOOSTED (CLK_DIV(AS3525_PLLA_FREQ, AS3525_PCLK_FREQ_BOOSTED) - 1)
176
177#else 172#else
178 173
179#define AS3525_PCLK_SEL AS3525_CLK_FCLK 174#define AS3525_PCLK_SEL AS3525_CLK_FCLK
@@ -184,10 +179,8 @@
184 /* PCLK as Source */ 179 /* PCLK as Source */
185 #define AS3525_DBOP_DIV (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1) /*div=1/(n+1)*/ 180 #define AS3525_DBOP_DIV (CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ) - 1) /*div=1/(n+1)*/
186 #define AS3525_I2C_PRESCALER CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ) 181 #define AS3525_I2C_PRESCALER CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ)
187 #define AS3525_I2C_PRESCALER_BOOSTED CLK_DIV(AS3525_PCLK_FREQ_BOOSTED, AS3525_I2C_FREQ)
188 #define AS3525_I2C_FREQ 400000 182 #define AS3525_I2C_FREQ 400000
189 #define AS3525_SD_IDENT_DIV ((CLK_DIV(AS3525_PCLK_FREQ, AS3525_SD_IDENT_FREQ) / 2) - 1) 183 #define AS3525_SD_IDENT_DIV ((CLK_DIV(AS3525_PCLK_FREQ, AS3525_SD_IDENT_FREQ) / 2) - 1)
190 #define AS3525_SD_IDENT_DIV_BOOSTED ((CLK_DIV(AS3525_PCLK_FREQ_BOOSTED, AS3525_SD_IDENT_FREQ) / 2) - 1)
191 #define AS3525_SD_IDENT_FREQ 400000 /* must be between 100 & 400 kHz */ 184 #define AS3525_SD_IDENT_FREQ 400000 /* must be between 100 & 400 kHz */
192 #define AS3525_SSP_PRESCALER ((CLK_DIV(AS3525_PCLK_FREQ, AS3525_SSP_FREQ) + 1) & ~1) /* must be an even number */ 185 #define AS3525_SSP_PRESCALER ((CLK_DIV(AS3525_PCLK_FREQ, AS3525_SSP_FREQ) + 1) & ~1) /* must be an even number */
193 #define AS3525_SSP_FREQ 12000000 186 #define AS3525_SSP_FREQ 12000000
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c
index 9950ccd9c6..513295edcb 100644
--- a/firmware/target/arm/as3525/debug-as3525.c
+++ b/firmware/target/arm/as3525/debug-as3525.c
@@ -182,12 +182,7 @@ static int calc_freq(int clk)
182 return 0; 182 return 0;
183 } 183 }
184 case CLK_I2C: 184 case CLK_I2C:
185#if CONFIG_CPU == AS3525 185 return calc_freq(CLK_PCLK)/AS3525_I2C_PRESCALER;
186 if (cpu_frequency == CPUFREQ_MAX)
187 return calc_freq(CLK_PCLK)/AS3525_I2C_PRESCALER_BOOSTED;
188 else
189#endif
190 return calc_freq(CLK_PCLK)/AS3525_I2C_PRESCALER;
191 case CLK_I2SI: 186 case CLK_I2SI:
192 switch((CGU_AUDIO>>12) & 3) { 187 switch((CGU_AUDIO>>12) & 3) {
193 case 0: 188 case 0:
@@ -223,7 +218,7 @@ static int calc_freq(int clk)
223 case CLK_SD_MCLK_MSD: 218 case CLK_SD_MCLK_MSD:
224 if(!(MCI_SD & (1<<8))) 219 if(!(MCI_SD & (1<<8)))
225 return 0; 220 return 0;
226 else if(MCI_SD & (1<<10)) /* bypass */ 221 else if(MCI_SD & (1<<10))
227 return calc_freq(CLK_PCLK); 222 return calc_freq(CLK_PCLK);
228 else 223 else
229 return calc_freq(CLK_PCLK)/(((MCI_SD & 0xff)+1)*2); 224 return calc_freq(CLK_PCLK)/(((MCI_SD & 0xff)+1)*2);
@@ -352,7 +347,7 @@ bool __dbg_hw_info(void)
352 calc_freq(CLK_SD_MCLK_NAND)/1000000); 347 calc_freq(CLK_SD_MCLK_NAND)/1000000);
353#ifdef HAVE_MULTIDRIVE 348#ifdef HAVE_MULTIDRIVE
354 lcd_putsf(0, line++, "uSD :%3dMHz %3dMHz", 349 lcd_putsf(0, line++, "uSD :%3dMHz %3dMHz",
355 ((calc_freq(CLK_PCLK)/ 1000000) / 350 ((AS3525_PCLK_FREQ/ 1000000) /
356 ((last_sd & MCI_CLOCK_BYPASS) ? 1: (((last_sd & 0xff) + 1) * 2))), 351 ((last_sd & MCI_CLOCK_BYPASS) ? 1: (((last_sd & 0xff) + 1) * 2))),
357 calc_freq(CLK_SD_MCLK_MSD)/1000000); 352 calc_freq(CLK_SD_MCLK_MSD)/1000000);
358#endif 353#endif
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 6f11145ee6..0dc29c8aa5 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -116,8 +116,9 @@ static void init_pl180_controller(const int drive);
116static tCardInfo card_info[NUM_DRIVES]; 116static tCardInfo card_info[NUM_DRIVES];
117 117
118/* maximum timeouts recommanded in the SD Specification v2.00 */ 118/* maximum timeouts recommanded in the SD Specification v2.00 */
119#define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ*(cpu_frequency==CPUFREQ_MAX?2:1)) / 1000 * 100) /* 100 ms */ 119#define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */
120#define SD_MAX_WRITE_TIMEOUT ((AS3525_PCLK_FREQ*(cpu_frequency==CPUFREQ_MAX?2:1)) / 1000 * 250) /* 250 ms */ 120#define SD_MAX_WRITE_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 250) /* 250 ms */
121
121/* for compatibility */ 122/* for compatibility */
122static long last_disk_activity = -1; 123static long last_disk_activity = -1;
123 124
@@ -139,8 +140,6 @@ static struct wakeup transfer_completion_signal;
139static volatile unsigned int transfer_error[NUM_VOLUMES]; 140static volatile unsigned int transfer_error[NUM_VOLUMES];
140#define PL180_MAX_TRANSFER_ERRORS 10 141#define PL180_MAX_TRANSFER_ERRORS 10
141 142
142extern long cpu_frequency;
143
144#define UNALIGNED_NUM_SECTORS 10 143#define UNALIGNED_NUM_SECTORS 10
145static unsigned char aligned_buffer[UNALIGNED_NUM_SECTORS* SD_BLOCK_SIZE] __attribute__((aligned(32))); /* align on cache line size */ 144static unsigned char aligned_buffer[UNALIGNED_NUM_SECTORS* SD_BLOCK_SIZE] __attribute__((aligned(32))); /* align on cache line size */
146static unsigned char *uncached_buffer = AS3525_UNCACHED_ADDR(&aligned_buffer[0]); 145static unsigned char *uncached_buffer = AS3525_UNCACHED_ADDR(&aligned_buffer[0]);
@@ -284,7 +283,7 @@ static bool send_cmd(const int drive, const int cmd, const int arg,
284#define MCI_HALFSPEED (MCI_CLOCK_ENABLE) /* MCLK/2 */ 283#define MCI_HALFSPEED (MCI_CLOCK_ENABLE) /* MCLK/2 */
285#define MCI_QUARTERSPEED (MCI_CLOCK_ENABLE | 1) /* MCLK/4 */ 284#define MCI_QUARTERSPEED (MCI_CLOCK_ENABLE | 1) /* MCLK/4 */
286#define MCI_IDENTSPEED (MCI_CLOCK_ENABLE | AS3525_SD_IDENT_DIV) /* IDENT */ 285#define MCI_IDENTSPEED (MCI_CLOCK_ENABLE | AS3525_SD_IDENT_DIV) /* IDENT */
287#define MCI_IDENTSPEED_BOOSTED (MCI_CLOCK_ENABLE | AS3525_SD_IDENT_DIV_BOOSTED) 286
288static int sd_init_card(const int drive) 287static int sd_init_card(const int drive)
289{ 288{
290 unsigned long response; 289 unsigned long response;
@@ -294,10 +293,7 @@ static int sd_init_card(const int drive)
294 card_info[drive].rca = 0; 293 card_info[drive].rca = 0;
295 294
296 /* MCLCK on and set to 400kHz ident frequency */ 295 /* MCLCK on and set to 400kHz ident frequency */
297 if (cpu_frequency == CPUFREQ_MAX) 296 MCI_CLOCK(drive) = MCI_IDENTSPEED;
298 MCI_CLOCK(drive) = MCI_IDENTSPEED_BOOSTED;
299 else
300 MCI_CLOCK(drive) = MCI_IDENTSPEED;
301 297
302 /* 100 - 400kHz clock required for Identification Mode */ 298 /* 100 - 400kHz clock required for Identification Mode */
303 /* Start of Card Identification Mode ************************************/ 299 /* Start of Card Identification Mode ************************************/
@@ -379,12 +375,8 @@ static int sd_init_card(const int drive)
379 MCI_CLOCK(drive) = MCI_HALFSPEED; /* MCICLK = IDE_CLK/2 = 25 MHz */ 375 MCI_CLOCK(drive) = MCI_HALFSPEED; /* MCICLK = IDE_CLK/2 = 25 MHz */
380#if defined(HAVE_MULTIDRIVE) 376#if defined(HAVE_MULTIDRIVE)
381 else 377 else
382 { /* PCLK = 31Mhz (62 boosted) MCI = 31Mhz(hs) or 15.5 */ 378 /* MCICLK = PCLK/2 = 31MHz(HS) or PCLK/4 = 15.5 Mhz (STD)*/
383 if (cpu_frequency == CPUFREQ_MAX ) 379 MCI_CLOCK(drive) = (hs_card ? MCI_HALFSPEED : MCI_QUARTERSPEED);
384 MCI_CLOCK(drive) = (hs_card ? MCI_HALFSPEED : MCI_QUARTERSPEED);
385 else
386 MCI_CLOCK(drive) = (hs_card ? MCI_FULLSPEED : MCI_HALFSPEED);
387 }
388#endif 380#endif
389 381
390 /* CMD7 w/rca: Select card to put it in TRAN state */ 382 /* CMD7 w/rca: Select card to put it in TRAN state */
@@ -531,26 +523,6 @@ static void sd_thread(void)
531 } 523 }
532} 524}
533 525
534#ifdef HAVE_MULTIDRIVE
535void sd_set_boosted_divider(void)
536{
537 if ( !sd_enabled )
538 return;
539 /* 62Mhz/2 - 62/4 */
540 MCI_CLOCK(SD_SLOT_AS3525) = (hs_card ?
541 MCI_HALFSPEED : MCI_QUARTERSPEED);
542}
543
544void sd_set_unboosted_divider(void)
545{
546 if ( !sd_enabled )
547 return;
548 /* 31Mhz/1 - 31/2 */
549 MCI_CLOCK(SD_SLOT_AS3525) = (hs_card ?
550 MCI_FULLSPEED : MCI_HALFSPEED);
551}
552#endif
553
554static void init_pl180_controller(const int drive) 526static void init_pl180_controller(const int drive)
555{ 527{
556 MCI_COMMAND(drive) = MCI_DATA_CTRL(drive) = 0; 528 MCI_COMMAND(drive) = MCI_DATA_CTRL(drive) = 0;
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
index 2c4543fa33..d8059715d0 100644
--- a/firmware/target/arm/as3525/system-as3525.c
+++ b/firmware/target/arm/as3525/system-as3525.c
@@ -33,12 +33,6 @@
33#include "backlight-target.h" 33#include "backlight-target.h"
34#include "lcd.h" 34#include "lcd.h"
35 35
36/* FIXME */
37#define I2C2_CPSR0 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x1C))
38#define I2C2_CPSR1 *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x20))
39extern void sd_set_boosted_divider(void);
40extern void sd_set_unboosted_divider(void);
41
42#define default_interrupt(name) \ 36#define default_interrupt(name) \
43 extern __attribute__((weak,alias("UIRQ"))) void name (void) 37 extern __attribute__((weak,alias("UIRQ"))) void name (void)
44 38
@@ -292,12 +286,7 @@ void system_init(void)
292#endif 286#endif
293 287
294 /* Initialize power management settings */ 288 /* Initialize power management settings */
295#if CONFIG_CPU == AS3525
296 ascodec_write(AS3514_CVDD_DCDC3, AS314_CP_DCDC3_SETTING|CVDD_1_10);
297#else
298 ascodec_write(AS3514_CVDD_DCDC3, AS314_CP_DCDC3_SETTING); 289 ascodec_write(AS3514_CVDD_DCDC3, AS314_CP_DCDC3_SETTING);
299#endif
300
301#if CONFIG_TUNER 290#if CONFIG_TUNER
302 fmradio_i2c_init(); 291 fmradio_i2c_init();
303#endif 292#endif
@@ -365,9 +354,7 @@ void set_cpu_frequency(long frequency)
365{ 354{
366 if(frequency == CPUFREQ_MAX) 355 if(frequency == CPUFREQ_MAX)
367 { 356 {
368#if defined(HAVE_ADJUSTABLE_CPU_VOLTAGE) && (CPUFREQ_MAX > 200000000) 357#ifdef HAVE_ADJUSTABLE_CPU_VOLTAGE
369 /* This doesn't work anymore. It was written before ascodec
370 was switched to use interrupts */
371 /* Increasing frequency so boost voltage before change */ 358 /* Increasing frequency so boost voltage before change */
372 ascodec_write(AS3514_CVDD_DCDC3, (AS314_CP_DCDC3_SETTING | CVDD_1_20)); 359 ascodec_write(AS3514_CVDD_DCDC3, (AS314_CP_DCDC3_SETTING | CVDD_1_20));
373 360
@@ -387,35 +374,10 @@ void set_cpu_frequency(long frequency)
387 "mcr p15, 0, r0, c1, c0 \n" 374 "mcr p15, 0, r0, c1, c0 \n"
388 : : : "r0" ); 375 : : : "r0" );
389 376
390#ifdef HAVE_MULTIDRIVE
391 /* Set uSD frequency */
392 sd_set_boosted_divider();
393#endif
394 /* Set I2C frequency */
395 I2C2_CPSR0 = AS3525_I2C_PRESCALER_BOOSTED & 0xFF; /* 8 lsb */
396 I2C2_CPSR1 = (AS3525_I2C_PRESCALER_BOOSTED >> 8) & 0x3; /* 2 msb */
397 /* Set PCLK frequency */
398 CGU_PERI = ((CGU_PERI & ~0x7F) | /* reset divider & clksel bits */
399 (AS3525_PCLK_DIV0_BOOSTED << 2) |
400 (AS3525_PCLK_DIV1_BOOSTED << 6) |
401 AS3525_PCLK_SEL);
402 cpu_frequency = CPUFREQ_MAX; 377 cpu_frequency = CPUFREQ_MAX;
403 } 378 }
404 else 379 else
405 { 380 {
406 /* Set I2C frequency */
407 I2C2_CPSR0 = AS3525_I2C_PRESCALER & 0xFF; /* 8 lsb */
408 I2C2_CPSR1 = (AS3525_I2C_PRESCALER >> 8) & 0x3; /* 2 msb */
409 /* Set PCLK frequency */
410 CGU_PERI = ((CGU_PERI & ~0x7F) | /* reset divider & clksel bits */
411 (AS3525_PCLK_DIV0 << 2) |
412 (AS3525_PCLK_DIV1 << 6) |
413 AS3525_PCLK_SEL);
414
415#ifdef HAVE_MULTIDRIVE
416 /* Set uSD frequency */
417 sd_set_unboosted_divider();
418#endif
419 asm volatile( 381 asm volatile(
420 "mrc p15, 0, r0, c1, c0 \n" 382 "mrc p15, 0, r0, c1, c0 \n"
421 "bic r0, r0, #3<<30 \n" /* fastbus clocking */ 383 "bic r0, r0, #3<<30 \n" /* fastbus clocking */
@@ -425,7 +387,7 @@ void set_cpu_frequency(long frequency)
425 /* FCLK is unused so put it to the lowest freq we can */ 387 /* FCLK is unused so put it to the lowest freq we can */
426 CGU_PROC = ((0xf << 4) | (0x3 << 2) | AS3525_CLK_MAIN); 388 CGU_PROC = ((0xf << 4) | (0x3 << 2) | AS3525_CLK_MAIN);
427 389
428#if defined(HAVE_ADJUSTABLE_CPU_VOLTAGE) && (CPUFREQ_MAX > 200000000) 390#ifdef HAVE_ADJUSTABLE_CPU_VOLTAGE
429 /* Decreasing frequency so reduce voltage after change */ 391 /* Decreasing frequency so reduce voltage after change */
430 ascodec_write(AS3514_CVDD_DCDC3, (AS314_CP_DCDC3_SETTING | CVDD_1_10)); 392 ascodec_write(AS3514_CVDD_DCDC3, (AS314_CP_DCDC3_SETTING | CVDD_1_10));
431#endif /* HAVE_ADJUSTABLE_CPU_VOLTAGE */ 393#endif /* HAVE_ADJUSTABLE_CPU_VOLTAGE */