pnv-pci.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2014 IBM Corp.
  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 _ASM_PNV_PCI_H
  10. #define _ASM_PNV_PCI_H
  11. #include <linux/pci.h>
  12. #include <linux/pci_hotplug.h>
  13. #include <linux/irq.h>
  14. #include <misc/cxl-base.h>
  15. #include <asm/opal-api.h>
  16. #define PCI_SLOT_ID_PREFIX (1UL << 63)
  17. #define PCI_SLOT_ID(phb_id, bdfn) \
  18. (PCI_SLOT_ID_PREFIX | ((uint64_t)(bdfn) << 16) | (phb_id))
  19. extern int pnv_pci_get_slot_id(struct device_node *np, uint64_t *id);
  20. extern int pnv_pci_get_device_tree(uint32_t phandle, void *buf, uint64_t len);
  21. extern int pnv_pci_get_presence_state(uint64_t id, uint8_t *state);
  22. extern int pnv_pci_get_power_state(uint64_t id, uint8_t *state);
  23. extern int pnv_pci_set_power_state(uint64_t id, uint8_t state,
  24. struct opal_msg *msg);
  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_chip *chip, unsigned int hw_irq);
  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. /* Support for the cxl kernel api on the real PHB (instead of vPHB) */
  40. int pnv_cxl_enable_phb_kernel_api(struct pci_controller *hose, bool enable);
  41. bool pnv_pci_on_cxl_phb(struct pci_dev *dev);
  42. struct cxl_afu *pnv_cxl_phb_to_afu(struct pci_controller *hose);
  43. void pnv_cxl_phb_set_peer_afu(struct pci_dev *dev, struct cxl_afu *afu);
  44. #endif
  45. struct pnv_php_slot {
  46. struct hotplug_slot slot;
  47. struct hotplug_slot_info slot_info;
  48. uint64_t id;
  49. char *name;
  50. int slot_no;
  51. struct kref kref;
  52. #define PNV_PHP_STATE_INITIALIZED 0
  53. #define PNV_PHP_STATE_REGISTERED 1
  54. #define PNV_PHP_STATE_POPULATED 2
  55. #define PNV_PHP_STATE_OFFLINE 3
  56. int state;
  57. int irq;
  58. struct workqueue_struct *wq;
  59. struct device_node *dn;
  60. struct pci_dev *pdev;
  61. struct pci_bus *bus;
  62. bool power_state_check;
  63. void *fdt;
  64. void *dt;
  65. struct of_changeset ocs;
  66. struct pnv_php_slot *parent;
  67. struct list_head children;
  68. struct list_head link;
  69. };
  70. extern struct pnv_php_slot *pnv_php_find_slot(struct device_node *dn);
  71. extern int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
  72. uint8_t state);
  73. #endif