diff options
-rw-r--r-- | firmware/target/arm/gigabeat/meg-fx/system-target.h (renamed from firmware/target/arm/gigabeat/meg-fx/system-meg-fx.h) | 8 | ||||
-rw-r--r-- | firmware/target/arm/iriver/ifp7xx/system-target.h | 34 | ||||
-rw-r--r-- | firmware/target/arm/system-arm.h | 130 | ||||
-rw-r--r-- | firmware/target/arm/system-pp.h | 53 | ||||
-rw-r--r-- | firmware/target/arm/system-target.h | 142 |
5 files changed, 195 insertions, 172 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/system-meg-fx.h b/firmware/target/arm/gigabeat/meg-fx/system-target.h index 7d598af360..215b5a4daa 100644 --- a/firmware/target/arm/gigabeat/meg-fx/system-meg-fx.h +++ b/firmware/target/arm/gigabeat/meg-fx/system-target.h | |||
@@ -16,8 +16,15 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #ifndef SYSTEM_TARGET_H | ||
20 | #define SYSTEM_TARGET_H | ||
19 | 21 | ||
20 | #include "mmu-meg-fx.h" | 22 | #include "mmu-meg-fx.h" |
23 | #include "system-arm.h" | ||
24 | |||
25 | #define CPUFREQ_DEFAULT 98784000 | ||
26 | #define CPUFREQ_NORMAL 98784000 | ||
27 | #define CPUFREQ_MAX 296352000 | ||
21 | 28 | ||
22 | #define HAVE_INVALIDATE_ICACHE | 29 | #define HAVE_INVALIDATE_ICACHE |
23 | static inline void invalidate_icache(void) | 30 | static inline void invalidate_icache(void) |
@@ -30,3 +37,4 @@ static inline void invalidate_icache(void) | |||
30 | ); | 37 | ); |
31 | } | 38 | } |
32 | 39 | ||
40 | #endif /* SYSTEM_TARGET_H */ | ||
diff --git a/firmware/target/arm/iriver/ifp7xx/system-target.h b/firmware/target/arm/iriver/ifp7xx/system-target.h new file mode 100644 index 0000000000..dc11bb74da --- /dev/null +++ b/firmware/target/arm/iriver/ifp7xx/system-target.h | |||
@@ -0,0 +1,34 @@ | |||
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 | #ifndef SYSTEM_TARGET_H | ||
20 | #define SYSTEM_TARGET_H | ||
21 | |||
22 | #include "system-arm.h" | ||
23 | |||
24 | #define CPUFREQ_DEFAULT 12000000 | ||
25 | #define CPUFREQ_NORMAL 48000000 | ||
26 | #define CPUFREQ_MAX 60000000 | ||
27 | |||
28 | typedef void (*interrupt_handler_t)(void); | ||
29 | |||
30 | void irq_set_int_handler(int n, interrupt_handler_t handler); | ||
31 | void irq_enable_int(int n); | ||
32 | void irq_disable_int(int n); | ||
33 | |||
34 | #endif /* SYSTEM_TARGET_H */ | ||
diff --git a/firmware/target/arm/system-arm.h b/firmware/target/arm/system-arm.h new file mode 100644 index 0000000000..7126350a64 --- /dev/null +++ b/firmware/target/arm/system-arm.h | |||
@@ -0,0 +1,130 @@ | |||
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 | #ifndef SYSTEM_ARM_H | ||
20 | #define SYSTEM_ARM_H | ||
21 | |||
22 | #define nop \ | ||
23 | asm volatile ("nop") | ||
24 | |||
25 | /* This gets too complicated otherwise with all the ARM variation and would | ||
26 | have conflicts with another system-target.h elsewhere so include a | ||
27 | subheader from here. */ | ||
28 | |||
29 | /* TODO: Implement set_irq_level and check CPU frequencies */ | ||
30 | |||
31 | #if CONFIG_CPU != S3C2440 && CONFIG_CPU != PNX0101 | ||
32 | |||
33 | /* TODO: Finish targeting this stuff */ | ||
34 | #define CPUFREQ_DEFAULT_MULT 8 | ||
35 | #define CPUFREQ_DEFAULT 24000000 | ||
36 | #define CPUFREQ_NORMAL_MULT 10 | ||
37 | #define CPUFREQ_NORMAL 30000000 | ||
38 | #define CPUFREQ_MAX_MULT 25 | ||
39 | #define CPUFREQ_MAX 75000000 | ||
40 | |||
41 | #endif | ||
42 | |||
43 | static inline uint16_t swap16(uint16_t value) | ||
44 | /* | ||
45 | result[15..8] = value[ 7..0]; | ||
46 | result[ 7..0] = value[15..8]; | ||
47 | */ | ||
48 | { | ||
49 | return (value >> 8) | (value << 8); | ||
50 | } | ||
51 | |||
52 | static inline uint32_t swap32(uint32_t value) | ||
53 | /* | ||
54 | result[31..24] = value[ 7.. 0]; | ||
55 | result[23..16] = value[15.. 8]; | ||
56 | result[15.. 8] = value[23..16]; | ||
57 | result[ 7.. 0] = value[31..24]; | ||
58 | */ | ||
59 | { | ||
60 | uint32_t tmp; | ||
61 | |||
62 | asm volatile ( | ||
63 | "eor %1, %0, %0, ror #16 \n\t" | ||
64 | "bic %1, %1, #0xff0000 \n\t" | ||
65 | "mov %0, %0, ror #8 \n\t" | ||
66 | "eor %0, %0, %1, lsr #8 \n\t" | ||
67 | : "+r" (value), "=r" (tmp) | ||
68 | ); | ||
69 | return value; | ||
70 | } | ||
71 | |||
72 | static inline uint32_t swap_odd_even32(uint32_t value) | ||
73 | { | ||
74 | /* | ||
75 | result[31..24],[15.. 8] = value[23..16],[ 7.. 0] | ||
76 | result[23..16],[ 7.. 0] = value[31..24],[15.. 8] | ||
77 | */ | ||
78 | uint32_t tmp; | ||
79 | |||
80 | asm volatile ( /* ABCD */ | ||
81 | "bic %1, %0, #0x00ff00 \n\t" /* AB.D */ | ||
82 | "bic %0, %0, #0xff0000 \n\t" /* A.CD */ | ||
83 | "mov %0, %0, lsr #8 \n\t" /* .A.C */ | ||
84 | "orr %0, %0, %1, lsl #8 \n\t" /* B.D.|.A.C */ | ||
85 | : "+r" (value), "=r" (tmp) /* BADC */ | ||
86 | ); | ||
87 | return value; | ||
88 | } | ||
89 | |||
90 | #define HIGHEST_IRQ_LEVEL (1) | ||
91 | |||
92 | static inline int set_irq_level(int level) | ||
93 | { | ||
94 | unsigned long cpsr; | ||
95 | /* Read the old level and set the new one */ | ||
96 | asm volatile ("mrs %0,cpsr" : "=r" (cpsr)); | ||
97 | asm volatile ("msr cpsr_c,%0" | ||
98 | : : "r" ((cpsr & ~0x80) | (level << 7))); | ||
99 | return (cpsr >> 7) & 1; | ||
100 | } | ||
101 | |||
102 | static inline void set_fiq_handler(void(*fiq_handler)(void)) | ||
103 | { | ||
104 | /* Install the FIQ handler */ | ||
105 | *((unsigned int*)(15*4)) = (unsigned int)fiq_handler; | ||
106 | } | ||
107 | |||
108 | static inline void enable_fiq(void) | ||
109 | { | ||
110 | /* Clear FIQ disable bit */ | ||
111 | asm volatile ( | ||
112 | "mrs r0, cpsr \n"\ | ||
113 | "bic r0, r0, #0x40 \n"\ | ||
114 | "msr cpsr_c, r0 " | ||
115 | : : : "r0" | ||
116 | ); | ||
117 | } | ||
118 | |||
119 | static inline void disable_fiq(void) | ||
120 | { | ||
121 | /* Set FIQ disable bit */ | ||
122 | asm volatile ( | ||
123 | "mrs r0, cpsr \n"\ | ||
124 | "orr r0, r0, #0x40 \n"\ | ||
125 | "msr cpsr_c, r0 " | ||
126 | : : : "r0" | ||
127 | ); | ||
128 | } | ||
129 | |||
130 | #endif /* SYSTEM_ARM_H */ | ||
diff --git a/firmware/target/arm/system-pp.h b/firmware/target/arm/system-pp.h deleted file mode 100644 index 47ef48218c..0000000000 --- a/firmware/target/arm/system-pp.h +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
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 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #define inl(a) (*(volatile unsigned long *) (a)) | ||
22 | #define outl(a,b) (*(volatile unsigned long *) (b) = (a)) | ||
23 | #define inb(a) (*(volatile unsigned char *) (a)) | ||
24 | #define outb(a,b) (*(volatile unsigned char *) (b) = (a)) | ||
25 | #define inw(a) (*(volatile unsigned short *) (a)) | ||
26 | #define outw(a,b) (*(volatile unsigned short *) (b) = (a)) | ||
27 | extern unsigned int ipod_hw_rev; | ||
28 | |||
29 | static inline void udelay(unsigned usecs) | ||
30 | { | ||
31 | unsigned stop = USEC_TIMER + usecs; | ||
32 | while (TIME_BEFORE(USEC_TIMER, stop)); | ||
33 | } | ||
34 | |||
35 | unsigned int current_core(void); | ||
36 | |||
37 | #if CONFIG_CPU != PP5002 | ||
38 | |||
39 | #define HAVE_INVALIDATE_ICACHE | ||
40 | static inline void invalidate_icache(void) | ||
41 | { | ||
42 | outl(inl(0xf000f044) | 0x6, 0xf000f044); | ||
43 | while ((CACHE_CTL & 0x8000) != 0); | ||
44 | } | ||
45 | |||
46 | #define HAVE_FLUSH_ICACHE | ||
47 | static inline void flush_icache(void) | ||
48 | { | ||
49 | outl(inl(0xf000f044) | 0x2, 0xf000f044); | ||
50 | while ((CACHE_CTL & 0x8000) != 0); | ||
51 | } | ||
52 | |||
53 | #endif /* CONFIG_CPU */ | ||
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h index ceb8be2079..2b72e9293e 100644 --- a/firmware/target/arm/system-target.h +++ b/firmware/target/arm/system-target.h | |||
@@ -8,6 +8,7 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2002 by Alan Korr | 10 | * Copyright (C) 2002 by Alan Korr |
11 | * Copyright (C) 2007 by Michael Sevakis | ||
11 | * | 12 | * |
12 | * All files in this archive are subject to the GNU General Public License. | 13 | * 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 | * See the file COPYING in the source tree root for full license agreement. |
@@ -19,137 +20,40 @@ | |||
19 | #ifndef SYSTEM_TARGET_H | 20 | #ifndef SYSTEM_TARGET_H |
20 | #define SYSTEM_TARGET_H | 21 | #define SYSTEM_TARGET_H |
21 | 22 | ||
22 | #define nop \ | 23 | #include "system-arm.h" |
23 | asm volatile ("nop") | ||
24 | 24 | ||
25 | /* This gets too complicated otherwise with all the ARM variation and would | 25 | #define inl(a) (*(volatile unsigned long *) (a)) |
26 | have conflicts with another system-target.h elsewhere so include a | 26 | #define outl(a,b) (*(volatile unsigned long *) (b) = (a)) |
27 | subheader from here. */ | 27 | #define inb(a) (*(volatile unsigned char *) (a)) |
28 | #define outb(a,b) (*(volatile unsigned char *) (b) = (a)) | ||
29 | #define inw(a) (*(volatile unsigned short *) (a)) | ||
30 | #define outw(a,b) (*(volatile unsigned short *) (b) = (a)) | ||
31 | extern unsigned int ipod_hw_rev; | ||
28 | 32 | ||
29 | #ifdef CPU_PP | 33 | static inline void udelay(unsigned usecs) |
30 | #include "system-pp.h" | ||
31 | #elif CONFIG_CPU == S3C2440 | ||
32 | #include "system-meg-fx.h" | ||
33 | #endif | ||
34 | |||
35 | /* TODO: Implement set_irq_level and check CPU frequencies */ | ||
36 | |||
37 | #if CONFIG_CPU == S3C2440 | ||
38 | |||
39 | #define CPUFREQ_DEFAULT 98784000 | ||
40 | #define CPUFREQ_NORMAL 98784000 | ||
41 | #define CPUFREQ_MAX 296352000 | ||
42 | |||
43 | #elif CONFIG_CPU == PNX0101 | ||
44 | |||
45 | #define CPUFREQ_DEFAULT 12000000 | ||
46 | #define CPUFREQ_NORMAL 48000000 | ||
47 | #define CPUFREQ_MAX 60000000 | ||
48 | |||
49 | #else | ||
50 | |||
51 | #define CPUFREQ_DEFAULT_MULT 8 | ||
52 | #define CPUFREQ_DEFAULT 24000000 | ||
53 | #define CPUFREQ_NORMAL_MULT 10 | ||
54 | #define CPUFREQ_NORMAL 30000000 | ||
55 | #define CPUFREQ_MAX_MULT 25 | ||
56 | #define CPUFREQ_MAX 75000000 | ||
57 | |||
58 | #endif | ||
59 | |||
60 | static inline uint16_t swap16(uint16_t value) | ||
61 | /* | ||
62 | result[15..8] = value[ 7..0]; | ||
63 | result[ 7..0] = value[15..8]; | ||
64 | */ | ||
65 | { | 34 | { |
66 | return (value >> 8) | (value << 8); | 35 | unsigned stop = USEC_TIMER + usecs; |
36 | while (TIME_BEFORE(USEC_TIMER, stop)); | ||
67 | } | 37 | } |
68 | 38 | ||
69 | static inline uint32_t swap32(uint32_t value) | 39 | unsigned int current_core(void); |
70 | /* | ||
71 | result[31..24] = value[ 7.. 0]; | ||
72 | result[23..16] = value[15.. 8]; | ||
73 | result[15.. 8] = value[23..16]; | ||
74 | result[ 7.. 0] = value[31..24]; | ||
75 | */ | ||
76 | { | ||
77 | uint32_t tmp; | ||
78 | 40 | ||
79 | asm volatile ( | 41 | #if CONFIG_CPU != PP5002 |
80 | "eor %1, %0, %0, ror #16 \n\t" | ||
81 | "bic %1, %1, #0xff0000 \n\t" | ||
82 | "mov %0, %0, ror #8 \n\t" | ||
83 | "eor %0, %0, %1, lsr #8 \n\t" | ||
84 | : "+r" (value), "=r" (tmp) | ||
85 | ); | ||
86 | return value; | ||
87 | } | ||
88 | 42 | ||
89 | static inline uint32_t swap_odd_even32(uint32_t value) | 43 | #define HAVE_INVALIDATE_ICACHE |
44 | static inline void invalidate_icache(void) | ||
90 | { | 45 | { |
91 | /* | 46 | outl(inl(0xf000f044) | 0x6, 0xf000f044); |
92 | result[31..24],[15.. 8] = value[23..16],[ 7.. 0] | 47 | while ((CACHE_CTL & 0x8000) != 0); |
93 | result[23..16],[ 7.. 0] = value[31..24],[15.. 8] | ||
94 | */ | ||
95 | uint32_t tmp; | ||
96 | |||
97 | asm volatile ( /* ABCD */ | ||
98 | "bic %1, %0, #0x00ff00 \n\t" /* AB.D */ | ||
99 | "bic %0, %0, #0xff0000 \n\t" /* A.CD */ | ||
100 | "mov %0, %0, lsr #8 \n\t" /* .A.C */ | ||
101 | "orr %0, %0, %1, lsl #8 \n\t" /* B.D.|.A.C */ | ||
102 | : "+r" (value), "=r" (tmp) /* BADC */ | ||
103 | ); | ||
104 | return value; | ||
105 | } | 48 | } |
106 | 49 | ||
107 | #define HIGHEST_IRQ_LEVEL (1) | 50 | #define HAVE_FLUSH_ICACHE |
108 | 51 | static inline void flush_icache(void) | |
109 | static inline int set_irq_level(int level) | ||
110 | { | ||
111 | unsigned long cpsr; | ||
112 | /* Read the old level and set the new one */ | ||
113 | asm volatile ("mrs %0,cpsr" : "=r" (cpsr)); | ||
114 | asm volatile ("msr cpsr_c,%0" | ||
115 | : : "r" ((cpsr & ~0x80) | (level << 7))); | ||
116 | return (cpsr >> 7) & 1; | ||
117 | } | ||
118 | |||
119 | static inline void set_fiq_handler(void(*fiq_handler)(void)) | ||
120 | { | 52 | { |
121 | /* Install the FIQ handler */ | 53 | outl(inl(0xf000f044) | 0x2, 0xf000f044); |
122 | *((unsigned int*)(15*4)) = (unsigned int)fiq_handler; | 54 | while ((CACHE_CTL & 0x8000) != 0); |
123 | } | 55 | } |
124 | 56 | ||
125 | static inline void enable_fiq(void) | 57 | #endif /* CONFIG_CPU */ |
126 | { | ||
127 | /* Clear FIQ disable bit */ | ||
128 | asm volatile ( | ||
129 | "mrs r0, cpsr \n"\ | ||
130 | "bic r0, r0, #0x40 \n"\ | ||
131 | "msr cpsr_c, r0 " | ||
132 | : : : "r0" | ||
133 | ); | ||
134 | } | ||
135 | |||
136 | static inline void disable_fiq(void) | ||
137 | { | ||
138 | /* Set FIQ disable bit */ | ||
139 | asm volatile ( | ||
140 | "mrs r0, cpsr \n"\ | ||
141 | "orr r0, r0, #0x40 \n"\ | ||
142 | "msr cpsr_c, r0 " | ||
143 | : : : "r0" | ||
144 | ); | ||
145 | } | ||
146 | |||
147 | #if CONFIG_CPU == PNX0101 | ||
148 | typedef void (*interrupt_handler_t)(void); | ||
149 | |||
150 | void irq_set_int_handler(int n, interrupt_handler_t handler); | ||
151 | void irq_enable_int(int n); | ||
152 | void irq_disable_int(int n); | ||
153 | #endif | ||
154 | 58 | ||
155 | #endif /* SYSTEM_TARGET_H */ | 59 | #endif /* SYSTEM_TARGET_H */ |