sh_intc.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef __SH_INTC_H
  2. #define __SH_INTC_H
  3. #include <linux/ioport.h>
  4. #ifdef CONFIG_SUPERH
  5. #define INTC_NR_IRQS 512
  6. #else
  7. #define INTC_NR_IRQS 1024
  8. #endif
  9. /*
  10. * Convert back and forth between INTEVT and IRQ values.
  11. */
  12. #ifdef CONFIG_CPU_HAS_INTEVT
  13. #define evt2irq(evt) (((evt) >> 5) - 16)
  14. #define irq2evt(irq) (((irq) + 16) << 5)
  15. #else
  16. #define evt2irq(evt) (evt)
  17. #define irq2evt(irq) (irq)
  18. #endif
  19. typedef unsigned char intc_enum;
  20. struct intc_vect {
  21. intc_enum enum_id;
  22. unsigned short vect;
  23. };
  24. #define INTC_VECT(enum_id, vect) { enum_id, vect }
  25. #define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq))
  26. struct intc_group {
  27. intc_enum enum_id;
  28. intc_enum enum_ids[32];
  29. };
  30. #define INTC_GROUP(enum_id, ids...) { enum_id, { ids } }
  31. struct intc_subgroup {
  32. unsigned long reg, reg_width;
  33. intc_enum parent_id;
  34. intc_enum enum_ids[32];
  35. };
  36. struct intc_mask_reg {
  37. unsigned long set_reg, clr_reg, reg_width;
  38. intc_enum enum_ids[32];
  39. #ifdef CONFIG_INTC_BALANCING
  40. unsigned long dist_reg;
  41. #endif
  42. #ifdef CONFIG_SMP
  43. unsigned long smp;
  44. #endif
  45. };
  46. struct intc_prio_reg {
  47. unsigned long set_reg, clr_reg, reg_width, field_width;
  48. intc_enum enum_ids[16];
  49. #ifdef CONFIG_SMP
  50. unsigned long smp;
  51. #endif
  52. };
  53. struct intc_sense_reg {
  54. unsigned long reg, reg_width, field_width;
  55. intc_enum enum_ids[16];
  56. };
  57. #ifdef CONFIG_INTC_BALANCING
  58. #define INTC_SMP_BALANCING(reg) .dist_reg = (reg)
  59. #else
  60. #define INTC_SMP_BALANCING(reg)
  61. #endif
  62. #ifdef CONFIG_SMP
  63. #define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8)
  64. #else
  65. #define INTC_SMP(stride, nr)
  66. #endif
  67. struct intc_hw_desc {
  68. struct intc_vect *vectors;
  69. unsigned int nr_vectors;
  70. struct intc_group *groups;
  71. unsigned int nr_groups;
  72. struct intc_mask_reg *mask_regs;
  73. unsigned int nr_mask_regs;
  74. struct intc_prio_reg *prio_regs;
  75. unsigned int nr_prio_regs;
  76. struct intc_sense_reg *sense_regs;
  77. unsigned int nr_sense_regs;
  78. struct intc_mask_reg *ack_regs;
  79. unsigned int nr_ack_regs;
  80. struct intc_subgroup *subgroups;
  81. unsigned int nr_subgroups;
  82. };
  83. #define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
  84. #define INTC_HW_DESC(vectors, groups, mask_regs, \
  85. prio_regs, sense_regs, ack_regs) \
  86. { \
  87. _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
  88. _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
  89. _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \
  90. }
  91. struct intc_desc {
  92. char *name;
  93. struct resource *resource;
  94. unsigned int num_resources;
  95. intc_enum force_enable;
  96. intc_enum force_disable;
  97. bool skip_syscore_suspend;
  98. struct intc_hw_desc hw;
  99. };
  100. #define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
  101. mask_regs, prio_regs, sense_regs) \
  102. struct intc_desc symbol __initdata = { \
  103. .name = chipname, \
  104. .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
  105. prio_regs, sense_regs, NULL), \
  106. }
  107. #define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
  108. mask_regs, prio_regs, sense_regs, ack_regs) \
  109. struct intc_desc symbol __initdata = { \
  110. .name = chipname, \
  111. .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
  112. prio_regs, sense_regs, ack_regs), \
  113. }
  114. int register_intc_controller(struct intc_desc *desc);
  115. int intc_set_priority(unsigned int irq, unsigned int prio);
  116. int intc_irq_lookup(const char *chipname, intc_enum enum_id);
  117. void intc_finalize(void);
  118. #ifdef CONFIG_INTC_USERIMASK
  119. int register_intc_userimask(unsigned long addr);
  120. #else
  121. static inline int register_intc_userimask(unsigned long addr)
  122. {
  123. return 0;
  124. }
  125. #endif
  126. #endif /* __SH_INTC_H */