internals.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #include <linux/sh_intc.h>
  2. #include <linux/irq.h>
  3. #include <linux/list.h>
  4. #include <linux/kernel.h>
  5. #include <linux/types.h>
  6. #include <linux/radix-tree.h>
  7. #include <linux/sysdev.h>
  8. #define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \
  9. ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \
  10. ((addr_e) << 16) | ((addr_d << 24)))
  11. #define _INTC_SHIFT(h) (h & 0x1f)
  12. #define _INTC_WIDTH(h) ((h >> 5) & 0xf)
  13. #define _INTC_FN(h) ((h >> 9) & 0xf)
  14. #define _INTC_MODE(h) ((h >> 13) & 0x7)
  15. #define _INTC_ADDR_E(h) ((h >> 16) & 0xff)
  16. #define _INTC_ADDR_D(h) ((h >> 24) & 0xff)
  17. #ifdef CONFIG_SMP
  18. #define IS_SMP(x) (x.smp)
  19. #define INTC_REG(d, x, c) (d->reg[(x)] + ((d->smp[(x)] & 0xff) * c))
  20. #define SMP_NR(d, x) ((d->smp[(x)] >> 8) ? (d->smp[(x)] >> 8) : 1)
  21. #else
  22. #define IS_SMP(x) 0
  23. #define INTC_REG(d, x, c) (d->reg[(x)])
  24. #define SMP_NR(d, x) 1
  25. #endif
  26. struct intc_handle_int {
  27. unsigned int irq;
  28. unsigned long handle;
  29. };
  30. struct intc_window {
  31. phys_addr_t phys;
  32. void __iomem *virt;
  33. unsigned long size;
  34. };
  35. struct intc_map_entry {
  36. intc_enum enum_id;
  37. struct intc_desc_int *desc;
  38. };
  39. struct intc_subgroup_entry {
  40. unsigned int pirq;
  41. intc_enum enum_id;
  42. unsigned long handle;
  43. };
  44. struct intc_desc_int {
  45. struct list_head list;
  46. struct sys_device sysdev;
  47. struct radix_tree_root tree;
  48. raw_spinlock_t lock;
  49. unsigned int index;
  50. unsigned long *reg;
  51. #ifdef CONFIG_SMP
  52. unsigned long *smp;
  53. #endif
  54. unsigned int nr_reg;
  55. struct intc_handle_int *prio;
  56. unsigned int nr_prio;
  57. struct intc_handle_int *sense;
  58. unsigned int nr_sense;
  59. struct intc_window *window;
  60. unsigned int nr_windows;
  61. struct irq_chip chip;
  62. };
  63. enum {
  64. REG_FN_ERR = 0,
  65. REG_FN_TEST_BASE = 1,
  66. REG_FN_WRITE_BASE = 5,
  67. REG_FN_MODIFY_BASE = 9
  68. };
  69. enum { MODE_ENABLE_REG = 0, /* Bit(s) set -> interrupt enabled */
  70. MODE_MASK_REG, /* Bit(s) set -> interrupt disabled */
  71. MODE_DUAL_REG, /* Two registers, set bit to enable / disable */
  72. MODE_PRIO_REG, /* Priority value written to enable interrupt */
  73. MODE_PCLR_REG, /* Above plus all bits set to disable interrupt */
  74. };
  75. static inline struct intc_desc_int *get_intc_desc(unsigned int irq)
  76. {
  77. struct irq_chip *chip = irq_get_chip(irq);
  78. return container_of(chip, struct intc_desc_int, chip);
  79. }
  80. /*
  81. * Grumble.
  82. */
  83. static inline void activate_irq(int irq)
  84. {
  85. #ifdef CONFIG_ARM
  86. /* ARM requires an extra step to clear IRQ_NOREQUEST, which it
  87. * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE.
  88. */
  89. set_irq_flags(irq, IRQF_VALID);
  90. #else
  91. /* same effect on other architectures */
  92. irq_set_noprobe(irq);
  93. #endif
  94. }
  95. /* access.c */
  96. extern unsigned long
  97. (*intc_reg_fns[])(unsigned long addr, unsigned long h, unsigned long data);
  98. extern unsigned long
  99. (*intc_enable_fns[])(unsigned long addr, unsigned long handle,
  100. unsigned long (*fn)(unsigned long,
  101. unsigned long, unsigned long),
  102. unsigned int irq);
  103. extern unsigned long
  104. (*intc_disable_fns[])(unsigned long addr, unsigned long handle,
  105. unsigned long (*fn)(unsigned long,
  106. unsigned long, unsigned long),
  107. unsigned int irq);
  108. extern unsigned long
  109. (*intc_enable_noprio_fns[])(unsigned long addr, unsigned long handle,
  110. unsigned long (*fn)(unsigned long,
  111. unsigned long, unsigned long),
  112. unsigned int irq);
  113. unsigned long intc_phys_to_virt(struct intc_desc_int *d, unsigned long address);
  114. unsigned int intc_get_reg(struct intc_desc_int *d, unsigned long address);
  115. unsigned int intc_set_field_from_handle(unsigned int value,
  116. unsigned int field_value,
  117. unsigned int handle);
  118. unsigned long intc_get_field_from_handle(unsigned int value,
  119. unsigned int handle);
  120. /* balancing.c */
  121. #ifdef CONFIG_INTC_BALANCING
  122. void intc_balancing_enable(unsigned int irq);
  123. void intc_balancing_disable(unsigned int irq);
  124. void intc_set_dist_handle(unsigned int irq, struct intc_desc *desc,
  125. struct intc_desc_int *d, intc_enum id);
  126. #else
  127. static inline void intc_balancing_enable(unsigned int irq) { }
  128. static inline void intc_balancing_disable(unsigned int irq) { }
  129. static inline void
  130. intc_set_dist_handle(unsigned int irq, struct intc_desc *desc,
  131. struct intc_desc_int *d, intc_enum id) { }
  132. #endif
  133. /* chip.c */
  134. extern struct irq_chip intc_irq_chip;
  135. void _intc_enable(struct irq_data *data, unsigned long handle);
  136. /* core.c */
  137. extern struct list_head intc_list;
  138. extern raw_spinlock_t intc_big_lock;
  139. extern unsigned int nr_intc_controllers;
  140. extern struct sysdev_class intc_sysdev_class;
  141. unsigned int intc_get_dfl_prio_level(void);
  142. unsigned int intc_get_prio_level(unsigned int irq);
  143. void intc_set_prio_level(unsigned int irq, unsigned int level);
  144. /* handle.c */
  145. unsigned int intc_get_mask_handle(struct intc_desc *desc,
  146. struct intc_desc_int *d,
  147. intc_enum enum_id, int do_grps);
  148. unsigned int intc_get_prio_handle(struct intc_desc *desc,
  149. struct intc_desc_int *d,
  150. intc_enum enum_id, int do_grps);
  151. unsigned int intc_get_sense_handle(struct intc_desc *desc,
  152. struct intc_desc_int *d,
  153. intc_enum enum_id);
  154. void intc_set_ack_handle(unsigned int irq, struct intc_desc *desc,
  155. struct intc_desc_int *d, intc_enum id);
  156. unsigned long intc_get_ack_handle(unsigned int irq);
  157. void intc_enable_disable_enum(struct intc_desc *desc, struct intc_desc_int *d,
  158. intc_enum enum_id, int enable);
  159. /* virq.c */
  160. void intc_subgroup_init(struct intc_desc *desc, struct intc_desc_int *d);
  161. void intc_irq_xlate_set(unsigned int irq, intc_enum id, struct intc_desc_int *d);
  162. struct intc_map_entry *intc_irq_xlate_get(unsigned int irq);