pci.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. /*
  34. * I/O routine helpers
  35. */
  36. #if defined(CONFIG_CPU_SUBTYPE_SH7780) || defined(CONFIG_CPU_SUBTYPE_SH7785)
  37. #define PCI_IO_AREA 0xFE400000
  38. #define PCI_IO_SIZE 0x00400000
  39. #elif defined(CONFIG_CPU_SH5)
  40. extern unsigned long PCI_IO_AREA;
  41. #define PCI_IO_SIZE 0x00010000
  42. #else
  43. #define PCI_IO_AREA 0xFE240000
  44. #define PCI_IO_SIZE 0x00040000
  45. #endif
  46. #define PCI_MEM_SIZE 0x01000000
  47. #define SH4_PCIIOBR_MASK 0xFFFC0000
  48. #define pci_ioaddr(addr) (PCI_IO_AREA + (addr & ~SH4_PCIIOBR_MASK))
  49. #if defined(CONFIG_PCI)
  50. #define is_pci_ioaddr(port) \
  51. (((port) >= PCIBIOS_MIN_IO) && \
  52. ((port) < (PCIBIOS_MIN_IO + PCI_IO_SIZE)))
  53. #else
  54. #define is_pci_ioaddr(port) (0)
  55. #endif
  56. struct pci_dev;
  57. extern void pcibios_set_master(struct pci_dev *dev);
  58. static inline void pcibios_penalize_isa_irq(int irq, int active)
  59. {
  60. /* We don't do dynamic PCI IRQ allocation */
  61. }
  62. /* Dynamic DMA mapping stuff.
  63. * SuperH has everything mapped statically like x86.
  64. */
  65. /* The PCI address space does equal the physical memory
  66. * address space. The networking and block device layers use
  67. * this boolean for bounce buffer decisions.
  68. */
  69. #define PCI_DMA_BUS_IS_PHYS (1)
  70. #include <linux/types.h>
  71. #include <linux/slab.h>
  72. #include <asm/scatterlist.h>
  73. #include <linux/string.h>
  74. #include <asm/io.h>
  75. /* pci_unmap_{single,page} being a nop depends upon the
  76. * configuration.
  77. */
  78. #ifdef CONFIG_SH_PCIDMA_NONCOHERENT
  79. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
  80. dma_addr_t ADDR_NAME;
  81. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
  82. __u32 LEN_NAME;
  83. #define pci_unmap_addr(PTR, ADDR_NAME) \
  84. ((PTR)->ADDR_NAME)
  85. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  86. (((PTR)->ADDR_NAME) = (VAL))
  87. #define pci_unmap_len(PTR, LEN_NAME) \
  88. ((PTR)->LEN_NAME)
  89. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  90. (((PTR)->LEN_NAME) = (VAL))
  91. #else
  92. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
  93. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
  94. #define pci_unmap_addr(PTR, ADDR_NAME) (0)
  95. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
  96. #define pci_unmap_len(PTR, LEN_NAME) (0)
  97. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
  98. #endif
  99. #ifdef CONFIG_PCI
  100. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  101. enum pci_dma_burst_strategy *strat,
  102. unsigned long *strategy_parameter)
  103. {
  104. *strat = PCI_DMA_BURST_INFINITY;
  105. *strategy_parameter = ~0UL;
  106. }
  107. static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
  108. {
  109. struct pci_channel *p;
  110. struct resource *res;
  111. for (p = board_pci_channels; p->init; p++) {
  112. res = p->mem_resource;
  113. if (p->enabled && (phys_addr >= res->start) &&
  114. (phys_addr + size) <= (res->end + 1))
  115. return 1;
  116. }
  117. return 0;
  118. }
  119. #else
  120. static inline int __is_pci_memory(unsigned long phys_addr, unsigned long size)
  121. {
  122. return 0;
  123. }
  124. #endif
  125. /* Board-specific fixup routines. */
  126. void pcibios_fixup(void);
  127. int pcibios_init_platform(void);
  128. int pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin);
  129. #ifdef CONFIG_PCI_AUTO
  130. int pciauto_assign_resources(int busno, struct pci_channel *hose);
  131. #endif
  132. #endif /* __KERNEL__ */
  133. /* generic pci stuff */
  134. #include <asm-generic/pci.h>
  135. /* generic DMA-mapping stuff */
  136. #include <asm-generic/pci-dma-compat.h>
  137. #endif /* __ASM_SH_PCI_H */