ipipe.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. #ifndef __ASM_BLACKFIN_IPIPE_H
  22. #define __ASM_BLACKFIN_IPIPE_H
  23. #ifdef CONFIG_IPIPE
  24. #include <linux/cpumask.h>
  25. #include <linux/list.h>
  26. #include <linux/threads.h>
  27. #include <linux/irq.h>
  28. #include <linux/ipipe_percpu.h>
  29. #include <asm/ptrace.h>
  30. #include <asm/irq.h>
  31. #include <asm/bitops.h>
  32. #include <asm/atomic.h>
  33. #include <asm/traps.h>
  34. #define IPIPE_ARCH_STRING "1.9-00"
  35. #define IPIPE_MAJOR_NUMBER 1
  36. #define IPIPE_MINOR_NUMBER 9
  37. #define IPIPE_PATCH_NUMBER 0
  38. #ifdef CONFIG_SMP
  39. #error "I-pipe/blackfin: SMP not implemented"
  40. #else /* !CONFIG_SMP */
  41. #define ipipe_processor_id() 0
  42. #endif /* CONFIG_SMP */
  43. #define prepare_arch_switch(next) \
  44. do { \
  45. ipipe_schedule_notify(current, next); \
  46. local_irq_disable_hw(); \
  47. } while (0)
  48. #define task_hijacked(p) \
  49. ({ \
  50. int __x__ = ipipe_current_domain != ipipe_root_domain; \
  51. /* We would need to clear the SYNC flag for the root domain */ \
  52. /* over the current processor in SMP mode. */ \
  53. local_irq_enable_hw(); __x__; \
  54. })
  55. struct ipipe_domain;
  56. struct ipipe_sysinfo {
  57. int ncpus; /* Number of CPUs on board */
  58. u64 cpufreq; /* CPU frequency (in Hz) */
  59. /* Arch-dependent block */
  60. struct {
  61. unsigned tmirq; /* Timer tick IRQ */
  62. u64 tmfreq; /* Timer frequency */
  63. } archdep;
  64. };
  65. #define ipipe_read_tsc(t) \
  66. ({ \
  67. unsigned long __cy2; \
  68. __asm__ __volatile__ ("1: %0 = CYCLES2\n" \
  69. "%1 = CYCLES\n" \
  70. "%2 = CYCLES2\n" \
  71. "CC = %2 == %0\n" \
  72. "if ! CC jump 1b\n" \
  73. : "=d,a" (((unsigned long *)&t)[1]), \
  74. "=d,a" (((unsigned long *)&t)[0]), \
  75. "=d,a" (__cy2) \
  76. : /*no input*/ : "CC"); \
  77. t; \
  78. })
  79. #define ipipe_cpu_freq() __ipipe_core_clock
  80. #define ipipe_tsc2ns(_t) (((unsigned long)(_t)) * __ipipe_freq_scale)
  81. #define ipipe_tsc2us(_t) (ipipe_tsc2ns(_t) / 1000 + 1)
  82. /* Private interface -- Internal use only */
  83. #define __ipipe_check_platform() do { } while (0)
  84. #define __ipipe_init_platform() do { } while (0)
  85. extern atomic_t __ipipe_irq_lvdepth[IVG15 + 1];
  86. extern unsigned long __ipipe_irq_lvmask;
  87. extern struct ipipe_domain ipipe_root;
  88. /* enable/disable_irqdesc _must_ be used in pairs. */
  89. void __ipipe_enable_irqdesc(struct ipipe_domain *ipd,
  90. unsigned irq);
  91. void __ipipe_disable_irqdesc(struct ipipe_domain *ipd,
  92. unsigned irq);
  93. #define __ipipe_enable_irq(irq) (irq_desc[irq].chip->unmask(irq))
  94. #define __ipipe_disable_irq(irq) (irq_desc[irq].chip->mask(irq))
  95. static inline int __ipipe_check_tickdev(const char *devname)
  96. {
  97. return 1;
  98. }
  99. static inline void __ipipe_lock_root(void)
  100. {
  101. set_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
  102. }
  103. static inline void __ipipe_unlock_root(void)
  104. {
  105. clear_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
  106. }
  107. void __ipipe_enable_pipeline(void);
  108. #define __ipipe_hook_critical_ipi(ipd) do { } while (0)
  109. #define __ipipe_sync_pipeline ___ipipe_sync_pipeline
  110. void ___ipipe_sync_pipeline(unsigned long syncmask);
  111. void __ipipe_handle_irq(unsigned irq, struct pt_regs *regs);
  112. int __ipipe_get_irq_priority(unsigned irq);
  113. void __ipipe_stall_root_raw(void);
  114. void __ipipe_unstall_root_raw(void);
  115. void __ipipe_serial_debug(const char *fmt, ...);
  116. asmlinkage void __ipipe_call_irqtail(unsigned long addr);
  117. DECLARE_PER_CPU(struct pt_regs, __ipipe_tick_regs);
  118. extern unsigned long __ipipe_core_clock;
  119. extern unsigned long __ipipe_freq_scale;
  120. extern unsigned long __ipipe_irq_tail_hook;
  121. static inline unsigned long __ipipe_ffnz(unsigned long ul)
  122. {
  123. return ffs(ul) - 1;
  124. }
  125. #define __ipipe_run_irqtail() /* Must be a macro */ \
  126. do { \
  127. unsigned long __pending; \
  128. CSYNC(); \
  129. __pending = bfin_read_IPEND(); \
  130. if (__pending & 0x8000) { \
  131. __pending &= ~0x8010; \
  132. if (__pending && (__pending & (__pending - 1)) == 0) \
  133. __ipipe_call_irqtail(__ipipe_irq_tail_hook); \
  134. } \
  135. } while (0)
  136. #define __ipipe_run_isr(ipd, irq) \
  137. do { \
  138. if (ipd == ipipe_root_domain) { \
  139. local_irq_enable_hw(); \
  140. if (ipipe_virtual_irq_p(irq)) \
  141. ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \
  142. else \
  143. ipd->irqs[irq].handler(irq, &__raw_get_cpu_var(__ipipe_tick_regs)); \
  144. local_irq_disable_hw(); \
  145. } else { \
  146. __clear_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \
  147. local_irq_enable_nohead(ipd); \
  148. ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \
  149. /* Attempt to exit the outer interrupt level before \
  150. * starting the deferred IRQ processing. */ \
  151. local_irq_disable_nohead(ipd); \
  152. __ipipe_run_irqtail(); \
  153. __set_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \
  154. } \
  155. } while (0)
  156. #define __ipipe_syscall_watched_p(p, sc) \
  157. (((p)->flags & PF_EVNOTIFY) || (unsigned long)sc >= NR_syscalls)
  158. void ipipe_init_irq_threads(void);
  159. int ipipe_start_irq_thread(unsigned irq, struct irq_desc *desc);
  160. #ifdef CONFIG_GENERIC_CLOCKEVENTS
  161. #define IRQ_SYSTMR IRQ_CORETMR
  162. #define IRQ_PRIOTMR IRQ_CORETMR
  163. #else
  164. #define IRQ_SYSTMR IRQ_TIMER0
  165. #define IRQ_PRIOTMR CONFIG_IRQ_TIMER0
  166. #endif
  167. #ifdef CONFIG_BF561
  168. #define bfin_write_TIMER_DISABLE(val) bfin_write_TMRS8_DISABLE(val)
  169. #define bfin_write_TIMER_ENABLE(val) bfin_write_TMRS8_ENABLE(val)
  170. #define bfin_write_TIMER_STATUS(val) bfin_write_TMRS8_STATUS(val)
  171. #define bfin_read_TIMER_STATUS() bfin_read_TMRS8_STATUS()
  172. #elif defined(CONFIG_BF54x)
  173. #define bfin_write_TIMER_DISABLE(val) bfin_write_TIMER_DISABLE0(val)
  174. #define bfin_write_TIMER_ENABLE(val) bfin_write_TIMER_ENABLE0(val)
  175. #define bfin_write_TIMER_STATUS(val) bfin_write_TIMER_STATUS0(val)
  176. #define bfin_read_TIMER_STATUS(val) bfin_read_TIMER_STATUS0(val)
  177. #endif
  178. #define __ipipe_root_tick_p(regs) ((regs->ipend & 0x10) != 0)
  179. #else /* !CONFIG_IPIPE */
  180. #define task_hijacked(p) 0
  181. #define ipipe_trap_notify(t, r) 0
  182. #define __ipipe_stall_root_raw() do { } while (0)
  183. #define __ipipe_unstall_root_raw() do { } while (0)
  184. #define ipipe_init_irq_threads() do { } while (0)
  185. #define ipipe_start_irq_thread(irq, desc) 0
  186. #define IRQ_SYSTMR IRQ_CORETMR
  187. #define IRQ_PRIOTMR IRQ_CORETMR
  188. #define __ipipe_root_tick_p(regs) 1
  189. #endif /* !CONFIG_IPIPE */
  190. #define ipipe_update_tick_evtdev(evtdev) do { } while (0)
  191. #endif /* !__ASM_BLACKFIN_IPIPE_H */