pcibr_provider.h 5.4 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-2004 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. /* Workarounds */
  11. #define PV907516 (1 << 1) /* TIOCP: Don't write the write buffer flush reg */
  12. #define BUSTYPE_MASK 0x1
  13. /* Macros given a pcibus structure */
  14. #define IS_PCIX(ps) ((ps)->pbi_bridge_mode & BUSTYPE_MASK)
  15. #define IS_PCI_BRIDGE_ASIC(asic) (asic == PCIIO_ASIC_TYPE_PIC || \
  16. asic == PCIIO_ASIC_TYPE_TIOCP)
  17. #define IS_PIC_SOFT(ps) (ps->pbi_bridge_type == PCIBR_BRIDGETYPE_PIC)
  18. /*
  19. * The different PCI Bridge types supported on the SGI Altix platforms
  20. */
  21. #define PCIBR_BRIDGETYPE_UNKNOWN -1
  22. #define PCIBR_BRIDGETYPE_PIC 2
  23. #define PCIBR_BRIDGETYPE_TIOCP 3
  24. /*
  25. * Bridge 64bit Direct Map Attributes
  26. */
  27. #define PCI64_ATTR_PREF (1ull << 59)
  28. #define PCI64_ATTR_PREC (1ull << 58)
  29. #define PCI64_ATTR_VIRTUAL (1ull << 57)
  30. #define PCI64_ATTR_BAR (1ull << 56)
  31. #define PCI64_ATTR_SWAP (1ull << 55)
  32. #define PCI64_ATTR_VIRTUAL1 (1ull << 54)
  33. #define PCI32_LOCAL_BASE 0
  34. #define PCI32_MAPPED_BASE 0x40000000
  35. #define PCI32_DIRECT_BASE 0x80000000
  36. #define IS_PCI32_MAPPED(x) ((uint64_t)(x) < PCI32_DIRECT_BASE && \
  37. (uint64_t)(x) >= PCI32_MAPPED_BASE)
  38. #define IS_PCI32_DIRECT(x) ((uint64_t)(x) >= PCI32_MAPPED_BASE)
  39. /*
  40. * Bridge PMU Address Transaltion Entry Attibutes
  41. */
  42. #define PCI32_ATE_V (0x1 << 0)
  43. #define PCI32_ATE_CO (0x1 << 1)
  44. #define PCI32_ATE_PREC (0x1 << 2)
  45. #define PCI32_ATE_PREF (0x1 << 3)
  46. #define PCI32_ATE_BAR (0x1 << 4)
  47. #define PCI32_ATE_ADDR_SHFT 12
  48. #define MINIMAL_ATES_REQUIRED(addr, size) \
  49. (IOPG(IOPGOFF(addr) + (size) - 1) == IOPG((size) - 1))
  50. #define MINIMAL_ATE_FLAG(addr, size) \
  51. (MINIMAL_ATES_REQUIRED((uint64_t)addr, size) ? 1 : 0)
  52. /* bit 29 of the pci address is the SWAP bit */
  53. #define ATE_SWAPSHIFT 29
  54. #define ATE_SWAP_ON(x) ((x) |= (1 << ATE_SWAPSHIFT))
  55. #define ATE_SWAP_OFF(x) ((x) &= ~(1 << ATE_SWAPSHIFT))
  56. /*
  57. * I/O page size
  58. */
  59. #if PAGE_SIZE < 16384
  60. #define IOPFNSHIFT 12 /* 4K per mapped page */
  61. #else
  62. #define IOPFNSHIFT 14 /* 16K per mapped page */
  63. #endif
  64. #define IOPGSIZE (1 << IOPFNSHIFT)
  65. #define IOPG(x) ((x) >> IOPFNSHIFT)
  66. #define IOPGOFF(x) ((x) & (IOPGSIZE-1))
  67. #define PCIBR_DEV_SWAP_DIR (1ull << 19)
  68. #define PCIBR_CTRL_PAGE_SIZE (0x1 << 21)
  69. /*
  70. * PMU resources.
  71. */
  72. struct ate_resource{
  73. uint64_t *ate;
  74. uint64_t num_ate;
  75. uint64_t lowest_free_index;
  76. };
  77. struct pcibus_info {
  78. struct pcibus_bussoft pbi_buscommon; /* common header */
  79. uint32_t pbi_moduleid;
  80. short pbi_bridge_type;
  81. short pbi_bridge_mode;
  82. struct ate_resource pbi_int_ate_resource;
  83. uint64_t pbi_int_ate_size;
  84. uint64_t pbi_dir_xbase;
  85. char pbi_hub_xid;
  86. uint64_t pbi_devreg[8];
  87. spinlock_t pbi_lock;
  88. uint32_t pbi_valid_devices;
  89. uint32_t pbi_enabled_devices;
  90. };
  91. /*
  92. * pcibus_info structure locking macros
  93. */
  94. inline static unsigned long
  95. pcibr_lock(struct pcibus_info *pcibus_info)
  96. {
  97. unsigned long flag;
  98. spin_lock_irqsave(&pcibus_info->pbi_lock, flag);
  99. return(flag);
  100. }
  101. #define pcibr_unlock(pcibus_info, flag) spin_unlock_irqrestore(&pcibus_info->pbi_lock, flag)
  102. extern int pcibr_init_provider(void);
  103. extern void *pcibr_bus_fixup(struct pcibus_bussoft *);
  104. extern dma_addr_t pcibr_dma_map(struct pci_dev *, unsigned long, size_t);
  105. extern dma_addr_t pcibr_dma_map_consistent(struct pci_dev *, unsigned long, size_t);
  106. extern void pcibr_dma_unmap(struct pci_dev *, dma_addr_t, int);
  107. /*
  108. * prototypes for the bridge asic register access routines in pcibr_reg.c
  109. */
  110. extern void pcireg_control_bit_clr(struct pcibus_info *, uint64_t);
  111. extern void pcireg_control_bit_set(struct pcibus_info *, uint64_t);
  112. extern uint64_t pcireg_tflush_get(struct pcibus_info *);
  113. extern uint64_t pcireg_intr_status_get(struct pcibus_info *);
  114. extern void pcireg_intr_enable_bit_clr(struct pcibus_info *, uint64_t);
  115. extern void pcireg_intr_enable_bit_set(struct pcibus_info *, uint64_t);
  116. extern void pcireg_intr_addr_addr_set(struct pcibus_info *, int, uint64_t);
  117. extern void pcireg_force_intr_set(struct pcibus_info *, int);
  118. extern uint64_t pcireg_wrb_flush_get(struct pcibus_info *, int);
  119. extern void pcireg_int_ate_set(struct pcibus_info *, int, uint64_t);
  120. extern uint64_t * pcireg_int_ate_addr(struct pcibus_info *, int);
  121. extern void pcibr_force_interrupt(struct sn_irq_info *sn_irq_info);
  122. extern void pcibr_change_devices_irq(struct sn_irq_info *sn_irq_info);
  123. extern int pcibr_ate_alloc(struct pcibus_info *, int);
  124. extern void pcibr_ate_free(struct pcibus_info *, int);
  125. extern void ate_write(struct pcibus_info *, int, int, uint64_t);
  126. #endif