tpci200.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * driver for the carrier TEWS TPCI-200
  4. *
  5. * Copyright (C) 2009-2012 CERN (www.cern.ch)
  6. * Author: Nicolas Serafini, EIC2 SA
  7. * Author: Samuel Iglesias Gonsalvez <[email protected]>
  8. */
  9. #ifndef _TPCI200_H_
  10. #define _TPCI200_H_
  11. #include <linux/limits.h>
  12. #include <linux/pci.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/swab.h>
  15. #include <linux/io.h>
  16. #include <linux/ipack.h>
  17. #define TPCI200_NB_SLOT 0x4
  18. #define TPCI200_NB_BAR 0x6
  19. #define TPCI200_VENDOR_ID 0x1498
  20. #define TPCI200_DEVICE_ID 0x30C8
  21. #define TPCI200_SUBVENDOR_ID 0x1498
  22. #define TPCI200_SUBDEVICE_ID 0x300A
  23. #define TPCI200_CFG_MEM_BAR 0
  24. #define TPCI200_IP_INTERFACE_BAR 2
  25. #define TPCI200_IO_ID_INT_SPACES_BAR 3
  26. #define TPCI200_MEM16_SPACE_BAR 4
  27. #define TPCI200_MEM8_SPACE_BAR 5
  28. struct tpci200_regs {
  29. __le16 revision;
  30. /* writes to control should occur with the mutex held to protect
  31. * read-modify-write operations */
  32. __le16 control[4];
  33. __le16 reset;
  34. __le16 status;
  35. u8 reserved[242];
  36. } __packed;
  37. #define TPCI200_IFACE_SIZE 0x100
  38. #define TPCI200_IO_SPACE_OFF 0x0000
  39. #define TPCI200_IO_SPACE_INTERVAL 0x0100
  40. #define TPCI200_IO_SPACE_SIZE 0x0080
  41. #define TPCI200_ID_SPACE_OFF 0x0080
  42. #define TPCI200_ID_SPACE_INTERVAL 0x0100
  43. #define TPCI200_ID_SPACE_SIZE 0x0040
  44. #define TPCI200_INT_SPACE_OFF 0x00C0
  45. #define TPCI200_INT_SPACE_INTERVAL 0x0100
  46. #define TPCI200_INT_SPACE_SIZE 0x0040
  47. #define TPCI200_IOIDINT_SIZE 0x0400
  48. #define TPCI200_MEM8_SPACE_INTERVAL 0x00400000
  49. #define TPCI200_MEM8_SPACE_SIZE 0x00400000
  50. #define TPCI200_MEM16_SPACE_INTERVAL 0x00800000
  51. #define TPCI200_MEM16_SPACE_SIZE 0x00800000
  52. /* control field in tpci200_regs */
  53. #define TPCI200_INT0_EN 0x0040
  54. #define TPCI200_INT1_EN 0x0080
  55. #define TPCI200_INT0_EDGE 0x0010
  56. #define TPCI200_INT1_EDGE 0x0020
  57. #define TPCI200_ERR_INT_EN 0x0008
  58. #define TPCI200_TIME_INT_EN 0x0004
  59. #define TPCI200_RECOVER_EN 0x0002
  60. #define TPCI200_CLK32 0x0001
  61. /* reset field in tpci200_regs */
  62. #define TPCI200_A_RESET 0x0001
  63. #define TPCI200_B_RESET 0x0002
  64. #define TPCI200_C_RESET 0x0004
  65. #define TPCI200_D_RESET 0x0008
  66. /* status field in tpci200_regs */
  67. #define TPCI200_A_TIMEOUT 0x1000
  68. #define TPCI200_B_TIMEOUT 0x2000
  69. #define TPCI200_C_TIMEOUT 0x4000
  70. #define TPCI200_D_TIMEOUT 0x8000
  71. #define TPCI200_A_ERROR 0x0100
  72. #define TPCI200_B_ERROR 0x0200
  73. #define TPCI200_C_ERROR 0x0400
  74. #define TPCI200_D_ERROR 0x0800
  75. #define TPCI200_A_INT0 0x0001
  76. #define TPCI200_A_INT1 0x0002
  77. #define TPCI200_B_INT0 0x0004
  78. #define TPCI200_B_INT1 0x0008
  79. #define TPCI200_C_INT0 0x0010
  80. #define TPCI200_C_INT1 0x0020
  81. #define TPCI200_D_INT0 0x0040
  82. #define TPCI200_D_INT1 0x0080
  83. #define TPCI200_SLOT_INT_MASK 0x00FF
  84. /* PCI Configuration registers. The PCI bridge is a PLX Technology PCI9030. */
  85. #define LAS1_DESC 0x2C
  86. #define LAS2_DESC 0x30
  87. /* Bits in the LAS?_DESC registers */
  88. #define LAS_BIT_BIGENDIAN 24
  89. #define VME_IOID_SPACE "IOID"
  90. #define VME_MEM_SPACE "MEM"
  91. /**
  92. * struct slot_irq - slot IRQ definition.
  93. * @vector Vector number
  94. * @handler Handler called when IRQ arrives
  95. * @arg Handler argument
  96. *
  97. */
  98. struct slot_irq {
  99. struct ipack_device *holder;
  100. int vector;
  101. irqreturn_t (*handler)(void *);
  102. void *arg;
  103. };
  104. /**
  105. * struct tpci200_slot - data specific to the tpci200 slot.
  106. * @slot_id Slot identification gived to external interface
  107. * @irq Slot IRQ infos
  108. * @io_phys IO physical base address register of the slot
  109. * @id_phys ID physical base address register of the slot
  110. * @int_phys INT physical base address register of the slot
  111. * @mem_phys MEM physical base address register of the slot
  112. *
  113. */
  114. struct tpci200_slot {
  115. struct slot_irq *irq;
  116. };
  117. /**
  118. * struct tpci200_infos - informations specific of the TPCI200 tpci200.
  119. * @pci_dev PCI device
  120. * @interface_regs Pointer to IP interface space (Bar 2)
  121. * @ioidint_space Pointer to IP ID, IO and INT space (Bar 3)
  122. * @mem8_space Pointer to MEM space (Bar 4)
  123. *
  124. */
  125. struct tpci200_infos {
  126. struct pci_dev *pdev;
  127. struct pci_device_id *id_table;
  128. struct tpci200_regs __iomem *interface_regs;
  129. void __iomem *cfg_regs;
  130. struct ipack_bus_device *ipack_bus;
  131. };
  132. struct tpci200_board {
  133. unsigned int number;
  134. struct mutex mutex;
  135. spinlock_t regs_lock;
  136. struct tpci200_slot *slots;
  137. struct tpci200_infos *info;
  138. phys_addr_t mod_mem[IPACK_SPACE_COUNT];
  139. };
  140. #endif /* _TPCI200_H_ */