pci.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #ifndef __ASM_SH_PCI_H
  2. #define __ASM_SH_PCI_H
  3. #ifdef __KERNEL__
  4. #include <linux/dma-mapping.h>
  5. /* Can be used to override the logic in pci_scan_bus for skipping
  6. already-configured bus numbers - to be used for buggy BIOSes
  7. or architectures with incomplete PCI setup by the loader */
  8. #define pcibios_assign_all_busses() 1
  9. #define pcibios_scan_all_fns(a, b) 0
  10. /*
  11. * A board can define one or more PCI channels that represent built-in (or
  12. * external) PCI controllers.
  13. */
  14. struct pci_channel {
  15. struct pci_channel *next;
  16. int (*init)(struct pci_channel *chan);
  17. struct pci_ops *pci_ops;
  18. struct resource *io_resource;
  19. struct resource *mem_resource;
  20. unsigned long io_offset;
  21. unsigned long mem_offset;
  22. int first_devfn;
  23. int last_devfn;
  24. int enabled;
  25. unsigned long reg_base;
  26. unsigned long io_base;
  27. unsigned long io_map_base;
  28. };
  29. /*
  30. * Each board initializes this array and terminates it with a NULL entry.
  31. */
  32. extern struct pci_channel board_pci_channels[];
  33. extern void register_pci_controller(struct pci_channel *hose);
  34. extern unsigned long PCIBIOS_MIN_IO, PCIBIOS_MIN_MEM;
  35. struct pci_dev;
  36. #define HAVE_PCI_MMAP
  37. extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  38. enum pci_mmap_state mmap_state, int write_combine);
  39. extern void pcibios_set_master(struct pci_dev *dev);
  40. static inline void pcibios_penalize_isa_irq(int irq, int active)
  41. {
  42. /* We don't do dynamic PCI IRQ allocation */
  43. }
  44. /* Dynamic DMA mapping stuff.
  45. * SuperH has everything mapped statically like x86.
  46. */
  47. /* The PCI address space does equal the physical memory
  48. * address space. The networking and block device layers use
  49. * this boolean for bounce buffer decisions.
  50. */
  51. #define PCI_DMA_BUS_IS_PHYS (1)
  52. #include <linux/types.h>
  53. #include <linux/slab.h>
  54. #include <asm/scatterlist.h>
  55. #include <linux/string.h>
  56. #include <asm/io.h>
  57. /* pci_unmap_{single,page} being a nop depends upon the
  58. * configuration.
  59. */
  60. #ifdef CONFIG_SH_PCIDMA_NONCOHERENT
  61. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
  62. dma_addr_t ADDR_NAME;
  63. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
  64. __u32 LEN_NAME;
  65. #define pci_unmap_addr(PTR, ADDR_NAME) \
  66. ((PTR)->ADDR_NAME)
  67. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  68. (((PTR)->ADDR_NAME) = (VAL))
  69. #define pci_unmap_len(PTR, LEN_NAME) \
  70. ((PTR)->LEN_NAME)
  71. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  72. (((PTR)->LEN_NAME) = (VAL))
  73. #else
  74. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
  75. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
  76. #define pci_unmap_addr(PTR, ADDR_NAME) (0)
  77. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
  78. #define pci_unmap_len(PTR, LEN_NAME) (0)
  79. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
  80. #endif
  81. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  82. enum pci_dma_burst_strategy *strat,
  83. unsigned long *strategy_parameter)
  84. {
  85. *strat = PCI_DMA_BURST_INFINITY;
  86. *strategy_parameter = ~0UL;
  87. }
  88. #ifdef CONFIG_SUPERH32
  89. /*
  90. * If we're on an SH7751 or SH7780 PCI controller, PCI memory is mapped
  91. * at the end of the address space in a special non-translatable area.
  92. */
  93. #define PCI_MEM_FIXED_START 0xfd000000
  94. #define PCI_MEM_FIXED_END (PCI_MEM_FIXED_START + 0x01000000)
  95. #define is_pci_memory_fixed_range(s, e) \
  96. ((s) >= PCI_MEM_FIXED_START && (e) < PCI_MEM_FIXED_END)
  97. #else
  98. #define is_pci_memory_fixed_range(s, e) (0)
  99. #endif
  100. /* Board-specific fixup routines. */
  101. int pcibios_init_platform(void);
  102. int pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin);
  103. #ifdef CONFIG_PCI_AUTO
  104. int pciauto_assign_resources(int busno, struct pci_channel *hose);
  105. #endif
  106. extern void pcibios_resource_to_bus(struct pci_dev *dev,
  107. struct pci_bus_region *region, struct resource *res);
  108. extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
  109. struct pci_bus_region *region);
  110. static inline struct resource *
  111. pcibios_select_root(struct pci_dev *pdev, struct resource *res)
  112. {
  113. struct resource *root = NULL;
  114. if (res->flags & IORESOURCE_IO)
  115. root = &ioport_resource;
  116. if (res->flags & IORESOURCE_MEM)
  117. root = &iomem_resource;
  118. return root;
  119. }
  120. /* Chances are this interrupt is wired PC-style ... */
  121. static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
  122. {
  123. return channel ? 15 : 14;
  124. }
  125. /* generic DMA-mapping stuff */
  126. #include <asm-generic/pci-dma-compat.h>
  127. #endif /* __KERNEL__ */
  128. #endif /* __ASM_SH_PCI_H */