ntb_hw_idt.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  1. /*
  2. * This file is provided under a GPLv2 license. When using or
  3. * redistributing this file, you may do so under that license.
  4. *
  5. * GPL LICENSE SUMMARY
  6. *
  7. * Copyright (C) 2016 T-Platforms All Rights Reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms and conditions of the GNU General Public License,
  11. * version 2, as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  16. * Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, one can be found http://www.gnu.org/licenses/.
  20. *
  21. * The full GNU General Public License is included in this distribution in
  22. * the file called "COPYING".
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. * IDT PCIe-switch NTB Linux driver
  37. *
  38. * Contact Information:
  39. * Serge Semin <fancer.lancer@gmail.com>, <Sergey.Semin@t-platforms.ru>
  40. */
  41. #ifndef NTB_HW_IDT_H
  42. #define NTB_HW_IDT_H
  43. #include <linux/types.h>
  44. #include <linux/pci.h>
  45. #include <linux/pci_ids.h>
  46. #include <linux/interrupt.h>
  47. #include <linux/spinlock.h>
  48. #include <linux/ntb.h>
  49. /*
  50. * Macro is used to create the struct pci_device_id that matches
  51. * the supported IDT PCIe-switches
  52. * @devname: Capitalized name of the particular device
  53. * @data: Variable passed to the driver of the particular device
  54. */
  55. #define IDT_PCI_DEVICE_IDS(devname, data) \
  56. .vendor = PCI_VENDOR_ID_IDT, .device = PCI_DEVICE_ID_IDT_##devname, \
  57. .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
  58. .class = (PCI_CLASS_BRIDGE_OTHER << 8), .class_mask = (0xFFFF00), \
  59. .driver_data = (kernel_ulong_t)&data
  60. /*
  61. * IDT PCIe-switches device IDs
  62. */
  63. #define PCI_DEVICE_ID_IDT_89HPES24NT6AG2 0x8091
  64. #define PCI_DEVICE_ID_IDT_89HPES32NT8AG2 0x808F
  65. #define PCI_DEVICE_ID_IDT_89HPES32NT8BG2 0x8088
  66. #define PCI_DEVICE_ID_IDT_89HPES12NT12G2 0x8092
  67. #define PCI_DEVICE_ID_IDT_89HPES16NT16G2 0x8090
  68. #define PCI_DEVICE_ID_IDT_89HPES24NT24G2 0x808E
  69. #define PCI_DEVICE_ID_IDT_89HPES32NT24AG2 0x808C
  70. #define PCI_DEVICE_ID_IDT_89HPES32NT24BG2 0x808A
  71. /*
  72. * NT-function Configuration Space registers
  73. * NOTE 1) The IDT PCIe-switch internal data is little-endian
  74. * so it must be taken into account in the driver
  75. * internals.
  76. * 2) Additionally the registers should be accessed either
  77. * with byte-enables corresponding to their native size or
  78. * the size of one DWORD
  79. *
  80. * So to simplify the driver code, there is only DWORD-sized read/write
  81. * operations utilized.
  82. */
  83. /* PCI Express Configuration Space */
  84. /* PCI Express command/status register (DWORD) */
  85. #define IDT_NT_PCICMDSTS 0x00004U
  86. /* PCI Express Device Capabilities (DWORD) */
  87. #define IDT_NT_PCIEDCAP 0x00044U
  88. /* PCI Express Device Control/Status (WORD+WORD) */
  89. #define IDT_NT_PCIEDCTLSTS 0x00048U
  90. /* PCI Express Link Capabilities (DWORD) */
  91. #define IDT_NT_PCIELCAP 0x0004CU
  92. /* PCI Express Link Control/Status (WORD+WORD) */
  93. #define IDT_NT_PCIELCTLSTS 0x00050U
  94. /* PCI Express Device Capabilities 2 (DWORD) */
  95. #define IDT_NT_PCIEDCAP2 0x00064U
  96. /* PCI Express Device Control 2 (WORD+WORD) */
  97. #define IDT_NT_PCIEDCTL2 0x00068U
  98. /* PCI Power Management Control and Status (DWORD) */
  99. #define IDT_NT_PMCSR 0x000C4U
  100. /*==========================================*/
  101. /* IDT Proprietary NT-port-specific registers */
  102. /* NT-function main control registers */
  103. /* NT Endpoint Control (DWORD) */
  104. #define IDT_NT_NTCTL 0x00400U
  105. /* NT Endpoint Interrupt Status/Mask (DWORD) */
  106. #define IDT_NT_NTINTSTS 0x00404U
  107. #define IDT_NT_NTINTMSK 0x00408U
  108. /* NT Endpoint Signal Data (DWORD) */
  109. #define IDT_NT_NTSDATA 0x0040CU
  110. /* NT Endpoint Global Signal (DWORD) */
  111. #define IDT_NT_NTGSIGNAL 0x00410U
  112. /* Internal Error Reporting Mask 0/1 (DWORD) */
  113. #define IDT_NT_NTIERRORMSK0 0x00414U
  114. #define IDT_NT_NTIERRORMSK1 0x00418U
  115. /* Doorbel registers */
  116. /* NT Outbound Doorbell Set (DWORD) */
  117. #define IDT_NT_OUTDBELLSET 0x00420U
  118. /* NT Inbound Doorbell Status/Mask (DWORD) */
  119. #define IDT_NT_INDBELLSTS 0x00428U
  120. #define IDT_NT_INDBELLMSK 0x0042CU
  121. /* Message registers */
  122. /* Outbound Message N (DWORD) */
  123. #define IDT_NT_OUTMSG0 0x00430U
  124. #define IDT_NT_OUTMSG1 0x00434U
  125. #define IDT_NT_OUTMSG2 0x00438U
  126. #define IDT_NT_OUTMSG3 0x0043CU
  127. /* Inbound Message N (DWORD) */
  128. #define IDT_NT_INMSG0 0x00440U
  129. #define IDT_NT_INMSG1 0x00444U
  130. #define IDT_NT_INMSG2 0x00448U
  131. #define IDT_NT_INMSG3 0x0044CU
  132. /* Inbound Message Source N (DWORD) */
  133. #define IDT_NT_INMSGSRC0 0x00450U
  134. #define IDT_NT_INMSGSRC1 0x00454U
  135. #define IDT_NT_INMSGSRC2 0x00458U
  136. #define IDT_NT_INMSGSRC3 0x0045CU
  137. /* Message Status (DWORD) */
  138. #define IDT_NT_MSGSTS 0x00460U
  139. /* Message Status Mask (DWORD) */
  140. #define IDT_NT_MSGSTSMSK 0x00464U
  141. /* BAR-setup registers */
  142. /* BAR N Setup/Limit Address/Lower and Upper Translated Base Address (DWORD) */
  143. #define IDT_NT_BARSETUP0 0x00470U
  144. #define IDT_NT_BARLIMIT0 0x00474U
  145. #define IDT_NT_BARLTBASE0 0x00478U
  146. #define IDT_NT_BARUTBASE0 0x0047CU
  147. #define IDT_NT_BARSETUP1 0x00480U
  148. #define IDT_NT_BARLIMIT1 0x00484U
  149. #define IDT_NT_BARLTBASE1 0x00488U
  150. #define IDT_NT_BARUTBASE1 0x0048CU
  151. #define IDT_NT_BARSETUP2 0x00490U
  152. #define IDT_NT_BARLIMIT2 0x00494U
  153. #define IDT_NT_BARLTBASE2 0x00498U
  154. #define IDT_NT_BARUTBASE2 0x0049CU
  155. #define IDT_NT_BARSETUP3 0x004A0U
  156. #define IDT_NT_BARLIMIT3 0x004A4U
  157. #define IDT_NT_BARLTBASE3 0x004A8U
  158. #define IDT_NT_BARUTBASE3 0x004ACU
  159. #define IDT_NT_BARSETUP4 0x004B0U
  160. #define IDT_NT_BARLIMIT4 0x004B4U
  161. #define IDT_NT_BARLTBASE4 0x004B8U
  162. #define IDT_NT_BARUTBASE4 0x004BCU
  163. #define IDT_NT_BARSETUP5 0x004C0U
  164. #define IDT_NT_BARLIMIT5 0x004C4U
  165. #define IDT_NT_BARLTBASE5 0x004C8U
  166. #define IDT_NT_BARUTBASE5 0x004CCU
  167. /* NT mapping table registers */
  168. /* NT Mapping Table Address/Status/Data (DWORD) */
  169. #define IDT_NT_NTMTBLADDR 0x004D0U
  170. #define IDT_NT_NTMTBLSTS 0x004D4U
  171. #define IDT_NT_NTMTBLDATA 0x004D8U
  172. /* Requester ID (Bus:Device:Function) Capture (DWORD) */
  173. #define IDT_NT_REQIDCAP 0x004DCU
  174. /* Memory Windows Lookup table registers */
  175. /* Lookup Table Offset/Lower, Middle and Upper data (DWORD) */
  176. #define IDT_NT_LUTOFFSET 0x004E0U
  177. #define IDT_NT_LUTLDATA 0x004E4U
  178. #define IDT_NT_LUTMDATA 0x004E8U
  179. #define IDT_NT_LUTUDATA 0x004ECU
  180. /* NT Endpoint Uncorrectable/Correctable Errors Emulation registers (DWORD) */
  181. #define IDT_NT_NTUEEM 0x004F0U
  182. #define IDT_NT_NTCEEM 0x004F4U
  183. /* Global Address Space Access/Data registers (DWARD) */
  184. #define IDT_NT_GASAADDR 0x00FF8U
  185. #define IDT_NT_GASADATA 0x00FFCU
  186. /*
  187. * IDT PCIe-switch Global Configuration and Status registers
  188. */
  189. /* Port N Configuration register in global space */
  190. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  191. #define IDT_SW_NTP0_PCIECMDSTS 0x01004U
  192. #define IDT_SW_NTP0_PCIELCTLSTS 0x01050U
  193. /* NT-function control register (DWORD) */
  194. #define IDT_SW_NTP0_NTCTL 0x01400U
  195. /* BAR setup/limit/base address registers (DWORD) */
  196. #define IDT_SW_NTP0_BARSETUP0 0x01470U
  197. #define IDT_SW_NTP0_BARLIMIT0 0x01474U
  198. #define IDT_SW_NTP0_BARLTBASE0 0x01478U
  199. #define IDT_SW_NTP0_BARUTBASE0 0x0147CU
  200. #define IDT_SW_NTP0_BARSETUP1 0x01480U
  201. #define IDT_SW_NTP0_BARLIMIT1 0x01484U
  202. #define IDT_SW_NTP0_BARLTBASE1 0x01488U
  203. #define IDT_SW_NTP0_BARUTBASE1 0x0148CU
  204. #define IDT_SW_NTP0_BARSETUP2 0x01490U
  205. #define IDT_SW_NTP0_BARLIMIT2 0x01494U
  206. #define IDT_SW_NTP0_BARLTBASE2 0x01498U
  207. #define IDT_SW_NTP0_BARUTBASE2 0x0149CU
  208. #define IDT_SW_NTP0_BARSETUP3 0x014A0U
  209. #define IDT_SW_NTP0_BARLIMIT3 0x014A4U
  210. #define IDT_SW_NTP0_BARLTBASE3 0x014A8U
  211. #define IDT_SW_NTP0_BARUTBASE3 0x014ACU
  212. #define IDT_SW_NTP0_BARSETUP4 0x014B0U
  213. #define IDT_SW_NTP0_BARLIMIT4 0x014B4U
  214. #define IDT_SW_NTP0_BARLTBASE4 0x014B8U
  215. #define IDT_SW_NTP0_BARUTBASE4 0x014BCU
  216. #define IDT_SW_NTP0_BARSETUP5 0x014C0U
  217. #define IDT_SW_NTP0_BARLIMIT5 0x014C4U
  218. #define IDT_SW_NTP0_BARLTBASE5 0x014C8U
  219. #define IDT_SW_NTP0_BARUTBASE5 0x014CCU
  220. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  221. #define IDT_SW_NTP2_PCIECMDSTS 0x05004U
  222. #define IDT_SW_NTP2_PCIELCTLSTS 0x05050U
  223. /* NT-function control register (DWORD) */
  224. #define IDT_SW_NTP2_NTCTL 0x05400U
  225. /* BAR setup/limit/base address registers (DWORD) */
  226. #define IDT_SW_NTP2_BARSETUP0 0x05470U
  227. #define IDT_SW_NTP2_BARLIMIT0 0x05474U
  228. #define IDT_SW_NTP2_BARLTBASE0 0x05478U
  229. #define IDT_SW_NTP2_BARUTBASE0 0x0547CU
  230. #define IDT_SW_NTP2_BARSETUP1 0x05480U
  231. #define IDT_SW_NTP2_BARLIMIT1 0x05484U
  232. #define IDT_SW_NTP2_BARLTBASE1 0x05488U
  233. #define IDT_SW_NTP2_BARUTBASE1 0x0548CU
  234. #define IDT_SW_NTP2_BARSETUP2 0x05490U
  235. #define IDT_SW_NTP2_BARLIMIT2 0x05494U
  236. #define IDT_SW_NTP2_BARLTBASE2 0x05498U
  237. #define IDT_SW_NTP2_BARUTBASE2 0x0549CU
  238. #define IDT_SW_NTP2_BARSETUP3 0x054A0U
  239. #define IDT_SW_NTP2_BARLIMIT3 0x054A4U
  240. #define IDT_SW_NTP2_BARLTBASE3 0x054A8U
  241. #define IDT_SW_NTP2_BARUTBASE3 0x054ACU
  242. #define IDT_SW_NTP2_BARSETUP4 0x054B0U
  243. #define IDT_SW_NTP2_BARLIMIT4 0x054B4U
  244. #define IDT_SW_NTP2_BARLTBASE4 0x054B8U
  245. #define IDT_SW_NTP2_BARUTBASE4 0x054BCU
  246. #define IDT_SW_NTP2_BARSETUP5 0x054C0U
  247. #define IDT_SW_NTP2_BARLIMIT5 0x054C4U
  248. #define IDT_SW_NTP2_BARLTBASE5 0x054C8U
  249. #define IDT_SW_NTP2_BARUTBASE5 0x054CCU
  250. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  251. #define IDT_SW_NTP4_PCIECMDSTS 0x09004U
  252. #define IDT_SW_NTP4_PCIELCTLSTS 0x09050U
  253. /* NT-function control register (DWORD) */
  254. #define IDT_SW_NTP4_NTCTL 0x09400U
  255. /* BAR setup/limit/base address registers (DWORD) */
  256. #define IDT_SW_NTP4_BARSETUP0 0x09470U
  257. #define IDT_SW_NTP4_BARLIMIT0 0x09474U
  258. #define IDT_SW_NTP4_BARLTBASE0 0x09478U
  259. #define IDT_SW_NTP4_BARUTBASE0 0x0947CU
  260. #define IDT_SW_NTP4_BARSETUP1 0x09480U
  261. #define IDT_SW_NTP4_BARLIMIT1 0x09484U
  262. #define IDT_SW_NTP4_BARLTBASE1 0x09488U
  263. #define IDT_SW_NTP4_BARUTBASE1 0x0948CU
  264. #define IDT_SW_NTP4_BARSETUP2 0x09490U
  265. #define IDT_SW_NTP4_BARLIMIT2 0x09494U
  266. #define IDT_SW_NTP4_BARLTBASE2 0x09498U
  267. #define IDT_SW_NTP4_BARUTBASE2 0x0949CU
  268. #define IDT_SW_NTP4_BARSETUP3 0x094A0U
  269. #define IDT_SW_NTP4_BARLIMIT3 0x094A4U
  270. #define IDT_SW_NTP4_BARLTBASE3 0x094A8U
  271. #define IDT_SW_NTP4_BARUTBASE3 0x094ACU
  272. #define IDT_SW_NTP4_BARSETUP4 0x094B0U
  273. #define IDT_SW_NTP4_BARLIMIT4 0x094B4U
  274. #define IDT_SW_NTP4_BARLTBASE4 0x094B8U
  275. #define IDT_SW_NTP4_BARUTBASE4 0x094BCU
  276. #define IDT_SW_NTP4_BARSETUP5 0x094C0U
  277. #define IDT_SW_NTP4_BARLIMIT5 0x094C4U
  278. #define IDT_SW_NTP4_BARLTBASE5 0x094C8U
  279. #define IDT_SW_NTP4_BARUTBASE5 0x094CCU
  280. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  281. #define IDT_SW_NTP6_PCIECMDSTS 0x0D004U
  282. #define IDT_SW_NTP6_PCIELCTLSTS 0x0D050U
  283. /* NT-function control register (DWORD) */
  284. #define IDT_SW_NTP6_NTCTL 0x0D400U
  285. /* BAR setup/limit/base address registers (DWORD) */
  286. #define IDT_SW_NTP6_BARSETUP0 0x0D470U
  287. #define IDT_SW_NTP6_BARLIMIT0 0x0D474U
  288. #define IDT_SW_NTP6_BARLTBASE0 0x0D478U
  289. #define IDT_SW_NTP6_BARUTBASE0 0x0D47CU
  290. #define IDT_SW_NTP6_BARSETUP1 0x0D480U
  291. #define IDT_SW_NTP6_BARLIMIT1 0x0D484U
  292. #define IDT_SW_NTP6_BARLTBASE1 0x0D488U
  293. #define IDT_SW_NTP6_BARUTBASE1 0x0D48CU
  294. #define IDT_SW_NTP6_BARSETUP2 0x0D490U
  295. #define IDT_SW_NTP6_BARLIMIT2 0x0D494U
  296. #define IDT_SW_NTP6_BARLTBASE2 0x0D498U
  297. #define IDT_SW_NTP6_BARUTBASE2 0x0D49CU
  298. #define IDT_SW_NTP6_BARSETUP3 0x0D4A0U
  299. #define IDT_SW_NTP6_BARLIMIT3 0x0D4A4U
  300. #define IDT_SW_NTP6_BARLTBASE3 0x0D4A8U
  301. #define IDT_SW_NTP6_BARUTBASE3 0x0D4ACU
  302. #define IDT_SW_NTP6_BARSETUP4 0x0D4B0U
  303. #define IDT_SW_NTP6_BARLIMIT4 0x0D4B4U
  304. #define IDT_SW_NTP6_BARLTBASE4 0x0D4B8U
  305. #define IDT_SW_NTP6_BARUTBASE4 0x0D4BCU
  306. #define IDT_SW_NTP6_BARSETUP5 0x0D4C0U
  307. #define IDT_SW_NTP6_BARLIMIT5 0x0D4C4U
  308. #define IDT_SW_NTP6_BARLTBASE5 0x0D4C8U
  309. #define IDT_SW_NTP6_BARUTBASE5 0x0D4CCU
  310. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  311. #define IDT_SW_NTP8_PCIECMDSTS 0x11004U
  312. #define IDT_SW_NTP8_PCIELCTLSTS 0x11050U
  313. /* NT-function control register (DWORD) */
  314. #define IDT_SW_NTP8_NTCTL 0x11400U
  315. /* BAR setup/limit/base address registers (DWORD) */
  316. #define IDT_SW_NTP8_BARSETUP0 0x11470U
  317. #define IDT_SW_NTP8_BARLIMIT0 0x11474U
  318. #define IDT_SW_NTP8_BARLTBASE0 0x11478U
  319. #define IDT_SW_NTP8_BARUTBASE0 0x1147CU
  320. #define IDT_SW_NTP8_BARSETUP1 0x11480U
  321. #define IDT_SW_NTP8_BARLIMIT1 0x11484U
  322. #define IDT_SW_NTP8_BARLTBASE1 0x11488U
  323. #define IDT_SW_NTP8_BARUTBASE1 0x1148CU
  324. #define IDT_SW_NTP8_BARSETUP2 0x11490U
  325. #define IDT_SW_NTP8_BARLIMIT2 0x11494U
  326. #define IDT_SW_NTP8_BARLTBASE2 0x11498U
  327. #define IDT_SW_NTP8_BARUTBASE2 0x1149CU
  328. #define IDT_SW_NTP8_BARSETUP3 0x114A0U
  329. #define IDT_SW_NTP8_BARLIMIT3 0x114A4U
  330. #define IDT_SW_NTP8_BARLTBASE3 0x114A8U
  331. #define IDT_SW_NTP8_BARUTBASE3 0x114ACU
  332. #define IDT_SW_NTP8_BARSETUP4 0x114B0U
  333. #define IDT_SW_NTP8_BARLIMIT4 0x114B4U
  334. #define IDT_SW_NTP8_BARLTBASE4 0x114B8U
  335. #define IDT_SW_NTP8_BARUTBASE4 0x114BCU
  336. #define IDT_SW_NTP8_BARSETUP5 0x114C0U
  337. #define IDT_SW_NTP8_BARLIMIT5 0x114C4U
  338. #define IDT_SW_NTP8_BARLTBASE5 0x114C8U
  339. #define IDT_SW_NTP8_BARUTBASE5 0x114CCU
  340. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  341. #define IDT_SW_NTP12_PCIECMDSTS 0x19004U
  342. #define IDT_SW_NTP12_PCIELCTLSTS 0x19050U
  343. /* NT-function control register (DWORD) */
  344. #define IDT_SW_NTP12_NTCTL 0x19400U
  345. /* BAR setup/limit/base address registers (DWORD) */
  346. #define IDT_SW_NTP12_BARSETUP0 0x19470U
  347. #define IDT_SW_NTP12_BARLIMIT0 0x19474U
  348. #define IDT_SW_NTP12_BARLTBASE0 0x19478U
  349. #define IDT_SW_NTP12_BARUTBASE0 0x1947CU
  350. #define IDT_SW_NTP12_BARSETUP1 0x19480U
  351. #define IDT_SW_NTP12_BARLIMIT1 0x19484U
  352. #define IDT_SW_NTP12_BARLTBASE1 0x19488U
  353. #define IDT_SW_NTP12_BARUTBASE1 0x1948CU
  354. #define IDT_SW_NTP12_BARSETUP2 0x19490U
  355. #define IDT_SW_NTP12_BARLIMIT2 0x19494U
  356. #define IDT_SW_NTP12_BARLTBASE2 0x19498U
  357. #define IDT_SW_NTP12_BARUTBASE2 0x1949CU
  358. #define IDT_SW_NTP12_BARSETUP3 0x194A0U
  359. #define IDT_SW_NTP12_BARLIMIT3 0x194A4U
  360. #define IDT_SW_NTP12_BARLTBASE3 0x194A8U
  361. #define IDT_SW_NTP12_BARUTBASE3 0x194ACU
  362. #define IDT_SW_NTP12_BARSETUP4 0x194B0U
  363. #define IDT_SW_NTP12_BARLIMIT4 0x194B4U
  364. #define IDT_SW_NTP12_BARLTBASE4 0x194B8U
  365. #define IDT_SW_NTP12_BARUTBASE4 0x194BCU
  366. #define IDT_SW_NTP12_BARSETUP5 0x194C0U
  367. #define IDT_SW_NTP12_BARLIMIT5 0x194C4U
  368. #define IDT_SW_NTP12_BARLTBASE5 0x194C8U
  369. #define IDT_SW_NTP12_BARUTBASE5 0x194CCU
  370. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  371. #define IDT_SW_NTP16_PCIECMDSTS 0x21004U
  372. #define IDT_SW_NTP16_PCIELCTLSTS 0x21050U
  373. /* NT-function control register (DWORD) */
  374. #define IDT_SW_NTP16_NTCTL 0x21400U
  375. /* BAR setup/limit/base address registers (DWORD) */
  376. #define IDT_SW_NTP16_BARSETUP0 0x21470U
  377. #define IDT_SW_NTP16_BARLIMIT0 0x21474U
  378. #define IDT_SW_NTP16_BARLTBASE0 0x21478U
  379. #define IDT_SW_NTP16_BARUTBASE0 0x2147CU
  380. #define IDT_SW_NTP16_BARSETUP1 0x21480U
  381. #define IDT_SW_NTP16_BARLIMIT1 0x21484U
  382. #define IDT_SW_NTP16_BARLTBASE1 0x21488U
  383. #define IDT_SW_NTP16_BARUTBASE1 0x2148CU
  384. #define IDT_SW_NTP16_BARSETUP2 0x21490U
  385. #define IDT_SW_NTP16_BARLIMIT2 0x21494U
  386. #define IDT_SW_NTP16_BARLTBASE2 0x21498U
  387. #define IDT_SW_NTP16_BARUTBASE2 0x2149CU
  388. #define IDT_SW_NTP16_BARSETUP3 0x214A0U
  389. #define IDT_SW_NTP16_BARLIMIT3 0x214A4U
  390. #define IDT_SW_NTP16_BARLTBASE3 0x214A8U
  391. #define IDT_SW_NTP16_BARUTBASE3 0x214ACU
  392. #define IDT_SW_NTP16_BARSETUP4 0x214B0U
  393. #define IDT_SW_NTP16_BARLIMIT4 0x214B4U
  394. #define IDT_SW_NTP16_BARLTBASE4 0x214B8U
  395. #define IDT_SW_NTP16_BARUTBASE4 0x214BCU
  396. #define IDT_SW_NTP16_BARSETUP5 0x214C0U
  397. #define IDT_SW_NTP16_BARLIMIT5 0x214C4U
  398. #define IDT_SW_NTP16_BARLTBASE5 0x214C8U
  399. #define IDT_SW_NTP16_BARUTBASE5 0x214CCU
  400. /* PCI Express command/status and link control/status registers (WORD+WORD) */
  401. #define IDT_SW_NTP20_PCIECMDSTS 0x29004U
  402. #define IDT_SW_NTP20_PCIELCTLSTS 0x29050U
  403. /* NT-function control register (DWORD) */
  404. #define IDT_SW_NTP20_NTCTL 0x29400U
  405. /* BAR setup/limit/base address registers (DWORD) */
  406. #define IDT_SW_NTP20_BARSETUP0 0x29470U
  407. #define IDT_SW_NTP20_BARLIMIT0 0x29474U
  408. #define IDT_SW_NTP20_BARLTBASE0 0x29478U
  409. #define IDT_SW_NTP20_BARUTBASE0 0x2947CU
  410. #define IDT_SW_NTP20_BARSETUP1 0x29480U
  411. #define IDT_SW_NTP20_BARLIMIT1 0x29484U
  412. #define IDT_SW_NTP20_BARLTBASE1 0x29488U
  413. #define IDT_SW_NTP20_BARUTBASE1 0x2948CU
  414. #define IDT_SW_NTP20_BARSETUP2 0x29490U
  415. #define IDT_SW_NTP20_BARLIMIT2 0x29494U
  416. #define IDT_SW_NTP20_BARLTBASE2 0x29498U
  417. #define IDT_SW_NTP20_BARUTBASE2 0x2949CU
  418. #define IDT_SW_NTP20_BARSETUP3 0x294A0U
  419. #define IDT_SW_NTP20_BARLIMIT3 0x294A4U
  420. #define IDT_SW_NTP20_BARLTBASE3 0x294A8U
  421. #define IDT_SW_NTP20_BARUTBASE3 0x294ACU
  422. #define IDT_SW_NTP20_BARSETUP4 0x294B0U
  423. #define IDT_SW_NTP20_BARLIMIT4 0x294B4U
  424. #define IDT_SW_NTP20_BARLTBASE4 0x294B8U
  425. #define IDT_SW_NTP20_BARUTBASE4 0x294BCU
  426. #define IDT_SW_NTP20_BARSETUP5 0x294C0U
  427. #define IDT_SW_NTP20_BARLIMIT5 0x294C4U
  428. #define IDT_SW_NTP20_BARLTBASE5 0x294C8U
  429. #define IDT_SW_NTP20_BARUTBASE5 0x294CCU
  430. /* IDT PCIe-switch control register (DWORD) */
  431. #define IDT_SW_CTL 0x3E000U
  432. /* Boot Configuration Vector Status (DWORD) */
  433. #define IDT_SW_BCVSTS 0x3E004U
  434. /* Port Clocking Mode (DWORD) */
  435. #define IDT_SW_PCLKMODE 0x3E008U
  436. /* Reset Drain Delay (DWORD) */
  437. #define IDT_SW_RDRAINDELAY 0x3E080U
  438. /* Port Operating Mode Change Drain Delay (DWORD) */
  439. #define IDT_SW_POMCDELAY 0x3E084U
  440. /* Side Effect Delay (DWORD) */
  441. #define IDT_SW_SEDELAY 0x3E088U
  442. /* Upstream Secondary Bus Reset Delay (DWORD) */
  443. #define IDT_SW_SSBRDELAY 0x3E08CU
  444. /* Switch partition N Control/Status/Failover registers */
  445. #define IDT_SW_SWPART0CTL 0x3E100U
  446. #define IDT_SW_SWPART0STS 0x3E104U
  447. #define IDT_SW_SWPART0FCTL 0x3E108U
  448. #define IDT_SW_SWPART1CTL 0x3E120U
  449. #define IDT_SW_SWPART1STS 0x3E124U
  450. #define IDT_SW_SWPART1FCTL 0x3E128U
  451. #define IDT_SW_SWPART2CTL 0x3E140U
  452. #define IDT_SW_SWPART2STS 0x3E144U
  453. #define IDT_SW_SWPART2FCTL 0x3E148U
  454. #define IDT_SW_SWPART3CTL 0x3E160U
  455. #define IDT_SW_SWPART3STS 0x3E164U
  456. #define IDT_SW_SWPART3FCTL 0x3E168U
  457. #define IDT_SW_SWPART4CTL 0x3E180U
  458. #define IDT_SW_SWPART4STS 0x3E184U
  459. #define IDT_SW_SWPART4FCTL 0x3E188U
  460. #define IDT_SW_SWPART5CTL 0x3E1A0U
  461. #define IDT_SW_SWPART5STS 0x3E1A4U
  462. #define IDT_SW_SWPART5FCTL 0x3E1A8U
  463. #define IDT_SW_SWPART6CTL 0x3E1C0U
  464. #define IDT_SW_SWPART6STS 0x3E1C4U
  465. #define IDT_SW_SWPART6FCTL 0x3E1C8U
  466. #define IDT_SW_SWPART7CTL 0x3E1E0U
  467. #define IDT_SW_SWPART7STS 0x3E1E4U
  468. #define IDT_SW_SWPART7FCTL 0x3E1E8U
  469. /* Switch port N control and status registers */
  470. #define IDT_SW_SWPORT0CTL 0x3E200U
  471. #define IDT_SW_SWPORT0STS 0x3E204U
  472. #define IDT_SW_SWPORT0FCTL 0x3E208U
  473. #define IDT_SW_SWPORT2CTL 0x3E240U
  474. #define IDT_SW_SWPORT2STS 0x3E244U
  475. #define IDT_SW_SWPORT2FCTL 0x3E248U
  476. #define IDT_SW_SWPORT4CTL 0x3E280U
  477. #define IDT_SW_SWPORT4STS 0x3E284U
  478. #define IDT_SW_SWPORT4FCTL 0x3E288U
  479. #define IDT_SW_SWPORT6CTL 0x3E2C0U
  480. #define IDT_SW_SWPORT6STS 0x3E2C4U
  481. #define IDT_SW_SWPORT6FCTL 0x3E2C8U
  482. #define IDT_SW_SWPORT8CTL 0x3E300U
  483. #define IDT_SW_SWPORT8STS 0x3E304U
  484. #define IDT_SW_SWPORT8FCTL 0x3E308U
  485. #define IDT_SW_SWPORT12CTL 0x3E380U
  486. #define IDT_SW_SWPORT12STS 0x3E384U
  487. #define IDT_SW_SWPORT12FCTL 0x3E388U
  488. #define IDT_SW_SWPORT16CTL 0x3E400U
  489. #define IDT_SW_SWPORT16STS 0x3E404U
  490. #define IDT_SW_SWPORT16FCTL 0x3E408U
  491. #define IDT_SW_SWPORT20CTL 0x3E480U
  492. #define IDT_SW_SWPORT20STS 0x3E484U
  493. #define IDT_SW_SWPORT20FCTL 0x3E488U
  494. /* Switch Event registers */
  495. /* Switch Event Status/Mask/Partition mask (DWORD) */
  496. #define IDT_SW_SESTS 0x3EC00U
  497. #define IDT_SW_SEMSK 0x3EC04U
  498. #define IDT_SW_SEPMSK 0x3EC08U
  499. /* Switch Event Link Up/Down Status/Mask (DWORD) */
  500. #define IDT_SW_SELINKUPSTS 0x3EC0CU
  501. #define IDT_SW_SELINKUPMSK 0x3EC10U
  502. #define IDT_SW_SELINKDNSTS 0x3EC14U
  503. #define IDT_SW_SELINKDNMSK 0x3EC18U
  504. /* Switch Event Fundamental Reset Status/Mask (DWORD) */
  505. #define IDT_SW_SEFRSTSTS 0x3EC1CU
  506. #define IDT_SW_SEFRSTMSK 0x3EC20U
  507. /* Switch Event Hot Reset Status/Mask (DWORD) */
  508. #define IDT_SW_SEHRSTSTS 0x3EC24U
  509. #define IDT_SW_SEHRSTMSK 0x3EC28U
  510. /* Switch Event Failover Mask (DWORD) */
  511. #define IDT_SW_SEFOVRMSK 0x3EC2CU
  512. /* Switch Event Global Signal Status/Mask (DWORD) */
  513. #define IDT_SW_SEGSIGSTS 0x3EC30U
  514. #define IDT_SW_SEGSIGMSK 0x3EC34U
  515. /* NT Global Doorbell Status (DWORD) */
  516. #define IDT_SW_GDBELLSTS 0x3EC3CU
  517. /* Switch partition N message M control (msgs routing table) (DWORD) */
  518. #define IDT_SW_SWP0MSGCTL0 0x3EE00U
  519. #define IDT_SW_SWP1MSGCTL0 0x3EE04U
  520. #define IDT_SW_SWP2MSGCTL0 0x3EE08U
  521. #define IDT_SW_SWP3MSGCTL0 0x3EE0CU
  522. #define IDT_SW_SWP4MSGCTL0 0x3EE10U
  523. #define IDT_SW_SWP5MSGCTL0 0x3EE14U
  524. #define IDT_SW_SWP6MSGCTL0 0x3EE18U
  525. #define IDT_SW_SWP7MSGCTL0 0x3EE1CU
  526. #define IDT_SW_SWP0MSGCTL1 0x3EE20U
  527. #define IDT_SW_SWP1MSGCTL1 0x3EE24U
  528. #define IDT_SW_SWP2MSGCTL1 0x3EE28U
  529. #define IDT_SW_SWP3MSGCTL1 0x3EE2CU
  530. #define IDT_SW_SWP4MSGCTL1 0x3EE30U
  531. #define IDT_SW_SWP5MSGCTL1 0x3EE34U
  532. #define IDT_SW_SWP6MSGCTL1 0x3EE38U
  533. #define IDT_SW_SWP7MSGCTL1 0x3EE3CU
  534. #define IDT_SW_SWP0MSGCTL2 0x3EE40U
  535. #define IDT_SW_SWP1MSGCTL2 0x3EE44U
  536. #define IDT_SW_SWP2MSGCTL2 0x3EE48U
  537. #define IDT_SW_SWP3MSGCTL2 0x3EE4CU
  538. #define IDT_SW_SWP4MSGCTL2 0x3EE50U
  539. #define IDT_SW_SWP5MSGCTL2 0x3EE54U
  540. #define IDT_SW_SWP6MSGCTL2 0x3EE58U
  541. #define IDT_SW_SWP7MSGCTL2 0x3EE5CU
  542. #define IDT_SW_SWP0MSGCTL3 0x3EE60U
  543. #define IDT_SW_SWP1MSGCTL3 0x3EE64U
  544. #define IDT_SW_SWP2MSGCTL3 0x3EE68U
  545. #define IDT_SW_SWP3MSGCTL3 0x3EE6CU
  546. #define IDT_SW_SWP4MSGCTL3 0x3EE70U
  547. #define IDT_SW_SWP5MSGCTL3 0x3EE74U
  548. #define IDT_SW_SWP6MSGCTL3 0x3EE78U
  549. #define IDT_SW_SWP7MSGCTL3 0x3EE7CU
  550. /* SMBus Status and Control registers (DWORD) */
  551. #define IDT_SW_SMBUSSTS 0x3F188U
  552. #define IDT_SW_SMBUSCTL 0x3F18CU
  553. /* Serial EEPROM Interface (DWORD) */
  554. #define IDT_SW_EEPROMINTF 0x3F190U
  555. /* MBus I/O Expander Address N (DWORD) */
  556. #define IDT_SW_IOEXPADDR0 0x3F198U
  557. #define IDT_SW_IOEXPADDR1 0x3F19CU
  558. #define IDT_SW_IOEXPADDR2 0x3F1A0U
  559. #define IDT_SW_IOEXPADDR3 0x3F1A4U
  560. #define IDT_SW_IOEXPADDR4 0x3F1A8U
  561. #define IDT_SW_IOEXPADDR5 0x3F1ACU
  562. /* General Purpose Events Control and Status registers (DWORD) */
  563. #define IDT_SW_GPECTL 0x3F1B0U
  564. #define IDT_SW_GPESTS 0x3F1B4U
  565. /* Temperature sensor Control/Status/Alarm/Adjustment/Slope registers */
  566. #define IDT_SW_TMPCTL 0x3F1D4U
  567. #define IDT_SW_TMPSTS 0x3F1D8U
  568. #define IDT_SW_TMPALARM 0x3F1DCU
  569. #define IDT_SW_TMPADJ 0x3F1E0U
  570. #define IDT_SW_TSSLOPE 0x3F1E4U
  571. /* SMBus Configuration Block header log (DWORD) */
  572. #define IDT_SW_SMBUSCBHL 0x3F1E8U
  573. /*
  574. * Common registers related constants
  575. * @IDT_REG_ALIGN: Registers alignment used in the driver
  576. * @IDT_REG_PCI_MAX: Maximum PCI configuration space register value
  577. * @IDT_REG_SW_MAX: Maximum global register value
  578. */
  579. #define IDT_REG_ALIGN 4
  580. #define IDT_REG_PCI_MAX 0x00FFFU
  581. #define IDT_REG_SW_MAX 0x3FFFFU
  582. /*
  583. * PCICMDSTS register fields related constants
  584. * @IDT_PCICMDSTS_IOAE: I/O access enable
  585. * @IDT_PCICMDSTS_MAE: Memory access enable
  586. * @IDT_PCICMDSTS_BME: Bus master enable
  587. */
  588. #define IDT_PCICMDSTS_IOAE 0x00000001U
  589. #define IDT_PCICMDSTS_MAE 0x00000002U
  590. #define IDT_PCICMDSTS_BME 0x00000004U
  591. /*
  592. * PCIEDCAP register fields related constants
  593. * @IDT_PCIEDCAP_MPAYLOAD_MASK: Maximum payload size mask
  594. * @IDT_PCIEDCAP_MPAYLOAD_FLD: Maximum payload size field offset
  595. * @IDT_PCIEDCAP_MPAYLOAD_S128: Max supported payload size of 128 bytes
  596. * @IDT_PCIEDCAP_MPAYLOAD_S256: Max supported payload size of 256 bytes
  597. * @IDT_PCIEDCAP_MPAYLOAD_S512: Max supported payload size of 512 bytes
  598. * @IDT_PCIEDCAP_MPAYLOAD_S1024: Max supported payload size of 1024 bytes
  599. * @IDT_PCIEDCAP_MPAYLOAD_S2048: Max supported payload size of 2048 bytes
  600. */
  601. #define IDT_PCIEDCAP_MPAYLOAD_MASK 0x00000007U
  602. #define IDT_PCIEDCAP_MPAYLOAD_FLD 0
  603. #define IDT_PCIEDCAP_MPAYLOAD_S128 0x00000000U
  604. #define IDT_PCIEDCAP_MPAYLOAD_S256 0x00000001U
  605. #define IDT_PCIEDCAP_MPAYLOAD_S512 0x00000002U
  606. #define IDT_PCIEDCAP_MPAYLOAD_S1024 0x00000003U
  607. #define IDT_PCIEDCAP_MPAYLOAD_S2048 0x00000004U
  608. /*
  609. * PCIEDCTLSTS registers fields related constants
  610. * @IDT_PCIEDCTL_MPS_MASK: Maximum payload size mask
  611. * @IDT_PCIEDCTL_MPS_FLD: MPS field offset
  612. * @IDT_PCIEDCTL_MPS_S128: Max payload size of 128 bytes
  613. * @IDT_PCIEDCTL_MPS_S256: Max payload size of 256 bytes
  614. * @IDT_PCIEDCTL_MPS_S512: Max payload size of 512 bytes
  615. * @IDT_PCIEDCTL_MPS_S1024: Max payload size of 1024 bytes
  616. * @IDT_PCIEDCTL_MPS_S2048: Max payload size of 2048 bytes
  617. * @IDT_PCIEDCTL_MPS_S4096: Max payload size of 4096 bytes
  618. */
  619. #define IDT_PCIEDCTLSTS_MPS_MASK 0x000000E0U
  620. #define IDT_PCIEDCTLSTS_MPS_FLD 5
  621. #define IDT_PCIEDCTLSTS_MPS_S128 0x00000000U
  622. #define IDT_PCIEDCTLSTS_MPS_S256 0x00000020U
  623. #define IDT_PCIEDCTLSTS_MPS_S512 0x00000040U
  624. #define IDT_PCIEDCTLSTS_MPS_S1024 0x00000060U
  625. #define IDT_PCIEDCTLSTS_MPS_S2048 0x00000080U
  626. #define IDT_PCIEDCTLSTS_MPS_S4096 0x000000A0U
  627. /*
  628. * PCIELCAP register fields related constants
  629. * @IDT_PCIELCAP_PORTNUM_MASK: Port number field mask
  630. * @IDT_PCIELCAP_PORTNUM_FLD: Port number field offset
  631. */
  632. #define IDT_PCIELCAP_PORTNUM_MASK 0xFF000000U
  633. #define IDT_PCIELCAP_PORTNUM_FLD 24
  634. /*
  635. * PCIELCTLSTS registers fields related constants
  636. * @IDT_PCIELSTS_CLS_MASK: Current link speed mask
  637. * @IDT_PCIELSTS_CLS_FLD: Current link speed field offset
  638. * @IDT_PCIELSTS_NLW_MASK: Negotiated link width mask
  639. * @IDT_PCIELSTS_NLW_FLD: Negotiated link width field offset
  640. * @IDT_PCIELSTS_SCLK_COM: Common slot clock configuration
  641. */
  642. #define IDT_PCIELCTLSTS_CLS_MASK 0x000F0000U
  643. #define IDT_PCIELCTLSTS_CLS_FLD 16
  644. #define IDT_PCIELCTLSTS_NLW_MASK 0x03F00000U
  645. #define IDT_PCIELCTLSTS_NLW_FLD 20
  646. #define IDT_PCIELCTLSTS_SCLK_COM 0x10000000U
  647. /*
  648. * NTCTL register fields related constants
  649. * @IDT_NTCTL_IDPROTDIS: ID Protection check disable (disable MTBL)
  650. * @IDT_NTCTL_CPEN: Completion enable
  651. * @IDT_NTCTL_RNS: Request no snoop processing (if MTBL disabled)
  652. * @IDT_NTCTL_ATP: Address type processing (if MTBL disabled)
  653. */
  654. #define IDT_NTCTL_IDPROTDIS 0x00000001U
  655. #define IDT_NTCTL_CPEN 0x00000002U
  656. #define IDT_NTCTL_RNS 0x00000004U
  657. #define IDT_NTCTL_ATP 0x00000008U
  658. /*
  659. * NTINTSTS register fields related constants
  660. * @IDT_NTINTSTS_MSG: Message interrupt bit
  661. * @IDT_NTINTSTS_DBELL: Doorbell interrupt bit
  662. * @IDT_NTINTSTS_SEVENT: Switch Event interrupt bit
  663. * @IDT_NTINTSTS_TMPSENSOR: Temperature sensor interrupt bit
  664. */
  665. #define IDT_NTINTSTS_MSG 0x00000001U
  666. #define IDT_NTINTSTS_DBELL 0x00000002U
  667. #define IDT_NTINTSTS_SEVENT 0x00000008U
  668. #define IDT_NTINTSTS_TMPSENSOR 0x00000080U
  669. /*
  670. * NTINTMSK register fields related constants
  671. * @IDT_NTINTMSK_MSG: Message interrupt mask bit
  672. * @IDT_NTINTMSK_DBELL: Doorbell interrupt mask bit
  673. * @IDT_NTINTMSK_SEVENT: Switch Event interrupt mask bit
  674. * @IDT_NTINTMSK_TMPSENSOR: Temperature sensor interrupt mask bit
  675. * @IDT_NTINTMSK_ALL: All the useful interrupts mask
  676. */
  677. #define IDT_NTINTMSK_MSG 0x00000001U
  678. #define IDT_NTINTMSK_DBELL 0x00000002U
  679. #define IDT_NTINTMSK_SEVENT 0x00000008U
  680. #define IDT_NTINTMSK_TMPSENSOR 0x00000080U
  681. #define IDT_NTINTMSK_ALL \
  682. (IDT_NTINTMSK_MSG | IDT_NTINTMSK_DBELL | \
  683. IDT_NTINTMSK_SEVENT | IDT_NTINTMSK_TMPSENSOR)
  684. /*
  685. * NTGSIGNAL register fields related constants
  686. * @IDT_NTGSIGNAL_SET: Set global signal of the local partition
  687. */
  688. #define IDT_NTGSIGNAL_SET 0x00000001U
  689. /*
  690. * BARSETUP register fields related constants
  691. * @IDT_BARSETUP_TYPE_MASK: Mask of the TYPE field
  692. * @IDT_BARSETUP_TYPE_32: 32-bit addressing BAR
  693. * @IDT_BARSETUP_TYPE_64: 64-bit addressing BAR
  694. * @IDT_BARSETUP_PREF: Value of the BAR prefetchable field
  695. * @IDT_BARSETUP_SIZE_MASK: Mask of the SIZE field
  696. * @IDT_BARSETUP_SIZE_FLD: SIZE field offset
  697. * @IDT_BARSETUP_SIZE_CFG: SIZE field value in case of config space MODE
  698. * @IDT_BARSETUP_MODE_CFG: Configuration space BAR mode
  699. * @IDT_BARSETUP_ATRAN_MASK: ATRAN field mask
  700. * @IDT_BARSETUP_ATRAN_FLD: ATRAN field offset
  701. * @IDT_BARSETUP_ATRAN_DIR: Direct address translation memory window
  702. * @IDT_BARSETUP_ATRAN_LUT12: 12-entry lookup table
  703. * @IDT_BARSETUP_ATRAN_LUT24: 24-entry lookup table
  704. * @IDT_BARSETUP_TPART_MASK: TPART field mask
  705. * @IDT_BARSETUP_TPART_FLD: TPART field offset
  706. * @IDT_BARSETUP_EN: BAR enable bit
  707. */
  708. #define IDT_BARSETUP_TYPE_MASK 0x00000006U
  709. #define IDT_BARSETUP_TYPE_FLD 0
  710. #define IDT_BARSETUP_TYPE_32 0x00000000U
  711. #define IDT_BARSETUP_TYPE_64 0x00000004U
  712. #define IDT_BARSETUP_PREF 0x00000008U
  713. #define IDT_BARSETUP_SIZE_MASK 0x000003F0U
  714. #define IDT_BARSETUP_SIZE_FLD 4
  715. #define IDT_BARSETUP_SIZE_CFG 0x000000C0U
  716. #define IDT_BARSETUP_MODE_CFG 0x00000400U
  717. #define IDT_BARSETUP_ATRAN_MASK 0x00001800U
  718. #define IDT_BARSETUP_ATRAN_FLD 11
  719. #define IDT_BARSETUP_ATRAN_DIR 0x00000000U
  720. #define IDT_BARSETUP_ATRAN_LUT12 0x00000800U
  721. #define IDT_BARSETUP_ATRAN_LUT24 0x00001000U
  722. #define IDT_BARSETUP_TPART_MASK 0x0000E000U
  723. #define IDT_BARSETUP_TPART_FLD 13
  724. #define IDT_BARSETUP_EN 0x80000000U
  725. /*
  726. * NTMTBLDATA register fields related constants
  727. * @IDT_NTMTBLDATA_VALID: Set the MTBL entry being valid
  728. * @IDT_NTMTBLDATA_REQID_MASK: Bus:Device:Function field mask
  729. * @IDT_NTMTBLDATA_REQID_FLD: Bus:Device:Function field offset
  730. * @IDT_NTMTBLDATA_PART_MASK: Partition field mask
  731. * @IDT_NTMTBLDATA_PART_FLD: Partition field offset
  732. * @IDT_NTMTBLDATA_ATP_TRANS: Enable AT field translation on request TLPs
  733. * @IDT_NTMTBLDATA_CNS_INV: Enable No Snoop attribute inversion of
  734. * Completion TLPs
  735. * @IDT_NTMTBLDATA_RNS_INV: Enable No Snoop attribute inversion of
  736. * Request TLPs
  737. */
  738. #define IDT_NTMTBLDATA_VALID 0x00000001U
  739. #define IDT_NTMTBLDATA_REQID_MASK 0x0001FFFEU
  740. #define IDT_NTMTBLDATA_REQID_FLD 1
  741. #define IDT_NTMTBLDATA_PART_MASK 0x000E0000U
  742. #define IDT_NTMTBLDATA_PART_FLD 17
  743. #define IDT_NTMTBLDATA_ATP_TRANS 0x20000000U
  744. #define IDT_NTMTBLDATA_CNS_INV 0x40000000U
  745. #define IDT_NTMTBLDATA_RNS_INV 0x80000000U
  746. /*
  747. * REQIDCAP register fields related constants
  748. * @IDT_REQIDCAP_REQID_MASK: Request ID field mask
  749. * @IDT_REQIDCAP_REQID_FLD: Request ID field offset
  750. */
  751. #define IDT_REQIDCAP_REQID_MASK 0x0000FFFFU
  752. #define IDT_REQIDCAP_REQID_FLD 0
  753. /*
  754. * LUTOFFSET register fields related constants
  755. * @IDT_LUTOFFSET_INDEX_MASK: Lookup table index field mask
  756. * @IDT_LUTOFFSET_INDEX_FLD: Lookup table index field offset
  757. * @IDT_LUTOFFSET_BAR_MASK: Lookup table BAR select field mask
  758. * @IDT_LUTOFFSET_BAR_FLD: Lookup table BAR select field offset
  759. */
  760. #define IDT_LUTOFFSET_INDEX_MASK 0x0000001FU
  761. #define IDT_LUTOFFSET_INDEX_FLD 0
  762. #define IDT_LUTOFFSET_BAR_MASK 0x00000700U
  763. #define IDT_LUTOFFSET_BAR_FLD 8
  764. /*
  765. * LUTUDATA register fields related constants
  766. * @IDT_LUTUDATA_PART_MASK: Partition field mask
  767. * @IDT_LUTUDATA_PART_FLD: Partition field offset
  768. * @IDT_LUTUDATA_VALID: Lookup table entry valid bit
  769. */
  770. #define IDT_LUTUDATA_PART_MASK 0x0000000FU
  771. #define IDT_LUTUDATA_PART_FLD 0
  772. #define IDT_LUTUDATA_VALID 0x80000000U
  773. /*
  774. * SWPARTxSTS register fields related constants
  775. * @IDT_SWPARTxSTS_SCI: Switch partition state change initiated
  776. * @IDT_SWPARTxSTS_SCC: Switch partition state change completed
  777. * @IDT_SWPARTxSTS_STATE_MASK: Switch partition state mask
  778. * @IDT_SWPARTxSTS_STATE_FLD: Switch partition state field offset
  779. * @IDT_SWPARTxSTS_STATE_DIS: Switch partition disabled
  780. * @IDT_SWPARTxSTS_STATE_ACT: Switch partition enabled
  781. * @IDT_SWPARTxSTS_STATE_RES: Switch partition in reset
  782. * @IDT_SWPARTxSTS_US: Switch partition has upstream port
  783. * @IDT_SWPARTxSTS_USID_MASK: Switch partition upstream port ID mask
  784. * @IDT_SWPARTxSTS_USID_FLD: Switch partition upstream port ID field offset
  785. * @IDT_SWPARTxSTS_NT: Upstream port has NT function
  786. * @IDT_SWPARTxSTS_DMA: Upstream port has DMA function
  787. */
  788. #define IDT_SWPARTxSTS_SCI 0x00000001U
  789. #define IDT_SWPARTxSTS_SCC 0x00000002U
  790. #define IDT_SWPARTxSTS_STATE_MASK 0x00000060U
  791. #define IDT_SWPARTxSTS_STATE_FLD 5
  792. #define IDT_SWPARTxSTS_STATE_DIS 0x00000000U
  793. #define IDT_SWPARTxSTS_STATE_ACT 0x00000020U
  794. #define IDT_SWPARTxSTS_STATE_RES 0x00000060U
  795. #define IDT_SWPARTxSTS_US 0x00000100U
  796. #define IDT_SWPARTxSTS_USID_MASK 0x00003E00U
  797. #define IDT_SWPARTxSTS_USID_FLD 9
  798. #define IDT_SWPARTxSTS_NT 0x00004000U
  799. #define IDT_SWPARTxSTS_DMA 0x00008000U
  800. /*
  801. * SWPORTxSTS register fields related constants
  802. * @IDT_SWPORTxSTS_OMCI: Operation mode change initiated
  803. * @IDT_SWPORTxSTS_OMCC: Operation mode change completed
  804. * @IDT_SWPORTxSTS_LINKUP: Link up status
  805. * @IDT_SWPORTxSTS_DS: Port lanes behave as downstream lanes
  806. * @IDT_SWPORTxSTS_MODE_MASK: Port mode field mask
  807. * @IDT_SWPORTxSTS_MODE_FLD: Port mode field offset
  808. * @IDT_SWPORTxSTS_MODE_DIS: Port mode - disabled
  809. * @IDT_SWPORTxSTS_MODE_DS: Port mode - downstream switch port
  810. * @IDT_SWPORTxSTS_MODE_US: Port mode - upstream switch port
  811. * @IDT_SWPORTxSTS_MODE_NT: Port mode - NT function
  812. * @IDT_SWPORTxSTS_MODE_USNT: Port mode - upstream switch port with NTB
  813. * @IDT_SWPORTxSTS_MODE_UNAT: Port mode - unattached
  814. * @IDT_SWPORTxSTS_MODE_USDMA: Port mode - upstream switch port with DMA
  815. * @IDT_SWPORTxSTS_MODE_USNTDMA:Port mode - upstream port with NTB and DMA
  816. * @IDT_SWPORTxSTS_MODE_NTDMA: Port mode - NT function with DMA
  817. * @IDT_SWPORTxSTS_SWPART_MASK: Port partition field mask
  818. * @IDT_SWPORTxSTS_SWPART_FLD: Port partition field offset
  819. * @IDT_SWPORTxSTS_DEVNUM_MASK: Port device number field mask
  820. * @IDT_SWPORTxSTS_DEVNUM_FLD: Port device number field offset
  821. */
  822. #define IDT_SWPORTxSTS_OMCI 0x00000001U
  823. #define IDT_SWPORTxSTS_OMCC 0x00000002U
  824. #define IDT_SWPORTxSTS_LINKUP 0x00000010U
  825. #define IDT_SWPORTxSTS_DS 0x00000020U
  826. #define IDT_SWPORTxSTS_MODE_MASK 0x000003C0U
  827. #define IDT_SWPORTxSTS_MODE_FLD 6
  828. #define IDT_SWPORTxSTS_MODE_DIS 0x00000000U
  829. #define IDT_SWPORTxSTS_MODE_DS 0x00000040U
  830. #define IDT_SWPORTxSTS_MODE_US 0x00000080U
  831. #define IDT_SWPORTxSTS_MODE_NT 0x000000C0U
  832. #define IDT_SWPORTxSTS_MODE_USNT 0x00000100U
  833. #define IDT_SWPORTxSTS_MODE_UNAT 0x00000140U
  834. #define IDT_SWPORTxSTS_MODE_USDMA 0x00000180U
  835. #define IDT_SWPORTxSTS_MODE_USNTDMA 0x000001C0U
  836. #define IDT_SWPORTxSTS_MODE_NTDMA 0x00000200U
  837. #define IDT_SWPORTxSTS_SWPART_MASK 0x00001C00U
  838. #define IDT_SWPORTxSTS_SWPART_FLD 10
  839. #define IDT_SWPORTxSTS_DEVNUM_MASK 0x001F0000U
  840. #define IDT_SWPORTxSTS_DEVNUM_FLD 16
  841. /*
  842. * SEMSK register fields related constants
  843. * @IDT_SEMSK_LINKUP: Link Up event mask bit
  844. * @IDT_SEMSK_LINKDN: Link Down event mask bit
  845. * @IDT_SEMSK_GSIGNAL: Global Signal event mask bit
  846. */
  847. #define IDT_SEMSK_LINKUP 0x00000001U
  848. #define IDT_SEMSK_LINKDN 0x00000002U
  849. #define IDT_SEMSK_GSIGNAL 0x00000020U
  850. /*
  851. * SWPxMSGCTL register fields related constants
  852. * @IDT_SWPxMSGCTL_REG_MASK: Register select field mask
  853. * @IDT_SWPxMSGCTL_REG_FLD: Register select field offset
  854. * @IDT_SWPxMSGCTL_PART_MASK: Partition select field mask
  855. * @IDT_SWPxMSGCTL_PART_FLD: Partition select field offset
  856. */
  857. #define IDT_SWPxMSGCTL_REG_MASK 0x00000003U
  858. #define IDT_SWPxMSGCTL_REG_FLD 0
  859. #define IDT_SWPxMSGCTL_PART_MASK 0x00000070U
  860. #define IDT_SWPxMSGCTL_PART_FLD 4
  861. /*
  862. * TMPSTS register fields related constants
  863. * @IDT_TMPSTS_TEMP_MASK: Current temperature field mask
  864. * @IDT_TMPSTS_TEMP_FLD: Current temperature field offset
  865. */
  866. #define IDT_TMPSTS_TEMP_MASK 0x000000FFU
  867. #define IDT_TMPSTS_TEMP_FLD 0
  868. /*
  869. * Helper macro to get/set the corresponding field value
  870. * @GET_FIELD: Retrieve the value of the corresponding field
  871. * @SET_FIELD: Set the specified field up
  872. * @IS_FLD_SET: Check whether a field is set with value
  873. */
  874. #define GET_FIELD(field, data) \
  875. (((u32)(data) & IDT_ ##field## _MASK) >> IDT_ ##field## _FLD)
  876. #define SET_FIELD(field, data, value) \
  877. (((u32)(data) & ~IDT_ ##field## _MASK) | \
  878. ((u32)(value) << IDT_ ##field## _FLD))
  879. #define IS_FLD_SET(field, data, value) \
  880. (((u32)(data) & IDT_ ##field## _MASK) == IDT_ ##field## _ ##value)
  881. /*
  882. * Useful registers masks:
  883. * @IDT_DBELL_MASK: Doorbell bits mask
  884. * @IDT_OUTMSG_MASK: Out messages status bits mask
  885. * @IDT_INMSG_MASK: In messages status bits mask
  886. * @IDT_MSG_MASK: Any message status bits mask
  887. */
  888. #define IDT_DBELL_MASK ((u32)0xFFFFFFFFU)
  889. #define IDT_OUTMSG_MASK ((u32)0x0000000FU)
  890. #define IDT_INMSG_MASK ((u32)0x000F0000U)
  891. #define IDT_MSG_MASK (IDT_INMSG_MASK | IDT_OUTMSG_MASK)
  892. /*
  893. * Number of IDT NTB resources:
  894. * @IDT_MSG_CNT: Number of Message registers
  895. * @IDT_BAR_CNT: Number of BARs of each port
  896. * @IDT_MTBL_ENTRY_CNT: Number mapping table entries
  897. */
  898. #define IDT_MSG_CNT 4
  899. #define IDT_BAR_CNT 6
  900. #define IDT_MTBL_ENTRY_CNT 64
  901. /*
  902. * General IDT PCIe-switch constant
  903. * @IDT_MAX_NR_PORTS: Maximum number of ports per IDT PCIe-switch
  904. * @IDT_MAX_NR_PARTS: Maximum number of partitions per IDT PCIe-switch
  905. * @IDT_MAX_NR_PEERS: Maximum number of NT-peers per IDT PCIe-switch
  906. * @IDT_MAX_NR_MWS: Maximum number of Memory Widows
  907. * @IDT_PCIE_REGSIZE: Size of the registers in bytes
  908. * @IDT_TRANS_ALIGN: Alignment of translated base address
  909. * @IDT_DIR_SIZE_ALIGN: Alignment of size setting for direct translated MWs.
  910. * Even though the lower 10 bits are reserved, they are
  911. * treated by IDT as one's so basically there is no any
  912. * alignment of size limit for DIR address translation.
  913. */
  914. #define IDT_MAX_NR_PORTS 24
  915. #define IDT_MAX_NR_PARTS 8
  916. #define IDT_MAX_NR_PEERS 8
  917. #define IDT_MAX_NR_MWS 29
  918. #define IDT_PCIE_REGSIZE 4
  919. #define IDT_TRANS_ALIGN 4
  920. #define IDT_DIR_SIZE_ALIGN 1
  921. /*
  922. * IDT Memory Windows type. Depending on the device settings, IDT supports
  923. * Direct Address Translation MW registers and Lookup Table registers
  924. * @IDT_MW_DIR: Direct address translation
  925. * @IDT_MW_LUT12: 12-entry lookup table entry
  926. * @IDT_MW_LUT24: 24-entry lookup table entry
  927. *
  928. * NOTE These values are exactly the same as one of the BARSETUP ATRAN field
  929. */
  930. enum idt_mw_type {
  931. IDT_MW_DIR = 0x0,
  932. IDT_MW_LUT12 = 0x1,
  933. IDT_MW_LUT24 = 0x2
  934. };
  935. /*
  936. * IDT PCIe-switch model private data
  937. * @name: Device name
  938. * @port_cnt: Total number of NT endpoint ports
  939. * @ports: Port ids
  940. */
  941. struct idt_89hpes_cfg {
  942. char *name;
  943. unsigned char port_cnt;
  944. unsigned char ports[];
  945. };
  946. /*
  947. * Memory window configuration structure
  948. * @type: Type of the memory window (direct address translation or lookup
  949. * table)
  950. *
  951. * @bar: PCIe BAR the memory window referenced to
  952. * @idx: Index of the memory window within the BAR
  953. *
  954. * @addr_align: Alignment of translated address
  955. * @size_align: Alignment of memory window size
  956. * @size_max: Maximum size of memory window
  957. */
  958. struct idt_mw_cfg {
  959. enum idt_mw_type type;
  960. unsigned char bar;
  961. unsigned char idx;
  962. u64 addr_align;
  963. u64 size_align;
  964. u64 size_max;
  965. };
  966. /*
  967. * Description structure of peer IDT NT-functions:
  968. * @port: NT-function port
  969. * @part: NT-function partition
  970. *
  971. * @mw_cnt: Number of memory windows supported by NT-function
  972. * @mws: Array of memory windows descriptors
  973. */
  974. struct idt_ntb_peer {
  975. unsigned char port;
  976. unsigned char part;
  977. unsigned char mw_cnt;
  978. struct idt_mw_cfg *mws;
  979. };
  980. /*
  981. * Description structure of local IDT NT-function:
  982. * @ntb: Linux NTB-device description structure
  983. * @swcfg: Pointer to the structure of local IDT PCIe-switch
  984. * specific cofnfigurations
  985. *
  986. * @port: Local NT-function port
  987. * @part: Local NT-function partition
  988. *
  989. * @peer_cnt: Number of peers with activated NTB-function
  990. * @peers: Array of peers descripting structures
  991. * @port_idx_map: Map of port number -> peer index
  992. * @part_idx_map: Map of partition number -> peer index
  993. *
  994. * @mtbl_lock: Mapping table access lock
  995. *
  996. * @mw_cnt: Number of memory windows supported by NT-function
  997. * @mws: Array of memory windows descriptors
  998. * @lut_lock: Lookup table access lock
  999. *
  1000. * @msg_locks: Message registers mapping table lockers
  1001. *
  1002. * @cfgspc: Virtual address of the memory mapped configuration
  1003. * space of the NT-function
  1004. * @db_mask_lock: Doorbell mask register lock
  1005. * @msg_mask_lock: Message mask register lock
  1006. * @gasa_lock: GASA registers access lock
  1007. *
  1008. * @dbgfs_info: DebugFS info node
  1009. */
  1010. struct idt_ntb_dev {
  1011. struct ntb_dev ntb;
  1012. struct idt_89hpes_cfg *swcfg;
  1013. unsigned char port;
  1014. unsigned char part;
  1015. unsigned char peer_cnt;
  1016. struct idt_ntb_peer peers[IDT_MAX_NR_PEERS];
  1017. char port_idx_map[IDT_MAX_NR_PORTS];
  1018. char part_idx_map[IDT_MAX_NR_PARTS];
  1019. spinlock_t mtbl_lock;
  1020. unsigned char mw_cnt;
  1021. struct idt_mw_cfg *mws;
  1022. spinlock_t lut_lock;
  1023. spinlock_t msg_locks[IDT_MSG_CNT];
  1024. void __iomem *cfgspc;
  1025. spinlock_t db_mask_lock;
  1026. spinlock_t msg_mask_lock;
  1027. spinlock_t gasa_lock;
  1028. struct dentry *dbgfs_info;
  1029. };
  1030. #define to_ndev_ntb(__ntb) container_of(__ntb, struct idt_ntb_dev, ntb)
  1031. /*
  1032. * Descriptor of the IDT PCIe-switch BAR resources
  1033. * @setup: BAR setup register
  1034. * @limit: BAR limit register
  1035. * @ltbase: Lower translated base address
  1036. * @utbase: Upper translated base address
  1037. */
  1038. struct idt_ntb_bar {
  1039. unsigned int setup;
  1040. unsigned int limit;
  1041. unsigned int ltbase;
  1042. unsigned int utbase;
  1043. };
  1044. /*
  1045. * Descriptor of the IDT PCIe-switch message resources
  1046. * @in: Inbound message register
  1047. * @out: Outbound message register
  1048. * @src: Source of inbound message register
  1049. */
  1050. struct idt_ntb_msg {
  1051. unsigned int in;
  1052. unsigned int out;
  1053. unsigned int src;
  1054. };
  1055. /*
  1056. * Descriptor of the IDT PCIe-switch NT-function specific parameters in the
  1057. * PCI Configuration Space
  1058. * @bars: BARs related registers
  1059. * @msgs: Messaging related registers
  1060. */
  1061. struct idt_ntb_regs {
  1062. struct idt_ntb_bar bars[IDT_BAR_CNT];
  1063. struct idt_ntb_msg msgs[IDT_MSG_CNT];
  1064. };
  1065. /*
  1066. * Descriptor of the IDT PCIe-switch port specific parameters in the
  1067. * Global Configuration Space
  1068. * @pcicmdsts: PCI command/status register
  1069. * @pcielctlsts: PCIe link control/status
  1070. *
  1071. * @ctl: Port control register
  1072. * @sts: Port status register
  1073. *
  1074. * @bars: BARs related registers
  1075. */
  1076. struct idt_ntb_port {
  1077. unsigned int pcicmdsts;
  1078. unsigned int pcielctlsts;
  1079. unsigned int ntctl;
  1080. unsigned int ctl;
  1081. unsigned int sts;
  1082. struct idt_ntb_bar bars[IDT_BAR_CNT];
  1083. };
  1084. /*
  1085. * Descriptor of the IDT PCIe-switch partition specific parameters.
  1086. * @ctl: Partition control register in the Global Address Space
  1087. * @sts: Partition status register in the Global Address Space
  1088. * @msgctl: Messages control registers
  1089. */
  1090. struct idt_ntb_part {
  1091. unsigned int ctl;
  1092. unsigned int sts;
  1093. unsigned int msgctl[IDT_MSG_CNT];
  1094. };
  1095. #endif /* NTB_HW_IDT_H */