pnv-pci.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2014 IBM Corp.
  4. */
  5. #ifndef _ASM_PNV_PCI_H
  6. #define _ASM_PNV_PCI_H
  7. #include <linux/pci.h>
  8. #include <linux/pci_hotplug.h>
  9. #include <linux/irq.h>
  10. #include <linux/of.h>
  11. #include <misc/cxl-base.h>
  12. #include <asm/opal-api.h>
  13. #define PCI_SLOT_ID_PREFIX (1UL << 63)
  14. #define PCI_SLOT_ID(phb_id, bdfn) \
  15. (PCI_SLOT_ID_PREFIX | ((uint64_t)(bdfn) << 16) | (phb_id))
  16. #define PCI_PHB_SLOT_ID(phb_id) (phb_id)
  17. extern int pnv_pci_get_slot_id(struct device_node *np, uint64_t *id);
  18. extern int pnv_pci_get_device_tree(uint32_t phandle, void *buf, uint64_t len);
  19. extern int pnv_pci_get_presence_state(uint64_t id, uint8_t *state);
  20. extern int pnv_pci_get_power_state(uint64_t id, uint8_t *state);
  21. extern int pnv_pci_set_power_state(uint64_t id, uint8_t state,
  22. struct opal_msg *msg);
  23. extern int pnv_pci_set_tunnel_bar(struct pci_dev *dev, uint64_t addr,
  24. int enable);
  25. int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode);
  26. int pnv_cxl_ioda_msi_setup(struct pci_dev *dev, unsigned int hwirq,
  27. unsigned int virq);
  28. int pnv_cxl_alloc_hwirqs(struct pci_dev *dev, int num);
  29. void pnv_cxl_release_hwirqs(struct pci_dev *dev, int hwirq, int num);
  30. int pnv_cxl_get_irq_count(struct pci_dev *dev);
  31. struct device_node *pnv_pci_get_phb_node(struct pci_dev *dev);
  32. int64_t pnv_opal_pci_msi_eoi(struct irq_data *d);
  33. bool is_pnv_opal_msi(struct irq_chip *chip);
  34. #ifdef CONFIG_CXL_BASE
  35. int pnv_cxl_alloc_hwirq_ranges(struct cxl_irq_ranges *irqs,
  36. struct pci_dev *dev, int num);
  37. void pnv_cxl_release_hwirq_ranges(struct cxl_irq_ranges *irqs,
  38. struct pci_dev *dev);
  39. #endif
  40. struct pnv_php_slot {
  41. struct hotplug_slot slot;
  42. uint64_t id;
  43. char *name;
  44. int slot_no;
  45. unsigned int flags;
  46. #define PNV_PHP_FLAG_BROKEN_PDC 0x1
  47. struct kref kref;
  48. #define PNV_PHP_STATE_INITIALIZED 0
  49. #define PNV_PHP_STATE_REGISTERED 1
  50. #define PNV_PHP_STATE_POPULATED 2
  51. #define PNV_PHP_STATE_OFFLINE 3
  52. int state;
  53. int irq;
  54. struct workqueue_struct *wq;
  55. struct device_node *dn;
  56. struct pci_dev *pdev;
  57. struct pci_bus *bus;
  58. bool power_state_check;
  59. u8 attention_state;
  60. void *fdt;
  61. void *dt;
  62. struct of_changeset ocs;
  63. struct pnv_php_slot *parent;
  64. struct list_head children;
  65. struct list_head link;
  66. };
  67. extern struct pnv_php_slot *pnv_php_find_slot(struct device_node *dn);
  68. extern int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
  69. uint8_t state);
  70. #endif