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