pci_impl.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. 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. const 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. struct resource mem64_space;
  84. struct resource busn;
  85. /* Base of PCI Config space, can be per-PBM or shared. */
  86. unsigned long config_space;
  87. /* This will be 12 on PCI-E controllers, 8 elsewhere. */
  88. unsigned long config_space_reg_bits;
  89. unsigned long pci_afsr;
  90. unsigned long pci_afar;
  91. unsigned long pci_csr;
  92. /* State of 66MHz capabilities on this PBM. */
  93. int is_66mhz_capable;
  94. int all_devs_66mhz;
  95. #ifdef CONFIG_PCI_MSI
  96. /* MSI info. */
  97. u32 msiq_num;
  98. u32 msiq_ent_count;
  99. u32 msiq_first;
  100. u32 msiq_first_devino;
  101. u32 msiq_rotor;
  102. struct sparc64_msiq_cookie *msiq_irq_cookies;
  103. u32 msi_num;
  104. u32 msi_first;
  105. u32 msi_data_mask;
  106. u32 msix_data_width;
  107. u64 msi32_start;
  108. u64 msi64_start;
  109. u32 msi32_len;
  110. u32 msi64_len;
  111. void *msi_queues;
  112. unsigned long *msi_bitmap;
  113. unsigned int *msi_irq_table;
  114. int (*setup_msi_irq)(unsigned int *irq_p, struct pci_dev *pdev,
  115. struct msi_desc *entry);
  116. void (*teardown_msi_irq)(unsigned int irq, struct pci_dev *pdev);
  117. const struct sparc64_msiq_ops *msi_ops;
  118. #endif /* !(CONFIG_PCI_MSI) */
  119. /* This PBM's streaming buffer. */
  120. struct strbuf stc;
  121. /* IOMMU state, potentially shared by both PBM segments. */
  122. struct iommu *iommu;
  123. /* Now things for the actual PCI bus probes. */
  124. unsigned int pci_first_busno;
  125. unsigned int pci_last_busno;
  126. struct pci_bus *pci_bus;
  127. struct pci_ops *pci_ops;
  128. int numa_node;
  129. };
  130. extern struct pci_pbm_info *pci_pbm_root;
  131. extern int pci_num_pbms;
  132. /* PCI bus scanning and fixup support. */
  133. void pci_get_pbm_props(struct pci_pbm_info *pbm);
  134. struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
  135. struct device *parent);
  136. void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
  137. /* Error reporting support. */
  138. void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *);
  139. void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *);
  140. void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *);
  141. /* Configuration space access. */
  142. void pci_config_read8(u8 *addr, u8 *ret);
  143. void pci_config_read16(u16 *addr, u16 *ret);
  144. void pci_config_read32(u32 *addr, u32 *ret);
  145. void pci_config_write8(u8 *addr, u8 val);
  146. void pci_config_write16(u16 *addr, u16 val);
  147. void pci_config_write32(u32 *addr, u32 val);
  148. extern struct pci_ops sun4u_pci_ops;
  149. extern struct pci_ops sun4v_pci_ops;
  150. extern volatile int pci_poke_in_progress;
  151. extern volatile int pci_poke_cpu;
  152. extern volatile int pci_poke_faulted;
  153. #endif /* !(PCI_IMPL_H) */