diff options
author | Barry Wardell <rockbox@barrywardell.net> | 2007-04-22 12:03:17 +0000 |
---|---|---|
committer | Barry Wardell <rockbox@barrywardell.net> | 2007-04-22 12:03:17 +0000 |
commit | f43e50dc5333c096366a2a1cfd24728ea8030f62 (patch) | |
tree | d2701b71e2691ce3b6920bcd4032332d1b4af162 /firmware/target/arm/system-pp5002.c | |
parent | 0a643b8d9085f96e0c8ea267c12d634e2addf572 (diff) | |
download | rockbox-f43e50dc5333c096366a2a1cfd24728ea8030f62.tar.gz rockbox-f43e50dc5333c096366a2a1cfd24728ea8030f62.zip |
Move PortalPlayer system.c code into the target tree.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13239 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/system-pp5002.c')
-rw-r--r-- | firmware/target/arm/system-pp5002.c | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/firmware/target/arm/system-pp5002.c b/firmware/target/arm/system-pp5002.c new file mode 100644 index 0000000000..4954d0660a --- /dev/null +++ b/firmware/target/arm/system-pp5002.c | |||
@@ -0,0 +1,184 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include <stdio.h> | ||
20 | #include "config.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "lcd.h" | ||
23 | #include "font.h" | ||
24 | #include "system.h" | ||
25 | #include "kernel.h" | ||
26 | #include "thread.h" | ||
27 | #include "timer.h" | ||
28 | #include "inttypes.h" | ||
29 | #include "string.h" | ||
30 | |||
31 | unsigned int ipod_hw_rev; | ||
32 | #ifndef BOOTLOADER | ||
33 | extern void TIMER1(void); | ||
34 | extern void TIMER2(void); | ||
35 | |||
36 | void irq(void) | ||
37 | { | ||
38 | if(CURRENT_CORE == CPU) | ||
39 | { | ||
40 | if (CPU_INT_STAT & TIMER1_MASK) | ||
41 | TIMER1(); | ||
42 | else if (CPU_INT_STAT & TIMER2_MASK) | ||
43 | TIMER2(); | ||
44 | } else { | ||
45 | if (COP_INT_STAT & TIMER1_MASK) | ||
46 | TIMER1(); | ||
47 | else if (COP_INT_STAT & TIMER2_MASK) | ||
48 | TIMER2(); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | #endif | ||
53 | |||
54 | unsigned int current_core(void) | ||
55 | { | ||
56 | if(((*(volatile unsigned long *)(0xc4000000)) & 0xff) == 0x55) | ||
57 | { | ||
58 | return CPU; | ||
59 | } | ||
60 | return COP; | ||
61 | } | ||
62 | |||
63 | |||
64 | /* TODO: The following two function have been lifted straight from IPL, and | ||
65 | hence have a lot of numeric addresses used straight. I'd like to use | ||
66 | #defines for these, but don't know what most of them are for or even what | ||
67 | they should be named. Because of this I also have no way of knowing how | ||
68 | to extend the funtions to do alternate cache configurations and/or | ||
69 | some other CPU frequency scaling. */ | ||
70 | |||
71 | #ifndef BOOTLOADER | ||
72 | static void ipod_init_cache(void) | ||
73 | { | ||
74 | int i =0; | ||
75 | /* Initialising the cache in the iPod bootloader prevents Rockbox from starting */ | ||
76 | outl(inl(0xcf004050) & ~0x700, 0xcf004050); | ||
77 | outl(0x4000, 0xcf004020); | ||
78 | |||
79 | outl(0x2, 0xcf004024); | ||
80 | |||
81 | /* PP5002 has 8KB cache */ | ||
82 | for (i = 0xf0004000; i < (int)(0xf0006000); i += 16) { | ||
83 | outl(0x0, i); | ||
84 | } | ||
85 | |||
86 | outl(0x0, 0xf000f020); | ||
87 | outl(0x3fc0, 0xf000f024); | ||
88 | |||
89 | outl(0x3, 0xcf004024); | ||
90 | } | ||
91 | |||
92 | #endif | ||
93 | |||
94 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
95 | void set_cpu_frequency(long frequency) | ||
96 | { | ||
97 | unsigned long postmult; | ||
98 | |||
99 | if (CURRENT_CORE == CPU) | ||
100 | { | ||
101 | if (frequency == CPUFREQ_NORMAL) | ||
102 | postmult = CPUFREQ_NORMAL_MULT; | ||
103 | else if (frequency == CPUFREQ_MAX) | ||
104 | postmult = CPUFREQ_MAX_MULT; | ||
105 | else | ||
106 | postmult = CPUFREQ_DEFAULT_MULT; | ||
107 | cpu_frequency = frequency; | ||
108 | |||
109 | outl(0x02, 0xcf005008); | ||
110 | outl(0x55, 0xcf00500c); | ||
111 | outl(0x6000, 0xcf005010); | ||
112 | |||
113 | /* Clock frequency = (24/8)*postmult */ | ||
114 | outl(8, 0xcf005018); | ||
115 | outl(postmult, 0xcf00501c); | ||
116 | |||
117 | outl(0xe000, 0xcf005010); | ||
118 | |||
119 | /* Wait for PLL relock? */ | ||
120 | udelay(2000); | ||
121 | |||
122 | /* Select PLL as clock source? */ | ||
123 | outl(0xa8, 0xcf00500c); | ||
124 | } | ||
125 | } | ||
126 | #elif !defined(BOOTLOADER) | ||
127 | static void ipod_set_cpu_speed(void) | ||
128 | { | ||
129 | outl(0x02, 0xcf005008); | ||
130 | outl(0x55, 0xcf00500c); | ||
131 | outl(0x6000, 0xcf005010); | ||
132 | #if 1 | ||
133 | // 75 MHz (24/24 * 75) (default) | ||
134 | outl(24, 0xcf005018); | ||
135 | outl(75, 0xcf00501c); | ||
136 | #endif | ||
137 | |||
138 | #if 0 | ||
139 | // 66 MHz (24/3 * 8) | ||
140 | outl(3, 0xcf005018); | ||
141 | outl(8, 0xcf00501c); | ||
142 | #endif | ||
143 | |||
144 | outl(0xe000, 0xcf005010); | ||
145 | |||
146 | udelay(2000); | ||
147 | |||
148 | outl(0xa8, 0xcf00500c); | ||
149 | } | ||
150 | #endif | ||
151 | |||
152 | void system_init(void) | ||
153 | { | ||
154 | #ifndef BOOTLOADER | ||
155 | if (CURRENT_CORE == CPU) | ||
156 | { | ||
157 | /* Remap the flash ROM from 0x00000000 to 0x20000000. */ | ||
158 | MMAP3_LOGICAL = 0x20000000 | 0x3a00; | ||
159 | MMAP3_PHYSICAL = 0x00000000 | 0x3f84; | ||
160 | |||
161 | ipod_hw_rev = (*((volatile unsigned long*)(0x01fffffc))); | ||
162 | outl(-1, 0xcf00101c); | ||
163 | outl(-1, 0xcf001028); | ||
164 | outl(-1, 0xcf001038); | ||
165 | #ifndef HAVE_ADJUSTABLE_CPU_FREQ | ||
166 | ipod_set_cpu_speed(); | ||
167 | #endif | ||
168 | } | ||
169 | ipod_init_cache(); | ||
170 | #endif | ||
171 | } | ||
172 | |||
173 | void system_reboot(void) | ||
174 | { | ||
175 | outl(inl(0xcf005030) | 0x4, 0xcf005030); | ||
176 | } | ||
177 | |||
178 | int system_memory_guard(int newmode) | ||
179 | { | ||
180 | (void)newmode; | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | |||