bonito_irq.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* $OpenBSD: bonito_irq.h,v 1.2 2010/05/08 21:59:56 miod Exp $ */
  2. /*
  3. * Copyright (c) 2009, 2010 Miodrag Vallat.
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /*
  18. * Bonito interrupt assignments
  19. */
  20. /*
  21. * Loongson 2F assignments
  22. */
  23. #define LOONGSON_INTR_GPIO0 0
  24. #define LOONGSON_INTR_GPIO1 1
  25. #define LOONGSON_INTR_GPIO2 2
  26. #define LOONGSON_INTR_GPIO3 3
  27. /* pci interrupts */
  28. #define LOONGSON_INTR_PCIA 4
  29. #define LOONGSON_INTR_PCIB 5
  30. #define LOONGSON_INTR_PCIC 6
  31. #define LOONGSON_INTR_PCID 7
  32. #define LOONGSON_INTR_PCI_PARERR 8
  33. #define LOONGSON_INTR_PCI_SYSERR 9
  34. #define LOONGSON_INTR_DRAM_PARERR 10
  35. /* non-PCI interrupts */
  36. #define LOONGSON_INTR_INT0 11
  37. #define LOONGSON_INTR_INT1 12
  38. #define LOONGSON_INTR_INT2 13
  39. #define LOONGSON_INTR_INT3 14
  40. #define LOONGSON_INTRMASK_GPIO0 0x00000001 /* can't interrupt */
  41. #define LOONGSON_INTRMASK_GPIO1 0x00000002
  42. #define LOONGSON_INTRMASK_GPIO2 0x00000004
  43. #define LOONGSON_INTRMASK_GPIO3 0x00000008
  44. #define LOONGSON_INTRMASK_GPIO 0x0000000f
  45. /* pci interrupts */
  46. #define LOONGSON_INTRMASK_PCIA 0x00000010
  47. #define LOONGSON_INTRMASK_PCIB 0x00000020
  48. #define LOONGSON_INTRMASK_PCIC 0x00000040
  49. #define LOONGSON_INTRMASK_PCID 0x00000080
  50. #define LOONGSON_INTRMASK_PCI_PARERR 0x00000100
  51. #define LOONGSON_INTRMASK_PCI_SYSERR 0x00000200
  52. #define LOONGSON_INTRMASK_DRAM_PARERR 0x00000400
  53. /* non-PCI interrupts */
  54. #define LOONGSON_INTRMASK_INT0 0x00000800
  55. #define LOONGSON_INTRMASK_INT1 0x00001000
  56. #define LOONGSON_INTRMASK_INT2 0x00002000
  57. #define LOONGSON_INTRMASK_INT3 0x00004000
  58. #define LOONGSON_INTRMASK_LVL0 0x00007800 /* not maskable in bonito */
  59. #define LOONGSON_INTRMASK_LVL4 0x000007ff
  60. /*
  61. * Loongson 2E (Bonito64) assignments
  62. */
  63. #define BONITO_INTRMASK_MBOX 0x0000000f
  64. #define BONITO_INTR_MBOX 0
  65. #define BONITO_INTRMASK_DMARDY 0x00000010
  66. #define BONITO_INTRMASK_DMAEMPTY 0x00000020
  67. #define BONITO_INTRMASK_COPYRDY 0x00000040
  68. #define BONITO_INTRMASK_COPYEMPTY 0x00000080
  69. #define BONITO_INTRMASK_COPYERR 0x00000100
  70. #define BONITO_INTRMASK_PCIIRQ 0x00000200
  71. #define BONITO_INTRMASK_MASTERERR 0x00000400
  72. #define BONITO_INTRMASK_SYSTEMERR 0x00000800
  73. #define BONITO_INTRMASK_DRAMPERR 0x00001000
  74. #define BONITO_INTRMASK_RETRYERR 0x00002000
  75. #define BONITO_INTRMASK_GPIO 0x01ff0000
  76. #define BONITO_INTR_GPIO 16
  77. #define BONITO_INTRMASK_GPIN 0x7e000000
  78. #define BONITO_INTR_GPIN 25
  79. /*
  80. * Bonito interrupt handling recipes:
  81. * - we have up to 32 interrupts at the Bonito level.
  82. * - systems with ISA devices also have 16 (well, 15) ISA interrupts with the
  83. * usual 8259 pair. Bonito and ISA interrupts happen on two different levels.
  84. *
  85. * These arbitrary values may be changed as long as interrupt mask variables
  86. * use large enough integer types and always use the following macros to
  87. * handle interrupt masks.
  88. */
  89. #define INTPRI_BONITO (INTPRI_CLOCK + 1)
  90. #define INTPRI_ISA (INTPRI_BONITO + 1)
  91. #define BONITO_NDIRECT 32
  92. #define BONITO_NISA 16
  93. #define BONITO_NINTS (BONITO_NDIRECT + BONITO_NISA)
  94. #define BONITO_ISA_IRQ(i) ((i) + BONITO_NDIRECT)
  95. #define BONITO_DIRECT_IRQ(i) (i)
  96. #define BONITO_IRQ_IS_ISA(i) ((i) >= BONITO_NDIRECT)
  97. #define BONITO_IRQ_TO_ISA(i) ((i) - BONITO_NDIRECT)
  98. #define BONITO_DIRECT_MASK(imask) ((imask) & ((1L << BONITO_NDIRECT) - 1))
  99. #define BONITO_ISA_MASK(imask) ((imask) >> BONITO_NDIRECT)
  100. extern struct intrhand *bonito_intrhand[BONITO_NINTS];
  101. extern uint64_t bonito_intem;
  102. extern uint64_t bonito_imask[NIPLS];