pci-bridge.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #ifndef _ASM_POWERPC_PCI_BRIDGE_H
  2. #define _ASM_POWERPC_PCI_BRIDGE_H
  3. #ifdef __KERNEL__
  4. #ifndef CONFIG_PPC64
  5. #include <asm-ppc/pci-bridge.h>
  6. #else
  7. #include <linux/pci.h>
  8. #include <linux/list.h>
  9. /*
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. /*
  16. * Structure of a PCI controller (host bridge)
  17. */
  18. struct pci_controller {
  19. struct pci_bus *bus;
  20. char is_dynamic;
  21. void *arch_data;
  22. struct list_head list_node;
  23. int first_busno;
  24. int last_busno;
  25. void __iomem *io_base_virt;
  26. unsigned long io_base_phys;
  27. /* Some machines have a non 1:1 mapping of
  28. * the PCI memory space in the CPU bus space
  29. */
  30. unsigned long pci_mem_offset;
  31. unsigned long pci_io_size;
  32. struct pci_ops *ops;
  33. volatile unsigned int __iomem *cfg_addr;
  34. volatile void __iomem *cfg_data;
  35. /* Currently, we limit ourselves to 1 IO range and 3 mem
  36. * ranges since the common pci_bus structure can't handle more
  37. */
  38. struct resource io_resource;
  39. struct resource mem_resources[3];
  40. int global_number;
  41. int local_number;
  42. unsigned long buid;
  43. unsigned long dma_window_base_cur;
  44. unsigned long dma_window_size;
  45. };
  46. /*
  47. * PCI stuff, for nodes representing PCI devices, pointed to
  48. * by device_node->data.
  49. */
  50. struct pci_controller;
  51. struct iommu_table;
  52. struct pci_dn {
  53. int busno; /* pci bus number */
  54. int bussubno; /* pci subordinate bus number */
  55. int devfn; /* pci device and function number */
  56. int class_code; /* pci device class */
  57. #ifdef CONFIG_PPC_PSERIES
  58. int eeh_mode; /* See eeh.h for possible EEH_MODEs */
  59. int eeh_config_addr;
  60. int eeh_pe_config_addr; /* new-style partition endpoint address */
  61. int eeh_check_count; /* # times driver ignored error */
  62. int eeh_freeze_count; /* # times this device froze up. */
  63. #endif
  64. int pci_ext_config_space; /* for pci devices */
  65. struct pci_controller *phb; /* for pci devices */
  66. struct iommu_table *iommu_table; /* for phb's or bridges */
  67. struct pci_dev *pcidev; /* back-pointer to the pci device */
  68. struct device_node *node; /* back-pointer to the device_node */
  69. #ifdef CONFIG_PPC_ISERIES
  70. struct list_head Device_List;
  71. int Irq; /* Assigned IRQ */
  72. int Flags; /* Possible flags(disable/bist)*/
  73. u8 LogicalSlot; /* Hv Slot Index for Tces */
  74. #endif
  75. u32 config_space[16]; /* saved PCI config space */
  76. };
  77. /* Get the pointer to a device_node's pci_dn */
  78. #define PCI_DN(dn) ((struct pci_dn *) (dn)->data)
  79. struct device_node *fetch_dev_dn(struct pci_dev *dev);
  80. /* Get a device_node from a pci_dev. This code must be fast except
  81. * in the case where the sysdata is incorrect and needs to be fixed
  82. * up (this will only happen once).
  83. * In this case the sysdata will have been inherited from a PCI host
  84. * bridge or a PCI-PCI bridge further up the tree, so it will point
  85. * to a valid struct pci_dn, just not the one we want.
  86. */
  87. static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
  88. {
  89. struct device_node *dn = dev->sysdata;
  90. struct pci_dn *pdn = dn->data;
  91. if (pdn && pdn->devfn == dev->devfn && pdn->busno == dev->bus->number)
  92. return dn; /* fast path. sysdata is good */
  93. return fetch_dev_dn(dev);
  94. }
  95. static inline int pci_device_from_OF_node(struct device_node *np,
  96. u8 *bus, u8 *devfn)
  97. {
  98. if (!PCI_DN(np))
  99. return -ENODEV;
  100. *bus = PCI_DN(np)->busno;
  101. *devfn = PCI_DN(np)->devfn;
  102. return 0;
  103. }
  104. static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
  105. {
  106. if (bus->self)
  107. return pci_device_to_OF_node(bus->self);
  108. else
  109. return bus->sysdata; /* Must be root bus (PHB) */
  110. }
  111. /** Find the bus corresponding to the indicated device node */
  112. struct pci_bus * pcibios_find_pci_bus(struct device_node *dn);
  113. extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
  114. struct device_node *dev, int primary);
  115. /** Remove all of the PCI devices under this bus */
  116. void pcibios_remove_pci_devices(struct pci_bus *bus);
  117. /** Discover new pci devices under this bus, and add them */
  118. void pcibios_add_pci_devices(struct pci_bus * bus);
  119. void pcibios_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus);
  120. extern int pcibios_remove_root_bus(struct pci_controller *phb);
  121. static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
  122. {
  123. struct device_node *busdn = bus->sysdata;
  124. BUG_ON(busdn == NULL);
  125. return PCI_DN(busdn)->phb;
  126. }
  127. extern struct pci_controller*
  128. pci_find_hose_for_OF_device(struct device_node* node);
  129. extern struct pci_controller *
  130. pcibios_alloc_controller(struct device_node *dev);
  131. extern void pcibios_free_controller(struct pci_controller *phb);
  132. #ifdef CONFIG_PCI
  133. extern unsigned long pci_address_to_pio(phys_addr_t address);
  134. #else
  135. static inline unsigned long pci_address_to_pio(phys_addr_t address)
  136. {
  137. return (unsigned long)-1;
  138. }
  139. #endif
  140. /* Return values for ppc_md.pci_probe_mode function */
  141. #define PCI_PROBE_NONE -1 /* Don't look at this bus at all */
  142. #define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */
  143. #define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */
  144. #endif /* CONFIG_PPC64 */
  145. #endif /* __KERNEL__ */
  146. #endif