40 #include <linux/pci.h>
199 #define IPATH_KREG_OFFSET(field) (offsetof( \
200 struct _infinipath_do_not_use_kernel_regs, field) / sizeof(u64))
201 #define IPATH_CREG_OFFSET(field) (offsetof( \
202 struct _infinipath_do_not_use_counters, field) / sizeof(u64))
308 #define INFINIPATH_I_RCVURG_MASK ((1U<<9)-1)
309 #define INFINIPATH_I_RCVURG_SHIFT 0
310 #define INFINIPATH_I_RCVAVAIL_MASK ((1U<<9)-1)
311 #define INFINIPATH_I_RCVAVAIL_SHIFT 12
314 #define INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT 0
315 #define INFINIPATH_HWE_HTCMEMPARITYERR_MASK 0x3FFFFFULL
316 #define INFINIPATH_HWE_HTCLNKABYTE0CRCERR 0x0000000000800000ULL
317 #define INFINIPATH_HWE_HTCLNKABYTE1CRCERR 0x0000000001000000ULL
318 #define INFINIPATH_HWE_HTCLNKBBYTE0CRCERR 0x0000000002000000ULL
319 #define INFINIPATH_HWE_HTCLNKBBYTE1CRCERR 0x0000000004000000ULL
320 #define INFINIPATH_HWE_HTCMISCERR4 0x0000000008000000ULL
321 #define INFINIPATH_HWE_HTCMISCERR5 0x0000000010000000ULL
322 #define INFINIPATH_HWE_HTCMISCERR6 0x0000000020000000ULL
323 #define INFINIPATH_HWE_HTCMISCERR7 0x0000000040000000ULL
324 #define INFINIPATH_HWE_HTCBUSTREQPARITYERR 0x0000000080000000ULL
325 #define INFINIPATH_HWE_HTCBUSTRESPPARITYERR 0x0000000100000000ULL
326 #define INFINIPATH_HWE_HTCBUSIREQPARITYERR 0x0000000200000000ULL
327 #define INFINIPATH_HWE_COREPLL_FBSLIP 0x0080000000000000ULL
328 #define INFINIPATH_HWE_COREPLL_RFSLIP 0x0100000000000000ULL
329 #define INFINIPATH_HWE_HTBPLL_FBSLIP 0x0200000000000000ULL
330 #define INFINIPATH_HWE_HTBPLL_RFSLIP 0x0400000000000000ULL
331 #define INFINIPATH_HWE_HTAPLL_FBSLIP 0x0800000000000000ULL
332 #define INFINIPATH_HWE_HTAPLL_RFSLIP 0x1000000000000000ULL
333 #define INFINIPATH_HWE_SERDESPLLFAILED 0x2000000000000000ULL
335 #define IBA6110_IBCS_LINKTRAININGSTATE_MASK 0xf
336 #define IBA6110_IBCS_LINKSTATE_SHIFT 4
339 #define INFINIPATH_EXTS_FREQSEL 0x2
340 #define INFINIPATH_EXTS_SERDESSEL 0x4
341 #define INFINIPATH_EXTS_MEMBIST_ENDTEST 0x0000000000004000
342 #define INFINIPATH_EXTS_MEMBIST_CORRECT 0x0000000000008000
346 #define INFINIPATH_RT_ADDR_MASK 0xFFFFFFFFFFULL
347 #define INFINIPATH_RT_VALID 0x8000000000000000ULL
348 #define INFINIPATH_RT_ADDR_SHIFT 0
349 #define INFINIPATH_RT_BUFSIZE_MASK 0x3FFFULL
350 #define INFINIPATH_RT_BUFSIZE_SHIFT 48
352 #define INFINIPATH_R_INTRAVAIL_SHIFT 16
353 #define INFINIPATH_R_TAILUPD_SHIFT 31
356 #define INFINIPATH_XGXS_RESET 0x7ULL
362 static const ipath_err_t infinipath_hwe_htcmemparityerr_mask =
364 static const ipath_err_t infinipath_hwe_htcmemparityerr_shift =
367 static const ipath_err_t infinipath_hwe_htclnkabyte0crcerr =
369 static const ipath_err_t infinipath_hwe_htclnkabyte1crcerr =
371 static const ipath_err_t infinipath_hwe_htclnkbbyte0crcerr =
373 static const ipath_err_t infinipath_hwe_htclnkbbyte1crcerr =
376 #define _IPATH_GPIO_SDA_NUM 1
377 #define _IPATH_GPIO_SCL_NUM 0
379 #define IPATH_GPIO_SDA \
380 (1ULL << (_IPATH_GPIO_SDA_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
381 #define IPATH_GPIO_SCL \
382 (1ULL << (_IPATH_GPIO_SCL_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT))
385 #define _IPATH_HTLINK0_CRCBITS (infinipath_hwe_htclnkabyte0crcerr | \
386 infinipath_hwe_htclnkabyte1crcerr)
387 #define _IPATH_HTLINK1_CRCBITS (infinipath_hwe_htclnkbbyte0crcerr | \
388 infinipath_hwe_htclnkbbyte1crcerr)
389 #define _IPATH_HTLANE0_CRCBITS (infinipath_hwe_htclnkabyte0crcerr | \
390 infinipath_hwe_htclnkbbyte0crcerr)
391 #define _IPATH_HTLANE1_CRCBITS (infinipath_hwe_htclnkabyte1crcerr | \
392 infinipath_hwe_htclnkbbyte1crcerr)
395 char *
msg,
size_t msgl)
402 crcbits &= ~infinipath_hwe_htclnkabyte1crcerr;
405 crcbits &= ~infinipath_hwe_htclnkbbyte1crcerr;
413 "[HT%s lane %s CRC (%llx); powercycle to completely clear]",
416 ?
"1 (B)" :
"0+1 (A+B)"),
419 "0+1"), (
unsigned long long) crcbits);
427 if (pci_read_config_word(dd->
pcidev,
431 "linkctrl0 of slave/primary "
433 else if (!(ctrl0 & 1 << 6))
435 ipath_dbg(
"HT linkctrl0 0x%x%s%s\n", ctrl0,
436 ((ctrl0 >> 8) & 7) ?
" CRC" :
"",
437 ((ctrl0 >> 4) & 1) ?
"linkfail" :
439 if (pci_read_config_word(dd->
pcidev,
443 "linkctrl1 of slave/primary "
445 else if (!(ctrl1 & 1 << 6))
447 ipath_dbg(
"HT linkctrl1 0x%x%s%s\n", ctrl1,
448 ((ctrl1 >> 8) & 7) ?
" CRC" :
"",
449 ((ctrl1 >> 4) & 1) ?
"linkfail" :
454 ipath_write_kreg(dd, dd->
ipath_kregs->kr_hwerrmask,
458 ipath_dbg(
"ignoring HT crc errors 0x%llx, "
459 "not in use\n", (
unsigned long long)
476 #define TXE_PIO_PARITY ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF | \
477 INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC) \
478 << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT)
479 #define RXE_EAGER_PARITY (INFINIPATH_HWE_RXEMEMPARITYERR_EAGERTID \
480 << INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT)
486 "Recovering from TXE PIO parity error\n");
510 hwerrs = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_hwerrstatus);
520 }
else if (hwerrs == -1
LL) {
522 "(all bits set); ignoring\n");
532 ipath_write_kreg(dd, dd->
ipath_kregs->kr_hwerrclear,
551 "(cleared)\n", (
unsigned long long) hwerrs);
556 "%llx set\n", (
unsigned long long)
559 ctrl = ipath_read_kreg32(dd, dd->
ipath_kregs->kr_control);
570 ipath_ht_txe_recover(dd);
571 hwerrs &= ~TXE_PIO_PARITY;
575 ipath_dbg(
"Clearing freezemode on ignored or "
576 "recovered hardware error\n");
587 if (hwerrs & (infinipath_hwe_htcmemparityerr_mask
589 bits = (
u32) ((hwerrs >>
592 snprintf(bitsmsg,
sizeof bitsmsg,
"[HTC Parity Errs %x] ",
598 ipath_6110_hwerror_msgs,
603 hwerr_crcbits(dd, hwerrs, msg, msgl);
606 strlcat(msg,
"[Memory BIST test failed, InfiniPath hardware unusable]",
610 ipath_write_kreg(dd, dd->
ipath_kregs->kr_hwerrmask,
613 #define _IPATH_PLL_FAIL (INFINIPATH_HWE_COREPLL_FBSLIP | \
614 INFINIPATH_HWE_COREPLL_RFSLIP | \
615 INFINIPATH_HWE_HTBPLL_FBSLIP | \
616 INFINIPATH_HWE_HTBPLL_RFSLIP | \
617 INFINIPATH_HWE_HTAPLL_FBSLIP | \
618 INFINIPATH_HWE_HTAPLL_RFSLIP)
620 if (hwerrs & _IPATH_PLL_FAIL) {
622 "[PLL failed (%llx), InfiniPath hardware unusable]",
623 (
unsigned long long) (hwerrs & _IPATH_PLL_FAIL));
627 ipath_write_kreg(dd, dd->
ipath_kregs->kr_hwerrmask,
637 ipath_write_kreg(dd, dd->
ipath_kregs->kr_hwerrmask,
652 ipath_setup_ht_setextled(dd,
656 "mode), no longer usable, SN %.16s\n",
708 n =
"InfiniPath_QHT7040";
712 n =
"InfiniPath_QHT7140";
716 "with ID %u\n", boardrev);
717 snprintf(name, namelen,
"Unknown_InfiniPath_QHT7xxx_%u",
725 ipath_dev_err(dd,
"Unsupported InfiniPath board %s!\n", name);
734 "Unsupported InfiniPath hardware revision %u.%u!\n",
748 "Incorrectly configured for HT @ %uMHz\n",
756 ipath_read_kreg32(dd, dd->
ipath_kregs->kr_pagealign);
764 u8 linkerr, link_off,
i;
766 for (i = 0; i < 2; i++) {
768 if (pci_read_config_byte(dd->
pcidev, link_off, &linkerr))
770 "linkerror%d of HT slave/primary block\n",
772 else if (linkerr & 0xf0) {
774 "clearing\n", linkerr >> 4, i);
779 if (pci_write_config_byte(dd->
pcidev, link_off,
783 if (pci_read_config_byte(dd->
pcidev, link_off,
786 "Couldn't reread linkerror%d of "
787 "HT slave/primary block\n", i);
788 else if (linkerr & 0xf0)
790 "HT linkerror%d bits 0x%x "
791 "couldn't be cleared\n",
799 ipath_dbg(
"No reset possible for this InfiniPath hardware\n");
803 #define HT_INTR_DISC_CONFIG 0x80
804 #define HT_INTR_REG_INDEX 2
815 int pos,
u8 cap_type)
817 u8 linkwidth = 0, linkerr, link_a_b_off, link_off;
824 if ((cap_type >> 2) & 1)
829 link_a_b_off ? 1 : 0,
830 link_a_b_off ?
'B' :
'A');
838 for (i = 0; i < 2; i++) {
839 link_off = pos + i * 4 + 0x4;
840 if (pci_read_config_word(pdev, link_off, &linkctrl))
843 else if (linkctrl & (0xf << 8)) {
845 "bits %x\n", i, linkctrl & (0xf << 8));
849 pci_write_config_word(pdev, link_off,
850 linkctrl & (0xf << 8));
858 for (i = 0; i < 2; i++) {
859 link_off = pos + i * 4 + 0xd;
860 if (pci_read_config_byte(pdev, link_off, &linkerr))
862 "of HT slave/primary block\n", i);
863 else if (linkerr & 0xf0) {
865 "clearing\n", linkerr >> 4, i);
870 if (pci_write_config_byte
871 (pdev, link_off, linkerr))
874 if (pci_read_config_byte(pdev, link_off, &linkerr))
876 "linkerror%d of HT slave/primary "
878 else if (linkerr & 0xf0)
880 "0x%x couldn't be cleared\n",
890 if (pci_read_config_byte(pdev, link_a_b_off + 7, &linkwidth))
892 "config register\n");
895 switch (linkwidth & 7) {
916 if (linkwidth != 0x11) {
918 "(%x)\n", linkwidth);
919 if (!(linkwidth & 0xf)) {
920 ipath_dbg(
"Will ignore HT lane1 errors\n");
930 if (pci_read_config_byte(pdev, link_a_b_off + 0xd, &linkwidth))
932 "config register\n");
935 switch (linkwidth & 0xf) {
966 "HyperTransport,%uMHz,x%u\n",
976 ipath_write_kreg(dd, dd->
ipath_kregs->kr_interruptconfig,
981 "interrupt address\n");
988 static void ipath_ht_irq_update(
struct pci_dev *
dev,
int irq,
1004 ipath_ht_intconfig(dd);
1039 "capability; no interrupts\n");
1050 if (pci_read_config_byte(pdev, pos + 3, &cap_type)) {
1052 "command @ %d\n", pos);
1055 if (!(cap_type & 0xE0))
1056 slave_or_pri_blk(dd, pdev, pos, cap_type);
1073 static void ipath_setup_ht_cleanup(
struct ipath_devdata *dd)
1099 static void ipath_setup_ht_setextled(
struct ipath_devdata *dd,
1103 unsigned long flags = 0;
1148 ipath_write_kreg(dd, dd->
ipath_kregs->kr_extctrl, extctl);
1152 static void ipath_init_ht_variables(
struct ipath_devdata *dd)
1246 INFINIPATH_HWE_MEMBISTFAILED |
1253 INFINIPATH_HWE_SERDESPLLFAILED |
1297 static void ipath_ht_init_hwerrors(
struct ipath_devdata *dd)
1302 extsval = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_extstatus);
1309 ipath_check_htlink(dd);
1315 val &= ~infinipath_hwe_htclnkabyte1crcerr;
1318 val &= ~infinipath_hwe_htclnkbbyte1crcerr;
1327 val &= ~(INFINIPATH_HWE_SERDESPLLFAILED |
1342 val &= ~INFINIPATH_HWE_SERDESPLLFAILED;
1353 static int ipath_ht_bringup_serdes(
struct ipath_devdata *dd)
1356 int ret = 0, change = 0;
1358 ipath_dbg(
"Trying to bringup serdes\n");
1360 if (ipath_read_kreg64(dd, dd->
ipath_kregs->kr_hwerrstatus) &
1361 INFINIPATH_HWE_SERDESPLLFAILED)
1363 ipath_dbg(
"At start, serdes PLL failed bit set in "
1364 "hwerrstatus, clearing and continuing\n");
1365 ipath_write_kreg(dd, dd->
ipath_kregs->kr_hwerrclear,
1366 INFINIPATH_HWE_SERDESPLLFAILED);
1369 val = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_serdesconfig0);
1370 config1 = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_serdesconfig1);
1373 "config1=%llx, sstatus=%llx xgxs %llx\n",
1374 (
unsigned long long) val, (
unsigned long long) config1,
1375 (
unsigned long long)
1376 ipath_read_kreg64(dd, dd->
ipath_kregs->kr_serdesstatus),
1377 (
unsigned long long)
1378 ipath_read_kreg64(dd, dd->
ipath_kregs->kr_xgxsconfig));
1384 ipath_write_kreg(dd, dd->
ipath_kregs->kr_serdesconfig0, val);
1388 u64 val2 = val &= ~INFINIPATH_SERDC0_RESET_PLL;
1393 "%llx)\n", (
unsigned long long) val2);
1394 ipath_write_kreg(dd, dd->
ipath_kregs->kr_serdesconfig0,
1399 val = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_scratch);
1408 if (val & (INFINIPATH_SERDC0_RESET_PLL |
1411 val &= ~(INFINIPATH_SERDC0_RESET_PLL |
1415 ipath_write_kreg(dd, dd->
ipath_kregs->kr_serdesconfig0,
1419 val = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_xgxsconfig);
1422 val &= ~INFINIPATH_XGXS_RESET;
1428 val &= ~(INFINIPATH_XGXS_RX_POL_MASK <<
1435 ipath_write_kreg(dd, dd->
ipath_kregs->kr_xgxsconfig, val);
1437 val = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_serdesconfig0);
1440 config1 &= ~0x0ffffffff00ULL;
1442 config1 |= 0x00000000000ULL;
1444 config1 |= 0x0cccc000000ULL;
1445 ipath_write_kreg(dd, dd->
ipath_kregs->kr_serdesconfig1, config1);
1448 "config1=%llx, sstatus=%llx xgxs %llx\n",
1449 (
unsigned long long) val, (
unsigned long long) config1,
1450 (
unsigned long long)
1451 ipath_read_kreg64(dd, dd->
ipath_kregs->kr_serdesstatus),
1452 (
unsigned long long)
1453 ipath_read_kreg64(dd, dd->
ipath_kregs->kr_xgxsconfig));
1465 u64 val = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_serdesconfig0);
1468 ipath_dbg(
"Setting TxIdleEn on serdes (config0 = %llx)\n",
1469 (
unsigned long long) val);
1470 ipath_write_kreg(dd, dd->
ipath_kregs->kr_serdesconfig0, val);
1494 "physaddr %lx has more than "
1495 "40 bits, using only 40!!!\n", pa);
1603 ipath_ht_tidtemplate(dd);
1615 ipath_ht_clear_tids(dd, val32);
1650 "(serial number %.16s)!\n",
1660 ipath_write_kreg(dd, dd->
ipath_kregs->kr_gpio_mask,
1676 static int ipath_ht_get_base_info(
struct ipath_portdata *pd,
void *kbase)
1683 if (pd->
port_dd->ipath_minrev < 4)
1701 &rhf_addr[
sizeof(
u64) /
sizeof(
u32)];
1707 ipath_read_kreg32(dd, dd->
ipath_kregs->kr_portcnt);
1709 ipath_read_kreg32(dd, dd->
ipath_kregs->kr_rcvegrcnt);
1712 static void ipath_ht_read_counters(
struct ipath_devdata *dd,
1819 static int ipath_ht_nointr_fallback(
struct ipath_devdata *dd)
1835 prev_val = ipath_read_kreg64(dd, dd->
ipath_kregs->kr_xgxsconfig);
1837 prev_val &= ~INFINIPATH_XGXS_RESET;
1840 ipath_write_kreg(dd, dd->
ipath_kregs->kr_xgxsconfig, val);
1841 ipath_read_kreg32(dd, dd->
ipath_kregs->kr_scratch);
1842 ipath_write_kreg(dd, dd->
ipath_kregs->kr_xgxsconfig, prev_val);
1848 static int ipath_ht_get_ib_cfg(
struct ipath_devdata *dd,
int which)
1874 static int ipath_ht_set_ib_cfg(
struct ipath_devdata *dd,
int which,
u32 val)
1893 static int ipath_ht_ib_updown(
struct ipath_devdata *dd,
int ibup,
u64 ibcs)
1895 ipath_setup_ht_setextled(dd, ipath_ib_linkstate(dd, ibcs),
1896 ipath_ib_linktrstate(dd, ibcs));
1939 ipath_init_ht_variables(dd);