irq.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  4. */
  5. #ifndef _ASM_IRQ_H
  6. #define _ASM_IRQ_H
  7. #include <linux/irqdomain.h>
  8. #include <linux/irqreturn.h>
  9. #define IRQ_STACK_SIZE THREAD_SIZE
  10. #define IRQ_STACK_START (IRQ_STACK_SIZE - 16)
  11. DECLARE_PER_CPU(unsigned long, irq_stack);
  12. /*
  13. * The highest address on the IRQ stack contains a dummy frame which is
  14. * structured as follows:
  15. *
  16. * top ------------
  17. * | task sp | <- irq_stack[cpu] + IRQ_STACK_START
  18. * ------------
  19. * | | <- First frame of IRQ context
  20. * ------------
  21. *
  22. * task sp holds a copy of the task stack pointer where the struct pt_regs
  23. * from exception entry can be found.
  24. */
  25. static inline bool on_irq_stack(int cpu, unsigned long sp)
  26. {
  27. unsigned long low = per_cpu(irq_stack, cpu);
  28. unsigned long high = low + IRQ_STACK_SIZE;
  29. return (low <= sp && sp <= high);
  30. }
  31. void spurious_interrupt(void);
  32. #define NR_IRQS_LEGACY 16
  33. #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
  34. void arch_trigger_cpumask_backtrace(const struct cpumask *mask, bool exclude_self);
  35. #define MAX_IO_PICS 2
  36. #define NR_IRQS (64 + (256 * MAX_IO_PICS))
  37. struct acpi_vector_group {
  38. int node;
  39. int pci_segment;
  40. struct irq_domain *parent;
  41. };
  42. extern struct acpi_vector_group pch_group[MAX_IO_PICS];
  43. extern struct acpi_vector_group msi_group[MAX_IO_PICS];
  44. #define CORES_PER_EIO_NODE 4
  45. #define LOONGSON_CPU_UART0_VEC 10 /* CPU UART0 */
  46. #define LOONGSON_CPU_THSENS_VEC 14 /* CPU Thsens */
  47. #define LOONGSON_CPU_HT0_VEC 16 /* CPU HT0 irq vector base number */
  48. #define LOONGSON_CPU_HT1_VEC 24 /* CPU HT1 irq vector base number */
  49. /* IRQ number definitions */
  50. #define LOONGSON_LPC_IRQ_BASE 0
  51. #define LOONGSON_LPC_LAST_IRQ (LOONGSON_LPC_IRQ_BASE + 15)
  52. #define LOONGSON_CPU_IRQ_BASE 16
  53. #define LOONGSON_CPU_LAST_IRQ (LOONGSON_CPU_IRQ_BASE + 14)
  54. #define LOONGSON_PCH_IRQ_BASE 64
  55. #define LOONGSON_PCH_ACPI_IRQ (LOONGSON_PCH_IRQ_BASE + 47)
  56. #define LOONGSON_PCH_LAST_IRQ (LOONGSON_PCH_IRQ_BASE + 64 - 1)
  57. #define LOONGSON_MSI_IRQ_BASE (LOONGSON_PCH_IRQ_BASE + 64)
  58. #define LOONGSON_MSI_LAST_IRQ (LOONGSON_PCH_IRQ_BASE + 256 - 1)
  59. #define GSI_MIN_LPC_IRQ LOONGSON_LPC_IRQ_BASE
  60. #define GSI_MAX_LPC_IRQ (LOONGSON_LPC_IRQ_BASE + 16 - 1)
  61. #define GSI_MIN_CPU_IRQ LOONGSON_CPU_IRQ_BASE
  62. #define GSI_MAX_CPU_IRQ (LOONGSON_CPU_IRQ_BASE + 48 - 1)
  63. #define GSI_MIN_PCH_IRQ LOONGSON_PCH_IRQ_BASE
  64. #define GSI_MAX_PCH_IRQ (LOONGSON_PCH_IRQ_BASE + 256 - 1)
  65. struct acpi_madt_lio_pic;
  66. struct acpi_madt_eio_pic;
  67. struct acpi_madt_ht_pic;
  68. struct acpi_madt_bio_pic;
  69. struct acpi_madt_msi_pic;
  70. struct acpi_madt_lpc_pic;
  71. int liointc_acpi_init(struct irq_domain *parent,
  72. struct acpi_madt_lio_pic *acpi_liointc);
  73. int eiointc_acpi_init(struct irq_domain *parent,
  74. struct acpi_madt_eio_pic *acpi_eiointc);
  75. struct irq_domain *htvec_acpi_init(struct irq_domain *parent,
  76. struct acpi_madt_ht_pic *acpi_htvec);
  77. int pch_lpc_acpi_init(struct irq_domain *parent,
  78. struct acpi_madt_lpc_pic *acpi_pchlpc);
  79. int pch_msi_acpi_init(struct irq_domain *parent,
  80. struct acpi_madt_msi_pic *acpi_pchmsi);
  81. int pch_pic_acpi_init(struct irq_domain *parent,
  82. struct acpi_madt_bio_pic *acpi_pchpic);
  83. int find_pch_pic(u32 gsi);
  84. struct fwnode_handle *get_pch_msi_handle(int pci_segment);
  85. extern struct acpi_madt_lio_pic *acpi_liointc;
  86. extern struct acpi_madt_eio_pic *acpi_eiointc[MAX_IO_PICS];
  87. extern struct acpi_madt_ht_pic *acpi_htintc;
  88. extern struct acpi_madt_lpc_pic *acpi_pchlpc;
  89. extern struct acpi_madt_msi_pic *acpi_pchmsi[MAX_IO_PICS];
  90. extern struct acpi_madt_bio_pic *acpi_pchpic[MAX_IO_PICS];
  91. extern struct fwnode_handle *cpuintc_handle;
  92. extern struct fwnode_handle *liointc_handle;
  93. extern struct fwnode_handle *pch_lpc_handle;
  94. extern struct fwnode_handle *pch_pic_handle[MAX_IO_PICS];
  95. extern irqreturn_t loongson_ipi_interrupt(int irq, void *dev);
  96. #include <asm-generic/irq.h>
  97. #endif /* _ASM_IRQ_H */