1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Alan Korr
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 #include "adc-target.h"
25 #include "button-target.h"
27 extern void TIMER1(void);
28 extern void TIMER2(void);
32 if(CURRENT_CORE
== CPU
)
34 if (CPU_INT_STAT
& TIMER1_MASK
)
36 else if (CPU_INT_STAT
& TIMER2_MASK
)
38 else if (CPU_INT_STAT
& GPIO_MASK
)
43 if (GPIOB_INT_STAT
& 0x04)
50 if (COP_INT_STAT
& TIMER2_MASK
)
57 /* TODO: The following two function have been lifted straight from IPL, and
58 hence have a lot of numeric addresses used straight. I'd like to use
59 #defines for these, but don't know what most of them are for or even what
60 they should be named. Because of this I also have no way of knowing how
61 to extend the funtions to do alternate cache configurations and/or
62 some other CPU frequency scaling. */
65 void flush_icache(void) ICODE_ATTR
;
66 void flush_icache(void)
70 for (b
= (intptr_t)&CACHE_FLUSH_BASE
, e
= b
+ CACHE_SIZE
;
76 void invalidate_icache(void) ICODE_ATTR
;
77 void invalidate_icache(void)
82 for (b
= (intptr_t)&CACHE_FLUSH_BASE
, e
= b
+ CACHE_SIZE
;
88 for (b
= (intptr_t)&CACHE_INVALIDATE_BASE
, e
= b
+ CACHE_SIZE
;
94 static void ipod_init_cache(void)
98 /* Initialising the cache in the iPod bootloader prevents Rockbox from starting */
100 outl(0x4000, 0xcf004020);
102 CACHE_CTL
= CACHE_INIT
;
104 for (b
= (intptr_t)&CACHE_INVALIDATE_BASE
, e
= b
+ CACHE_SIZE
;
109 /* Cache if (addr & mask) >> 16 == (mask & match) >> 16:
110 * yes: 0x00000000 - 0x03ffffff
111 * no: 0x04000000 - 0x1fffffff
112 * yes: 0x20000000 - 0x23ffffff
113 * no: 0x24000000 - 0x3fffffff <= range containing uncached alias
115 CACHE_MASK
= 0x00001c00;
116 CACHE_OPERATION
= 0x3fc0;
118 CACHE_CTL
= CACHE_INIT
| CACHE_RUN
;
121 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
122 void set_cpu_frequency(long frequency
)
124 static void pp_set_cpu_frequency(long frequency
)
127 cpu_frequency
= frequency
;
129 PLL_CONTROL
|= 0x6000; /* make sure some enable bits are set */
130 CLOCK_ENABLE
= 0x01; /* select source #1 */
135 PLL_UNLOCK
= 0xd19b; /* unlock frequencies > 66MHz */
136 CLOCK_SOURCE
= 0xa9; /* source #1: 24 Mhz, source #2..#4: PLL */
137 PLL_CONTROL
= 0xe000; /* PLL enabled */
138 PLL_DIV
= 3; /* 10/3 * 24MHz */
140 udelay(200); /* wait for relock */
144 CLOCK_SOURCE
= 0xa9; /* source #1: 24 Mhz, source #2..#4: PLL */
145 PLL_CONTROL
= 0xe000; /* PLL enabled */
146 PLL_DIV
= 4; /* 5/4 * 24MHz */
148 udelay(200); /* wait for relock */
152 CLOCK_SOURCE
= 0x51; /* source #2: 32kHz, #1, #2, #4: 24MHz */
153 PLL_CONTROL
= 0x6000; /* PLL disabled */
154 udelay(10000); /* let 32kHz source stabilize? */
158 CLOCK_SOURCE
= 0x55; /* source #1..#4: 24 Mhz */
159 PLL_CONTROL
= 0x6000; /* PLL disabled */
160 cpu_frequency
= CPUFREQ_DEFAULT
;
163 CLOCK_ENABLE
= 0x02; /* select source #2 */
165 #endif /* !BOOTLOADER */
167 void system_init(void)
170 if (CURRENT_CORE
== CPU
)
172 /* Remap the flash ROM on CPU, keep hidden from COP:
173 * 0x00000000-0x03ffffff = 0x20000000-0x23ffffff */
174 MMAP1_LOGICAL
= 0x20003c00;
175 MMAP1_PHYSICAL
= 0x00003f84;
177 #if defined(IPOD_1G2G) || defined(IPOD_3G)
178 DEV_EN
= 0x0b9f; /* don't clock unused PP5002 hardware components */
179 outl(0x0035, 0xcf005004); /* DEV_EN2 ? */
191 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
196 pp_set_cpu_frequency(CPUFREQ_MAX
);
203 void system_reboot(void)
208 int system_memory_guard(int newmode
)