xics.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Common definitions accross all variants of ICP and ICS interrupt
  3. * controllers.
  4. */
  5. #ifndef _XICS_H
  6. #define _XICS_H
  7. #include <linux/interrupt.h>
  8. #define XICS_IPI 2
  9. #define XICS_IRQ_SPURIOUS 0
  10. /* Want a priority other than 0. Various HW issues require this. */
  11. #define DEFAULT_PRIORITY 5
  12. /*
  13. * Mark IPIs as higher priority so we can take them inside interrupts
  14. * FIXME: still true now?
  15. */
  16. #define IPI_PRIORITY 4
  17. /* The least favored priority */
  18. #define LOWEST_PRIORITY 0xFF
  19. /* The number of priorities defined above */
  20. #define MAX_NUM_PRIORITIES 3
  21. /* Native ICP */
  22. #ifdef CONFIG_PPC_ICP_NATIVE
  23. extern int icp_native_init(void);
  24. #else
  25. static inline int icp_native_init(void) { return -ENODEV; }
  26. #endif
  27. /* PAPR ICP */
  28. #ifdef CONFIG_PPC_ICP_HV
  29. extern int icp_hv_init(void);
  30. #else
  31. static inline int icp_hv_init(void) { return -ENODEV; }
  32. #endif
  33. /* ICP ops */
  34. struct icp_ops {
  35. unsigned int (*get_irq)(void);
  36. void (*eoi)(struct irq_data *d);
  37. void (*set_priority)(unsigned char prio);
  38. void (*teardown_cpu)(void);
  39. void (*flush_ipi)(void);
  40. #ifdef CONFIG_SMP
  41. void (*cause_ipi)(int cpu, unsigned long data);
  42. irq_handler_t ipi_action;
  43. #endif
  44. };
  45. extern const struct icp_ops *icp_ops;
  46. /* Native ICS */
  47. extern int ics_native_init(void);
  48. /* RTAS ICS */
  49. #ifdef CONFIG_PPC_ICS_RTAS
  50. extern int ics_rtas_init(void);
  51. #else
  52. static inline int ics_rtas_init(void) { return -ENODEV; }
  53. #endif
  54. /* HAL ICS */
  55. #ifdef CONFIG_PPC_POWERNV
  56. extern int ics_opal_init(void);
  57. #else
  58. static inline int ics_opal_init(void) { return -ENODEV; }
  59. #endif
  60. /* ICS instance, hooked up to chip_data of an irq */
  61. struct ics {
  62. struct list_head link;
  63. int (*map)(struct ics *ics, unsigned int virq);
  64. void (*mask_unknown)(struct ics *ics, unsigned long vec);
  65. long (*get_server)(struct ics *ics, unsigned long vec);
  66. int (*host_match)(struct ics *ics, struct device_node *node);
  67. char data[];
  68. };
  69. /* Commons */
  70. extern unsigned int xics_default_server;
  71. extern unsigned int xics_default_distrib_server;
  72. extern unsigned int xics_interrupt_server_size;
  73. extern struct irq_domain *xics_host;
  74. struct xics_cppr {
  75. unsigned char stack[MAX_NUM_PRIORITIES];
  76. int index;
  77. };
  78. DECLARE_PER_CPU(struct xics_cppr, xics_cppr);
  79. static inline void xics_push_cppr(unsigned int vec)
  80. {
  81. struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
  82. if (WARN_ON(os_cppr->index >= MAX_NUM_PRIORITIES - 1))
  83. return;
  84. if (vec == XICS_IPI)
  85. os_cppr->stack[++os_cppr->index] = IPI_PRIORITY;
  86. else
  87. os_cppr->stack[++os_cppr->index] = DEFAULT_PRIORITY;
  88. }
  89. static inline unsigned char xics_pop_cppr(void)
  90. {
  91. struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
  92. if (WARN_ON(os_cppr->index < 1))
  93. return LOWEST_PRIORITY;
  94. return os_cppr->stack[--os_cppr->index];
  95. }
  96. static inline void xics_set_base_cppr(unsigned char cppr)
  97. {
  98. struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
  99. /* we only really want to set the priority when there's
  100. * just one cppr value on the stack
  101. */
  102. WARN_ON(os_cppr->index != 0);
  103. os_cppr->stack[0] = cppr;
  104. }
  105. static inline unsigned char xics_cppr_top(void)
  106. {
  107. struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
  108. return os_cppr->stack[os_cppr->index];
  109. }
  110. DECLARE_PER_CPU_SHARED_ALIGNED(unsigned long, xics_ipi_message);
  111. extern void xics_init(void);
  112. extern void xics_setup_cpu(void);
  113. extern void xics_update_irq_servers(void);
  114. extern void xics_set_cpu_giq(unsigned int gserver, unsigned int join);
  115. extern void xics_mask_unknown_vec(unsigned int vec);
  116. extern irqreturn_t xics_ipi_dispatch(int cpu);
  117. extern int xics_smp_probe(void);
  118. extern void xics_register_ics(struct ics *ics);
  119. extern void xics_teardown_cpu(void);
  120. extern void xics_kexec_teardown_cpu(int secondary);
  121. extern void xics_migrate_irqs_away(void);
  122. #ifdef CONFIG_SMP
  123. extern int xics_get_irq_server(unsigned int virq, const struct cpumask *cpumask,
  124. unsigned int strict_check);
  125. #else
  126. #define xics_get_irq_server(virq, cpumask, strict_check) (xics_default_server)
  127. #endif
  128. #endif /* _XICS_H */