pci.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. void * 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. #define HBA_DATA(d) ((struct pci_hba_data *) (d))
  58. /*
  59. ** We support 2^16 I/O ports per HBA. These are set up in the form
  60. ** 0xbbxxxx, where bb is the bus number and xxxx is the I/O port
  61. ** space address.
  62. */
  63. #define HBA_PORT_SPACE_BITS 16
  64. #define HBA_PORT_BASE(h) ((h) << HBA_PORT_SPACE_BITS)
  65. #define HBA_PORT_SPACE_SIZE (1UL << HBA_PORT_SPACE_BITS)
  66. #define PCI_PORT_HBA(a) ((a) >> HBA_PORT_SPACE_BITS)
  67. #define PCI_PORT_ADDR(a) ((a) & (HBA_PORT_SPACE_SIZE - 1))
  68. #ifdef CONFIG_64BIT
  69. #define PCI_F_EXTEND 0xffffffff00000000UL
  70. #else /* !CONFIG_64BIT */
  71. #define PCI_F_EXTEND 0UL
  72. #endif /* !CONFIG_64BIT */
  73. /*
  74. ** Most PCI devices (eg Tulip, NCR720) also export the same registers
  75. ** to both MMIO and I/O port space. Due to poor performance of I/O Port
  76. ** access under HP PCI bus adapters, strongly recommend the use of MMIO
  77. ** address space.
  78. **
  79. ** While I'm at it more PA programming notes:
  80. **
  81. ** 1) MMIO stores (writes) are posted operations. This means the processor
  82. ** gets an "ACK" before the write actually gets to the device. A read
  83. ** to the same device (or typically the bus adapter above it) will
  84. ** force in-flight write transaction(s) out to the targeted device
  85. ** before the read can complete.
  86. **
  87. ** 2) The Programmed I/O (PIO) data may not always be strongly ordered with
  88. ** respect to DMA on all platforms. Ie PIO data can reach the processor
  89. ** before in-flight DMA reaches memory. Since most SMP PA platforms
  90. ** are I/O coherent, it generally doesn't matter...but sometimes
  91. ** it does.
  92. **
  93. ** I've helped device driver writers debug both types of problems.
  94. */
  95. struct pci_port_ops {
  96. u8 (*inb) (struct pci_hba_data *hba, u16 port);
  97. u16 (*inw) (struct pci_hba_data *hba, u16 port);
  98. u32 (*inl) (struct pci_hba_data *hba, u16 port);
  99. void (*outb) (struct pci_hba_data *hba, u16 port, u8 data);
  100. void (*outw) (struct pci_hba_data *hba, u16 port, u16 data);
  101. void (*outl) (struct pci_hba_data *hba, u16 port, u32 data);
  102. };
  103. struct pci_bios_ops {
  104. void (*init)(void);
  105. void (*fixup_bus)(struct pci_bus *bus);
  106. };
  107. /*
  108. ** Stuff declared in arch/parisc/kernel/pci.c
  109. */
  110. extern struct pci_port_ops *pci_port;
  111. extern struct pci_bios_ops *pci_bios;
  112. #ifdef CONFIG_PCI
  113. extern void pcibios_register_hba(struct pci_hba_data *);
  114. #else
  115. static inline void pcibios_register_hba(struct pci_hba_data *x)
  116. {
  117. }
  118. #endif
  119. extern void pcibios_init_bridge(struct pci_dev *);
  120. /*
  121. * pcibios_assign_all_busses() is used in drivers/pci/pci.c:pci_do_scan_bus()
  122. * 0 == check if bridge is numbered before re-numbering.
  123. * 1 == pci_do_scan_bus() should automatically number all PCI-PCI bridges.
  124. *
  125. * We *should* set this to zero for "legacy" platforms and one
  126. * for PAT platforms.
  127. *
  128. * But legacy platforms also need to renumber the busses below a Host
  129. * Bus controller. Adding a 4-port Tulip card on the first PCI root
  130. * bus of a C200 resulted in the secondary bus being numbered as 1.
  131. * The second PCI host bus controller's root bus had already been
  132. * assigned bus number 1 by firmware and sysfs complained.
  133. *
  134. * Firmware isn't doing anything wrong here since each controller
  135. * is its own PCI domain. It's simpler and easier for us to renumber
  136. * the busses rather than treat each Dino as a separate PCI domain.
  137. * Eventually, we may want to introduce PCI domains for Superdome or
  138. * rp7420/8420 boxes and then revisit this issue.
  139. */
  140. #define pcibios_assign_all_busses() (1)
  141. #define PCIBIOS_MIN_IO 0x10
  142. #define PCIBIOS_MIN_MEM 0x1000 /* NBPG - but pci/setup-res.c dies */
  143. static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
  144. {
  145. return channel ? 15 : 14;
  146. }
  147. #define HAVE_PCI_MMAP
  148. #define ARCH_GENERIC_PCI_MMAP_RESOURCE
  149. #endif /* __ASM_PARISC_PCI_H */