diff options
Diffstat (limited to 'firmware/target/arm/pp/system-target.h')
-rw-r--r-- | firmware/target/arm/pp/system-target.h | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/firmware/target/arm/pp/system-target.h b/firmware/target/arm/pp/system-target.h new file mode 100644 index 0000000000..e7f9ce0245 --- /dev/null +++ b/firmware/target/arm/pp/system-target.h | |||
@@ -0,0 +1,206 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * Copyright (C) 2007 by Michael Sevakis | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | #ifndef SYSTEM_TARGET_H | ||
23 | #define SYSTEM_TARGET_H | ||
24 | |||
25 | #include "config.h" | ||
26 | #include "system-arm.h" | ||
27 | #include <stdbool.h> | ||
28 | |||
29 | #ifdef CPU_PP | ||
30 | /* TODO: This header is actually portalplayer specific, and should be | ||
31 | * moved into an appropriate subdir (or even split in 2). */ | ||
32 | |||
33 | #if CONFIG_CPU == PP5002 | ||
34 | #define CPUFREQ_SLEEP 32768 | ||
35 | #define CPUFREQ_DEFAULT 24000000 | ||
36 | #define CPUFREQ_NORMAL 30000000 | ||
37 | #define CPUFREQ_MAX 80000000 | ||
38 | |||
39 | #else /* PP5022, PP5024 */ | ||
40 | #define CPUFREQ_SLEEP 32768 | ||
41 | #define CPUFREQ_DEFAULT 24000000 | ||
42 | #define CPUFREQ_NORMAL 30000000 | ||
43 | #define CPUFREQ_MAX 80000000 | ||
44 | #endif | ||
45 | |||
46 | #define inl(a) (*(volatile unsigned long *) (a)) | ||
47 | #define outl(a,b) (*(volatile unsigned long *) (b) = (a)) | ||
48 | #define inb(a) (*(volatile unsigned char *) (a)) | ||
49 | #define outb(a,b) (*(volatile unsigned char *) (b) = (a)) | ||
50 | #define inw(a) (*(volatile unsigned short *) (a)) | ||
51 | #define outw(a,b) (*(volatile unsigned short *) (b) = (a)) | ||
52 | |||
53 | void usb_pin_init(void); | ||
54 | bool usb_plugged(void); | ||
55 | void firewire_insert_int(void); | ||
56 | void usb_insert_int(void); | ||
57 | |||
58 | static inline void udelay(unsigned usecs) | ||
59 | { | ||
60 | unsigned stop = USEC_TIMER + usecs; | ||
61 | while (TIME_BEFORE(USEC_TIMER, stop)); | ||
62 | } | ||
63 | |||
64 | static inline unsigned int current_core(void) | ||
65 | { | ||
66 | /* | ||
67 | * PROCESSOR_ID seems to be 32-bits: | ||
68 | * CPU = 0x55555555 = |01010101|01010101|01010101|01010101| | ||
69 | * COP = 0xaaaaaaaa = |10101010|10101010|10101010|10101010| | ||
70 | * ^ | ||
71 | */ | ||
72 | unsigned int core; | ||
73 | asm volatile ( | ||
74 | "ldrb %0, [%1] \n" /* Just load the LSB */ | ||
75 | "mov %0, %0, lsr #7 \n" /* Bit 7 => index */ | ||
76 | : "=r"(core) /* CPU=0, COP=1 */ | ||
77 | : "r"(&PROCESSOR_ID) | ||
78 | ); | ||
79 | return core; | ||
80 | } | ||
81 | |||
82 | /* Return the actual ID instead of core index */ | ||
83 | static inline unsigned int processor_id(void) | ||
84 | { | ||
85 | unsigned int id; | ||
86 | |||
87 | asm volatile ( | ||
88 | "ldrb %0, [%1] \n" | ||
89 | : "=r"(id) | ||
90 | : "r"(&PROCESSOR_ID) | ||
91 | ); | ||
92 | |||
93 | return id; | ||
94 | } | ||
95 | |||
96 | #if CONFIG_CPU == PP5002 | ||
97 | static inline void sleep_core(int core) | ||
98 | { | ||
99 | asm volatile ( | ||
100 | /* Sleep: PP5002 crashes if the instruction that puts it to sleep is | ||
101 | * located at 0xNNNNNNN0. 4/8/C works. This sequence makes sure | ||
102 | * that the correct alternative is executed. Don't change the order | ||
103 | * of the next 4 instructions! */ | ||
104 | "tst pc, #0x0c \n" | ||
105 | "mov r0, #0xca \n" | ||
106 | "strne r0, [%[ctl]] \n" | ||
107 | "streq r0, [%[ctl]] \n" | ||
108 | "nop \n" /* nop's needed because of pipeline */ | ||
109 | "nop \n" | ||
110 | "nop \n" | ||
111 | : | ||
112 | : [ctl]"r"(&PROC_CTL(core)) | ||
113 | : "r0" | ||
114 | ); | ||
115 | } | ||
116 | static inline void wake_core(int core) | ||
117 | { | ||
118 | asm volatile ( | ||
119 | "mov r0, #0xce \n" | ||
120 | "str r0, [%[ctl]] \n" | ||
121 | : | ||
122 | : [ctl]"r"(&PROC_CTL(core)) | ||
123 | : "r0" | ||
124 | ); | ||
125 | } | ||
126 | #else /* PP502x */ | ||
127 | static inline void sleep_core(int core) | ||
128 | { | ||
129 | asm volatile ( | ||
130 | "mov r0, #0x80000000 \n" | ||
131 | "str r0, [%[ctl]] \n" | ||
132 | "nop \n" | ||
133 | : | ||
134 | : [ctl]"r"(&PROC_CTL(core)) | ||
135 | : "r0" | ||
136 | ); | ||
137 | } | ||
138 | static inline void wake_core(int core) | ||
139 | { | ||
140 | asm volatile ( | ||
141 | "mov r0, #0 \n" | ||
142 | "str r0, [%[ctl]] \n" | ||
143 | : | ||
144 | : [ctl]"r"(&PROC_CTL(core)) | ||
145 | : "r0" | ||
146 | ); | ||
147 | } | ||
148 | #endif | ||
149 | |||
150 | void commit_dcache(void); | ||
151 | void commit_discard_dcache(void); | ||
152 | void commit_discard_idcache(void); | ||
153 | |||
154 | #if defined(BOOTLOADER) && !defined(HAVE_BOOTLOADER_USB_MODE) | ||
155 | /* All addresses within rockbox are in IRAM in the bootloader so | ||
156 | are therefore uncached */ | ||
157 | #define UNCACHED_ADDR(a) (a) | ||
158 | |||
159 | #else /* !BOOTLOADER */ | ||
160 | |||
161 | #if CONFIG_CPU == PP5002 | ||
162 | #define UNCACHED_BASE_ADDR 0x28000000 | ||
163 | #else /* PP502x */ | ||
164 | #define UNCACHED_BASE_ADDR 0x10000000 | ||
165 | #endif | ||
166 | |||
167 | #define UNCACHED_ADDR(a) \ | ||
168 | ((typeof (a))((uintptr_t)(a) | UNCACHED_BASE_ADDR)) | ||
169 | #endif /* BOOTLOADER */ | ||
170 | |||
171 | #if defined(CPU_PP502x) && defined(HAVE_ATA_DMA) | ||
172 | #define STORAGE_WANTS_ALIGN | ||
173 | #endif | ||
174 | |||
175 | #if defined(IPOD_VIDEO) && !defined(BOOTLOADER) | ||
176 | extern unsigned char probed_ramsize; | ||
177 | int battery_default_capacity(void); | ||
178 | #endif | ||
179 | |||
180 | |||
181 | #ifdef BOOTLOADER | ||
182 | #if defined(TATUNG_TPJ1022) | ||
183 | /* Some targets don't like yielding in the bootloader - force | ||
184 | * yield() to return without a context switch. */ | ||
185 | #define YIELD_KERNEL_HOOK() true | ||
186 | #endif | ||
187 | |||
188 | #ifdef HAVE_BOOTLOADER_USB_MODE | ||
189 | void tick_stop(void); | ||
190 | void system_prepare_fw_start(void); | ||
191 | |||
192 | #else /* !HAVE_BOOTLOADER_USB_MODE */ | ||
193 | |||
194 | /* Busy "sleep" without a tick */ | ||
195 | #define SLEEP_KERNEL_HOOK(ticks) \ | ||
196 | ({ unsigned _stop = USEC_TIMER + ((ticks) + 1) * (1000000/HZ); \ | ||
197 | while (TIME_BEFORE(USEC_TIMER, _stop)) \ | ||
198 | switch_thread(); \ | ||
199 | true; }) | ||
200 | #endif /* HAVE_BOOTLOADER_USB_MODE */ | ||
201 | |||
202 | #endif /* BOOTLOADER */ | ||
203 | |||
204 | #endif /* CPU_PP */ | ||
205 | |||
206 | #endif /* SYSTEM_TARGET_H */ | ||