xive-internal.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2016,2017 IBM Corporation.
  4. */
  5. #ifndef __XIVE_INTERNAL_H
  6. #define __XIVE_INTERNAL_H
  7. /*
  8. * A "disabled" interrupt should never fire, to catch problems
  9. * we set its logical number to this
  10. */
  11. #define XIVE_BAD_IRQ 0x7fffffff
  12. #define XIVE_MAX_IRQ (XIVE_BAD_IRQ - 1)
  13. /* Each CPU carry one of these with various per-CPU state */
  14. struct xive_cpu {
  15. #ifdef CONFIG_SMP
  16. /* HW irq number and data of IPI */
  17. u32 hw_ipi;
  18. struct xive_irq_data ipi_data;
  19. #endif /* CONFIG_SMP */
  20. int chip_id;
  21. /* Queue datas. Only one is populated */
  22. #define XIVE_MAX_QUEUES 8
  23. struct xive_q queue[XIVE_MAX_QUEUES];
  24. /*
  25. * Pending mask. Each bit corresponds to a priority that
  26. * potentially has pending interrupts.
  27. */
  28. u8 pending_prio;
  29. /* Cache of HW CPPR */
  30. u8 cppr;
  31. };
  32. /* Backend ops */
  33. struct xive_ops {
  34. int (*populate_irq_data)(u32 hw_irq, struct xive_irq_data *data);
  35. int (*configure_irq)(u32 hw_irq, u32 target, u8 prio, u32 sw_irq);
  36. int (*get_irq_config)(u32 hw_irq, u32 *target, u8 *prio,
  37. u32 *sw_irq);
  38. int (*setup_queue)(unsigned int cpu, struct xive_cpu *xc, u8 prio);
  39. void (*cleanup_queue)(unsigned int cpu, struct xive_cpu *xc, u8 prio);
  40. void (*prepare_cpu)(unsigned int cpu, struct xive_cpu *xc);
  41. void (*setup_cpu)(unsigned int cpu, struct xive_cpu *xc);
  42. void (*teardown_cpu)(unsigned int cpu, struct xive_cpu *xc);
  43. bool (*match)(struct device_node *np);
  44. void (*shutdown)(void);
  45. void (*update_pending)(struct xive_cpu *xc);
  46. void (*sync_source)(u32 hw_irq);
  47. u64 (*esb_rw)(u32 hw_irq, u32 offset, u64 data, bool write);
  48. #ifdef CONFIG_SMP
  49. int (*get_ipi)(unsigned int cpu, struct xive_cpu *xc);
  50. void (*put_ipi)(unsigned int cpu, struct xive_cpu *xc);
  51. #endif
  52. int (*debug_show)(struct seq_file *m, void *private);
  53. int (*debug_create)(struct dentry *xive_dir);
  54. const char *name;
  55. };
  56. bool xive_core_init(struct device_node *np, const struct xive_ops *ops,
  57. void __iomem *area, u32 offset, u8 max_prio);
  58. __be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift);
  59. int xive_core_debug_init(void);
  60. static inline u32 xive_alloc_order(u32 queue_shift)
  61. {
  62. return (queue_shift > PAGE_SHIFT) ? (queue_shift - PAGE_SHIFT) : 0;
  63. }
  64. extern bool xive_cmdline_disabled;
  65. extern bool xive_has_save_restore;
  66. #endif /* __XIVE_INTERNAL_H */