pci-bridge.h 3.7 KB

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