pci.h 5.7 KB

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