dataMonitoring.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * linux/arch/alpha/kernel/sys_cabriolet.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999, 2000 Richard Henderson
  7. *
  8. * Code supporting the Cabriolet (AlphaPC64), EB66+, and EB164,
  9. * PC164 and LX164.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/mm.h>
  14. #include <linux/sched.h>
  15. #include <linux/pci.h>
  16. #include <linux/init.h>
  17. #include <linux/bitops.h>
  18. #include <asm/ptrace.h>
  19. #include <asm/dma.h>
  20. #include <asm/irq.h>
  21. #include <asm/mmu_context.h>
  22. #include <asm/io.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/core_apecs.h>
  25. #include <asm/core_cia.h>
  26. #include <asm/core_lca.h>
  27. #include <asm/tlbflush.h>
  28. #include "proto.h"
  29. #include "irq_impl.h"
  30. #include "pci_impl.h"
  31. #include "machvec_impl.h"
  32. #include "pc873xx.h"
  33. /* Note mask bit is true for DISABLED irqs. */
  34. static unsigned long cached_irq_mask = ~0UL;
  35. static inline void
  36. cabriolet_update_irq_hw(unsigned int irq, unsigned long mask)
  37. {
  38. int ofs = (irq - 16) / 8;
  39. outb(mask >> (16 + ofs * 8), 0x804 + ofs);
  40. }
  41. static inline void
  42. cabriolet_enable_irq(struct irq_data *d)
  43. {
  44. cabriolet_update_irq_hw(d->irq, cached_irq_mask &= ~(1UL << d->irq));
  45. }
  46. static void
  47. cabriolet_disable_irq(struct irq_data *d)
  48. {
  49. cabriolet_update_irq_hw(d->irq, cached_irq_mask |= 1UL << d->irq);
  50. }
  51. static struct irq_chip cabriolet_irq_type = {
  52. .name = "CABRIOLET",
  53. .irq_unmask = cabriolet_enable_irq,
  54. .irq_mask = cabriolet_disable_irq,
  55. .irq_mask_ack = cabriolet_disable_irq,
  56. };
  57. static void
  58. cabriolet_device_interrupt(unsigned long v)
  59. {
  60. unsigned long pld;
  61. unsigned int i;
  62. /* Read the interrupt summary registers */
  63. pld = inb(0x804) | (inb(0x805) << 8) | (inb(0x806) << 16);
  64. /*
  65. * Now for every possible bit set, work through them and call
  66. * the appropriate interrupt handler.
  67. */
  68. while (pld) {
  69. i = ffz(~pld);
  70. pld &= pld - 1; /* clear least bit set */
  71. if (i == 4) {
  72. isa_device_interrupt(v);
  73. } else {
  74. handle_irq(16 + i);
  75. }
  76. }
  77. }
  78. static void __init
  79. common_init_irq(void (*srm_dev_int)(unsigned long v))
  80. {
  81. init_i8259a_irqs();
  82. if (alpha_using_srm) {
  83. alpha_mv.device_interrupt = srm_dev_int;
  84. init_srm_irqs(35, 0);
  85. }
  86. else {
  87. long i;
  88. outb(0xff, 0x804);
  89. outb(0xff, 0x805);
  90. outb(0xff, 0x806);
  91. for (i = 16; i < 35; ++i) {
  92. irq_set_chip_and_handler(i, &cabriolet_irq_type,
  93. handle_level_irq);
  94. irq_set_status_flags(i, IRQ_LEVEL);
  95. }
  96. }
  97. common_init_isa_dma();
  98. setup_irq(16+4, &isa_cascade_irqaction);
  99. }
  100. #ifndef CONFIG_ALPHA_PC164
  101. static void __init
  102. cabriolet_init_irq(void)
  103. {
  104. common_init_irq(srm_device_interrupt);
  105. }
  106. #endif
  107. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PC164)
  108. /* In theory, the PC164 has the same interrupt hardware as the other
  109. Cabriolet based systems. However, something got screwed up late
  110. in the development cycle which broke the interrupt masking hardware.
  111. Repeat, it is not possible to mask and ack interrupts. At all.
  112. In an attempt to work around this, while processing interrupts,
  113. we do not allow the IPL to drop below what it is currently. This
  114. prevents the possibility of recursion.
  115. ??? Another option might be to force all PCI devices to use edge
  116. triggered rather than level triggered interrupts. That might be
  117. too invasive though. */
  118. static void
  119. pc164_srm_device_interrupt(unsigned long v)
  120. {
  121. __min_ipl = getipl();
  122. srm_device_interrupt(v);
  123. __min_ipl = 0;
  124. }
  125. static void
  126. pc164_device_interrupt(unsigned long v)
  127. {
  128. __min_ipl = getipl();
  129. cabriolet_device_interrupt(v);
  130. __min_ipl = 0;
  131. }
  132. static void __init
  133. pc164_init_irq(void)
  134. {
  135. common_init_irq(pc164_srm_device_interrupt);
  136. }
  137. #endif
  138. /*
  139. * The EB66+ is very similar to the EB66 except that it does not have
  140. * the on-board NCR and Tulip chips. In the code below, I have used
  141. * slot number to refer to the id select line and *not* the slot
  142. * number used in the EB66+ documentation. However, in the table,
  143. * I've given the slot number, the id select line and the Jxx number
  144. * that's printed on the board. The interrupt pins from the PCI slots
  145. * are wired into 3 interrupt summary registers at 0x804, 0x805 and
  146. * 0x806 ISA.
  147. *
  148. * In the table, -1 means don't assign an IRQ number. This is usually
  149. * because it is the Saturn IO (SIO) PCI/ISA Bridge Chip.
  150. */
  151. static inline int __init
  152. eb66p_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  153. {
  154. static char irq_tab[5][5] __initdata = {
  155. /*INT INTA INTB INTC INTD */
  156. {16+0, 16+0, 16+5, 16+9, 16+13}, /* IdSel 6, slot 0, J25 */
  157. {16+1, 16+1, 16+6, 16+10, 16+14}, /* IdSel 7, slot 1, J26 */
  158. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  159. {16+2, 16+2, 16+7, 16+11, 16+15}, /* IdSel 9, slot 2, J27 */
  160. {16+3, 16+3, 16+8, 16+12, 16+6} /* IdSel 10, slot 3, J28 */
  161. };
  162. const long min_idsel = 6, max_idsel = 10, irqs_per_slot = 5;
  163. return COMMON_TABLE_LOOKUP;
  164. }
  165. /*
  166. * The AlphaPC64 is very similar to the EB66+ except that its slots
  167. * are numbered differently. In the code below, I have used slot
  168. * number to refer to the id select line and *not* the slot number
  169. * used in the AlphaPC64 documentation. However, in the table, I've
  170. * given the slot number, the id select line and the Jxx number that's
  171. * printed on the board. The interrupt pins from the PCI slots are
  172. * wired into 3 interrupt summary registers at 0x804, 0x805 and 0x806
  173. * ISA.
  174. *
  175. * In the table, -1 means don't assign an IRQ number. This is usually
  176. * because it is the Saturn IO (SIO) PCI/ISA Bridge Chip.
  177. */
  178. static inline int __init
  179. cabriolet_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  180. {
  181. static char irq_tab[5][5] __initdata = {
  182. /*INT INTA INTB INTC INTD */
  183. { 16+2, 16+2, 16+7, 16+11, 16+15}, /* IdSel 5, slot 2, J21 */
  184. { 16+0, 16+0, 16+5, 16+9, 16+13}, /* IdSel 6, slot 0, J19 */
  185. { 16+1, 16+1, 16+6, 16+10, 16+14}, /* IdSel 7, slot 1, J20 */
  186. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  187. { 16+3, 16+3, 16+8, 16+12, 16+16} /* IdSel 9, slot 3, J22 */
  188. };
  189. const long min_idsel = 5, max_idsel = 9, irqs_per_slot = 5;
  190. return COMMON_TABLE_LOOKUP;
  191. }
  192. static inline void __init
  193. cabriolet_enable_ide(void)
  194. {
  195. if (pc873xx_probe() == -1) {
  196. printk(KERN_ERR "Probing for PC873xx Super IO chip failed.\n");
  197. } else {
  198. printk(KERN_INFO "Found %s Super IO chip at 0x%x\n",
  199. pc873xx_get_model(), pc873xx_get_base());
  200. pc873xx_enable_ide();
  201. }
  202. }
  203. static inline void __init
  204. cabriolet_init_pci(void)
  205. {
  206. common_init_pci();
  207. cabriolet_enable_ide();
  208. }
  209. static inline void __init
  210. cia_cab_init_pci(void)
  211. {
  212. cia_init_pci();
  213. cabriolet_enable_ide();
  214. }
  215. /*
  216. * The PC164 and LX164 have 19 PCI interrupts, four from each of the four
  217. * PCI slots, the SIO, PCI/IDE, and USB.
  218. *