pci.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #ifndef __ASM_PARISC_PCI_H
  2. #define __ASM_PARISC_PCI_H
  3. #include <linux/scatterlist.h>
  4. /*
  5. ** HP PCI platforms generally support multiple bus adapters.
  6. ** (workstations 1-~4, servers 2-~32)
  7. **
  8. ** Newer platforms number the busses across PCI bus adapters *sparsely*.
  9. ** E.g. 0, 8, 16, ...
  10. **
  11. ** Under a PCI bus, most HP platforms support PPBs up to two or three
  12. ** levels deep. See "Bit3" product line.
  13. */
  14. #define PCI_MAX_BUSSES 256
  15. /* To be used as: mdelay(pci_post_reset_delay);
  16. *
  17. * post_reset is the time the kernel should stall to prevent anyone from
  18. * accessing the PCI bus once #RESET is de-asserted.
  19. * PCI spec somewhere says 1 second but with multi-PCI bus systems,
  20. * this makes the boot time much longer than necessary.
  21. * 20ms seems to work for all the HP PCI implementations to date.
  22. */
  23. #define pci_post_reset_delay 50
  24. /*
  25. ** pci_hba_data (aka H2P_OBJECT in HP/UX)
  26. **
  27. ** This is the "common" or "base" data structure which HBA drivers
  28. ** (eg Dino or LBA) are required to place at the top of their own
  29. ** platform_data structure. I've heard this called "C inheritance" too.
  30. **
  31. ** Data needed by pcibios layer belongs here.
  32. */
  33. struct pci_hba_data {
  34. void __iomem *base_addr; /* aka Host Physical Address */
  35. const struct parisc_device *dev; /* device from PA bus walk */
  36. struct pci_bus *hba_bus; /* primary PCI bus below HBA */
  37. int hba_num; /* I/O port space access "key" */
  38. struct resource bus_num; /* PCI bus numbers */
  39. struct resource io_space; /* PIOP */
  40. struct resource lmmio_space; /* bus addresses < 4Gb */
  41. struct resource elmmio_space; /* additional bus addresses < 4Gb */
  42. struct resource gmmio_space; /* bus addresses > 4Gb */
  43. /* NOTE: Dino code assumes it can use *all* of the lmmio_space,
  44. * elmmio_space and gmmio_space as a contiguous array of
  45. * resources. This #define represents the array size */
  46. #define DINO_MAX_LMMIO_RESOURCES 3
  47. unsigned long lmmio_space_offset; /* CPU view - PCI view */
  48. void * iommu; /* IOMMU this device is under */
  49. /* REVISIT - spinlock to protect resources? */
  50. #define HBA_NAME_SIZE 16
  51. char io_name[HBA_NAME_SIZE];
  52. char lmmio_name[HBA_NAME_SIZE];
  53. char elmmio_name[HBA_NAME_SIZE];
  54. char gmmio_name[HBA_NAME_SIZE];
  55. };
  56. #define HBA_DATA(d) ((struct pci_hba_data *) (d))
  57. /*
  58. ** We support 2^16 I/O ports per HBA. These are set up in the form
  59. ** 0xbbxxxx, where bb is the bus number and xxxx is the I/O port
  60. ** space address.
  61. */
  62. #define HBA_PORT_SPACE_BITS 16
  63. #define HBA_PORT_BASE(h) ((h) << HBA_PORT_SPACE_BITS)
  64. #define HBA_PORT_SPACE_SIZE (1UL << HBA_PORT_SPACE_BITS)
  65. #define PCI_PORT_HBA(a) ((a) >> HBA_PORT_SPACE_BITS)
  66. #define PCI_PORT_ADDR(a) ((a) & (HBA_PORT_SPACE_SIZE - 1))
  67. #ifdef CONFIG_64BIT
  68. #define PCI_F_EXTEND 0xffffffff00000000UL
  69. #else /* !CONFIG_64BIT */
  70. #define PCI_F_EXTEND 0UL
  71. #endif /* !CONFIG_64BIT */
  72. /*
  73. ** KLUGE: linux/pci.h include asm/pci.h BEFORE declaring struct pci_bus
  74. ** (This eliminates some of the warnings).
  75. */
  76. struct pci_bus;
  77. struct pci_dev;
  78. /*
  79. * If the PCI device's view of memory is the same as the CPU's view of memory,
  80. * PCI_DMA_BUS_IS_PHYS is true. The networking and block device layers use
  81. * this boolean for bounce buffer decisions.
  82. */
  83. #ifdef CONFIG_PA20
  84. /* All PA-2.0 machines have an IOMMU. */
  85. #define PCI_DMA_BUS_IS_PHYS 0
  86. #define parisc_has_iommu() do { } while (0)
  87. #else
  88. #if defined(CONFIG_IOMMU_CCIO) || defined(CONFIG_IOMMU_SBA)
  89. extern int parisc_bus_is_phys; /* in arch/parisc/kernel/setup.c */
  90. #define PCI_DMA_BUS_IS_PHYS parisc_bus_is_phys
  91. #define parisc_has_iommu() do { parisc_bus_is_phys = 0; } while (0)
  92. #else
  93. #define PCI_DMA_BUS_IS_PHYS 1
  94. #define parisc_has_iommu() do { } while (0)
  95. #endif
  96. #endif /* !CONFIG_PA20 */
  97. /*
  98. ** Most PCI devices (eg Tulip, NCR720) also export the same registers
  99. ** to both MMIO and I/O port space. Due to poor performance of I/O Port
  100. ** access under HP PCI bus adapters, strongly recommend the use of MMIO
  101. ** address space.
  102. **
  103. ** While I'm at it more PA programming notes:
  104. **
  105. ** 1) MMIO stores (writes) are posted operations. This means the processor
  106. ** gets an "ACK" before the write actually gets to the device. A read
  107. ** to the same device (or typically the bus adapter above it) will
  108. ** force in-flight write transaction(s) out to the targeted device
  109. ** before the read can complete.
  110. **
  111. ** 2) The Programmed I/O (PIO) data may not always be strongly ordered with
  112. ** respect to DMA on all platforms. Ie PIO data can reach the processor
  113. ** before in-flight DMA reaches memory. Since most SMP PA platforms
  114. ** are I/O coherent, it generally doesn't matter...but sometimes
  115. ** it does.
  116. **
  117. ** I've helped device driver writers debug both types of problems.
  118. */
  119. struct pci_port_ops {
  120. u8 (*inb) (struct pci_hba_data *hba, u16 port);
  121. u16 (*inw) (struct pci_hba_data *hba, u16 port);
  122. u32 (*inl) (struct pci_hba_data *hba, u16 port);
  123. void (*outb) (struct pci_hba_data *hba, u16 port, u8 data);
  124. void (*outw) (struct pci_hba_data *hba, u16 port, u16 data);
  125. void (*outl) (struct pci_hba_data *hba, u16 port, u32 data);
  126. };
  127. struct pci_bios_ops {
  128. void (*init)(void);
  129. void (*fixup_bus)(struct pci_bus *bus);
  130. };
  131. /*
  132. ** Stuff declared in arch/parisc/kernel/pci.c
  133. */
  134. extern struct pci_port_ops *pci_port;
  135. extern struct pci_bios_ops *pci_bios;
  136. #ifdef CONFIG_PCI
  137. extern void pcibios_register_hba(struct pci_hba_data *);
  138. extern void pcibios_set_master(struct pci_dev *);
  139. #else
  140. static inline void pcibios_register_hba(struct pci_hba_data *x)
  141. {
  142. }
  143. #endif
  144. extern void pcibios_init_bridge(struct pci_dev *);
  145. /*
  146. * pcibios_assign_all_busses() is used in drivers/pci/pci.c:pci_do_scan_bus()
  147. * 0 == check if bridge is numbered before re-numbering.
  148. * 1 == pci_do_scan_bus() should automatically number all PCI-PCI bridges.
  149. *
  150. * We *should* set this to zero for "legacy" platforms and one
  151. * for PAT platforms.
  152. *
  153. * But legacy platforms also need to renumber the busses below a Host
  154. * Bus controller. Adding a 4-port Tulip card on the first PCI root
  155. * bus of a C200 resulted in the secondary bus being numbered as 1.
  156. * The second PCI host bus controller's root bus had already been
  157. * assigned bus number 1 by firmware and sysfs complained.
  158. *
  159. * Firmware isn't doing anything wrong here since each controller
  160. * is its own PCI domain. It's simpler and easier for us to renumber
  161. * the busses rather than treat each Dino as a separate PCI domain.
  162. * Eventually, we may want to introduce PCI domains for Superdome or
  163. * rp7420/8420 boxes and then revisit this issue.
  164. */
  165. #define pcibios_assign_all_busses() (1)
  166. #define PCIBIOS_MIN_IO 0x10
  167. #define PCIBIOS_MIN_MEM 0x1000 /* NBPG - but pci/setup-res.c dies */
  168. static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
  169. {
  170. return channel ? 15 : 14;
  171. }
  172. #define HAVE_PCI_MMAP
  173. extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  174. enum pci_mmap_state mmap_state, int write_combine);
  175. #endif /* __ASM_PARISC_PCI_H */