irq.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * Platform dependent support for SGI SN1
  3.  *
  4.  * Copyright (C) 2000   Silicon Graphics
  5.  * Copyright (C) 2000   Jack Steiner (steiner@sgi.com)
  6.  * Copyright (C) 2000   Alan Mayer (ajm@sgi.com)
  7.  * Copyright (C) 2000   Kanoj Sarcar (kanoj@sgi.com)
  8.  */
  9. #include <linux/config.h>
  10. #include <linux/init.h>
  11. #include <linux/sched.h>
  12. #include <linux/slab.h>
  13. #include <asm/current.h>
  14. #include <linux/irq.h>
  15. #include <linux/interrupt.h>
  16. #include <asm/sn/sgi.h>
  17. #include <asm/sn/iograph.h>
  18. #include <asm/sn/invent.h>
  19. #include <linux/devfs_fs_kernel.h>
  20. #include <asm/sn/hcl.h>
  21. #include <asm/sn/types.h>
  22. #include <asm/sn/pci/bridge.h>
  23. #include <asm/sn/pci/pciio.h>
  24. #include <asm/sn/pci/pciio_private.h>
  25. #include <asm/sn/sn_cpuid.h>
  26. #include <asm/sn/sn1/bedrock.h>
  27. #include <asm/sn/intr.h>
  28. #include <asm/sn/addrs.h>
  29. #include <asm/sn/sn1/addrs.h>
  30. #include <asm/sn/iobus.h>
  31. #include <asm/sn/sn1/arch.h>
  32. #include <asm/sn/synergy.h>
  33. #define IRQ_BIT_OFFSET 64
  34. int bit_pos_to_irq(int bit)
  35. {
  36. if (bit > 118)
  37. bit = 118;
  38. return (bit + IRQ_BIT_OFFSET);
  39. }
  40. static inline int irq_to_bit_pos(int irq)
  41. {
  42. int bit = irq - IRQ_BIT_OFFSET;
  43. if (bit > 63)
  44. bit -= 64;
  45. return bit;
  46. }
  47. static unsigned int
  48. sn1_startup_irq(unsigned int irq)
  49. {
  50.         return(0);
  51. }
  52. static void
  53. sn1_shutdown_irq(unsigned int irq)
  54. {
  55. }
  56. static void
  57. sn1_disable_irq(unsigned int irq)
  58. {
  59. }
  60. static void
  61. sn1_enable_irq(unsigned int irq)
  62. {
  63. }
  64. static void
  65. sn1_ack_irq(unsigned int irq)
  66. {
  67. }
  68. static void
  69. sn1_end_irq(unsigned int irq)
  70. {
  71. int bit;
  72. bit = irq_to_bit_pos(irq);
  73. LOCAL_HUB_CLR_INTR(bit);
  74. }
  75. static void
  76. sn1_set_affinity_irq(unsigned int irq, unsigned long mask)
  77. {
  78. }
  79. struct hw_interrupt_type irq_type_sn1 = {
  80.         "sn1_irq",
  81.         sn1_startup_irq,
  82.         sn1_shutdown_irq,
  83.         sn1_enable_irq,
  84.         sn1_disable_irq,
  85.         sn1_ack_irq,
  86.         sn1_end_irq,
  87.         sn1_set_affinity_irq
  88. };
  89. void
  90. sn1_irq_init (void)
  91. {
  92. int i;
  93. for (i = 0; i <= NR_IRQS; ++i) {
  94. if (idesc_from_vector(i)->handler == &no_irq_type) {
  95. idesc_from_vector(i)->handler = &irq_type_sn1;
  96. }
  97. }
  98. }
  99. #if !defined(CONFIG_IA64_SGI_SN1)
  100. void
  101. sn1_pci_fixup(int arg)
  102. {
  103. }
  104. #endif
  105. #ifdef CONFIG_PERCPU_IRQ
  106. extern irq_desc_t irq_descX[NR_IRQS];
  107. irq_desc_t *irq_desc_ptr[NR_CPUS] = { irq_descX };
  108. /*
  109.  * Each slave AP allocates its own irq table.
  110.  */
  111. int __init cpu_irq_init(void)
  112. {
  113. irq_desc_ptr[smp_processor_id()] = (irq_desc_t *)kmalloc(sizeof(irq_descX), GFP_KERNEL);
  114. if (irq_desc_ptr[smp_processor_id()] == 0)
  115. return(-1);
  116. memcpy(irq_desc_ptr[smp_processor_id()], irq_desc_ptr[0], 
  117. sizeof(irq_descX));
  118. return(0);
  119. }
  120. /*
  121.  * This can also allocate the irq tables for the other cpus, specifically
  122.  * on their nodes.
  123.  */
  124. int __init master_irq_init(void)
  125. {
  126. return(0);
  127. }
  128. /*
  129.  * The input is an ivt level.
  130.  */
  131. irq_desc_t *idesc_from_vector(unsigned int ivnum)
  132. {
  133. return(irq_desc_ptr[smp_processor_id()] + ivnum);
  134. }
  135. /*
  136.  * The input is a "soft" level, that we encoded in.
  137.  */
  138. irq_desc_t *idesc_from_irq(unsigned int irq)
  139. {
  140. return(irq_desc_ptr[irq >> 8] + (irq & 0xff));
  141. }
  142. unsigned int ivector_from_irq(unsigned int irq)
  143. {
  144. return(irq & 0xff);
  145. }
  146. /*
  147.  * This should return the Linux irq # for the i/p vector on the
  148.  * i/p cpu. We currently do not track this.
  149.  */
  150. unsigned int irq_from_cpuvector(int cpunum, unsigned int vector)
  151. {
  152. return (vector);
  153. }
  154. #endif /* CONFIG_PERCPU_IRQ */