commandProcessing.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * linux/arch/alpha/kernel/sys_dp264.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996, 1999 Jay A Estabrook
  6. * Copyright (C) 1998, 1999 Richard Henderson
  7. *
  8. * Modified by Christopher C. Chimelis, 2001 to
  9. * add support for the addition of Shark to the
  10. * Tsunami family.
  11. *
  12. * Code supporting the DP264 (EV6+TSUNAMI).
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/types.h>
  16. #include <linux/mm.h>
  17. #include <linux/sched.h>
  18. #include <linux/pci.h>
  19. #include <linux/init.h>
  20. #include <linux/bitops.h>
  21. #include <asm/ptrace.h>
  22. #include <asm/dma.h>
  23. #include <asm/irq.h>
  24. #include <asm/mmu_context.h>
  25. #include <asm/io.h>
  26. #include <asm/pgtable.h>
  27. #include <asm/core_tsunami.h>
  28. #include <asm/hwrpb.h>
  29. #include <asm/tlbflush.h>
  30. #include "proto.h"
  31. #include "irq_impl.h"
  32. #include "pci_impl.h"
  33. #include "machvec_impl.h"
  34. /* Note mask bit is true for ENABLED irqs. */
  35. static unsigned long cached_irq_mask;
  36. /* dp264 boards handle at max four CPUs */
  37. static unsigned long cpu_irq_affinity[4] = { 0UL, 0UL, 0UL, 0UL };
  38. DEFINE_SPINLOCK(dp264_irq_lock);
  39. static void
  40. tsunami_update_irq_hw(unsigned long mask)
  41. {
  42. register tsunami_cchip *cchip = TSUNAMI_cchip;
  43. unsigned long isa_enable = 1UL << 55;
  44. register int bcpu = boot_cpuid;
  45. #ifdef CONFIG_SMP
  46. volatile unsigned long *dim0, *dim1, *dim2, *dim3;
  47. unsigned long mask0, mask1, mask2, mask3, dummy;
  48. mask &= ~isa_enable;
  49. mask0 = mask & cpu_irq_affinity[0];
  50. mask1 = mask & cpu_irq_affinity[1];
  51. mask2 = mask & cpu_irq_affinity[2];
  52. mask3 = mask & cpu_irq_affinity[3];
  53. if (bcpu == 0) mask0 |= isa_enable;
  54. else if (bcpu == 1) mask1 |= isa_enable;
  55. else if (bcpu == 2) mask2 |= isa_enable;
  56. else mask3 |= isa_enable;
  57. dim0 = &cchip->dim0.csr;
  58. dim1 = &cchip->dim1.csr;
  59. dim2 = &cchip->dim2.csr;
  60. dim3 = &cchip->dim3.csr;
  61. if (!cpu_possible(0)) dim0 = &dummy;
  62. if (!cpu_possible(1)) dim1 = &dummy;
  63. if (!cpu_possible(2)) dim2 = &dummy;
  64. if (!cpu_possible(3)) dim3 = &dummy;
  65. *dim0 = mask0;
  66. *dim1 = mask1;
  67. *dim2 = mask2;
  68. *dim3 = mask3;
  69. mb();
  70. *dim0;
  71. *dim1;
  72. *dim2;
  73. *dim3;
  74. #else
  75. volatile unsigned long *dimB;
  76. if (bcpu == 0) dimB = &cchip->dim0.csr;
  77. else if (bcpu == 1) dimB = &cchip->dim1.csr;
  78. else if (bcpu == 2) dimB = &cchip->dim2.csr;
  79. else dimB = &cchip->dim3.csr;
  80. *dimB = mask | isa_enable;
  81. mb();
  82. *dimB;
  83. #endif
  84. }
  85. static void
  86. dp264_enable_irq(struct irq_data *d)
  87. {
  88. spin_lock(&dp264_irq_lock);
  89. cached_irq_mask |= 1UL << d->irq;
  90. tsunami_update_irq_hw(cached_irq_mask);
  91. spin_unlock(&dp264_irq_lock);
  92. }
  93. static void
  94. dp264_disable_irq(struct irq_data *d)
  95. {
  96. spin_lock(&dp264_irq_lock);
  97. cached_irq_mask &= ~(1UL << d->irq);
  98. tsunami_update_irq_hw(cached_irq_mask);
  99. spin_unlock(&dp264_irq_lock);
  100. }
  101. static void
  102. clipper_enable_irq(struct irq_data *d)
  103. {
  104. spin_lock(&dp264_irq_lock);
  105. cached_irq_mask |= 1UL << (d->irq - 16);
  106. tsunami_update_irq_hw(cached_irq_mask);
  107. spin_unlock(&dp264_irq_lock);
  108. }
  109. static void
  110. clipper_disable_irq(struct irq_data *d)
  111. {
  112. spin_lock(&dp264_irq_lock);
  113. cached_irq_mask &= ~(1UL << (d->irq - 16));
  114. tsunami_update_irq_hw(cached_irq_mask);
  115. spin_unlock(&dp264_irq_lock);
  116. }
  117. static void
  118. cpu_set_irq_affinity(unsigned int irq, cpumask_t affinity)
  119. {
  120. int cpu;
  121. for (cpu = 0; cpu < 4; cpu++) {
  122. unsigned long aff = cpu_irq_affinity[cpu];
  123. if (cpumask_test_cpu(cpu, &affinity))
  124. aff |= 1UL << irq;
  125. else
  126. aff &= ~(1UL << irq);
  127. cpu_irq_affinity[cpu] = aff;
  128. }
  129. }
  130. static int
  131. dp264_set_affinity(struct irq_data *d, const struct cpumask *affinity,
  132. bool force)
  133. {
  134. spin_lock(&dp264_irq_lock);
  135. cpu_set_irq_affinity(d->irq, *affinity);
  136. tsunami_update_irq_hw(cached_irq_mask);
  137. spin_unlock(&dp264_irq_lock);
  138. return 0;
  139. }
  140. static int
  141. clipper_set_affinity(struct irq_data *d, const struct cpumask *affinity,
  142. bool force)
  143. {
  144. spin_lock(&dp264_irq_lock);
  145. cpu_set_irq_affinity(d->irq - 16, *affinity);
  146. tsunami_update_irq_hw(cached_irq_mask);
  147. spin_unlock(&dp264_irq_lock);
  148. return 0;
  149. }
  150. static struct irq_chip dp264_irq_type = {
  151. .name = "DP264",
  152. .irq_unmask = dp264_enable_irq,
  153. .irq_mask = dp264_disable_irq,
  154. .irq_mask_ack = dp264_disable_irq,
  155. .irq_set_affinity = dp264_set_affinity,
  156. };
  157. static struct irq_chip clipper_irq_type = {
  158. .name = "CLIPPER",
  159. .irq_unmask = clipper_enable_irq,
  160. .irq_mask = clipper_disable_irq,
  161. .irq_mask_ack = clipper_disable_irq,
  162. .irq_set_affinity = clipper_set_affinity,
  163. };
  164. static void
  165. dp264_device_interrupt(unsigned long vector)
  166. {
  167. #if 1
  168. printk("dp264_device_interrupt: NOT IMPLEMENTED YET!!\n");
  169. #else
  170. unsigned long pld;
  171. unsigned int i;
  172. /* Read the interrupt summary register of TSUNAMI */
  173. pld = TSUNAMI_cchip->dir0.csr;
  174. /*
  175. * Now for every possible bit set, work through them and call
  176. * the appropriate interrupt handler.
  177. */
  178. while (pld) {
  179. i = ffz(~pld);
  180. pld &= pld - 1; /* clear least bit set */
  181. if (i == 55)
  182. isa_device_interrupt(vector);
  183. else
  184. handle_irq(16 + i);
  185. #if 0
  186. TSUNAMI_cchip->dir0.csr = 1UL << i; mb();
  187. tmp = TSUNAMI_cchip->dir0.csr;
  188. #endif
  189. }
  190. #endif
  191. }
  192. static void
  193. dp264_srm_device_interrupt(unsigned long vector)
  194. {
  195. int irq;
  196. irq = (vector - 0x800) >> 4;
  197. /*
  198. * The SRM console reports PCI interrupts with a vector calculated by:
  199. *
  200. * 0x900 + (0x10 * DRIR-bit)
  201. *
  202. * So bit 16 shows up as IRQ 32, etc.
  203. *
  204. * On DP264/BRICK/MONET, we adjust it down by 16 because at least
  205. * that many of the low order bits of the DRIR are not used, and
  206. * so we don't count them.
  207. */
  208. if (irq >= 32)
  209. irq -= 16;
  210. handle_irq(irq);
  211. }
  212. static void
  213. clipper_srm_device_interrupt(unsigned long vector)
  214. {
  215. int irq;
  216. irq = (vector - 0x800) >> 4;
  217. /*
  218. * The SRM console reports PCI interrupts with a vector calculated by:
  219. *
  220. * 0x900 + (0x10 * DRIR-bit)
  221. *
  222. * So bit 16 shows up as IRQ 32, etc.
  223. *
  224. * CLIPPER uses bits 8-47 for PCI interrupts, so we do not need
  225. * to scale down the vector reported, we just use it.
  226. *
  227. * Eg IRQ 24 is DRIR bit 8, etc, etc
  228. */
  229. handle_irq(irq);
  230. }
  231. static void __init
  232. init_tsunami_irqs(struct irq_chip * ops, int imin, int imax)
  233. {
  234. long i;
  235. for (i = imin; i <= imax; ++i) {
  236. irq_set_chip_and_handler(i, ops, handle_level_irq);
  237. irq_set_status_flags(i, IRQ_LEVEL);
  238. }
  239. }
  240. static void __init
  241. dp264_init_irq(void)
  242. {
  243. outb(0, DMA1_RESET_REG);