ipath_iba6120.c 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  1. /*
  2. * Copyright (c) 2006 QLogic, Inc. All rights reserved.
  3. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. /*
  34. * This file contains all of the code that is specific to the
  35. * InfiniPath PCIe chip.
  36. */
  37. #include <linux/interrupt.h>
  38. #include <linux/pci.h>
  39. #include <linux/delay.h>
  40. #include "ipath_kernel.h"
  41. #include "ipath_registers.h"
  42. /*
  43. * This file contains all the chip-specific register information and
  44. * access functions for the QLogic InfiniPath PCI-Express chip.
  45. *
  46. * This lists the InfiniPath registers, in the actual chip layout.
  47. * This structure should never be directly accessed.
  48. */
  49. struct _infinipath_do_not_use_kernel_regs {
  50. unsigned long long Revision;
  51. unsigned long long Control;
  52. unsigned long long PageAlign;
  53. unsigned long long PortCnt;
  54. unsigned long long DebugPortSelect;
  55. unsigned long long Reserved0;
  56. unsigned long long SendRegBase;
  57. unsigned long long UserRegBase;
  58. unsigned long long CounterRegBase;
  59. unsigned long long Scratch;
  60. unsigned long long Reserved1;
  61. unsigned long long Reserved2;
  62. unsigned long long IntBlocked;
  63. unsigned long long IntMask;
  64. unsigned long long IntStatus;
  65. unsigned long long IntClear;
  66. unsigned long long ErrorMask;
  67. unsigned long long ErrorStatus;
  68. unsigned long long ErrorClear;
  69. unsigned long long HwErrMask;
  70. unsigned long long HwErrStatus;
  71. unsigned long long HwErrClear;
  72. unsigned long long HwDiagCtrl;
  73. unsigned long long MDIO;
  74. unsigned long long IBCStatus;
  75. unsigned long long IBCCtrl;
  76. unsigned long long ExtStatus;
  77. unsigned long long ExtCtrl;
  78. unsigned long long GPIOOut;
  79. unsigned long long GPIOMask;
  80. unsigned long long GPIOStatus;
  81. unsigned long long GPIOClear;
  82. unsigned long long RcvCtrl;
  83. unsigned long long RcvBTHQP;
  84. unsigned long long RcvHdrSize;
  85. unsigned long long RcvHdrCnt;
  86. unsigned long long RcvHdrEntSize;
  87. unsigned long long RcvTIDBase;
  88. unsigned long long RcvTIDCnt;
  89. unsigned long long RcvEgrBase;
  90. unsigned long long RcvEgrCnt;
  91. unsigned long long RcvBufBase;
  92. unsigned long long RcvBufSize;
  93. unsigned long long RxIntMemBase;
  94. unsigned long long RxIntMemSize;
  95. unsigned long long RcvPartitionKey;
  96. unsigned long long Reserved3;
  97. unsigned long long RcvPktLEDCnt;
  98. unsigned long long Reserved4[8];
  99. unsigned long long SendCtrl;
  100. unsigned long long SendPIOBufBase;
  101. unsigned long long SendPIOSize;
  102. unsigned long long SendPIOBufCnt;
  103. unsigned long long SendPIOAvailAddr;
  104. unsigned long long TxIntMemBase;
  105. unsigned long long TxIntMemSize;
  106. unsigned long long Reserved5;
  107. unsigned long long PCIeRBufTestReg0;
  108. unsigned long long PCIeRBufTestReg1;
  109. unsigned long long Reserved51[6];
  110. unsigned long long SendBufferError;
  111. unsigned long long SendBufferErrorCONT1;
  112. unsigned long long Reserved6SBE[6];
  113. unsigned long long RcvHdrAddr0;
  114. unsigned long long RcvHdrAddr1;
  115. unsigned long long RcvHdrAddr2;
  116. unsigned long long RcvHdrAddr3;
  117. unsigned long long RcvHdrAddr4;
  118. unsigned long long Reserved7RHA[11];
  119. unsigned long long RcvHdrTailAddr0;
  120. unsigned long long RcvHdrTailAddr1;
  121. unsigned long long RcvHdrTailAddr2;
  122. unsigned long long RcvHdrTailAddr3;
  123. unsigned long long RcvHdrTailAddr4;
  124. unsigned long long Reserved8RHTA[11];
  125. unsigned long long Reserved9SW[8];
  126. unsigned long long SerdesConfig0;
  127. unsigned long long SerdesConfig1;
  128. unsigned long long SerdesStatus;
  129. unsigned long long XGXSConfig;
  130. unsigned long long IBPLLCfg;
  131. unsigned long long Reserved10SW2[3];
  132. unsigned long long PCIEQ0SerdesConfig0;
  133. unsigned long long PCIEQ0SerdesConfig1;
  134. unsigned long long PCIEQ0SerdesStatus;
  135. unsigned long long Reserved11;
  136. unsigned long long PCIEQ1SerdesConfig0;
  137. unsigned long long PCIEQ1SerdesConfig1;
  138. unsigned long long PCIEQ1SerdesStatus;
  139. unsigned long long Reserved12;
  140. };
  141. #define IPATH_KREG_OFFSET(field) (offsetof(struct \
  142. _infinipath_do_not_use_kernel_regs, field) / sizeof(u64))
  143. #define IPATH_CREG_OFFSET(field) (offsetof( \
  144. struct infinipath_counters, field) / sizeof(u64))
  145. static const struct ipath_kregs ipath_pe_kregs = {
  146. .kr_control = IPATH_KREG_OFFSET(Control),
  147. .kr_counterregbase = IPATH_KREG_OFFSET(CounterRegBase),
  148. .kr_debugportselect = IPATH_KREG_OFFSET(DebugPortSelect),
  149. .kr_errorclear = IPATH_KREG_OFFSET(ErrorClear),
  150. .kr_errormask = IPATH_KREG_OFFSET(ErrorMask),
  151. .kr_errorstatus = IPATH_KREG_OFFSET(ErrorStatus),
  152. .kr_extctrl = IPATH_KREG_OFFSET(ExtCtrl),
  153. .kr_extstatus = IPATH_KREG_OFFSET(ExtStatus),
  154. .kr_gpio_clear = IPATH_KREG_OFFSET(GPIOClear),
  155. .kr_gpio_mask = IPATH_KREG_OFFSET(GPIOMask),
  156. .kr_gpio_out = IPATH_KREG_OFFSET(GPIOOut),
  157. .kr_gpio_status = IPATH_KREG_OFFSET(GPIOStatus),
  158. .kr_hwdiagctrl = IPATH_KREG_OFFSET(HwDiagCtrl),
  159. .kr_hwerrclear = IPATH_KREG_OFFSET(HwErrClear),
  160. .kr_hwerrmask = IPATH_KREG_OFFSET(HwErrMask),
  161. .kr_hwerrstatus = IPATH_KREG_OFFSET(HwErrStatus),
  162. .kr_ibcctrl = IPATH_KREG_OFFSET(IBCCtrl),
  163. .kr_ibcstatus = IPATH_KREG_OFFSET(IBCStatus),
  164. .kr_intblocked = IPATH_KREG_OFFSET(IntBlocked),
  165. .kr_intclear = IPATH_KREG_OFFSET(IntClear),
  166. .kr_intmask = IPATH_KREG_OFFSET(IntMask),
  167. .kr_intstatus = IPATH_KREG_OFFSET(IntStatus),
  168. .kr_mdio = IPATH_KREG_OFFSET(MDIO),
  169. .kr_pagealign = IPATH_KREG_OFFSET(PageAlign),
  170. .kr_partitionkey = IPATH_KREG_OFFSET(RcvPartitionKey),
  171. .kr_portcnt = IPATH_KREG_OFFSET(PortCnt),
  172. .kr_rcvbthqp = IPATH_KREG_OFFSET(RcvBTHQP),
  173. .kr_rcvbufbase = IPATH_KREG_OFFSET(RcvBufBase),
  174. .kr_rcvbufsize = IPATH_KREG_OFFSET(RcvBufSize),
  175. .kr_rcvctrl = IPATH_KREG_OFFSET(RcvCtrl),
  176. .kr_rcvegrbase = IPATH_KREG_OFFSET(RcvEgrBase),
  177. .kr_rcvegrcnt = IPATH_KREG_OFFSET(RcvEgrCnt),
  178. .kr_rcvhdrcnt = IPATH_KREG_OFFSET(RcvHdrCnt),
  179. .kr_rcvhdrentsize = IPATH_KREG_OFFSET(RcvHdrEntSize),
  180. .kr_rcvhdrsize = IPATH_KREG_OFFSET(RcvHdrSize),
  181. .kr_rcvintmembase = IPATH_KREG_OFFSET(RxIntMemBase),
  182. .kr_rcvintmemsize = IPATH_KREG_OFFSET(RxIntMemSize),
  183. .kr_rcvtidbase = IPATH_KREG_OFFSET(RcvTIDBase),
  184. .kr_rcvtidcnt = IPATH_KREG_OFFSET(RcvTIDCnt),
  185. .kr_revision = IPATH_KREG_OFFSET(Revision),
  186. .kr_scratch = IPATH_KREG_OFFSET(Scratch),
  187. .kr_sendbuffererror = IPATH_KREG_OFFSET(SendBufferError),
  188. .kr_sendctrl = IPATH_KREG_OFFSET(SendCtrl),
  189. .kr_sendpioavailaddr = IPATH_KREG_OFFSET(SendPIOAvailAddr),
  190. .kr_sendpiobufbase = IPATH_KREG_OFFSET(SendPIOBufBase),
  191. .kr_sendpiobufcnt = IPATH_KREG_OFFSET(SendPIOBufCnt),
  192. .kr_sendpiosize = IPATH_KREG_OFFSET(SendPIOSize),
  193. .kr_sendregbase = IPATH_KREG_OFFSET(SendRegBase),
  194. .kr_txintmembase = IPATH_KREG_OFFSET(TxIntMemBase),
  195. .kr_txintmemsize = IPATH_KREG_OFFSET(TxIntMemSize),
  196. .kr_userregbase = IPATH_KREG_OFFSET(UserRegBase),
  197. .kr_serdesconfig0 = IPATH_KREG_OFFSET(SerdesConfig0),
  198. .kr_serdesconfig1 = IPATH_KREG_OFFSET(SerdesConfig1),
  199. .kr_serdesstatus = IPATH_KREG_OFFSET(SerdesStatus),
  200. .kr_xgxsconfig = IPATH_KREG_OFFSET(XGXSConfig),
  201. .kr_ibpllcfg = IPATH_KREG_OFFSET(IBPLLCfg),
  202. /*
  203. * These should not be used directly via ipath_read_kreg64(),
  204. * use them with ipath_read_kreg64_port()
  205. */
  206. .kr_rcvhdraddr = IPATH_KREG_OFFSET(RcvHdrAddr0),
  207. .kr_rcvhdrtailaddr = IPATH_KREG_OFFSET(RcvHdrTailAddr0),
  208. /* The rcvpktled register controls one of the debug port signals, so
  209. * a packet activity LED can be connected to it. */
  210. .kr_rcvpktledcnt = IPATH_KREG_OFFSET(RcvPktLEDCnt),
  211. .kr_pcierbuftestreg0 = IPATH_KREG_OFFSET(PCIeRBufTestReg0),
  212. .kr_pcierbuftestreg1 = IPATH_KREG_OFFSET(PCIeRBufTestReg1),
  213. .kr_pcieq0serdesconfig0 = IPATH_KREG_OFFSET(PCIEQ0SerdesConfig0),
  214. .kr_pcieq0serdesconfig1 = IPATH_KREG_OFFSET(PCIEQ0SerdesConfig1),
  215. .kr_pcieq0serdesstatus = IPATH_KREG_OFFSET(PCIEQ0SerdesStatus),
  216. .kr_pcieq1serdesconfig0 = IPATH_KREG_OFFSET(PCIEQ1SerdesConfig0),
  217. .kr_pcieq1serdesconfig1 = IPATH_KREG_OFFSET(PCIEQ1SerdesConfig1),
  218. .kr_pcieq1serdesstatus = IPATH_KREG_OFFSET(PCIEQ1SerdesStatus)
  219. };
  220. static const struct ipath_cregs ipath_pe_cregs = {
  221. .cr_badformatcnt = IPATH_CREG_OFFSET(RxBadFormatCnt),
  222. .cr_erricrccnt = IPATH_CREG_OFFSET(RxICRCErrCnt),
  223. .cr_errlinkcnt = IPATH_CREG_OFFSET(RxLinkProblemCnt),
  224. .cr_errlpcrccnt = IPATH_CREG_OFFSET(RxLPCRCErrCnt),
  225. .cr_errpkey = IPATH_CREG_OFFSET(RxPKeyMismatchCnt),
  226. .cr_errrcvflowctrlcnt = IPATH_CREG_OFFSET(RxFlowCtrlErrCnt),
  227. .cr_err_rlencnt = IPATH_CREG_OFFSET(RxLenErrCnt),
  228. .cr_errslencnt = IPATH_CREG_OFFSET(TxLenErrCnt),
  229. .cr_errtidfull = IPATH_CREG_OFFSET(RxTIDFullErrCnt),
  230. .cr_errtidvalid = IPATH_CREG_OFFSET(RxTIDValidErrCnt),
  231. .cr_errvcrccnt = IPATH_CREG_OFFSET(RxVCRCErrCnt),
  232. .cr_ibstatuschange = IPATH_CREG_OFFSET(IBStatusChangeCnt),
  233. .cr_intcnt = IPATH_CREG_OFFSET(LBIntCnt),
  234. .cr_invalidrlencnt = IPATH_CREG_OFFSET(RxMaxMinLenErrCnt),
  235. .cr_invalidslencnt = IPATH_CREG_OFFSET(TxMaxMinLenErrCnt),
  236. .cr_lbflowstallcnt = IPATH_CREG_OFFSET(LBFlowStallCnt),
  237. .cr_pktrcvcnt = IPATH_CREG_OFFSET(RxDataPktCnt),
  238. .cr_pktrcvflowctrlcnt = IPATH_CREG_OFFSET(RxFlowPktCnt),
  239. .cr_pktsendcnt = IPATH_CREG_OFFSET(TxDataPktCnt),
  240. .cr_pktsendflowcnt = IPATH_CREG_OFFSET(TxFlowPktCnt),
  241. .cr_portovflcnt = IPATH_CREG_OFFSET(RxP0HdrEgrOvflCnt),
  242. .cr_rcvebpcnt = IPATH_CREG_OFFSET(RxEBPCnt),
  243. .cr_rcvovflcnt = IPATH_CREG_OFFSET(RxBufOvflCnt),
  244. .cr_senddropped = IPATH_CREG_OFFSET(TxDroppedPktCnt),
  245. .cr_sendstallcnt = IPATH_CREG_OFFSET(TxFlowStallCnt),
  246. .cr_sendunderruncnt = IPATH_CREG_OFFSET(TxUnderrunCnt),
  247. .cr_wordrcvcnt = IPATH_CREG_OFFSET(RxDwordCnt),
  248. .cr_wordsendcnt = IPATH_CREG_OFFSET(TxDwordCnt),
  249. .cr_unsupvlcnt = IPATH_CREG_OFFSET(TxUnsupVLErrCnt),
  250. .cr_rxdroppktcnt = IPATH_CREG_OFFSET(RxDroppedPktCnt),
  251. .cr_iblinkerrrecovcnt = IPATH_CREG_OFFSET(IBLinkErrRecoveryCnt),
  252. .cr_iblinkdowncnt = IPATH_CREG_OFFSET(IBLinkDownedCnt),
  253. .cr_ibsymbolerrcnt = IPATH_CREG_OFFSET(IBSymbolErrCnt)
  254. };
  255. /* kr_intstatus, kr_intclear, kr_intmask bits */
  256. #define INFINIPATH_I_RCVURG_MASK ((1U<<5)-1)
  257. #define INFINIPATH_I_RCVAVAIL_MASK ((1U<<5)-1)
  258. /* kr_hwerrclear, kr_hwerrmask, kr_hwerrstatus, bits */
  259. #define INFINIPATH_HWE_PCIEMEMPARITYERR_MASK 0x000000000000003fULL
  260. #define INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT 0
  261. #define INFINIPATH_HWE_PCIEPOISONEDTLP 0x0000000010000000ULL
  262. #define INFINIPATH_HWE_PCIECPLTIMEOUT 0x0000000020000000ULL
  263. #define INFINIPATH_HWE_PCIEBUSPARITYXTLH 0x0000000040000000ULL
  264. #define INFINIPATH_HWE_PCIEBUSPARITYXADM 0x0000000080000000ULL
  265. #define INFINIPATH_HWE_PCIEBUSPARITYRADM 0x0000000100000000ULL
  266. #define INFINIPATH_HWE_COREPLL_FBSLIP 0x0080000000000000ULL
  267. #define INFINIPATH_HWE_COREPLL_RFSLIP 0x0100000000000000ULL
  268. #define INFINIPATH_HWE_PCIE1PLLFAILED 0x0400000000000000ULL
  269. #define INFINIPATH_HWE_PCIE0PLLFAILED 0x0800000000000000ULL
  270. #define INFINIPATH_HWE_SERDESPLLFAILED 0x1000000000000000ULL
  271. /* kr_extstatus bits */
  272. #define INFINIPATH_EXTS_FREQSEL 0x2
  273. #define INFINIPATH_EXTS_SERDESSEL 0x4
  274. #define INFINIPATH_EXTS_MEMBIST_ENDTEST 0x0000000000004000
  275. #define INFINIPATH_EXTS_MEMBIST_FOUND 0x0000000000008000
  276. #define _IPATH_GPIO_SDA_NUM 1
  277. #define _IPATH_GPIO_SCL_NUM 0
  278. #define IPATH_GPIO_SDA (1ULL << \
  279. (_IPATH_GPIO_SDA_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
  280. #define IPATH_GPIO_SCL (1ULL << \
  281. (_IPATH_GPIO_SCL_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
  282. /*
  283. * Rev2 silicon allows suppressing check for ArmLaunch errors.
  284. * this can speed up short packet sends on systems that do
  285. * not guaranteee write-order.
  286. */
  287. #define INFINIPATH_XGXS_SUPPRESS_ARMLAUNCH_ERR (1ULL<<63)
  288. /* 6120 specific hardware errors... */
  289. static const struct ipath_hwerror_msgs ipath_6120_hwerror_msgs[] = {
  290. INFINIPATH_HWE_MSG(PCIEPOISONEDTLP, "PCIe Poisoned TLP"),
  291. INFINIPATH_HWE_MSG(PCIECPLTIMEOUT, "PCIe completion timeout"),
  292. /*
  293. * In practice, it's unlikely wthat we'll see PCIe PLL, or bus
  294. * parity or memory parity error failures, because most likely we
  295. * won't be able to talk to the core of the chip. Nonetheless, we
  296. * might see them, if they are in parts of the PCIe core that aren't
  297. * essential.
  298. */
  299. INFINIPATH_HWE_MSG(PCIE1PLLFAILED, "PCIePLL1"),
  300. INFINIPATH_HWE_MSG(PCIE0PLLFAILED, "PCIePLL0"),
  301. INFINIPATH_HWE_MSG(PCIEBUSPARITYXTLH, "PCIe XTLH core parity"),
  302. INFINIPATH_HWE_MSG(PCIEBUSPARITYXADM, "PCIe ADM TX core parity"),
  303. INFINIPATH_HWE_MSG(PCIEBUSPARITYRADM, "PCIe ADM RX core parity"),
  304. INFINIPATH_HWE_MSG(RXDSYNCMEMPARITYERR, "Rx Dsync"),
  305. INFINIPATH_HWE_MSG(SERDESPLLFAILED, "SerDes PLL"),
  306. };
  307. /**
  308. * ipath_pe_handle_hwerrors - display hardware errors.
  309. * @dd: the infinipath device
  310. * @msg: the output buffer
  311. * @msgl: the size of the output buffer
  312. *
  313. * Use same msg buffer as regular errors to avoid excessive stack
  314. * use. Most hardware errors are catastrophic, but for right now,
  315. * we'll print them and continue. We reuse the same message buffer as
  316. * ipath_handle_errors() to avoid excessive stack usage.
  317. */
  318. static void ipath_pe_handle_hwerrors(struct ipath_devdata *dd, char *msg,
  319. size_t msgl)
  320. {
  321. ipath_err_t hwerrs;
  322. u32 bits, ctrl;
  323. int isfatal = 0;
  324. char bitsmsg[64];
  325. hwerrs = ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus);
  326. if (!hwerrs) {
  327. /*
  328. * better than printing cofusing messages
  329. * This seems to be related to clearing the crc error, or
  330. * the pll error during init.
  331. */
  332. ipath_cdbg(VERBOSE, "Called but no hardware errors set\n");
  333. return;
  334. } else if (hwerrs == ~0ULL) {
  335. ipath_dev_err(dd, "Read of hardware error status failed "
  336. "(all bits set); ignoring\n");
  337. return;
  338. }
  339. ipath_stats.sps_hwerrs++;
  340. /* Always clear the error status register, except MEMBISTFAIL,
  341. * regardless of whether we continue or stop using the chip.
  342. * We want that set so we know it failed, even across driver reload.
  343. * We'll still ignore it in the hwerrmask. We do this partly for
  344. * diagnostics, but also for support */
  345. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,
  346. hwerrs&~INFINIPATH_HWE_MEMBISTFAILED);
  347. hwerrs &= dd->ipath_hwerrmask;
  348. /*
  349. * make sure we get this much out, unless told to be quiet,
  350. * or it's occurred within the last 5 seconds
  351. */
  352. if ((hwerrs & ~(dd->ipath_lasthwerror |
  353. ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF |
  354. INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC)
  355. << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT))) ||
  356. (ipath_debug & __IPATH_VERBDBG))
  357. dev_info(&dd->pcidev->dev, "Hardware error: hwerr=0x%llx "
  358. "(cleared)\n", (unsigned long long) hwerrs);
  359. dd->ipath_lasthwerror |= hwerrs;
  360. if (hwerrs & ~dd->ipath_hwe_bitsextant)
  361. ipath_dev_err(dd, "hwerror interrupt with unknown errors "
  362. "%llx set\n", (unsigned long long)
  363. (hwerrs & ~dd->ipath_hwe_bitsextant));
  364. ctrl = ipath_read_kreg32(dd, dd->ipath_kregs->kr_control);
  365. if (ctrl & INFINIPATH_C_FREEZEMODE) {
  366. /*
  367. * parity errors in send memory are recoverable,
  368. * just cancel the send (if indicated in * sendbuffererror),
  369. * count the occurrence, unfreeze (if no other handled
  370. * hardware error bits are set), and continue. They can
  371. * occur if a processor speculative read is done to the PIO
  372. * buffer while we are sending a packet, for example.
  373. */
  374. if (hwerrs & ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF |
  375. INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC)
  376. << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT)) {
  377. ipath_stats.sps_txeparity++;
  378. ipath_dbg("Recovering from TXE parity error (%llu), "
  379. "hwerrstatus=%llx\n",
  380. (unsigned long long) ipath_stats.sps_txeparity,
  381. (unsigned long long) hwerrs);
  382. ipath_disarm_senderrbufs(dd);
  383. hwerrs &= ~((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF |
  384. INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC)
  385. << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT);
  386. if (!hwerrs) { /* else leave in freeze mode */
  387. ipath_write_kreg(dd,
  388. dd->ipath_kregs->kr_control,
  389. dd->ipath_control);
  390. return;
  391. }
  392. }
  393. if (hwerrs) {
  394. /*
  395. * if any set that we aren't ignoring only make the
  396. * complaint once, in case it's stuck or recurring,
  397. * and we get here multiple times
  398. */
  399. if (dd->ipath_flags & IPATH_INITTED) {
  400. ipath_dev_err(dd, "Fatal Hardware Error (freeze "
  401. "mode), no longer usable, SN %.16s\n",
  402. dd->ipath_serial);
  403. isfatal = 1;
  404. }
  405. /*
  406. * Mark as having had an error for driver, and also
  407. * for /sys and status word mapped to user programs.
  408. * This marks unit as not usable, until reset
  409. */
  410. *dd->ipath_statusp &= ~IPATH_STATUS_IB_READY;
  411. *dd->ipath_statusp |= IPATH_STATUS_HWERROR;
  412. dd->ipath_flags &= ~IPATH_INITTED;
  413. } else {
  414. ipath_dbg("Clearing freezemode on ignored hardware "
  415. "error\n");
  416. ipath_write_kreg(dd, dd->ipath_kregs->kr_control,
  417. dd->ipath_control);
  418. }
  419. }
  420. *msg = '\0';
  421. if (hwerrs & INFINIPATH_HWE_MEMBISTFAILED) {
  422. strlcat(msg, "[Memory BIST test failed, InfiniPath hardware unusable]",
  423. msgl);
  424. /* ignore from now on, so disable until driver reloaded */
  425. *dd->ipath_statusp |= IPATH_STATUS_HWERROR;
  426. dd->ipath_hwerrmask &= ~INFINIPATH_HWE_MEMBISTFAILED;
  427. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  428. dd->ipath_hwerrmask);
  429. }
  430. ipath_format_hwerrors(hwerrs,
  431. ipath_6120_hwerror_msgs,
  432. sizeof(ipath_6120_hwerror_msgs)/
  433. sizeof(ipath_6120_hwerror_msgs[0]),
  434. msg, msgl);
  435. if (hwerrs & (INFINIPATH_HWE_PCIEMEMPARITYERR_MASK
  436. << INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT)) {
  437. bits = (u32) ((hwerrs >>
  438. INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT) &
  439. INFINIPATH_HWE_PCIEMEMPARITYERR_MASK);
  440. snprintf(bitsmsg, sizeof bitsmsg,
  441. "[PCIe Mem Parity Errs %x] ", bits);
  442. strlcat(msg, bitsmsg, msgl);
  443. }
  444. #define _IPATH_PLL_FAIL (INFINIPATH_HWE_COREPLL_FBSLIP | \
  445. INFINIPATH_HWE_COREPLL_RFSLIP )
  446. if (hwerrs & _IPATH_PLL_FAIL) {
  447. snprintf(bitsmsg, sizeof bitsmsg,
  448. "[PLL failed (%llx), InfiniPath hardware unusable]",
  449. (unsigned long long) hwerrs & _IPATH_PLL_FAIL);
  450. strlcat(msg, bitsmsg, msgl);
  451. /* ignore from now on, so disable until driver reloaded */
  452. dd->ipath_hwerrmask &= ~(hwerrs & _IPATH_PLL_FAIL);
  453. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  454. dd->ipath_hwerrmask);
  455. }
  456. if (hwerrs & INFINIPATH_HWE_SERDESPLLFAILED) {
  457. /*
  458. * If it occurs, it is left masked since the eternal
  459. * interface is unused
  460. */
  461. dd->ipath_hwerrmask &= ~INFINIPATH_HWE_SERDESPLLFAILED;
  462. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
  463. dd->ipath_hwerrmask);
  464. }
  465. ipath_dev_err(dd, "%s hardware error\n", msg);
  466. if (isfatal && !ipath_diag_inuse && dd->ipath_freezemsg) {
  467. /*
  468. * for /sys status file ; if no trailing } is copied, we'll
  469. * know it was truncated.
  470. */
  471. snprintf(dd->ipath_freezemsg, dd->ipath_freezelen,
  472. "{%s}", msg);
  473. }
  474. }
  475. /**
  476. * ipath_pe_boardname - fill in the board name
  477. * @dd: the infinipath device
  478. * @name: the output buffer
  479. * @namelen: the size of the output buffer
  480. *
  481. * info is based on the board revision register
  482. */
  483. static int ipath_pe_boardname(struct ipath_devdata *dd, char *name,
  484. size_t namelen)
  485. {
  486. char *n = NULL;
  487. u8 boardrev = dd->ipath_boardrev;
  488. int ret;
  489. switch (boardrev) {
  490. case 0:
  491. n = "InfiniPath_Emulation";
  492. break;
  493. case 1:
  494. n = "InfiniPath_QLE7140-Bringup";
  495. break;
  496. case 2:
  497. n = "InfiniPath_QLE7140";
  498. break;
  499. case 3:
  500. n = "InfiniPath_QMI7140";
  501. break;
  502. case 4:
  503. n = "InfiniPath_QEM7140";
  504. break;
  505. case 5:
  506. n = "InfiniPath_QMH7140";
  507. break;
  508. case 6:
  509. n = "InfiniPath_QLE7142";
  510. break;
  511. default:
  512. ipath_dev_err(dd,
  513. "Don't yet know about board with ID %u\n",
  514. boardrev);
  515. snprintf(name, namelen, "Unknown_InfiniPath_PCIe_%u",
  516. boardrev);
  517. break;
  518. }
  519. if (n)
  520. snprintf(name, namelen, "%s", n);
  521. if (dd->ipath_majrev != 4 || !dd->ipath_minrev || dd->ipath_minrev>2) {
  522. ipath_dev_err(dd, "Unsupported InfiniPath hardware revision %u.%u!\n",
  523. dd->ipath_majrev, dd->ipath_minrev);
  524. ret = 1;
  525. } else
  526. ret = 0;
  527. return ret;
  528. }
  529. /**
  530. * ipath_pe_init_hwerrors - enable hardware errors
  531. * @dd: the infinipath device
  532. *
  533. * now that we have finished initializing everything that might reasonably
  534. * cause a hardware error, and cleared those errors bits as they occur,
  535. * we can enable hardware errors in the mask (potentially enabling
  536. * freeze mode), and enable hardware errors as errors (along with
  537. * everything else) in errormask
  538. */
  539. static void ipath_pe_init_hwerrors(struct ipath_devdata *dd)
  540. {
  541. ipath_err_t val;
  542. u64 extsval;
  543. extsval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus);
  544. if (!(extsval & INFINIPATH_EXTS_MEMBIST_ENDTEST))
  545. ipath_dev_err(dd, "MemBIST did not complete!\n");
  546. val = ~0ULL; /* barring bugs, all hwerrors become interrupts, */
  547. if (!dd->ipath_boardrev) // no PLL for Emulator
  548. val &= ~INFINIPATH_HWE_SERDESPLLFAILED;
  549. if (dd->ipath_minrev < 2) {
  550. /* workaround bug 9460 in internal interface bus parity
  551. * checking. Fixed (HW bug 9490) in Rev2.
  552. */
  553. val &= ~INFINIPATH_HWE_PCIEBUSPARITYRADM;
  554. }
  555. dd->ipath_hwerrmask = val;
  556. }
  557. /**
  558. * ipath_pe_bringup_serdes - bring up the serdes
  559. * @dd: the infinipath device
  560. */
  561. static int ipath_pe_bringup_serdes(struct ipath_devdata *dd)
  562. {
  563. u64 val, config1, prev_val;
  564. int ret = 0;
  565. ipath_dbg("Trying to bringup serdes\n");
  566. if (ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus) &
  567. INFINIPATH_HWE_SERDESPLLFAILED) {
  568. ipath_dbg("At start, serdes PLL failed bit set "
  569. "in hwerrstatus, clearing and continuing\n");
  570. ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear,
  571. INFINIPATH_HWE_SERDESPLLFAILED);
  572. }
  573. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  574. config1 = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig1);
  575. ipath_cdbg(VERBOSE, "SerDes status config0=%llx config1=%llx, "
  576. "xgxsconfig %llx\n", (unsigned long long) val,
  577. (unsigned long long) config1, (unsigned long long)
  578. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  579. /*
  580. * Force reset on, also set rxdetect enable. Must do before reading
  581. * serdesstatus at least for simulation, or some of the bits in
  582. * serdes status will come back as undefined and cause simulation
  583. * failures
  584. */
  585. val |= INFINIPATH_SERDC0_RESET_PLL | INFINIPATH_SERDC0_RXDETECT_EN
  586. | INFINIPATH_SERDC0_L1PWR_DN;
  587. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  588. /* be sure chip saw it */
  589. ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  590. udelay(5); /* need pll reset set at least for a bit */
  591. /*
  592. * after PLL is reset, set the per-lane Resets and TxIdle and
  593. * clear the PLL reset and rxdetect (to get falling edge).
  594. * Leave L1PWR bits set (permanently)
  595. */
  596. val &= ~(INFINIPATH_SERDC0_RXDETECT_EN | INFINIPATH_SERDC0_RESET_PLL
  597. | INFINIPATH_SERDC0_L1PWR_DN);
  598. val |= INFINIPATH_SERDC0_RESET_MASK | INFINIPATH_SERDC0_TXIDLE;
  599. ipath_cdbg(VERBOSE, "Clearing pll reset and setting lane resets "
  600. "and txidle (%llx)\n", (unsigned long long) val);
  601. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  602. /* be sure chip saw it */
  603. ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  604. /* need PLL reset clear for at least 11 usec before lane
  605. * resets cleared; give it a few more to be sure */
  606. udelay(15);
  607. val &= ~(INFINIPATH_SERDC0_RESET_MASK | INFINIPATH_SERDC0_TXIDLE);
  608. ipath_cdbg(VERBOSE, "Clearing lane resets and txidle "
  609. "(writing %llx)\n", (unsigned long long) val);
  610. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  611. /* be sure chip saw it */
  612. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
  613. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig);
  614. prev_val = val;
  615. if (((val >> INFINIPATH_XGXS_MDIOADDR_SHIFT) &
  616. INFINIPATH_XGXS_MDIOADDR_MASK) != 3) {
  617. val &=
  618. ~(INFINIPATH_XGXS_MDIOADDR_MASK <<
  619. INFINIPATH_XGXS_MDIOADDR_SHIFT);
  620. /* MDIO address 3 */
  621. val |= 3ULL << INFINIPATH_XGXS_MDIOADDR_SHIFT;
  622. }
  623. if (val & INFINIPATH_XGXS_RESET) {
  624. val &= ~INFINIPATH_XGXS_RESET;
  625. }
  626. if (((val >> INFINIPATH_XGXS_RX_POL_SHIFT) &
  627. INFINIPATH_XGXS_RX_POL_MASK) != dd->ipath_rx_pol_inv ) {
  628. /* need to compensate for Tx inversion in partner */
  629. val &= ~(INFINIPATH_XGXS_RX_POL_MASK <<
  630. INFINIPATH_XGXS_RX_POL_SHIFT);
  631. val |= dd->ipath_rx_pol_inv <<
  632. INFINIPATH_XGXS_RX_POL_SHIFT;
  633. }
  634. if (dd->ipath_minrev >= 2) {
  635. /* Rev 2. can tolerate multiple writes to PBC, and
  636. * allowing them can provide lower latency on some
  637. * CPUs, but this feature is off by default, only
  638. * turned on by setting D63 of XGXSconfig reg.
  639. * May want to make this conditional more
  640. * fine-grained in future. This is not exactly
  641. * related to XGXS, but where the bit ended up.
  642. */
  643. val |= INFINIPATH_XGXS_SUPPRESS_ARMLAUNCH_ERR;
  644. }
  645. if (val != prev_val)
  646. ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val);
  647. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  648. /* clear current and de-emphasis bits */
  649. config1 &= ~0x0ffffffff00ULL;
  650. /* set current to 20ma */
  651. config1 |= 0x00000000000ULL;
  652. /* set de-emphasis to -5.68dB */
  653. config1 |= 0x0cccc000000ULL;
  654. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig1, config1);
  655. ipath_cdbg(VERBOSE, "done: SerDes status config0=%llx "
  656. "config1=%llx, sstatus=%llx xgxs=%llx\n",
  657. (unsigned long long) val, (unsigned long long) config1,
  658. (unsigned long long)
  659. ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesstatus),
  660. (unsigned long long)
  661. ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig));
  662. if (!ipath_waitfor_mdio_cmdready(dd)) {
  663. ipath_write_kreg(
  664. dd, dd->ipath_kregs->kr_mdio,
  665. ipath_mdio_req(IPATH_MDIO_CMD_READ, 31,
  666. IPATH_MDIO_CTRL_XGXS_REG_8, 0));
  667. if (ipath_waitfor_complete(dd, dd->ipath_kregs->kr_mdio,
  668. IPATH_MDIO_DATAVALID, &val))
  669. ipath_dbg("Never got MDIO data for XGXS "
  670. "status read\n");
  671. else
  672. ipath_cdbg(VERBOSE, "MDIO Read reg8, "
  673. "'bank' 31 %x\n", (u32) val);
  674. } else
  675. ipath_dbg("Never got MDIO cmdready for XGXS status read\n");
  676. return ret;
  677. }
  678. /**
  679. * ipath_pe_quiet_serdes - set serdes to txidle
  680. * @dd: the infinipath device
  681. * Called when driver is being unloaded
  682. */
  683. static void ipath_pe_quiet_serdes(struct ipath_devdata *dd)
  684. {
  685. u64 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0);
  686. val |= INFINIPATH_SERDC0_TXIDLE;
  687. ipath_dbg("Setting TxIdleEn on serdes (config0 = %llx)\n",
  688. (unsigned long long) val);
  689. ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
  690. }
  691. static int ipath_pe_intconfig(struct ipath_devdata *dd)
  692. {
  693. u64 val;
  694. u32 chiprev;
  695. /*
  696. * If the chip supports added error indication via GPIO pins,
  697. * enable interrupts on those bits so the interrupt routine
  698. * can count the events. Also set flag so interrupt routine
  699. * can know they are expected.
  700. */
  701. chiprev = dd->ipath_revision >> INFINIPATH_R_CHIPREVMINOR_SHIFT;
  702. if ((chiprev & INFINIPATH_R_CHIPREVMINOR_MASK) > 1) {
  703. /* Rev2+ reports extra errors via internal GPIO pins */
  704. dd->ipath_flags |= IPATH_GPIO_ERRINTRS;
  705. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_gpio_mask);
  706. val |= IPATH_GPIO_ERRINTR_MASK;
  707. ipath_write_kreg( dd, dd->ipath_kregs->kr_gpio_mask, val);
  708. }
  709. return 0;
  710. }
  711. /**
  712. * ipath_setup_pe_setextled - set the state of the two external LEDs
  713. * @dd: the infinipath device
  714. * @lst: the L state
  715. * @ltst: the LT state
  716. * These LEDs indicate the physical and logical state of IB link.
  717. * For this chip (at least with recommended board pinouts), LED1
  718. * is Yellow (logical state) and LED2 is Green (physical state),
  719. *
  720. * Note: We try to match the Mellanox HCA LED behavior as best
  721. * we can. Green indicates physical link state is OK (something is
  722. * plugged in, and we can train).
  723. * Amber indicates the link is logically up (ACTIVE).
  724. * Mellanox further blinks the amber LED to indicate data packet
  725. * activity, but we have no hardware support for that, so it would
  726. * require waking up every 10-20 msecs and checking the counters
  727. * on the chip, and then turning the LED off if appropriate. That's
  728. * visible overhead, so not something we will do.
  729. *
  730. */
  731. static void ipath_setup_pe_setextled(struct ipath_devdata *dd, u64 lst,
  732. u64 ltst)
  733. {
  734. u64 extctl;
  735. /* the diags use the LED to indicate diag info, so we leave
  736. * the external LED alone when the diags are running */
  737. if (ipath_diag_inuse)
  738. return;
  739. extctl = dd->ipath_extctrl & ~(INFINIPATH_EXTC_LED1PRIPORT_ON |
  740. INFINIPATH_EXTC_LED2PRIPORT_ON);
  741. if (ltst & INFINIPATH_IBCS_LT_STATE_LINKUP)
  742. extctl |= INFINIPATH_EXTC_LED2PRIPORT_ON;
  743. if (lst == INFINIPATH_IBCS_L_STATE_ACTIVE)
  744. extctl |= INFINIPATH_EXTC_LED1PRIPORT_ON;
  745. dd->ipath_extctrl = extctl;
  746. ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, extctl);
  747. }
  748. /**
  749. * ipath_setup_pe_cleanup - clean up any per-chip chip-specific stuff
  750. * @dd: the infinipath device
  751. *
  752. * This is called during driver unload.
  753. * We do the pci_disable_msi here, not in generic code, because it
  754. * isn't used for the HT chips. If we do end up needing pci_enable_msi
  755. * at some point in the future for HT, we'll move the call back
  756. * into the main init_one code.
  757. */
  758. static void ipath_setup_pe_cleanup(struct ipath_devdata *dd)
  759. {
  760. dd->ipath_msi_lo = 0; /* just in case unload fails */
  761. pci_disable_msi(dd->pcidev);
  762. }
  763. /**
  764. * ipath_setup_pe_config - setup PCIe config related stuff
  765. * @dd: the infinipath device
  766. * @pdev: the PCI device
  767. *
  768. * The pci_enable_msi() call will fail on systems with MSI quirks
  769. * such as those with AMD8131, even if the device of interest is not
  770. * attached to that device, (in the 2.6.13 - 2.6.15 kernels, at least, fixed
  771. * late in 2.6.16).
  772. * All that can be done is to edit the kernel source to remove the quirk
  773. * check until that is fixed.
  774. * We do not need to call enable_msi() for our HyperTransport chip,
  775. * even though it uses MSI, and we want to avoid the quirk warning, so
  776. * So we call enable_msi only for PCIe. If we do end up needing
  777. * pci_enable_msi at some point in the future for HT, we'll move the
  778. * call back into the main init_one code.
  779. * We save the msi lo and hi values, so we can restore them after
  780. * chip reset (the kernel PCI infrastructure doesn't yet handle that
  781. * correctly).
  782. */
  783. static int ipath_setup_pe_config(struct ipath_devdata *dd,
  784. struct pci_dev *pdev)
  785. {
  786. int pos, ret;
  787. dd->ipath_msi_lo = 0; /* used as a flag during reset processing */
  788. ret = pci_enable_msi(dd->pcidev);
  789. if (ret)
  790. ipath_dev_err(dd, "pci_enable_msi failed: %d, "
  791. "interrupts may not work\n", ret);
  792. /* continue even if it fails, we may still be OK... */
  793. dd->ipath_irq = pdev->irq;
  794. if ((pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI))) {
  795. u16 control;
  796. pci_read_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_LO,
  797. &dd->ipath_msi_lo);
  798. pci_read_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_HI,
  799. &dd->ipath_msi_hi);
  800. pci_read_config_word(dd->pcidev, pos + PCI_MSI_FLAGS,
  801. &control);
  802. /* now save the data (vector) info */
  803. pci_read_config_word(dd->pcidev,
  804. pos + ((control & PCI_MSI_FLAGS_64BIT)
  805. ? 12 : 8),
  806. &dd->ipath_msi_data);
  807. ipath_cdbg(VERBOSE, "Read msi data 0x%x from config offset "
  808. "0x%x, control=0x%x\n", dd->ipath_msi_data,
  809. pos + ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8),
  810. control);
  811. /* we save the cachelinesize also, although it doesn't
  812. * really matter */
  813. pci_read_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE,
  814. &dd->ipath_pci_cacheline);
  815. } else
  816. ipath_dev_err(dd, "Can't find MSI capability, "
  817. "can't save MSI settings for reset\n");
  818. if ((pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_EXP))) {
  819. u16 linkstat;
  820. pci_read_config_word(dd->pcidev, pos + PCI_EXP_LNKSTA,
  821. &linkstat);
  822. linkstat >>= 4;
  823. linkstat &= 0x1f;
  824. if (linkstat != 8)
  825. ipath_dev_err(dd, "PCIe width %u, "
  826. "performance reduced\n", linkstat);
  827. }
  828. else
  829. ipath_dev_err(dd, "Can't find PCI Express "
  830. "capability!\n");
  831. return 0;
  832. }
  833. static void ipath_init_pe_variables(struct ipath_devdata *dd)
  834. {
  835. /*
  836. * bits for selecting i2c direction and values,
  837. * used for I2C serial flash
  838. */
  839. dd->ipath_gpio_sda_num = _IPATH_GPIO_SDA_NUM;
  840. dd->ipath_gpio_scl_num = _IPATH_GPIO_SCL_NUM;
  841. dd->ipath_gpio_sda = IPATH_GPIO_SDA;
  842. dd->ipath_gpio_scl = IPATH_GPIO_SCL;
  843. /* variables for sanity checking interrupt and errors */
  844. dd->ipath_hwe_bitsextant =
  845. (INFINIPATH_HWE_RXEMEMPARITYERR_MASK <<
  846. INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT) |
  847. (INFINIPATH_HWE_TXEMEMPARITYERR_MASK <<
  848. INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT) |
  849. (INFINIPATH_HWE_PCIEMEMPARITYERR_MASK <<
  850. INFINIPATH_HWE_PCIEMEMPARITYERR_SHIFT) |
  851. INFINIPATH_HWE_PCIE1PLLFAILED |
  852. INFINIPATH_HWE_PCIE0PLLFAILED |
  853. INFINIPATH_HWE_PCIEPOISONEDTLP |
  854. INFINIPATH_HWE_PCIECPLTIMEOUT |
  855. INFINIPATH_HWE_PCIEBUSPARITYXTLH |
  856. INFINIPATH_HWE_PCIEBUSPARITYXADM |
  857. INFINIPATH_HWE_PCIEBUSPARITYRADM |
  858. INFINIPATH_HWE_MEMBISTFAILED |
  859. INFINIPATH_HWE_COREPLL_FBSLIP |
  860. INFINIPATH_HWE_COREPLL_RFSLIP |
  861. INFINIPATH_HWE_SERDESPLLFAILED |
  862. INFINIPATH_HWE_IBCBUSTOSPCPARITYERR |
  863. INFINIPATH_HWE_IBCBUSFRSPCPARITYERR;
  864. dd->ipath_i_bitsextant =
  865. (INFINIPATH_I_RCVURG_MASK << INFINIPATH_I_RCVURG_SHIFT) |
  866. (INFINIPATH_I_RCVAVAIL_MASK <<
  867. INFINIPATH_I_RCVAVAIL_SHIFT) |
  868. INFINIPATH_I_ERROR | INFINIPATH_I_SPIOSENT |
  869. INFINIPATH_I_SPIOBUFAVAIL | INFINIPATH_I_GPIO;
  870. dd->ipath_e_bitsextant =
  871. INFINIPATH_E_RFORMATERR | INFINIPATH_E_RVCRC |
  872. INFINIPATH_E_RICRC | INFINIPATH_E_RMINPKTLEN |
  873. INFINIPATH_E_RMAXPKTLEN | INFINIPATH_E_RLONGPKTLEN |
  874. INFINIPATH_E_RSHORTPKTLEN | INFINIPATH_E_RUNEXPCHAR |
  875. INFINIPATH_E_RUNSUPVL | INFINIPATH_E_REBP |
  876. INFINIPATH_E_RIBFLOW | INFINIPATH_E_RBADVERSION |
  877. INFINIPATH_E_RRCVEGRFULL | INFINIPATH_E_RRCVHDRFULL |
  878. INFINIPATH_E_RBADTID | INFINIPATH_E_RHDRLEN |
  879. INFINIPATH_E_RHDR | INFINIPATH_E_RIBLOSTLINK |
  880. INFINIPATH_E_SMINPKTLEN | INFINIPATH_E_SMAXPKTLEN |
  881. INFINIPATH_E_SUNDERRUN | INFINIPATH_E_SPKTLEN |
  882. INFINIPATH_E_SDROPPEDSMPPKT | INFINIPATH_E_SDROPPEDDATAPKT |
  883. INFINIPATH_E_SPIOARMLAUNCH | INFINIPATH_E_SUNEXPERRPKTNUM |
  884. INFINIPATH_E_SUNSUPVL | INFINIPATH_E_IBSTATUSCHANGED |
  885. INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET |
  886. INFINIPATH_E_HARDWARE;
  887. dd->ipath_i_rcvavail_mask = INFINIPATH_I_RCVAVAIL_MASK;
  888. dd->ipath_i_rcvurg_mask = INFINIPATH_I_RCVURG_MASK;
  889. }
  890. /* setup the MSI stuff again after a reset. I'd like to just call
  891. * pci_enable_msi() and request_irq() again, but when I do that,
  892. * the MSI enable bit doesn't get set in the command word, and
  893. * we switch to to a different interrupt vector, which is confusing,
  894. * so I instead just do it all inline. Perhaps somehow can tie this
  895. * into the PCIe hotplug support at some point
  896. * Note, because I'm doing it all here, I don't call pci_disable_msi()
  897. * or free_irq() at the start of ipath_setup_pe_reset().
  898. */
  899. static int ipath_reinit_msi(struct ipath_devdata *dd)
  900. {
  901. int pos;
  902. u16 control;
  903. int ret;
  904. if (!dd->ipath_msi_lo) {
  905. dev_info(&dd->pcidev->dev, "Can't restore MSI config, "
  906. "initial setup failed?\n");
  907. ret = 0;
  908. goto bail;
  909. }
  910. if (!(pos = pci_find_capability(dd->pcidev, PCI_CAP_ID_MSI))) {
  911. ipath_dev_err(dd, "Can't find MSI capability, "
  912. "can't restore MSI settings\n");
  913. ret = 0;
  914. goto bail;
  915. }
  916. ipath_cdbg(VERBOSE, "Writing msi_lo 0x%x to config offset 0x%x\n",
  917. dd->ipath_msi_lo, pos + PCI_MSI_ADDRESS_LO);
  918. pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_LO,
  919. dd->ipath_msi_lo);
  920. ipath_cdbg(VERBOSE, "Writing msi_lo 0x%x to config offset 0x%x\n",
  921. dd->ipath_msi_hi, pos + PCI_MSI_ADDRESS_HI);
  922. pci_write_config_dword(dd->pcidev, pos + PCI_MSI_ADDRESS_HI,
  923. dd->ipath_msi_hi);
  924. pci_read_config_word(dd->pcidev, pos + PCI_MSI_FLAGS, &control);
  925. if (!(control & PCI_MSI_FLAGS_ENABLE)) {
  926. ipath_cdbg(VERBOSE, "MSI control at off %x was %x, "
  927. "setting MSI enable (%x)\n", pos + PCI_MSI_FLAGS,
  928. control, control | PCI_MSI_FLAGS_ENABLE);
  929. control |= PCI_MSI_FLAGS_ENABLE;
  930. pci_write_config_word(dd->pcidev, pos + PCI_MSI_FLAGS,
  931. control);
  932. }
  933. /* now rewrite the data (vector) info */
  934. pci_write_config_word(dd->pcidev, pos +
  935. ((control & PCI_MSI_FLAGS_64BIT) ? 12 : 8),
  936. dd->ipath_msi_data);
  937. /* we restore the cachelinesize also, although it doesn't really
  938. * matter */
  939. pci_write_config_byte(dd->pcidev, PCI_CACHE_LINE_SIZE,
  940. dd->ipath_pci_cacheline);
  941. /* and now set the pci master bit again */
  942. pci_set_master(dd->pcidev);
  943. ret = 1;
  944. bail:
  945. return ret;
  946. }
  947. /* This routine sleeps, so it can only be called from user context, not
  948. * from interrupt context. If we need interrupt context, we can split
  949. * it into two routines.
  950. */
  951. static int ipath_setup_pe_reset(struct ipath_devdata *dd)
  952. {
  953. u64 val;
  954. int i;
  955. int ret;
  956. /* Use ERROR so it shows up in logs, etc. */
  957. ipath_dev_err(dd, "Resetting InfiniPath unit %u\n", dd->ipath_unit);
  958. /* keep chip from being accessed in a few places */
  959. dd->ipath_flags &= ~(IPATH_INITTED|IPATH_PRESENT);
  960. val = dd->ipath_control | INFINIPATH_C_RESET;
  961. ipath_write_kreg(dd, dd->ipath_kregs->kr_control, val);
  962. mb();
  963. for (i = 1; i <= 5; i++) {
  964. int r;
  965. /* allow MBIST, etc. to complete; longer on each retry.
  966. * We sometimes get machine checks from bus timeout if no
  967. * response, so for now, make it *really* long.
  968. */
  969. msleep(1000 + (1 + i) * 2000);
  970. if ((r =
  971. pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_0,
  972. dd->ipath_pcibar0)))
  973. ipath_dev_err(dd, "rewrite of BAR0 failed: %d\n",
  974. r);
  975. if ((r =
  976. pci_write_config_dword(dd->pcidev, PCI_BASE_ADDRESS_1,
  977. dd->ipath_pcibar1)))
  978. ipath_dev_err(dd, "rewrite of BAR1 failed: %d\n",
  979. r);
  980. /* now re-enable memory access */
  981. if ((r = pci_enable_device(dd->pcidev)))
  982. ipath_dev_err(dd, "pci_enable_device failed after "
  983. "reset: %d\n", r);
  984. /* whether it worked or not, mark as present, again */
  985. dd->ipath_flags |= IPATH_PRESENT;
  986. val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_revision);
  987. if (val == dd->ipath_revision) {
  988. ipath_cdbg(VERBOSE, "Got matching revision "
  989. "register %llx on try %d\n",
  990. (unsigned long long) val, i);
  991. ret = ipath_reinit_msi(dd);
  992. goto bail;
  993. }
  994. /* Probably getting -1 back */
  995. ipath_dbg("Didn't get expected revision register, "
  996. "got %llx, try %d\n", (unsigned long long) val,
  997. i + 1);
  998. }
  999. ret = 0; /* failed */
  1000. bail:
  1001. return ret;
  1002. }
  1003. /**
  1004. * ipath_pe_put_tid - write a TID in chip
  1005. * @dd: the infinipath device
  1006. * @tidptr: pointer to the expected TID (in chip) to udpate
  1007. * @tidtype: 0 for eager, 1 for expected
  1008. * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing
  1009. *
  1010. * This exists as a separate routine to allow for special locking etc.
  1011. * It's used for both the full cleanup on exit, as well as the normal
  1012. * setup and teardown.
  1013. */
  1014. static void ipath_pe_put_tid(struct ipath_devdata *dd, u64 __iomem *tidptr,
  1015. u32 type, unsigned long pa)
  1016. {
  1017. u32 __iomem *tidp32 = (u32 __iomem *)tidptr;
  1018. unsigned long flags = 0; /* keep gcc quiet */
  1019. if (pa != dd->ipath_tidinvalid) {
  1020. if (pa & ((1U << 11) - 1)) {
  1021. dev_info(&dd->pcidev->dev, "BUG: physaddr %lx "
  1022. "not 4KB aligned!\n", pa);
  1023. return;
  1024. }
  1025. pa >>= 11;
  1026. /* paranoia check */
  1027. if (pa & (7<<29))
  1028. ipath_dev_err(dd,
  1029. "BUG: Physical page address 0x%lx "
  1030. "has bits set in 31-29\n", pa);
  1031. if (type == 0)
  1032. pa |= dd->ipath_tidtemplate;
  1033. else /* for now, always full 4KB page */
  1034. pa |= 2 << 29;
  1035. }
  1036. /* workaround chip bug 9437 by writing each TID twice
  1037. * and holding a spinlock around the writes, so they don't
  1038. * intermix with other TID (eager or expected) writes
  1039. * Unfortunately, this call can be done from interrupt level
  1040. * for the port 0 eager TIDs, so we have to use irqsave
  1041. */
  1042. spin_lock_irqsave(&dd->ipath_tid_lock, flags);
  1043. ipath_write_kreg(dd, dd->ipath_kregs->kr_scratch, 0xfeeddeaf);
  1044. if (dd->ipath_kregbase)
  1045. writel(pa, tidp32);
  1046. ipath_write_kreg(dd, dd->ipath_kregs->kr_scratch, 0xdeadbeef);
  1047. mmiowb();
  1048. spin_unlock_irqrestore(&dd->ipath_tid_lock, flags);
  1049. }
  1050. /**
  1051. * ipath_pe_put_tid_2 - write a TID in chip, Revision 2 or higher
  1052. * @dd: the infinipath device
  1053. * @tidptr: pointer to the expected TID (in chip) to udpate
  1054. * @tidtype: 0 for eager, 1 for expected
  1055. * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing
  1056. *
  1057. * This exists as a separate routine to allow for selection of the
  1058. * appropriate "flavor". The static calls in cleanup just use the
  1059. * revision-agnostic form, as they are not performance critical.
  1060. */
  1061. static void ipath_pe_put_tid_2(struct ipath_devdata *dd, u64 __iomem *tidptr,
  1062. u32 type, unsigned long pa)
  1063. {
  1064. u32 __iomem *tidp32 = (u32 __iomem *)tidptr;
  1065. if (pa != dd->ipath_tidinvalid) {
  1066. if (pa & ((1U << 11) - 1)) {
  1067. dev_info(&dd->pcidev->dev, "BUG: physaddr %lx "
  1068. "not 2KB aligned!\n", pa);
  1069. return;
  1070. }
  1071. pa >>= 11;
  1072. /* paranoia check */
  1073. if (pa & (7<<29))
  1074. ipath_dev_err(dd,
  1075. "BUG: Physical page address 0x%lx "
  1076. "has bits set in 31-29\n", pa);
  1077. if (type == 0)
  1078. pa |= dd->ipath_tidtemplate;
  1079. else /* for now, always full 4KB page */
  1080. pa |= 2 << 29;
  1081. }
  1082. if (dd->ipath_kregbase)
  1083. writel(pa, tidp32);
  1084. mmiowb();
  1085. }
  1086. /**
  1087. * ipath_pe_clear_tid - clear all TID entries for a port, expected and eager
  1088. * @dd: the infinipath device
  1089. * @port: the port
  1090. *
  1091. * clear all TID entries for a port, expected and eager.
  1092. * Used from ipath_close(). On this chip, TIDs are only 32 bits,
  1093. * not 64, but they are still on 64 bit boundaries, so tidbase
  1094. * is declared as u64 * for the pointer math, even though we write 32 bits
  1095. */
  1096. static void ipath_pe_clear_tids(struct ipath_devdata *dd, unsigned port)
  1097. {
  1098. u64 __iomem *tidbase;
  1099. unsigned long tidinv;
  1100. int i;
  1101. if (!dd->ipath_kregbase)
  1102. return;
  1103. ipath_cdbg(VERBOSE, "Invalidate TIDs for port %u\n", port);
  1104. tidinv = dd->ipath_tidinvalid;
  1105. tidbase = (u64 __iomem *)
  1106. ((char __iomem *)(dd->ipath_kregbase) +
  1107. dd->ipath_rcvtidbase +
  1108. port * dd->ipath_rcvtidcnt * sizeof(*tidbase));
  1109. for (i = 0; i < dd->ipath_rcvtidcnt; i++)
  1110. ipath_pe_put_tid(dd, &tidbase[i], 0, tidinv);
  1111. tidbase = (u64 __iomem *)
  1112. ((char __iomem *)(dd->ipath_kregbase) +
  1113. dd->ipath_rcvegrbase +
  1114. port * dd->ipath_rcvegrcnt * sizeof(*tidbase));
  1115. for (i = 0; i < dd->ipath_rcvegrcnt; i++)
  1116. ipath_pe_put_tid(dd, &tidbase[i], 1, tidinv);
  1117. }
  1118. /**
  1119. * ipath_pe_tidtemplate - setup constants for TID updates
  1120. * @dd: the infinipath device
  1121. *
  1122. * We setup stuff that we use a lot, to avoid calculating each time
  1123. */
  1124. static void ipath_pe_tidtemplate(struct ipath_devdata *dd)
  1125. {
  1126. u32 egrsize = dd->ipath_rcvegrbufsize;
  1127. /* For now, we always allocate 4KB buffers (at init) so we can
  1128. * receive max size packets. We may want a module parameter to
  1129. * specify 2KB or 4KB and/or make be per port instead of per device
  1130. * for those who want to reduce memory footprint. Note that the
  1131. * ipath_rcvhdrentsize size must be large enough to hold the largest
  1132. * IB header (currently 96 bytes) that we expect to handle (plus of
  1133. * course the 2 dwords of RHF).
  1134. */
  1135. if (egrsize == 2048)
  1136. dd->ipath_tidtemplate = 1U << 29;
  1137. else if (egrsize == 4096)
  1138. dd->ipath_tidtemplate = 2U << 29;
  1139. else {
  1140. egrsize = 4096;
  1141. dev_info(&dd->pcidev->dev, "BUG: unsupported egrbufsize "
  1142. "%u, using %u\n", dd->ipath_rcvegrbufsize,
  1143. egrsize);
  1144. dd->ipath_tidtemplate = 2U << 29;
  1145. }
  1146. dd->ipath_tidinvalid = 0;
  1147. }
  1148. static int ipath_pe_early_init(struct ipath_devdata *dd)
  1149. {
  1150. dd->ipath_flags |= IPATH_4BYTE_TID;
  1151. /*
  1152. * For openfabrics, we need to be able to handle an IB header of
  1153. * 24 dwords. HT chip has arbitrary sized receive buffers, so we
  1154. * made them the same size as the PIO buffers. This chip does not
  1155. * handle arbitrary size buffers, so we need the header large enough
  1156. * to handle largest IB header, but still have room for a 2KB MTU
  1157. * standard IB packet.
  1158. */
  1159. dd->ipath_rcvhdrentsize = 24;
  1160. dd->ipath_rcvhdrsize = IPATH_DFLT_RCVHDRSIZE;
  1161. /*
  1162. * To truly support a 4KB MTU (for usermode), we need to
  1163. * bump this to a larger value. For now, we use them for
  1164. * the kernel only.
  1165. */
  1166. dd->ipath_rcvegrbufsize = 2048;
  1167. /*
  1168. * the min() check here is currently a nop, but it may not always
  1169. * be, depending on just how we do ipath_rcvegrbufsize
  1170. */
  1171. dd->ipath_ibmaxlen = min(dd->ipath_piosize2k,
  1172. dd->ipath_rcvegrbufsize +
  1173. (dd->ipath_rcvhdrentsize << 2));
  1174. dd->ipath_init_ibmaxlen = dd->ipath_ibmaxlen;
  1175. /*
  1176. * We can request a receive interrupt for 1 or
  1177. * more packets from current offset. For now, we set this
  1178. * up for a single packet.
  1179. */
  1180. dd->ipath_rhdrhead_intr_off = 1ULL<<32;
  1181. ipath_get_eeprom_info(dd);
  1182. return 0;
  1183. }
  1184. int __attribute__((weak)) ipath_unordered_wc(void)
  1185. {
  1186. return 0;
  1187. }
  1188. /**
  1189. * ipath_init_pe_get_base_info - set chip-specific flags for user code
  1190. * @pd: the infinipath port
  1191. * @kbase: ipath_base_info pointer
  1192. *
  1193. * We set the PCIE flag because the lower bandwidth on PCIe vs
  1194. * HyperTransport can affect some user packet algorithims.
  1195. */
  1196. static int ipath_pe_get_base_info(struct ipath_portdata *pd, void *kbase)
  1197. {
  1198. struct ipath_base_info *kinfo = kbase;
  1199. struct ipath_devdata *dd;
  1200. if (ipath_unordered_wc()) {
  1201. kinfo->spi_runtime_flags |= IPATH_RUNTIME_FORCE_WC_ORDER;
  1202. ipath_cdbg(PROC, "Intel processor, forcing WC order\n");
  1203. }
  1204. else
  1205. ipath_cdbg(PROC, "Not Intel processor, WC ordered\n");
  1206. if (pd == NULL)
  1207. goto done;
  1208. dd = pd->port_dd;
  1209. if (dd != NULL && dd->ipath_minrev >= 2) {
  1210. ipath_cdbg(PROC, "IBA6120 Rev2, allow multiple PBC write\n");
  1211. kinfo->spi_runtime_flags |= IPATH_RUNTIME_PBC_REWRITE;
  1212. ipath_cdbg(PROC, "IBA6120 Rev2, allow loose DMA alignment\n");
  1213. kinfo->spi_runtime_flags |= IPATH_RUNTIME_LOOSE_DMA_ALIGN;
  1214. }
  1215. done:
  1216. kinfo->spi_runtime_flags |= IPATH_RUNTIME_PCIE;
  1217. return 0;
  1218. }
  1219. static void ipath_pe_free_irq(struct ipath_devdata *dd)
  1220. {
  1221. free_irq(dd->ipath_irq, dd);
  1222. dd->ipath_irq = 0;
  1223. }
  1224. /**
  1225. * ipath_init_iba6120_funcs - set up the chip-specific function pointers
  1226. * @dd: the infinipath device
  1227. *
  1228. * This is global, and is called directly at init to set up the
  1229. * chip-specific function pointers for later use.
  1230. */
  1231. void ipath_init_iba6120_funcs(struct ipath_devdata *dd)
  1232. {
  1233. dd->ipath_f_intrsetup = ipath_pe_intconfig;
  1234. dd->ipath_f_bus = ipath_setup_pe_config;
  1235. dd->ipath_f_reset = ipath_setup_pe_reset;
  1236. dd->ipath_f_get_boardname = ipath_pe_boardname;
  1237. dd->ipath_f_init_hwerrors = ipath_pe_init_hwerrors;
  1238. dd->ipath_f_early_init = ipath_pe_early_init;
  1239. dd->ipath_f_handle_hwerrors = ipath_pe_handle_hwerrors;
  1240. dd->ipath_f_quiet_serdes = ipath_pe_quiet_serdes;
  1241. dd->ipath_f_bringup_serdes = ipath_pe_bringup_serdes;
  1242. dd->ipath_f_clear_tids = ipath_pe_clear_tids;
  1243. if (dd->ipath_minrev >= 2)
  1244. dd->ipath_f_put_tid = ipath_pe_put_tid_2;
  1245. else
  1246. dd->ipath_f_put_tid = ipath_pe_put_tid;
  1247. dd->ipath_f_cleanup = ipath_setup_pe_cleanup;
  1248. dd->ipath_f_setextled = ipath_setup_pe_setextled;
  1249. dd->ipath_f_get_base_info = ipath_pe_get_base_info;
  1250. dd->ipath_f_free_irq = ipath_pe_free_irq;
  1251. /* initialize chip-specific variables */
  1252. dd->ipath_f_tidtemplate = ipath_pe_tidtemplate;
  1253. /*
  1254. * setup the register offsets, since they are different for each
  1255. * chip
  1256. */
  1257. dd->ipath_kregs = &ipath_pe_kregs;
  1258. dd->ipath_cregs = &ipath_pe_cregs;
  1259. ipath_init_pe_variables(dd);
  1260. }