Commit | Line | Data |
---|---|---|
6a01f230 YL |
1 | /* -*- linux-c -*- |
2 | * include/asm-blackfin/ipipe.h | |
3 | * | |
4 | * Copyright (C) 2002-2007 Philippe Gerum. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, | |
9 | * USA; either version 2 of the License, or (at your option) any later | |
10 | * version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 | */ | |
21 | ||
22 | #ifndef __ASM_BLACKFIN_IPIPE_H | |
23 | #define __ASM_BLACKFIN_IPIPE_H | |
24 | ||
25 | #ifdef CONFIG_IPIPE | |
26 | ||
27 | #include <linux/cpumask.h> | |
28 | #include <linux/list.h> | |
29 | #include <linux/threads.h> | |
30 | #include <linux/irq.h> | |
31 | #include <linux/ipipe_percpu.h> | |
32 | #include <asm/ptrace.h> | |
33 | #include <asm/irq.h> | |
34 | #include <asm/bitops.h> | |
35 | #include <asm/atomic.h> | |
36 | #include <asm/traps.h> | |
37 | ||
51387009 | 38 | #define IPIPE_ARCH_STRING "1.9-01" |
6a01f230 | 39 | #define IPIPE_MAJOR_NUMBER 1 |
9bd50df6 | 40 | #define IPIPE_MINOR_NUMBER 9 |
51387009 | 41 | #define IPIPE_PATCH_NUMBER 1 |
6a01f230 YL |
42 | |
43 | #ifdef CONFIG_SMP | |
44 | #error "I-pipe/blackfin: SMP not implemented" | |
45 | #else /* !CONFIG_SMP */ | |
46 | #define ipipe_processor_id() 0 | |
47 | #endif /* CONFIG_SMP */ | |
48 | ||
49 | #define prepare_arch_switch(next) \ | |
50 | do { \ | |
51 | ipipe_schedule_notify(current, next); \ | |
52 | local_irq_disable_hw(); \ | |
53 | } while (0) | |
54 | ||
55 | #define task_hijacked(p) \ | |
56 | ({ \ | |
57 | int __x__ = ipipe_current_domain != ipipe_root_domain; \ | |
58 | /* We would need to clear the SYNC flag for the root domain */ \ | |
59 | /* over the current processor in SMP mode. */ \ | |
60 | local_irq_enable_hw(); __x__; \ | |
61 | }) | |
62 | ||
63 | struct ipipe_domain; | |
64 | ||
65 | struct ipipe_sysinfo { | |
66 | ||
67 | int ncpus; /* Number of CPUs on board */ | |
68 | u64 cpufreq; /* CPU frequency (in Hz) */ | |
69 | ||
70 | /* Arch-dependent block */ | |
71 | ||
72 | struct { | |
73 | unsigned tmirq; /* Timer tick IRQ */ | |
74 | u64 tmfreq; /* Timer frequency */ | |
75 | } archdep; | |
76 | }; | |
77 | ||
78 | #define ipipe_read_tsc(t) \ | |
79 | ({ \ | |
80 | unsigned long __cy2; \ | |
81 | __asm__ __volatile__ ("1: %0 = CYCLES2\n" \ | |
82 | "%1 = CYCLES\n" \ | |
83 | "%2 = CYCLES2\n" \ | |
84 | "CC = %2 == %0\n" \ | |
85 | "if ! CC jump 1b\n" \ | |
9bd50df6 PG |
86 | : "=d,a" (((unsigned long *)&t)[1]), \ |
87 | "=d,a" (((unsigned long *)&t)[0]), \ | |
88 | "=d,a" (__cy2) \ | |
6a01f230 YL |
89 | : /*no input*/ : "CC"); \ |
90 | t; \ | |
91 | }) | |
92 | ||
93 | #define ipipe_cpu_freq() __ipipe_core_clock | |
94 | #define ipipe_tsc2ns(_t) (((unsigned long)(_t)) * __ipipe_freq_scale) | |
95 | #define ipipe_tsc2us(_t) (ipipe_tsc2ns(_t) / 1000 + 1) | |
96 | ||
97 | /* Private interface -- Internal use only */ | |
98 | ||
99 | #define __ipipe_check_platform() do { } while (0) | |
100 | ||
101 | #define __ipipe_init_platform() do { } while (0) | |
102 | ||
103 | extern atomic_t __ipipe_irq_lvdepth[IVG15 + 1]; | |
104 | ||
105 | extern unsigned long __ipipe_irq_lvmask; | |
106 | ||
107 | extern struct ipipe_domain ipipe_root; | |
108 | ||
109 | /* enable/disable_irqdesc _must_ be used in pairs. */ | |
110 | ||
111 | void __ipipe_enable_irqdesc(struct ipipe_domain *ipd, | |
112 | unsigned irq); | |
113 | ||
114 | void __ipipe_disable_irqdesc(struct ipipe_domain *ipd, | |
115 | unsigned irq); | |
116 | ||
117 | #define __ipipe_enable_irq(irq) (irq_desc[irq].chip->unmask(irq)) | |
118 | ||
119 | #define __ipipe_disable_irq(irq) (irq_desc[irq].chip->mask(irq)) | |
120 | ||
9bd50df6 PG |
121 | static inline int __ipipe_check_tickdev(const char *devname) |
122 | { | |
123 | return 1; | |
124 | } | |
6a01f230 | 125 | |
9bd50df6 PG |
126 | static inline void __ipipe_lock_root(void) |
127 | { | |
128 | set_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status)); | |
129 | } | |
130 | ||
131 | static inline void __ipipe_unlock_root(void) | |
132 | { | |
133 | clear_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status)); | |
134 | } | |
6a01f230 YL |
135 | |
136 | void __ipipe_enable_pipeline(void); | |
137 | ||
138 | #define __ipipe_hook_critical_ipi(ipd) do { } while (0) | |
139 | ||
9bd50df6 PG |
140 | #define __ipipe_sync_pipeline ___ipipe_sync_pipeline |
141 | void ___ipipe_sync_pipeline(unsigned long syncmask); | |
6a01f230 YL |
142 | |
143 | void __ipipe_handle_irq(unsigned irq, struct pt_regs *regs); | |
144 | ||
145 | int __ipipe_get_irq_priority(unsigned irq); | |
146 | ||
6a01f230 YL |
147 | void __ipipe_stall_root_raw(void); |
148 | ||
149 | void __ipipe_unstall_root_raw(void); | |
150 | ||
151 | void __ipipe_serial_debug(const char *fmt, ...); | |
152 | ||
9bd50df6 PG |
153 | asmlinkage void __ipipe_call_irqtail(unsigned long addr); |
154 | ||
6a01f230 YL |
155 | DECLARE_PER_CPU(struct pt_regs, __ipipe_tick_regs); |
156 | ||
157 | extern unsigned long __ipipe_core_clock; | |
158 | ||
159 | extern unsigned long __ipipe_freq_scale; | |
160 | ||
161 | extern unsigned long __ipipe_irq_tail_hook; | |
162 | ||
163 | static inline unsigned long __ipipe_ffnz(unsigned long ul) | |
164 | { | |
165 | return ffs(ul) - 1; | |
166 | } | |
167 | ||
168 | #define __ipipe_run_irqtail() /* Must be a macro */ \ | |
169 | do { \ | |
6a01f230 | 170 | unsigned long __pending; \ |
9bd50df6 | 171 | CSYNC(); \ |
6a01f230 YL |
172 | __pending = bfin_read_IPEND(); \ |
173 | if (__pending & 0x8000) { \ | |
174 | __pending &= ~0x8010; \ | |
175 | if (__pending && (__pending & (__pending - 1)) == 0) \ | |
9bd50df6 | 176 | __ipipe_call_irqtail(__ipipe_irq_tail_hook); \ |
6a01f230 YL |
177 | } \ |
178 | } while (0) | |
179 | ||
180 | #define __ipipe_run_isr(ipd, irq) \ | |
181 | do { \ | |
182 | if (ipd == ipipe_root_domain) { \ | |
9bd50df6 PG |
183 | local_irq_enable_hw(); \ |
184 | if (ipipe_virtual_irq_p(irq)) \ | |
6a01f230 | 185 | ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \ |
9bd50df6 | 186 | else \ |
6a01f230 | 187 | ipd->irqs[irq].handler(irq, &__raw_get_cpu_var(__ipipe_tick_regs)); \ |
9bd50df6 | 188 | local_irq_disable_hw(); \ |
6a01f230 YL |
189 | } else { \ |
190 | __clear_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \ | |
191 | local_irq_enable_nohead(ipd); \ | |
192 | ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \ | |
193 | /* Attempt to exit the outer interrupt level before \ | |
194 | * starting the deferred IRQ processing. */ \ | |
195 | local_irq_disable_nohead(ipd); \ | |
196 | __ipipe_run_irqtail(); \ | |
197 | __set_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \ | |
198 | } \ | |
199 | } while (0) | |
200 | ||
201 | #define __ipipe_syscall_watched_p(p, sc) \ | |
202 | (((p)->flags & PF_EVNOTIFY) || (unsigned long)sc >= NR_syscalls) | |
203 | ||
204 | void ipipe_init_irq_threads(void); | |
205 | ||
206 | int ipipe_start_irq_thread(unsigned irq, struct irq_desc *desc); | |
207 | ||
9bd50df6 PG |
208 | #ifdef CONFIG_GENERIC_CLOCKEVENTS |
209 | #define IRQ_SYSTMR IRQ_CORETMR | |
210 | #define IRQ_PRIOTMR IRQ_CORETMR | |
211 | #else | |
6a01f230 YL |
212 | #define IRQ_SYSTMR IRQ_TIMER0 |
213 | #define IRQ_PRIOTMR CONFIG_IRQ_TIMER0 | |
9bd50df6 | 214 | #endif |
6a01f230 | 215 | |
9bd50df6 | 216 | #ifdef CONFIG_BF561 |
6a01f230 YL |
217 | #define bfin_write_TIMER_DISABLE(val) bfin_write_TMRS8_DISABLE(val) |
218 | #define bfin_write_TIMER_ENABLE(val) bfin_write_TMRS8_ENABLE(val) | |
219 | #define bfin_write_TIMER_STATUS(val) bfin_write_TMRS8_STATUS(val) | |
220 | #define bfin_read_TIMER_STATUS() bfin_read_TMRS8_STATUS() | |
221 | #elif defined(CONFIG_BF54x) | |
6a01f230 YL |
222 | #define bfin_write_TIMER_DISABLE(val) bfin_write_TIMER_DISABLE0(val) |
223 | #define bfin_write_TIMER_ENABLE(val) bfin_write_TIMER_ENABLE0(val) | |
224 | #define bfin_write_TIMER_STATUS(val) bfin_write_TIMER_STATUS0(val) | |
225 | #define bfin_read_TIMER_STATUS(val) bfin_read_TIMER_STATUS0(val) | |
6a01f230 YL |
226 | #endif |
227 | ||
228 | #define __ipipe_root_tick_p(regs) ((regs->ipend & 0x10) != 0) | |
229 | ||
230 | #else /* !CONFIG_IPIPE */ | |
231 | ||
232 | #define task_hijacked(p) 0 | |
233 | #define ipipe_trap_notify(t, r) 0 | |
234 | ||
235 | #define __ipipe_stall_root_raw() do { } while (0) | |
236 | #define __ipipe_unstall_root_raw() do { } while (0) | |
237 | ||
238 | #define ipipe_init_irq_threads() do { } while (0) | |
239 | #define ipipe_start_irq_thread(irq, desc) 0 | |
240 | ||
241 | #define IRQ_SYSTMR IRQ_CORETMR | |
242 | #define IRQ_PRIOTMR IRQ_CORETMR | |
243 | ||
244 | #define __ipipe_root_tick_p(regs) 1 | |
245 | ||
246 | #endif /* !CONFIG_IPIPE */ | |
247 | ||
9bd50df6 PG |
248 | #define ipipe_update_tick_evtdev(evtdev) do { } while (0) |
249 | ||
6a01f230 | 250 | #endif /* !__ASM_BLACKFIN_IPIPE_H */ |