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.11-00"
  35. #define IPIPE_MAJOR_NUMBER 1
  36. #define IPIPE_MINOR_NUMBER 11
  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_root_domain_p; \
  51. __clear_bit(IPIPE_SYNC_FLAG, &ipipe_root_cpudom_var(status)); \
  52. if (__x__) \
  53. local_irq_enable_hw(); \
  54. !__x__; \
  55. })
  56. struct ipipe_domain;
  57. struct ipipe_sysinfo {
  58. int ncpus; /* Number of CPUs on board */
  59. u64 cpufreq; /* CPU frequency (in Hz) */
  60. /* Arch-dependent block */
  61. struct {
  62. unsigned tmirq; /* Timer tick IRQ */
  63. u64 tmfreq; /* Timer frequency */
  64. } archdep;
  65. };
  66. #define ipipe_read_tsc(t) \
  67. ({ \
  68. unsigned long __cy2; \
  69. __asm__ __volatile__ ("1: %0 = CYCLES2\n" \
  70. "%1 = CYCLES\n" \
  71. "%2 = CYCLES2\n" \
  72. "CC = %2 == %0\n" \
  73. "if ! CC jump 1b\n" \
  74. : "=d,a" (((unsigned long *)&t)[1]), \
  75. "=d,a" (((unsigned long *)&t)[0]), \
  76. "=d,a" (__cy2) \
  77. : /*no input*/ : "CC"); \
  78. t; \
  79. })
  80. #define ipipe_cpu_freq() __ipipe_core_clock
  81. #define ipipe_tsc2ns(_t) (((unsigned long)(_t)) * __ipipe_freq_scale)
  82. #define ipipe_tsc2us(_t) (ipipe_tsc2ns(_t) / 1000 + 1)
  83. /* Private interface -- Internal use only */
  84. #define __ipipe_check_platform() do { } while (0)
  85. #define __ipipe_init_platform() do { } while (0)
  86. extern atomic_t __ipipe_irq_lvdepth[IVG15 + 1];
  87. extern unsigned long __ipipe_irq_lvmask;
  88. extern struct ipipe_domain ipipe_root;
  89. /* enable/disable_irqdesc _must_ be used in pairs. */
  90. void __ipipe_enable_irqdesc(struct ipipe_domain *ipd,
  91. unsigned irq);
  92. void __ipipe_disable_irqdesc(struct ipipe_domain *ipd,
  93. unsigned irq);
  94. #define __ipipe_enable_irq(irq) (irq_desc[irq].chip->unmask(irq))
  95. #define __ipipe_disable_irq(irq) (irq_desc[irq].chip->mask(irq))
  96. static inline int __ipipe_check_tickdev(const char *devname)
  97. {
  98. return 1;
  99. }
  100. static inline void __ipipe_lock_root(void)
  101. {
  102. set_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
  103. }
  104. static inline void __ipipe_unlock_root(void)
  105. {
  106. clear_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
  107. }
  108. void __ipipe_enable_pipeline(void);
  109. #define __ipipe_hook_critical_ipi(ipd) do { } while (0)
  110. #define __ipipe_sync_pipeline ___ipipe_sync_pipeline
  111. void ___ipipe_sync_pipeline(unsigned long syncmask);
  112. void __ipipe_handle_irq(unsigned irq, struct pt_regs *regs);
  113. int __ipipe_get_irq_priority(unsigned irq);
  114. void __ipipe_serial_debug(const char *fmt, ...);
  115. asmlinkage void __ipipe_call_irqtail(unsigned long addr);
  116. DECLARE_PER_CPU(struct pt_regs, __ipipe_tick_regs);
  117. extern unsigned long __ipipe_core_clock;
  118. extern unsigned long __ipipe_freq_scale;
  119. extern unsigned long __ipipe_irq_tail_hook;
  120. static inline unsigned long __ipipe_ffnz(unsigned long ul)
  121. {
  122. return ffs(ul) - 1;
  123. }
  124. #define __ipipe_run_irqtail() /* Must be a macro */ \
  125. do { \
  126. unsigned long __pending; \
  127. CSYNC(); \
  128. __pending = bfin_read_IPEND(); \
  129. if (__pending & 0x8000) { \
  130. __pending &= ~0x8010; \
  131. if (__pending && (__pending & (__pending - 1)) == 0) \
  132. __ipipe_call_irqtail(__ipipe_irq_tail_hook); \
  133. } \
  134. } while (0)
  135. #define __ipipe_run_isr(ipd, irq) \
  136. do { \
  137. if (!__ipipe_pipeline_head_p(ipd)) \
  138. local_irq_enable_hw(); \
  139. if (ipd == ipipe_root_domain) { \
  140. if (unlikely(ipipe_virtual_irq_p(irq))) { \
  141. irq_enter(); \
  142. ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \
  143. irq_exit(); \
  144. } else \
  145. ipd->irqs[irq].handler(irq, &__raw_get_cpu_var(__ipipe_tick_regs)); \
  146. } else { \
  147. __clear_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \
  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. __ipipe_run_irqtail(); \
  152. __set_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \
  153. } \
  154. local_irq_disable_hw(); \
  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_TICKSOURCE_CORETMR
  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_init_irq_threads() do { } while (0)
  183. #define ipipe_start_irq_thread(irq, desc) 0
  184. #ifndef CONFIG_TICKSOURCE_GPTMR0
  185. #define IRQ_SYSTMR IRQ_CORETMR
  186. #define IRQ_PRIOTMR IRQ_CORETMR
  187. #else
  188. #define IRQ_SYSTMR IRQ_TIMER0
  189. #define IRQ_PRIOTMR CONFIG_IRQ_TIMER0
  190. #endif
  191. #define __ipipe_root_tick_p(regs) 1
  192. #endif /* !CONFIG_IPIPE */
  193. #define ipipe_update_tick_evtdev(evtdev) do { } while (0)
  194. #endif /* !__ASM_BLACKFIN_IPIPE_H */