of_pci.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef __OF_PCI_H
  2. #define __OF_PCI_H
  3. #include <linux/pci.h>
  4. #include <linux/msi.h>
  5. struct pci_dev;
  6. struct of_phandle_args;
  7. struct device_node;
  8. #ifdef CONFIG_OF_PCI
  9. int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq);
  10. struct device_node *of_pci_find_child_device(struct device_node *parent,
  11. unsigned int devfn);
  12. int of_pci_get_devfn(struct device_node *np);
  13. int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin);
  14. int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
  15. int of_get_pci_domain_nr(struct device_node *node);
  16. int of_pci_get_max_link_speed(struct device_node *node);
  17. void of_pci_check_probe_only(void);
  18. int of_pci_map_rid(struct device_node *np, u32 rid,
  19. const char *map_name, const char *map_mask_name,
  20. struct device_node **target, u32 *id_out);
  21. #else
  22. static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
  23. {
  24. return 0;
  25. }
  26. static inline struct device_node *of_pci_find_child_device(struct device_node *parent,
  27. unsigned int devfn)
  28. {
  29. return NULL;
  30. }
  31. static inline int of_pci_get_devfn(struct device_node *np)
  32. {
  33. return -EINVAL;
  34. }
  35. static inline int
  36. of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
  37. {
  38. return 0;
  39. }
  40. static inline int
  41. of_pci_parse_bus_range(struct device_node *node, struct resource *res)
  42. {
  43. return -EINVAL;
  44. }
  45. static inline int
  46. of_get_pci_domain_nr(struct device_node *node)
  47. {
  48. return -1;
  49. }
  50. static inline int of_pci_map_rid(struct device_node *np, u32 rid,
  51. const char *map_name, const char *map_mask_name,
  52. struct device_node **target, u32 *id_out)
  53. {
  54. return -EINVAL;
  55. }
  56. static inline int
  57. of_pci_get_max_link_speed(struct device_node *node)
  58. {
  59. return -EINVAL;
  60. }
  61. static inline void of_pci_check_probe_only(void) { }
  62. #endif
  63. #if defined(CONFIG_OF_ADDRESS)
  64. int of_pci_get_host_bridge_resources(struct device_node *dev,
  65. unsigned char busno, unsigned char bus_max,
  66. struct list_head *resources, resource_size_t *io_base);
  67. #else
  68. static inline int of_pci_get_host_bridge_resources(struct device_node *dev,
  69. unsigned char busno, unsigned char bus_max,
  70. struct list_head *resources, resource_size_t *io_base)
  71. {
  72. return -EINVAL;
  73. }
  74. #endif
  75. #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI)
  76. int of_pci_msi_chip_add(struct msi_controller *chip);
  77. void of_pci_msi_chip_remove(struct msi_controller *chip);
  78. struct msi_controller *of_pci_find_msi_chip_by_node(struct device_node *of_node);
  79. #else
  80. static inline int of_pci_msi_chip_add(struct msi_controller *chip) { return -EINVAL; }
  81. static inline void of_pci_msi_chip_remove(struct msi_controller *chip) { }
  82. static inline struct msi_controller *
  83. of_pci_find_msi_chip_by_node(struct device_node *of_node) { return NULL; }
  84. #endif
  85. #endif