pci-bridge.h 4.3 KB

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