pcibr_provider.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1992-1997,2000-2006 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #ifndef _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H
  9. #define _ASM_IA64_SN_PCI_PCIBR_PROVIDER_H
  10. #include <asm/sn/intr.h>
  11. #include <asm/sn/pcibus_provider_defs.h>
  12. /* Workarounds */
  13. #define PV907516 (1 << 1) /* TIOCP: Don't write the write buffer flush reg */
  14. #define BUSTYPE_MASK 0x1
  15. /* Macros given a pcibus structure */
  16. #define IS_PCIX(ps) ((ps)->pbi_bridge_mode & BUSTYPE_MASK)
  17. #define IS_PCI_BRIDGE_ASIC(asic) (asic == PCIIO_ASIC_TYPE_PIC || \
  18. asic == PCIIO_ASIC_TYPE_TIOCP)
  19. #define IS_PIC_SOFT(ps) (ps->pbi_bridge_type == PCIBR_BRIDGETYPE_PIC)
  20. #define IS_TIOCP_SOFT(ps) (ps->pbi_bridge_type == PCIBR_BRIDGETYPE_TIOCP)
  21. /*
  22. * The different PCI Bridge types supported on the SGI Altix platforms
  23. */
  24. #define PCIBR_BRIDGETYPE_UNKNOWN -1
  25. #define PCIBR_BRIDGETYPE_PIC 2
  26. #define PCIBR_BRIDGETYPE_TIOCP 3
  27. /*
  28. * Bridge 64bit Direct Map Attributes
  29. */
  30. #define PCI64_ATTR_PREF (1ull << 59)
  31. #define PCI64_ATTR_PREC (1ull << 58)
  32. #define PCI64_ATTR_VIRTUAL (1ull << 57)
  33. #define PCI64_ATTR_BAR (1ull << 56)
  34. #define PCI64_ATTR_SWAP (1ull << 55)
  35. #define PCI64_ATTR_VIRTUAL1 (1ull << 54)
  36. #define PCI32_LOCAL_BASE 0
  37. #define PCI32_MAPPED_BASE 0x40000000
  38. #define PCI32_DIRECT_BASE 0x80000000
  39. #define IS_PCI32_MAPPED(x) ((u64)(x) < PCI32_DIRECT_BASE && \
  40. (u64)(x) >= PCI32_MAPPED_BASE)
  41. #define IS_PCI32_DIRECT(x) ((u64)(x) >= PCI32_MAPPED_BASE)
  42. /*
  43. * Bridge PMU Address Transaltion Entry Attibutes
  44. */
  45. #define PCI32_ATE_V (0x1 << 0)
  46. #define PCI32_ATE_CO (0x1 << 1) /* PIC ASIC ONLY */
  47. #define PCI32_ATE_PIO (0x1 << 1) /* TIOCP ASIC ONLY */
  48. #define PCI32_ATE_MSI (0x1 << 2)
  49. #define PCI32_ATE_PREF (0x1 << 3)
  50. #define PCI32_ATE_BAR (0x1 << 4)
  51. #define PCI32_ATE_ADDR_SHFT 12
  52. #define MINIMAL_ATES_REQUIRED(addr, size) \
  53. (IOPG(IOPGOFF(addr) + (size) - 1) == IOPG((size) - 1))
  54. #define MINIMAL_ATE_FLAG(addr, size) \
  55. (MINIMAL_ATES_REQUIRED((u64)addr, size) ? 1 : 0)
  56. /* bit 29 of the pci address is the SWAP bit */
  57. #define ATE_SWAPSHIFT 29
  58. #define ATE_SWAP_ON(x) ((x) |= (1 << ATE_SWAPSHIFT))
  59. #define ATE_SWAP_OFF(x) ((x) &= ~(1 << ATE_SWAPSHIFT))
  60. /*
  61. * I/O page size
  62. */
  63. #if PAGE_SIZE < 16384
  64. #define IOPFNSHIFT 12 /* 4K per mapped page */
  65. #else
  66. #define IOPFNSHIFT 14 /* 16K per mapped page */
  67. #endif
  68. #define IOPGSIZE (1 << IOPFNSHIFT)
  69. #define IOPG(x) ((x) >> IOPFNSHIFT)
  70. #define IOPGOFF(x) ((x) & (IOPGSIZE-1))
  71. #define PCIBR_DEV_SWAP_DIR (1ull << 19)
  72. #define PCIBR_CTRL_PAGE_SIZE (0x1 << 21)
  73. /*
  74. * PMU resources.
  75. */
  76. struct ate_resource{
  77. u64 *ate;
  78. u64 num_ate;
  79. u64 lowest_free_index;
  80. };
  81. struct pcibus_info {
  82. struct pcibus_bussoft pbi_buscommon; /* common header */
  83. u32 pbi_moduleid;
  84. short pbi_bridge_type;
  85. short pbi_bridge_mode;
  86. struct ate_resource pbi_int_ate_resource;
  87. u64 pbi_int_ate_size;
  88. u64 pbi_dir_xbase;
  89. char pbi_hub_xid;
  90. u64 pbi_devreg[8];
  91. u32 pbi_valid_devices;
  92. u32 pbi_enabled_devices;
  93. spinlock_t pbi_lock;
  94. };
  95. extern int pcibr_init_provider(void);
  96. extern void *pcibr_bus_fixup(struct pcibus_bussoft *, struct pci_controller *);
  97. extern dma_addr_t pcibr_dma_map(struct pci_dev *, unsigned long, size_t, int type);
  98. extern dma_addr_t pcibr_dma_map_consistent(struct pci_dev *, unsigned long, size_t, int type);
  99. extern void pcibr_dma_unmap(struct pci_dev *, dma_addr_t, int);
  100. /*
  101. * prototypes for the bridge asic register access routines in pcibr_reg.c
  102. */
  103. extern void pcireg_control_bit_clr(struct pcibus_info *, u64);
  104. extern void pcireg_control_bit_set(struct pcibus_info *, u64);
  105. extern u64 pcireg_tflush_get(struct pcibus_info *);
  106. extern u64 pcireg_intr_status_get(struct pcibus_info *);
  107. extern void pcireg_intr_enable_bit_clr(struct pcibus_info *, u64);
  108. extern void pcireg_intr_enable_bit_set(struct pcibus_info *, u64);
  109. extern void pcireg_intr_addr_addr_set(struct pcibus_info *, int, u64);
  110. extern void pcireg_force_intr_set(struct pcibus_info *, int);
  111. extern u64 pcireg_wrb_flush_get(struct pcibus_info *, int);
  112. extern void pcireg_int_ate_set(struct pcibus_info *, int, u64);
  113. extern u64 __iomem * pcireg_int_ate_addr(struct pcibus_info *, int);
  114. extern void pcibr_force_interrupt(struct sn_irq_info *sn_irq_info);
  115. extern void pcibr_change_devices_irq(struct sn_irq_info *sn_irq_info);
  116. extern int pcibr_ate_alloc(struct pcibus_info *, int);
  117. extern void pcibr_ate_free(struct pcibus_info *, int);
  118. extern void ate_write(struct pcibus_info *, int, int, u64);
  119. extern int sal_pcibr_slot_enable(struct pcibus_info *soft, int device,
  120. void *resp, char **ssdt);
  121. extern int sal_pcibr_slot_disable(struct pcibus_info *soft, int device,
  122. int action, void *resp);
  123. extern u16 sn_ioboard_to_pci_bus(struct pci_bus *pci_bus);
  124. #endif