pci_impl.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* pci_impl.h: Helper definitions for PCI controller support.
  2. *
  3. * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net)
  4. */
  5. #ifndef PCI_IMPL_H
  6. #define PCI_IMPL_H
  7. #include <linux/types.h>
  8. #include <linux/spinlock.h>
  9. #include <linux/pci.h>
  10. #include <linux/msi.h>
  11. #include <linux/of_device.h>
  12. #include <asm/io.h>
  13. #include <asm/prom.h>
  14. #include <asm/iommu.h>
  15. /* The abstraction used here is that there are PCI controllers,
  16. * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
  17. * underneath. Each PCI bus module uses an IOMMU (shared by both
  18. * PBMs of a controller, or per-PBM), and if a streaming buffer
  19. * is present, each PCI bus module has it's own. (ie. the IOMMU
  20. * might be shared between PBMs, the STC is never shared)
  21. * Furthermore, each PCI bus module controls it's own autonomous
  22. * PCI bus.
  23. */
  24. #define PCI_STC_FLUSHFLAG_INIT(STC) \
  25. (*((STC)->strbuf_flushflag) = 0UL)
  26. #define PCI_STC_FLUSHFLAG_SET(STC) \
  27. (*((STC)->strbuf_flushflag) != 0UL)
  28. #ifdef CONFIG_PCI_MSI
  29. struct pci_pbm_info;
  30. struct sparc64_msiq_ops {
  31. int (*get_head)(struct pci_pbm_info *pbm, unsigned long msiqid,
  32. unsigned long *head);
  33. int (*dequeue_msi)(struct pci_pbm_info *pbm, unsigned long msiqid,
  34. unsigned long *head, unsigned long *msi);
  35. int (*set_head)(struct pci_pbm_info *pbm, unsigned long msiqid,
  36. unsigned long head);
  37. int (*msi_setup)(struct pci_pbm_info *pbm, unsigned long msiqid,
  38. unsigned long msi, int is_msi64);
  39. int (*msi_teardown)(struct pci_pbm_info *pbm, unsigned long msi);
  40. int (*msiq_alloc)(struct pci_pbm_info *pbm);
  41. void (*msiq_free)(struct pci_pbm_info *pbm);
  42. int (*msiq_build_irq)(struct pci_pbm_info *pbm, unsigned long msiqid,
  43. unsigned long devino);
  44. };
  45. extern void sparc64_pbm_msi_init(struct pci_pbm_info *pbm,
  46. const struct sparc64_msiq_ops *ops);
  47. struct sparc64_msiq_cookie {
  48. struct pci_pbm_info *pbm;
  49. unsigned long msiqid;
  50. };
  51. #endif
  52. struct pci_pbm_info {
  53. struct pci_pbm_info *next;
  54. struct pci_pbm_info *sibling;
  55. int index;
  56. /* Physical address base of controller registers. */
  57. unsigned long controller_regs;
  58. /* Physical address base of PBM registers. */
  59. unsigned long pbm_regs;
  60. /* Physical address of DMA sync register, if any. */
  61. unsigned long sync_reg;
  62. /* Opaque 32-bit system bus Port ID. */
  63. u32 portid;
  64. /* Opaque 32-bit handle used for hypervisor calls. */
  65. u32 devhandle;
  66. /* Chipset version information. */
  67. int chip_type;
  68. #define PBM_CHIP_TYPE_SABRE 1
  69. #define PBM_CHIP_TYPE_PSYCHO 2
  70. #define PBM_CHIP_TYPE_SCHIZO 3
  71. #define PBM_CHIP_TYPE_SCHIZO_PLUS 4
  72. #define PBM_CHIP_TYPE_TOMATILLO 5
  73. int chip_version;
  74. int chip_revision;
  75. /* Name used for top-level resources. */
  76. char *name;
  77. /* OBP specific information. */
  78. struct platform_device *op;
  79. u64 ino_bitmap;
  80. /* PBM I/O and Memory space resources. */
  81. struct resource io_space;
  82. struct resource mem_space;
  83. /* Base of PCI Config space, can be per-PBM or shared. */
  84. unsigned long config_space;
  85. /* This will be 12 on PCI-E controllers, 8 elsewhere. */
  86. unsigned long config_space_reg_bits;
  87. unsigned long pci_afsr;
  88. unsigned long pci_afar;
  89. unsigned long pci_csr;
  90. /* State of 66MHz capabilities on this PBM. */
  91. int is_66mhz_capable;
  92. int all_devs_66mhz;
  93. #ifdef CONFIG_PCI_MSI
  94. /* MSI info. */
  95. u32 msiq_num;
  96. u32 msiq_ent_count;
  97. u32 msiq_first;
  98. u32 msiq_first_devino;
  99. u32 msiq_rotor;
  100. struct sparc64_msiq_cookie *msiq_irq_cookies;
  101. u32 msi_num;
  102. u32 msi_first;
  103. u32 msi_data_mask;
  104. u32 msix_data_width;
  105. u64 msi32_start;
  106. u64 msi64_start;
  107. u32 msi32_len;
  108. u32 msi64_len;
  109. void *msi_queues;
  110. unsigned long *msi_bitmap;
  111. unsigned int *msi_irq_table;
  112. int (*setup_msi_irq)(unsigned int *irq_p, struct pci_dev *pdev,
  113. struct msi_desc *entry);
  114. void (*teardown_msi_irq)(unsigned int irq, struct pci_dev *pdev);
  115. const struct sparc64_msiq_ops *msi_ops;
  116. #endif /* !(CONFIG_PCI_MSI) */
  117. /* This PBM's streaming buffer. */
  118. struct strbuf stc;
  119. /* IOMMU state, potentially shared by both PBM segments. */
  120. struct iommu *iommu;
  121. /* Now things for the actual PCI bus probes. */
  122. unsigned int pci_first_busno;
  123. unsigned int pci_last_busno;
  124. struct pci_bus *pci_bus;
  125. struct pci_ops *pci_ops;
  126. int numa_node;
  127. };
  128. extern struct pci_pbm_info *pci_pbm_root;
  129. extern int pci_num_pbms;
  130. /* PCI bus scanning and fixup support. */
  131. extern void pci_get_pbm_props(struct pci_pbm_info *pbm);
  132. extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
  133. struct device *parent);
  134. extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
  135. /* Error reporting support. */
  136. extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *);
  137. extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *);
  138. extern void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *);
  139. /* Configuration space access. */
  140. extern void pci_config_read8(u8 *addr, u8 *ret);
  141. extern void pci_config_read16(u16 *addr, u16 *ret);
  142. extern void pci_config_read32(u32 *addr, u32 *ret);
  143. extern void pci_config_write8(u8 *addr, u8 val);
  144. extern void pci_config_write16(u16 *addr, u16 val);
  145. extern void pci_config_write32(u32 *addr, u32 val);
  146. extern struct pci_ops sun4u_pci_ops;
  147. extern struct pci_ops sun4v_pci_ops;
  148. extern volatile int pci_poke_in_progress;
  149. extern volatile int pci_poke_cpu;
  150. extern volatile int pci_poke_faulted;
  151. #endif /* !(PCI_IMPL_H) */