loongarch_pic_common.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * LoongArch 7A1000 I/O interrupt controller definitions
  4. * Copyright (c) 2024 Loongson Technology Corporation Limited
  5. */
  6. #ifndef HW_LOONGARCH_PIC_COMMON_H
  7. #define HW_LOONGARCH_PIC_COMMON_H
  8. #include "hw/pci-host/ls7a.h"
  9. #include "hw/sysbus.h"
  10. #define PCH_PIC_INT_ID_VAL 0x7000000UL
  11. #define PCH_PIC_INT_ID_VER 0x1UL
  12. #define PCH_PIC_INT_ID_LO 0x00
  13. #define PCH_PIC_INT_ID_HI 0x04
  14. #define PCH_PIC_INT_MASK_LO 0x20
  15. #define PCH_PIC_INT_MASK_HI 0x24
  16. #define PCH_PIC_HTMSI_EN_LO 0x40
  17. #define PCH_PIC_HTMSI_EN_HI 0x44
  18. #define PCH_PIC_INT_EDGE_LO 0x60
  19. #define PCH_PIC_INT_EDGE_HI 0x64
  20. #define PCH_PIC_INT_CLEAR_LO 0x80
  21. #define PCH_PIC_INT_CLEAR_HI 0x84
  22. #define PCH_PIC_AUTO_CTRL0_LO 0xc0
  23. #define PCH_PIC_AUTO_CTRL0_HI 0xc4
  24. #define PCH_PIC_AUTO_CTRL1_LO 0xe0
  25. #define PCH_PIC_AUTO_CTRL1_HI 0xe4
  26. #define PCH_PIC_ROUTE_ENTRY_OFFSET 0x100
  27. #define PCH_PIC_ROUTE_ENTRY_END 0x13f
  28. #define PCH_PIC_HTMSI_VEC_OFFSET 0x200
  29. #define PCH_PIC_HTMSI_VEC_END 0x23f
  30. #define PCH_PIC_INT_STATUS_LO 0x3a0
  31. #define PCH_PIC_INT_STATUS_HI 0x3a4
  32. #define PCH_PIC_INT_POL_LO 0x3e0
  33. #define PCH_PIC_INT_POL_HI 0x3e4
  34. #define STATUS_LO_START 0
  35. #define STATUS_HI_START 0x4
  36. #define POL_LO_START 0x40
  37. #define POL_HI_START 0x44
  38. #define TYPE_LOONGARCH_PIC_COMMON "loongarch_pic_common"
  39. OBJECT_DECLARE_TYPE(LoongArchPICCommonState,
  40. LoongArchPICCommonClass, LOONGARCH_PIC_COMMON)
  41. struct LoongArchPICCommonState {
  42. SysBusDevice parent_obj;
  43. qemu_irq parent_irq[64];
  44. uint64_t int_mask; /* 0x020 interrupt mask register */
  45. uint64_t htmsi_en; /* 0x040 1=msi */
  46. uint64_t intedge; /* 0x060 edge=1 level=0 */
  47. uint64_t intclr; /* 0x080 clean edge int, set 1 clean, 0 noused */
  48. uint64_t auto_crtl0; /* 0x0c0 */
  49. uint64_t auto_crtl1; /* 0x0e0 */
  50. uint64_t last_intirr; /* edge detection */
  51. uint64_t intirr; /* 0x380 interrupt request register */
  52. uint64_t intisr; /* 0x3a0 interrupt service register */
  53. /*
  54. * 0x3e0 interrupt level polarity selection
  55. * register 0 for high level trigger
  56. */
  57. uint64_t int_polarity;
  58. uint8_t route_entry[64]; /* 0x100 - 0x138 */
  59. uint8_t htmsi_vector[64]; /* 0x200 - 0x238 */
  60. MemoryRegion iomem32_low;
  61. MemoryRegion iomem32_high;
  62. MemoryRegion iomem8;
  63. unsigned int irq_num;
  64. };
  65. struct LoongArchPICCommonClass {
  66. SysBusDeviceClass parent_class;
  67. DeviceRealize parent_realize;
  68. int (*pre_save)(LoongArchPICCommonState *s);
  69. int (*post_load)(LoongArchPICCommonState *s, int version_id);
  70. };
  71. #endif /* HW_LOONGARCH_PIC_COMMON_H */