pci-bridge.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_PCI_BRIDGE_H
  15. #define _ASM_TILE_PCI_BRIDGE_H
  16. #include <linux/ioport.h>
  17. #include <linux/pci.h>
  18. struct device_node;
  19. struct pci_controller;
  20. /*
  21. * pci_io_base returns the memory address at which you can access
  22. * the I/O space for PCI bus number `bus' (or NULL on error).
  23. */
  24. extern void __iomem *pci_bus_io_base(unsigned int bus);
  25. extern unsigned long pci_bus_io_base_phys(unsigned int bus);
  26. extern unsigned long pci_bus_mem_base_phys(unsigned int bus);
  27. /* Allocate a new PCI host bridge structure */
  28. extern struct pci_controller *pcibios_alloc_controller(void);
  29. /* Helper function for setting up resources */
  30. extern void pci_init_resource(struct resource *res, unsigned long start,
  31. unsigned long end, int flags, char *name);
  32. /* Get the PCI host controller for a bus */
  33. extern struct pci_controller *pci_bus_to_hose(int bus);
  34. /*
  35. * Structure of a PCI controller (host bridge)
  36. */
  37. struct pci_controller {
  38. int index; /* PCI domain number */
  39. struct pci_bus *root_bus;
  40. int first_busno;
  41. int last_busno;
  42. int hv_cfg_fd[2]; /* config{0,1} fds for this PCIe controller */
  43. int hv_mem_fd; /* fd to Hypervisor for MMIO operations */
  44. struct pci_ops *ops;
  45. int irq_base; /* Base IRQ from the Hypervisor */
  46. int plx_gen1; /* flag for PLX Gen 1 configuration */
  47. /* Address ranges that are routed to this controller/bridge. */
  48. struct resource mem_resources[3];
  49. };
  50. static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
  51. {
  52. return bus->sysdata;
  53. }
  54. extern void setup_indirect_pci_nomap(struct pci_controller *hose,
  55. void __iomem *cfg_addr, void __iomem *cfg_data);
  56. extern void setup_indirect_pci(struct pci_controller *hose,
  57. u32 cfg_addr, u32 cfg_data);
  58. extern void setup_grackle(struct pci_controller *hose);
  59. extern unsigned char common_swizzle(struct pci_dev *, unsigned char *);
  60. /*
  61. * The following code swizzles for exactly one bridge. The routine
  62. * common_swizzle below handles multiple bridges. But there are a
  63. * some boards that don't follow the PCI spec's suggestion so we
  64. * break this piece out separately.
  65. */
  66. static inline unsigned char bridge_swizzle(unsigned char pin,
  67. unsigned char idsel)
  68. {
  69. return (((pin-1) + idsel) % 4) + 1;
  70. }
  71. /*
  72. * The following macro is used to lookup irqs in a standard table
  73. * format for those PPC systems that do not already have PCI
  74. * interrupts properly routed.
  75. */
  76. /* FIXME - double check this */
  77. #define PCI_IRQ_TABLE_LOOKUP ({ \
  78. long _ctl_ = -1; \
  79. if (idsel >= min_idsel && idsel <= max_idsel && pin <= irqs_per_slot) \
  80. _ctl_ = pci_irq_table[idsel - min_idsel][pin-1]; \
  81. _ctl_; \
  82. })
  83. /*
  84. * Scan the buses below a given PCI host bridge and assign suitable
  85. * resources to all devices found.
  86. */
  87. extern int pciauto_bus_scan(struct pci_controller *, int);
  88. #ifdef CONFIG_PCI
  89. extern unsigned long pci_address_to_pio(phys_addr_t address);
  90. #else
  91. static inline unsigned long pci_address_to_pio(phys_addr_t address)
  92. {
  93. return (unsigned long)-1;
  94. }
  95. #endif
  96. #endif /* _ASM_TILE_PCI_BRIDGE_H */