pci.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. int (*init)(struct pci_channel *chan);
  16. struct pci_ops *pci_ops;
  17. struct resource *io_resource;
  18. struct resource *mem_resource;
  19. int first_devfn;
  20. int last_devfn;
  21. int enabled;
  22. unsigned long reg_base;
  23. unsigned long io_base;
  24. };
  25. /*
  26. * Each board initializes this array and terminates it with a NULL entry.
  27. */
  28. extern struct pci_channel board_pci_channels[];
  29. /* ugly as hell, but makes drivers/pci/setup-res.c compile and work */
  30. #define __PCI_CHAN(bus) ((struct pci_channel *)bus->sysdata)
  31. #define PCIBIOS_MIN_IO __PCI_CHAN(bus)->io_resource->start
  32. #define PCIBIOS_MIN_MEM __PCI_CHAN(bus)->mem_resource->start
  33. struct pci_dev;
  34. #define HAVE_PCI_MMAP
  35. extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  36. enum pci_mmap_state mmap_state, int write_combine);
  37. extern void pcibios_set_master(struct pci_dev *dev);
  38. static inline void pcibios_penalize_isa_irq(int irq, int active)
  39. {
  40. /* We don't do dynamic PCI IRQ allocation */
  41. }
  42. /* Dynamic DMA mapping stuff.
  43. * SuperH has everything mapped statically like x86.
  44. */
  45. /* The PCI address space does equal the physical memory
  46. * address space. The networking and block device layers use
  47. * this boolean for bounce buffer decisions.
  48. */
  49. #define PCI_DMA_BUS_IS_PHYS (1)
  50. #include <linux/types.h>
  51. #include <linux/slab.h>
  52. #include <asm/scatterlist.h>
  53. #include <linux/string.h>
  54. #include <asm/io.h>
  55. /* pci_unmap_{single,page} being a nop depends upon the
  56. * configuration.
  57. */
  58. #ifdef CONFIG_SH_PCIDMA_NONCOHERENT
  59. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
  60. dma_addr_t ADDR_NAME;
  61. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
  62. __u32 LEN_NAME;
  63. #define pci_unmap_addr(PTR, ADDR_NAME) \
  64. ((PTR)->ADDR_NAME)
  65. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  66. (((PTR)->ADDR_NAME) = (VAL))
  67. #define pci_unmap_len(PTR, LEN_NAME) \
  68. ((PTR)->LEN_NAME)
  69. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  70. (((PTR)->LEN_NAME) = (VAL))
  71. #else
  72. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
  73. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
  74. #define pci_unmap_addr(PTR, ADDR_NAME) (0)
  75. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
  76. #define pci_unmap_len(PTR, LEN_NAME) (0)
  77. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
  78. #endif
  79. #ifdef CONFIG_PCI
  80. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  81. enum pci_dma_burst_strategy *strat,
  82. unsigned long *strategy_parameter)
  83. {
  84. *strat = PCI_DMA_BURST_INFINITY;
  85. *strategy_parameter = ~0UL;
  86. }
  87. static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
  88. {
  89. struct pci_channel *p;
  90. struct resource *res;
  91. for (p = board_pci_channels; p->init; p++) {
  92. res = p->mem_resource;
  93. if (p->enabled && (phys_addr >= res->start) &&
  94. (phys_addr + size) <= (res->end + 1))
  95. return 1;
  96. }
  97. return 0;
  98. }
  99. static inline void __iomem *__get_pci_io_base(unsigned long port,
  100. unsigned long size)
  101. {
  102. struct pci_channel *p;
  103. struct resource *res;
  104. for (p = board_pci_channels; p->init; p++) {
  105. res = p->io_resource;
  106. if (p->enabled && (port >= res->start) &&
  107. (port + size) <= (res->end + 1))
  108. return (void __iomem *)(p->io_base + port);
  109. }
  110. return NULL;
  111. }
  112. #else
  113. static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
  114. {
  115. return 0;
  116. }
  117. static inline void __iomem *__get_pci_io_base(unsigned long port,
  118. unsigned long size)
  119. {
  120. return NULL;
  121. }
  122. #endif
  123. /* Board-specific fixup routines. */
  124. void pcibios_fixup(void);
  125. int pcibios_init_platform(void);
  126. int pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin);
  127. #ifdef CONFIG_PCI_AUTO
  128. int pciauto_assign_resources(int busno, struct pci_channel *hose);
  129. #endif
  130. extern void pcibios_resource_to_bus(struct pci_dev *dev,
  131. struct pci_bus_region *region, struct resource *res);
  132. extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
  133. struct pci_bus_region *region);
  134. static inline struct resource *
  135. pcibios_select_root(struct pci_dev *pdev, struct resource *res)
  136. {
  137. struct resource *root = NULL;
  138. if (res->flags & IORESOURCE_IO)
  139. root = &ioport_resource;
  140. if (res->flags & IORESOURCE_MEM)
  141. root = &iomem_resource;
  142. return root;
  143. }
  144. /* Chances are this interrupt is wired PC-style ... */
  145. static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
  146. {
  147. return channel ? 15 : 14;
  148. }
  149. /* generic DMA-mapping stuff */
  150. #include <asm-generic/pci-dma-compat.h>
  151. #endif /* __KERNEL__ */
  152. #endif /* __ASM_SH_PCI_H */