pci-bridge.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _ASM_MICROBLAZE_PCI_BRIDGE_H
  3. #define _ASM_MICROBLAZE_PCI_BRIDGE_H
  4. #ifdef __KERNEL__
  5. /*
  6. */
  7. #include <linux/pci.h>
  8. #include <linux/list.h>
  9. #include <linux/ioport.h>
  10. struct device_node;
  11. #ifdef CONFIG_PCI
  12. extern struct list_head hose_list;
  13. extern int pcibios_vaddr_is_ioport(void __iomem *address);
  14. #else
  15. static inline int pcibios_vaddr_is_ioport(void __iomem *address)
  16. {
  17. return 0;
  18. }
  19. #endif
  20. /*
  21. * Structure of a PCI controller (host bridge)
  22. */
  23. struct pci_controller {
  24. struct pci_bus *bus;
  25. char is_dynamic;
  26. struct device_node *dn;
  27. struct list_head list_node;
  28. struct device *parent;
  29. int first_busno;
  30. int last_busno;
  31. int self_busno;
  32. void __iomem *io_base_virt;
  33. resource_size_t io_base_phys;
  34. resource_size_t pci_io_size;
  35. /* Some machines (PReP) have a non 1:1 mapping of
  36. * the PCI memory space in the CPU bus space
  37. */
  38. resource_size_t pci_mem_offset;
  39. /* Some machines have a special region to forward the ISA
  40. * "memory" cycles such as VGA memory regions. Left to 0
  41. * if unsupported
  42. */
  43. resource_size_t isa_mem_phys;
  44. resource_size_t isa_mem_size;
  45. struct pci_ops *ops;
  46. unsigned int __iomem *cfg_addr;
  47. void __iomem *cfg_data;
  48. /*
  49. * Used for variants of PCI indirect handling and possible quirks:
  50. * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1
  51. * EXT_REG - provides access to PCI-e extended registers
  52. * SURPRESS_PRIMARY_BUS - we suppress the setting of PCI_PRIMARY_BUS
  53. * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS
  54. * to determine which bus number to match on when generating type0
  55. * config cycles
  56. * NO_PCIE_LINK - the Freescale PCI-e controllers have issues with
  57. * hanging if we don't have link and try to do config cycles to
  58. * anything but the PHB. Only allow talking to the PHB if this is
  59. * set.
  60. * BIG_ENDIAN - cfg_addr is a big endian register
  61. * BROKEN_MRM - the 440EPx/GRx chips have an errata that causes hangs
  62. * on the PLB4. Effectively disable MRM commands by setting this.
  63. */
  64. #define INDIRECT_TYPE_SET_CFG_TYPE 0x00000001
  65. #define INDIRECT_TYPE_EXT_REG 0x00000002
  66. #define INDIRECT_TYPE_SURPRESS_PRIMARY_BUS 0x00000004
  67. #define INDIRECT_TYPE_NO_PCIE_LINK 0x00000008
  68. #define INDIRECT_TYPE_BIG_ENDIAN 0x00000010
  69. #define INDIRECT_TYPE_BROKEN_MRM 0x00000020
  70. u32 indirect_type;
  71. /* Currently, we limit ourselves to 1 IO range and 3 mem
  72. * ranges since the common pci_bus structure can't handle more
  73. */
  74. struct resource io_resource;
  75. struct resource mem_resources[3];
  76. int global_number; /* PCI domain number */
  77. };
  78. #ifdef CONFIG_PCI
  79. static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
  80. {
  81. return bus->sysdata;
  82. }
  83. static inline int isa_vaddr_is_ioport(void __iomem *address)
  84. {
  85. /* No specific ISA handling on ppc32 at this stage, it
  86. * all goes through PCI
  87. */
  88. return 0;
  89. }
  90. #endif /* CONFIG_PCI */
  91. /* These are used for config access before all the PCI probing
  92. has been done. */
  93. extern int early_read_config_byte(struct pci_controller *hose, int bus,
  94. int dev_fn, int where, u8 *val);
  95. extern int early_read_config_word(struct pci_controller *hose, int bus,
  96. int dev_fn, int where, u16 *val);
  97. extern int early_read_config_dword(struct pci_controller *hose, int bus,
  98. int dev_fn, int where, u32 *val);
  99. extern int early_write_config_byte(struct pci_controller *hose, int bus,
  100. int dev_fn, int where, u8 val);
  101. extern int early_write_config_word(struct pci_controller *hose, int bus,
  102. int dev_fn, int where, u16 val);
  103. extern int early_write_config_dword(struct pci_controller *hose, int bus,
  104. int dev_fn, int where, u32 val);
  105. extern int early_find_capability(struct pci_controller *hose, int bus,
  106. int dev_fn, int cap);
  107. extern void setup_indirect_pci(struct pci_controller *hose,
  108. resource_size_t cfg_addr,
  109. resource_size_t cfg_data, u32 flags);
  110. /* Get the PCI host controller for an OF device */
  111. extern struct pci_controller *pci_find_hose_for_OF_device(
  112. struct device_node *node);
  113. /* Fill up host controller resources from the OF node */
  114. extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
  115. struct device_node *dev, int primary);
  116. /* Allocate & free a PCI host bridge structure */
  117. extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
  118. extern void pcibios_free_controller(struct pci_controller *phb);
  119. #endif /* __KERNEL__ */
  120. #endif /* _ASM_MICROBLAZE_PCI_BRIDGE_H */