xive-internal.h 2.2 KB

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