pci.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef _ASM_IA64_PCI_H
  2. #define _ASM_IA64_PCI_H
  3. #include <linux/mm.h>
  4. #include <linux/slab.h>
  5. #include <linux/spinlock.h>
  6. #include <linux/string.h>
  7. #include <linux/types.h>
  8. #include <asm/io.h>
  9. #include <asm/scatterlist.h>
  10. #include <asm/hw_irq.h>
  11. /*
  12. * Can be used to override the logic in pci_scan_bus for skipping already-configured bus
  13. * numbers - to be used for buggy BIOSes or architectures with incomplete PCI setup by the
  14. * loader.
  15. */
  16. #define pcibios_assign_all_busses() 0
  17. #define pcibios_scan_all_fns(a, b) 0
  18. #define PCIBIOS_MIN_IO 0x1000
  19. #define PCIBIOS_MIN_MEM 0x10000000
  20. void pcibios_config_init(void);
  21. struct pci_dev;
  22. /*
  23. * PCI_DMA_BUS_IS_PHYS should be set to 1 if there is _necessarily_ a direct
  24. * correspondence between device bus addresses and CPU physical addresses.
  25. * Platforms with a hardware I/O MMU _must_ turn this off to suppress the
  26. * bounce buffer handling code in the block and network device layers.
  27. * Platforms with separate bus address spaces _must_ turn this off and provide
  28. * a device DMA mapping implementation that takes care of the necessary
  29. * address translation.
  30. *
  31. * For now, the ia64 platforms which may have separate/multiple bus address
  32. * spaces all have I/O MMUs which support the merging of physically
  33. * discontiguous buffers, so we can use that as the sole factor to determine
  34. * the setting of PCI_DMA_BUS_IS_PHYS.
  35. */
  36. extern unsigned long ia64_max_iommu_merge_mask;
  37. #define PCI_DMA_BUS_IS_PHYS (ia64_max_iommu_merge_mask == ~0UL)
  38. static inline void
  39. pcibios_set_master (struct pci_dev *dev)
  40. {
  41. /* No special bus mastering setup handling */
  42. }
  43. static inline void
  44. pcibios_penalize_isa_irq (int irq, int active)
  45. {
  46. /* We don't do dynamic PCI IRQ allocation */
  47. }
  48. #include <asm-generic/pci-dma-compat.h>
  49. /* pci_unmap_{single,page} is not a nop, thus... */
  50. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
  51. dma_addr_t ADDR_NAME;
  52. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
  53. __u32 LEN_NAME;
  54. #define pci_unmap_addr(PTR, ADDR_NAME) \
  55. ((PTR)->ADDR_NAME)
  56. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  57. (((PTR)->ADDR_NAME) = (VAL))
  58. #define pci_unmap_len(PTR, LEN_NAME) \
  59. ((PTR)->LEN_NAME)
  60. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  61. (((PTR)->LEN_NAME) = (VAL))
  62. #ifdef CONFIG_PCI
  63. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  64. enum pci_dma_burst_strategy *strat,
  65. unsigned long *strategy_parameter)
  66. {
  67. unsigned long cacheline_size;
  68. u8 byte;
  69. pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte);
  70. if (byte == 0)
  71. cacheline_size = 1024;
  72. else
  73. cacheline_size = (int) byte * 4;
  74. *strat = PCI_DMA_BURST_MULTIPLE;
  75. *strategy_parameter = cacheline_size;
  76. }
  77. #endif
  78. #define HAVE_PCI_MMAP
  79. extern int pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
  80. enum pci_mmap_state mmap_state, int write_combine);
  81. #define HAVE_PCI_LEGACY
  82. extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
  83. struct vm_area_struct *vma);
  84. extern ssize_t pci_read_legacy_io(struct kobject *kobj,
  85. struct bin_attribute *bin_attr,
  86. char *buf, loff_t off, size_t count);
  87. extern ssize_t pci_write_legacy_io(struct kobject *kobj,
  88. struct bin_attribute *bin_attr,
  89. char *buf, loff_t off, size_t count);
  90. extern int pci_mmap_legacy_mem(struct kobject *kobj,
  91. struct bin_attribute *attr,
  92. struct vm_area_struct *vma);
  93. #define pci_get_legacy_mem platform_pci_get_legacy_mem
  94. #define pci_legacy_read platform_pci_legacy_read
  95. #define pci_legacy_write platform_pci_legacy_write
  96. struct pci_window {
  97. struct resource resource;
  98. u64 offset;
  99. };
  100. struct pci_controller {
  101. void *acpi_handle;
  102. void *iommu;
  103. int segment;
  104. int node; /* nearest node with memory or -1 for global allocation */
  105. unsigned int windows;
  106. struct pci_window *window;
  107. void *platform_data;
  108. };
  109. #define PCI_CONTROLLER(busdev) ((struct pci_controller *) busdev->sysdata)
  110. #define pci_domain_nr(busdev) (PCI_CONTROLLER(busdev)->segment)
  111. extern struct pci_ops pci_root_ops;
  112. static inline int pci_proc_domain(struct pci_bus *bus)
  113. {
  114. return (pci_domain_nr(bus) != 0);
  115. }
  116. extern void pcibios_resource_to_bus(struct pci_dev *dev,
  117. struct pci_bus_region *region, struct resource *res);
  118. extern void pcibios_bus_to_resource(struct pci_dev *dev,
  119. struct resource *res, struct pci_bus_region *region);
  120. static inline struct resource *
  121. pcibios_select_root(struct pci_dev *pdev, struct resource *res)
  122. {
  123. struct resource *root = NULL;
  124. if (res->flags & IORESOURCE_IO)
  125. root = &ioport_resource;
  126. if (res->flags & IORESOURCE_MEM)
  127. root = &iomem_resource;
  128. return root;
  129. }
  130. #define pcibios_scan_all_fns(a, b) 0
  131. #define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
  132. static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
  133. {
  134. return channel ? isa_irq_to_vector(15) : isa_irq_to_vector(14);
  135. }
  136. #endif /* _ASM_IA64_PCI_H */