Sun Jun 2 09:36:22 2013 UTC ()
Add I217 (and I218) support.
- The name of I217 is similar to I210, but the function is rather similar to
  PCH2.
- Not tested well. Tested with my own Intel DQ87PG which has I217LM onboard.
- It seems that PCH2 and PCH_LPT specific function for RAL should be written.
- Quick hack for the NVM checksum mismatch. if_wm.c currently has no
  wm_write_eeprom(), so it cannot update NVM's "updated bit". To avoid this
  problem, check only the last 12bits of the checksum. My own DQ87PG's
  updated bit is not set, and I could avoid the problem using with this
  hack.


(msaitoh)
diff -r1.248 -r1.249 src/sys/dev/pci/if_wm.c
diff -r1.15 -r1.16 src/sys/dev/pci/if_wmvar.h

cvs diff -r1.248 -r1.249 src/sys/dev/pci/if_wm.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_wm.c 2013/04/21 19:59:41 1.248
+++ src/sys/dev/pci/if_wm.c 2013/06/02 09:36:22 1.249
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_wm.c,v 1.248 2013/04/21 19:59:41 msaitoh Exp $ */ 1/* $NetBSD: if_wm.c,v 1.249 2013/06/02 09:36:22 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. 4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -66,27 +66,27 @@ @@ -66,27 +66,27 @@
66 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 66 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
67 POSSIBILITY OF SUCH DAMAGE. 67 POSSIBILITY OF SUCH DAMAGE.
68 68
69*******************************************************************************/ 69*******************************************************************************/
70/* 70/*
71 * Device driver for the Intel i8254x family of Gigabit Ethernet chips. 71 * Device driver for the Intel i8254x family of Gigabit Ethernet chips.
72 * 72 *
73 * TODO (in order of importance): 73 * TODO (in order of importance):
74 * 74 *
75 * - Rework how parameters are loaded from the EEPROM. 75 * - Rework how parameters are loaded from the EEPROM.
76 */ 76 */
77 77
78#include <sys/cdefs.h> 78#include <sys/cdefs.h>
79__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.248 2013/04/21 19:59:41 msaitoh Exp $"); 79__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.249 2013/06/02 09:36:22 msaitoh Exp $");
80 80
81#include <sys/param.h> 81#include <sys/param.h>
82#include <sys/systm.h> 82#include <sys/systm.h>
83#include <sys/callout.h> 83#include <sys/callout.h>
84#include <sys/mbuf.h> 84#include <sys/mbuf.h>
85#include <sys/malloc.h> 85#include <sys/malloc.h>
86#include <sys/kernel.h> 86#include <sys/kernel.h>
87#include <sys/socket.h> 87#include <sys/socket.h>
88#include <sys/ioctl.h> 88#include <sys/ioctl.h>
89#include <sys/errno.h> 89#include <sys/errno.h>
90#include <sys/device.h> 90#include <sys/device.h>
91#include <sys/queue.h> 91#include <sys/queue.h>
92#include <sys/syslog.h> 92#include <sys/syslog.h>
@@ -1035,26 +1035,38 @@ static const struct wm_product { @@ -1035,26 +1035,38 @@ static const struct wm_product {
1035 "I210 Gigabit Ethernet (Fiber)", 1035 "I210 Gigabit Ethernet (Fiber)",
1036 WM_T_I210, WMP_F_1000X }, 1036 WM_T_I210, WMP_F_1000X },
1037#if 0 1037#if 0
1038 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SERDES, 1038 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SERDES,
1039 "I210 Gigabit Ethernet (SERDES)", 1039 "I210 Gigabit Ethernet (SERDES)",
1040 WM_T_I210, WMP_F_SERDES }, 1040 WM_T_I210, WMP_F_SERDES },
1041 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SGMII, 1041 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I210_SGMII,
1042 "I210 Gigabit Ethernet (SGMII)", 1042 "I210 Gigabit Ethernet (SGMII)",
1043 WM_T_I210, WMP_F_SERDES }, 1043 WM_T_I210, WMP_F_SERDES },
1044#endif 1044#endif
1045 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I211_COPPER, 1045 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I211_COPPER,
1046 "I211 Ethernet (COPPER)", 1046 "I211 Ethernet (COPPER)",
1047 WM_T_I211, WMP_F_1000T }, 1047 WM_T_I211, WMP_F_1000T },
 1048 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I217_V,
 1049 "I217 V Ethernet Connection",
 1050 WM_T_PCH_LPT, WMP_F_1000T },
 1051 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I217_LM,
 1052 "I217 LM Ethernet Connection",
 1053 WM_T_PCH_LPT, WMP_F_1000T },
 1054 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_V,
 1055 "I218 V Ethernet Connection",
 1056 WM_T_PCH_LPT, WMP_F_1000T },
 1057 { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_I218_LM,
 1058 "I218 LM Ethernet Connection",
 1059 WM_T_PCH_LPT, WMP_F_1000T },
1048 { 0, 0, 1060 { 0, 0,
1049 NULL, 1061 NULL,
1050 0, 0 }, 1062 0, 0 },
1051}; 1063};
1052 1064
1053#ifdef WM_EVENT_COUNTERS 1065#ifdef WM_EVENT_COUNTERS
1054static char wm_txseg_evcnt_names[WM_NTXSEGS][sizeof("txsegXXX")]; 1066static char wm_txseg_evcnt_names[WM_NTXSEGS][sizeof("txsegXXX")];
1055#endif /* WM_EVENT_COUNTERS */ 1067#endif /* WM_EVENT_COUNTERS */
1056 1068
1057#if 0 /* Not currently used */ 1069#if 0 /* Not currently used */
1058static inline uint32_t 1070static inline uint32_t
1059wm_io_read(struct wm_softc *sc, int reg) 1071wm_io_read(struct wm_softc *sc, int reg)
1060{ 1072{
@@ -1337,27 +1349,28 @@ wm_attach(device_t parent, device_t self @@ -1337,27 +1349,28 @@ wm_attach(device_t parent, device_t self
1337 "Communication Streaming Architecture\n"); 1349 "Communication Streaming Architecture\n");
1338 if (sc->sc_type == WM_T_82547) { 1350 if (sc->sc_type == WM_T_82547) {
1339 callout_init(&sc->sc_txfifo_ch, 0); 1351 callout_init(&sc->sc_txfifo_ch, 0);
1340 callout_setfunc(&sc->sc_txfifo_ch, 1352 callout_setfunc(&sc->sc_txfifo_ch,
1341 wm_82547_txfifo_stall, sc); 1353 wm_82547_txfifo_stall, sc);
1342 aprint_verbose_dev(sc->sc_dev, 1354 aprint_verbose_dev(sc->sc_dev,
1343 "using 82547 Tx FIFO stall work-around\n"); 1355 "using 82547 Tx FIFO stall work-around\n");
1344 } 1356 }
1345 } else if (sc->sc_type >= WM_T_82571) { 1357 } else if (sc->sc_type >= WM_T_82571) {
1346 sc->sc_flags |= WM_F_PCIE; 1358 sc->sc_flags |= WM_F_PCIE;
1347 if ((sc->sc_type != WM_T_ICH8) && (sc->sc_type != WM_T_ICH9) 1359 if ((sc->sc_type != WM_T_ICH8) && (sc->sc_type != WM_T_ICH9)
1348 && (sc->sc_type != WM_T_ICH10) 1360 && (sc->sc_type != WM_T_ICH10)
1349 && (sc->sc_type != WM_T_PCH) 1361 && (sc->sc_type != WM_T_PCH)
1350 && (sc->sc_type != WM_T_PCH2)) { 1362 && (sc->sc_type != WM_T_PCH2)
 1363 && (sc->sc_type != WM_T_PCH_LPT)) {
1351 sc->sc_flags |= WM_F_EEPROM_SEMAPHORE; 1364 sc->sc_flags |= WM_F_EEPROM_SEMAPHORE;
1352 /* ICH* and PCH* have no PCIe capability registers */ 1365 /* ICH* and PCH* have no PCIe capability registers */
1353 if (pci_get_capability(pa->pa_pc, pa->pa_tag, 1366 if (pci_get_capability(pa->pa_pc, pa->pa_tag,
1354 PCI_CAP_PCIEXPRESS, &sc->sc_pcixe_capoff, 1367 PCI_CAP_PCIEXPRESS, &sc->sc_pcixe_capoff,
1355 NULL) == 0) 1368 NULL) == 0)
1356 aprint_error_dev(sc->sc_dev, 1369 aprint_error_dev(sc->sc_dev,
1357 "unable to find PCIe capability\n"); 1370 "unable to find PCIe capability\n");
1358 } 1371 }
1359 aprint_verbose_dev(sc->sc_dev, "PCI-Express bus\n"); 1372 aprint_verbose_dev(sc->sc_dev, "PCI-Express bus\n");
1360 } else { 1373 } else {
1361 reg = CSR_READ(sc, WMREG_STATUS); 1374 reg = CSR_READ(sc, WMREG_STATUS);
1362 if (reg & STATUS_BUS64) 1375 if (reg & STATUS_BUS64)
1363 sc->sc_flags |= WM_F_BUS64; 1376 sc->sc_flags |= WM_F_BUS64;
@@ -1506,46 +1519,48 @@ wm_attach(device_t parent, device_t self @@ -1506,46 +1519,48 @@ wm_attach(device_t parent, device_t self
1506 aprint_error_dev(sc->sc_dev, 1519 aprint_error_dev(sc->sc_dev,
1507 "unable to create Rx DMA map %d error = %d\n", 1520 "unable to create Rx DMA map %d error = %d\n",
1508 i, error); 1521 i, error);
1509 goto fail_5; 1522 goto fail_5;
1510 } 1523 }
1511 sc->sc_rxsoft[i].rxs_mbuf = NULL; 1524 sc->sc_rxsoft[i].rxs_mbuf = NULL;
1512 } 1525 }
1513 1526
1514 /* clear interesting stat counters */ 1527 /* clear interesting stat counters */
1515 CSR_READ(sc, WMREG_COLC); 1528 CSR_READ(sc, WMREG_COLC);
1516 CSR_READ(sc, WMREG_RXERRC); 1529 CSR_READ(sc, WMREG_RXERRC);
1517 1530
1518 /* get PHY control from SMBus to PCIe */ 1531 /* get PHY control from SMBus to PCIe */
1519 if ((sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2)) 1532 if ((sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2)
 1533 || (sc->sc_type == WM_T_PCH_LPT))
1520 wm_smbustopci(sc); 1534 wm_smbustopci(sc);
1521 1535
1522 /* 1536 /*
1523 * Reset the chip to a known state. 1537 * Reset the chip to a known state.
1524 */ 1538 */
1525 wm_reset(sc); 1539 wm_reset(sc);
1526 1540
1527 switch (sc->sc_type) { 1541 switch (sc->sc_type) {
1528 case WM_T_82571: 1542 case WM_T_82571:
1529 case WM_T_82572: 1543 case WM_T_82572:
1530 case WM_T_82573: 1544 case WM_T_82573:
1531 case WM_T_82574: 1545 case WM_T_82574:
1532 case WM_T_82583: 1546 case WM_T_82583:
1533 case WM_T_80003: 1547 case WM_T_80003:
1534 case WM_T_ICH8: 1548 case WM_T_ICH8:
1535 case WM_T_ICH9: 1549 case WM_T_ICH9:
1536 case WM_T_ICH10: 1550 case WM_T_ICH10:
1537 case WM_T_PCH: 1551 case WM_T_PCH:
1538 case WM_T_PCH2: 1552 case WM_T_PCH2:
 1553 case WM_T_PCH_LPT:
1539 if (wm_check_mng_mode(sc) != 0) 1554 if (wm_check_mng_mode(sc) != 0)
1540 wm_get_hw_control(sc); 1555 wm_get_hw_control(sc);
1541 break; 1556 break;
1542 default: 1557 default:
1543 break; 1558 break;
1544 } 1559 }
1545 1560
1546 /* 1561 /*
1547 * Get some information about the EEPROM. 1562 * Get some information about the EEPROM.
1548 */ 1563 */
1549 switch (sc->sc_type) { 1564 switch (sc->sc_type) {
1550 case WM_T_82542_2_0: 1565 case WM_T_82542_2_0:
1551 case WM_T_82542_2_1: 1566 case WM_T_82542_2_1:
@@ -1602,26 +1617,27 @@ wm_attach(device_t parent, device_t self @@ -1602,26 +1617,27 @@ wm_attach(device_t parent, device_t self
1602 case WM_T_82580: 1617 case WM_T_82580:
1603 case WM_T_82580ER: 1618 case WM_T_82580ER:
1604 case WM_T_I350: 1619 case WM_T_I350:
1605 case WM_T_80003: 1620 case WM_T_80003:
1606 /* SPI */ 1621 /* SPI */
1607 wm_set_spiaddrbits(sc); 1622 wm_set_spiaddrbits(sc);
1608 sc->sc_flags |= WM_F_EEPROM_EERDEEWR | WM_F_SWFW_SYNC; 1623 sc->sc_flags |= WM_F_EEPROM_EERDEEWR | WM_F_SWFW_SYNC;
1609 break; 1624 break;
1610 case WM_T_ICH8: 1625 case WM_T_ICH8:
1611 case WM_T_ICH9: 1626 case WM_T_ICH9:
1612 case WM_T_ICH10: 1627 case WM_T_ICH10:
1613 case WM_T_PCH: 1628 case WM_T_PCH:
1614 case WM_T_PCH2: 1629 case WM_T_PCH2:
 1630 case WM_T_PCH_LPT:
1615 /* FLASH */ 1631 /* FLASH */
1616 sc->sc_flags |= WM_F_EEPROM_FLASH | WM_F_SWFWHW_SYNC; 1632 sc->sc_flags |= WM_F_EEPROM_FLASH | WM_F_SWFWHW_SYNC;
1617 memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, WM_ICH8_FLASH); 1633 memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, WM_ICH8_FLASH);
1618 if (pci_mapreg_map(pa, WM_ICH8_FLASH, memtype, 0, 1634 if (pci_mapreg_map(pa, WM_ICH8_FLASH, memtype, 0,
1619 &sc->sc_flasht, &sc->sc_flashh, NULL, NULL)) { 1635 &sc->sc_flasht, &sc->sc_flashh, NULL, NULL)) {
1620 aprint_error_dev(sc->sc_dev, 1636 aprint_error_dev(sc->sc_dev,
1621 "can't map FLASH registers\n"); 1637 "can't map FLASH registers\n");
1622 return; 1638 return;
1623 } 1639 }
1624 reg = ICH8_FLASH_READ32(sc, ICH_FLASH_GFPREG); 1640 reg = ICH8_FLASH_READ32(sc, ICH_FLASH_GFPREG);
1625 sc->sc_ich8_flash_base = (reg & ICH_GFPREG_BASE_MASK) * 1641 sc->sc_ich8_flash_base = (reg & ICH_GFPREG_BASE_MASK) *
1626 ICH_FLASH_SECTOR_SIZE; 1642 ICH_FLASH_SECTOR_SIZE;
1627 sc->sc_ich8_flash_bank_size = 1643 sc->sc_ich8_flash_bank_size =
@@ -1752,26 +1768,27 @@ wm_attach(device_t parent, device_t self @@ -1752,26 +1768,27 @@ wm_attach(device_t parent, device_t self
1752 wm_read_eeprom(sc, (sc->sc_funcid == 1) ? EEPROM_OFF_CFG3_PORTB 1768 wm_read_eeprom(sc, (sc->sc_funcid == 1) ? EEPROM_OFF_CFG3_PORTB
1753 : EEPROM_OFF_CFG3_PORTA, 1, &eeprom_data); 1769 : EEPROM_OFF_CFG3_PORTA, 1, &eeprom_data);
1754 break; 1770 break;
1755 case WM_T_82575: 1771 case WM_T_82575:
1756 case WM_T_82576: 1772 case WM_T_82576:
1757 case WM_T_82580: 1773 case WM_T_82580:
1758 case WM_T_82580ER: 1774 case WM_T_82580ER:
1759 case WM_T_I350: 1775 case WM_T_I350:
1760 case WM_T_ICH8: 1776 case WM_T_ICH8:
1761 case WM_T_ICH9: 1777 case WM_T_ICH9:
1762 case WM_T_ICH10: 1778 case WM_T_ICH10:
1763 case WM_T_PCH: 1779 case WM_T_PCH:
1764 case WM_T_PCH2: 1780 case WM_T_PCH2:
 1781 case WM_T_PCH_LPT:
1765 /* XXX The funcid should be checked on some devices */ 1782 /* XXX The funcid should be checked on some devices */
1766 apme_mask = WUC_APME; 1783 apme_mask = WUC_APME;
1767 eeprom_data = CSR_READ(sc, WMREG_WUC); 1784 eeprom_data = CSR_READ(sc, WMREG_WUC);
1768 break; 1785 break;
1769 } 1786 }
1770 1787
1771 /* Check for WM_F_WOL flag after the setting of the EEPROM stuff */ 1788 /* Check for WM_F_WOL flag after the setting of the EEPROM stuff */
1772 if ((eeprom_data & apme_mask) != 0) 1789 if ((eeprom_data & apme_mask) != 0)
1773 sc->sc_flags |= WM_F_WOL; 1790 sc->sc_flags |= WM_F_WOL;
1774#ifdef WM_DEBUG 1791#ifdef WM_DEBUG
1775 if ((sc->sc_flags & WM_F_WOL) != 0) 1792 if ((sc->sc_flags & WM_F_WOL) != 0)
1776 printf("WOL\n"); 1793 printf("WOL\n");
1777#endif 1794#endif
@@ -1854,27 +1871,28 @@ wm_attach(device_t parent, device_t self @@ -1854,27 +1871,28 @@ wm_attach(device_t parent, device_t self
1854 1871
1855 if ((val & EEPROM_K1_CONFIG_ENABLE) != 0) 1872 if ((val & EEPROM_K1_CONFIG_ENABLE) != 0)
1856 sc->sc_nvm_k1_enabled = 1; 1873 sc->sc_nvm_k1_enabled = 1;
1857 else 1874 else
1858 sc->sc_nvm_k1_enabled = 0; 1875 sc->sc_nvm_k1_enabled = 0;
1859 } 1876 }
1860 1877
1861 /* 1878 /*
1862 * Determine if we're TBI,GMII or SGMII mode, and initialize the 1879 * Determine if we're TBI,GMII or SGMII mode, and initialize the
1863 * media structures accordingly. 1880 * media structures accordingly.
1864 */ 1881 */
1865 if (sc->sc_type == WM_T_ICH8 || sc->sc_type == WM_T_ICH9 1882 if (sc->sc_type == WM_T_ICH8 || sc->sc_type == WM_T_ICH9
1866 || sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_PCH 1883 || sc->sc_type == WM_T_ICH10 || sc->sc_type == WM_T_PCH
1867 || sc->sc_type == WM_T_PCH2 || sc->sc_type == WM_T_82573 1884 || sc->sc_type == WM_T_PCH2 || sc->sc_type == WM_T_PCH_LPT
 1885 || sc->sc_type == WM_T_82573
1868 || sc->sc_type == WM_T_82574 || sc->sc_type == WM_T_82583) { 1886 || sc->sc_type == WM_T_82574 || sc->sc_type == WM_T_82583) {
1869 /* STATUS_TBIMODE reserved/reused, can't rely on it */ 1887 /* STATUS_TBIMODE reserved/reused, can't rely on it */
1870 wm_gmii_mediainit(sc, wmp->wmp_product); 1888 wm_gmii_mediainit(sc, wmp->wmp_product);
1871 } else if (sc->sc_type < WM_T_82543 || 1889 } else if (sc->sc_type < WM_T_82543 ||
1872 (CSR_READ(sc, WMREG_STATUS) & STATUS_TBIMODE) != 0) { 1890 (CSR_READ(sc, WMREG_STATUS) & STATUS_TBIMODE) != 0) {
1873 if (wmp->wmp_flags & WMP_F_1000T) 1891 if (wmp->wmp_flags & WMP_F_1000T)
1874 aprint_error_dev(sc->sc_dev, 1892 aprint_error_dev(sc->sc_dev,
1875 "WARNING: TBIMODE set on 1000BASE-T product!\n"); 1893 "WARNING: TBIMODE set on 1000BASE-T product!\n");
1876 wm_tbi_mediainit(sc); 1894 wm_tbi_mediainit(sc);
1877 } else { 1895 } else {
1878 switch (sc->sc_type) { 1896 switch (sc->sc_type) {
1879 case WM_T_82575: 1897 case WM_T_82575:
1880 case WM_T_82576: 1898 case WM_T_82576:
@@ -1943,26 +1961,27 @@ wm_attach(device_t parent, device_t self @@ -1943,26 +1961,27 @@ wm_attach(device_t parent, device_t self
1943 case WM_T_82572: 1961 case WM_T_82572:
1944 case WM_T_82574: 1962 case WM_T_82574:
1945 case WM_T_82575: 1963 case WM_T_82575:
1946 case WM_T_82576: 1964 case WM_T_82576:
1947 case WM_T_82580: 1965 case WM_T_82580:
1948 case WM_T_82580ER: 1966 case WM_T_82580ER:
1949 case WM_T_I350: 1967 case WM_T_I350:
1950 case WM_T_I210: 1968 case WM_T_I210:
1951 case WM_T_I211: 1969 case WM_T_I211:
1952 case WM_T_80003: 1970 case WM_T_80003:
1953 case WM_T_ICH9: 1971 case WM_T_ICH9:
1954 case WM_T_ICH10: 1972 case WM_T_ICH10:
1955 case WM_T_PCH2: /* PCH2 supports 9K frame size */ 1973 case WM_T_PCH2: /* PCH2 supports 9K frame size */
 1974 case WM_T_PCH_LPT:
1956 /* XXX limited to 9234 */ 1975 /* XXX limited to 9234 */
1957 sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; 1976 sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
1958 break; 1977 break;
1959 case WM_T_PCH: 1978 case WM_T_PCH:
1960 /* XXX limited to 4096 */ 1979 /* XXX limited to 4096 */
1961 sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; 1980 sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU;
1962 break; 1981 break;
1963 case WM_T_82542_2_0: 1982 case WM_T_82542_2_0:
1964 case WM_T_82542_2_1: 1983 case WM_T_82542_2_1:
1965 case WM_T_82583: 1984 case WM_T_82583:
1966 case WM_T_ICH8: 1985 case WM_T_ICH8:
1967 /* No support for jumbo frame */ 1986 /* No support for jumbo frame */
1968 break; 1987 break;
@@ -4044,26 +4063,27 @@ wm_reset(struct wm_softc *sc) @@ -4044,26 +4063,27 @@ wm_reset(struct wm_softc *sc)
4044 case WM_T_82583: 4063 case WM_T_82583:
4045 sc->sc_pba = PBA_20K; 4064 sc->sc_pba = PBA_20K;
4046 break; 4065 break;
4047 case WM_T_ICH8: 4066 case WM_T_ICH8:
4048 sc->sc_pba = PBA_8K; 4067 sc->sc_pba = PBA_8K;
4049 CSR_WRITE(sc, WMREG_PBS, PBA_16K); 4068 CSR_WRITE(sc, WMREG_PBS, PBA_16K);
4050 break; 4069 break;
4051 case WM_T_ICH9: 4070 case WM_T_ICH9:
4052 case WM_T_ICH10: 4071 case WM_T_ICH10:
4053 sc->sc_pba = PBA_10K; 4072 sc->sc_pba = PBA_10K;
4054 break; 4073 break;
4055 case WM_T_PCH: 4074 case WM_T_PCH:
4056 case WM_T_PCH2: 4075 case WM_T_PCH2:
 4076 case WM_T_PCH_LPT:
4057 sc->sc_pba = PBA_26K; 4077 sc->sc_pba = PBA_26K;
4058 break; 4078 break;
4059 default: 4079 default:
4060 sc->sc_pba = sc->sc_ethercom.ec_if.if_mtu > 8192 ? 4080 sc->sc_pba = sc->sc_ethercom.ec_if.if_mtu > 8192 ?
4061 PBA_40K : PBA_48K; 4081 PBA_40K : PBA_48K;
4062 break; 4082 break;
4063 } 4083 }
4064 CSR_WRITE(sc, WMREG_PBA, sc->sc_pba); 4084 CSR_WRITE(sc, WMREG_PBA, sc->sc_pba);
4065 4085
4066 /* Prevent the PCI-E bus from sticking */ 4086 /* Prevent the PCI-E bus from sticking */
4067 if (sc->sc_flags & WM_F_PCIE) { 4087 if (sc->sc_flags & WM_F_PCIE) {
4068 int timeout = 800; 4088 int timeout = 800;
4069 4089
@@ -4158,26 +4178,27 @@ wm_reset(struct wm_softc *sc) @@ -4158,26 +4178,27 @@ wm_reset(struct wm_softc *sc)
4158 break; 4178 break;
4159 case WM_T_80003: 4179 case WM_T_80003:
4160 mask = swfwphysem[sc->sc_funcid]; 4180 mask = swfwphysem[sc->sc_funcid];
4161 reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST; 4181 reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST;
4162 wm_get_swfw_semaphore(sc, mask); 4182 wm_get_swfw_semaphore(sc, mask);
4163 CSR_WRITE(sc, WMREG_CTRL, reg); 4183 CSR_WRITE(sc, WMREG_CTRL, reg);
4164 wm_put_swfw_semaphore(sc, mask); 4184 wm_put_swfw_semaphore(sc, mask);
4165 break; 4185 break;
4166 case WM_T_ICH8: 4186 case WM_T_ICH8:
4167 case WM_T_ICH9: 4187 case WM_T_ICH9:
4168 case WM_T_ICH10: 4188 case WM_T_ICH10:
4169 case WM_T_PCH: 4189 case WM_T_PCH:
4170 case WM_T_PCH2: 4190 case WM_T_PCH2:
 4191 case WM_T_PCH_LPT:
4171 reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST; 4192 reg = CSR_READ(sc, WMREG_CTRL) | CTRL_RST;
4172 if (wm_check_reset_block(sc) == 0) { 4193 if (wm_check_reset_block(sc) == 0) {
4173 /* 4194 /*
4174 * Gate automatic PHY configuration by hardware on 4195 * Gate automatic PHY configuration by hardware on
4175 * non-managed 82579 4196 * non-managed 82579
4176 */ 4197 */
4177 if ((sc->sc_type == WM_T_PCH2) 4198 if ((sc->sc_type == WM_T_PCH2)
4178 && ((CSR_READ(sc, WMREG_FWSM) & FWSM_FW_VALID) 4199 && ((CSR_READ(sc, WMREG_FWSM) & FWSM_FW_VALID)
4179 != 0)) 4200 != 0))
4180 wm_gate_hw_phy_config_ich8lan(sc, 1); 4201 wm_gate_hw_phy_config_ich8lan(sc, 1);
4181 4202
4182 4203
4183 reg |= CTRL_PHY_RESET; 4204 reg |= CTRL_PHY_RESET;
@@ -4267,26 +4288,27 @@ wm_reset(struct wm_softc *sc) @@ -4267,26 +4288,27 @@ wm_reset(struct wm_softc *sc)
4267 case WM_T_82580ER: 4288 case WM_T_82580ER:
4268 case WM_T_I350: 4289 case WM_T_I350:
4269 case WM_T_I210: 4290 case WM_T_I210:
4270 case WM_T_I211: 4291 case WM_T_I211:
4271 case WM_T_80003: 4292 case WM_T_80003:
4272 case WM_T_ICH8: 4293 case WM_T_ICH8:
4273 case WM_T_ICH9: 4294 case WM_T_ICH9:
4274 /* check EECD_EE_AUTORD */ 4295 /* check EECD_EE_AUTORD */
4275 wm_get_auto_rd_done(sc); 4296 wm_get_auto_rd_done(sc);
4276 break; 4297 break;
4277 case WM_T_ICH10: 4298 case WM_T_ICH10:
4278 case WM_T_PCH: 4299 case WM_T_PCH:
4279 case WM_T_PCH2: 4300 case WM_T_PCH2:
 4301 case WM_T_PCH_LPT:
4280 wm_lan_init_done(sc); 4302 wm_lan_init_done(sc);
4281 break; 4303 break;
4282 default: 4304 default:
4283 panic("%s: unknown type\n", __func__); 4305 panic("%s: unknown type\n", __func__);
4284 } 4306 }
4285 4307
4286 /* Check whether EEPROM is present or not */ 4308 /* Check whether EEPROM is present or not */
4287 switch (sc->sc_type) { 4309 switch (sc->sc_type) {
4288 case WM_T_82575: 4310 case WM_T_82575:
4289 case WM_T_82576: 4311 case WM_T_82576:
4290#if 0 /* XXX */ 4312#if 0 /* XXX */
4291 case WM_T_82580: 4313 case WM_T_82580:
4292 case WM_T_82580ER: 4314 case WM_T_82580ER:
@@ -4400,26 +4422,27 @@ wm_init(struct ifnet *ifp) @@ -4400,26 +4422,27 @@ wm_init(struct ifnet *ifp)
4400 4422
4401 switch (sc->sc_type) { 4423 switch (sc->sc_type) {
4402 case WM_T_82571: 4424 case WM_T_82571:
4403 case WM_T_82572: 4425 case WM_T_82572:
4404 case WM_T_82573: 4426 case WM_T_82573:
4405 case WM_T_82574: 4427 case WM_T_82574:
4406 case WM_T_82583: 4428 case WM_T_82583:
4407 case WM_T_80003: 4429 case WM_T_80003:
4408 case WM_T_ICH8: 4430 case WM_T_ICH8:
4409 case WM_T_ICH9: 4431 case WM_T_ICH9:
4410 case WM_T_ICH10: 4432 case WM_T_ICH10:
4411 case WM_T_PCH: 4433 case WM_T_PCH:
4412 case WM_T_PCH2: 4434 case WM_T_PCH2:
 4435 case WM_T_PCH_LPT:
4413 if (wm_check_mng_mode(sc) != 0) 4436 if (wm_check_mng_mode(sc) != 0)
4414 wm_get_hw_control(sc); 4437 wm_get_hw_control(sc);
4415 break; 4438 break;
4416 default: 4439 default:
4417 break; 4440 break;
4418 } 4441 }
4419 4442
4420 /* Reset the PHY. */ 4443 /* Reset the PHY. */
4421 if (sc->sc_flags & WM_F_HAS_MII) 4444 if (sc->sc_flags & WM_F_HAS_MII)
4422 wm_gmii_reset(sc); 4445 wm_gmii_reset(sc);
4423 4446
4424 reg = CSR_READ(sc, WMREG_CTRL_EXT); 4447 reg = CSR_READ(sc, WMREG_CTRL_EXT);
4425 /* Enable PHY low-power state when MAC is at D3 w/o WoL */ 4448 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
@@ -4582,26 +4605,27 @@ wm_init(struct ifnet *ifp) @@ -4582,26 +4605,27 @@ wm_init(struct ifnet *ifp)
4582 /* Writes the control register. */ 4605 /* Writes the control register. */
4583 wm_set_vlan(sc); 4606 wm_set_vlan(sc);
4584 4607
4585 if (sc->sc_flags & WM_F_HAS_MII) { 4608 if (sc->sc_flags & WM_F_HAS_MII) {
4586 int val; 4609 int val;
4587 4610
4588 switch (sc->sc_type) { 4611 switch (sc->sc_type) {
4589 case WM_T_80003: 4612 case WM_T_80003:
4590 case WM_T_ICH8: 4613 case WM_T_ICH8:
4591 case WM_T_ICH9: 4614 case WM_T_ICH9:
4592 case WM_T_ICH10: 4615 case WM_T_ICH10:
4593 case WM_T_PCH: 4616 case WM_T_PCH:
4594 case WM_T_PCH2: 4617 case WM_T_PCH2:
 4618 case WM_T_PCH_LPT:
4595 /* 4619 /*
4596 * Set the mac to wait the maximum time between each 4620 * Set the mac to wait the maximum time between each
4597 * iteration and increase the max iterations when 4621 * iteration and increase the max iterations when
4598 * polling the phy; this fixes erroneous timeouts at 4622 * polling the phy; this fixes erroneous timeouts at
4599 * 10Mbps. 4623 * 10Mbps.
4600 */ 4624 */
4601 wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_TIMEOUTS, 4625 wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_TIMEOUTS,
4602 0xFFFF); 4626 0xFFFF);
4603 val = wm_kmrn_readreg(sc, 4627 val = wm_kmrn_readreg(sc,
4604 KUMCTRLSTA_OFFSET_INB_PARAM); 4628 KUMCTRLSTA_OFFSET_INB_PARAM);
4605 val |= 0x3F; 4629 val |= 0x3F;
4606 wm_kmrn_writereg(sc, 4630 wm_kmrn_writereg(sc,
4607 KUMCTRLSTA_OFFSET_INB_PARAM, val); 4631 KUMCTRLSTA_OFFSET_INB_PARAM, val);
@@ -4922,26 +4946,27 @@ wm_get_auto_rd_done(struct wm_softc *sc) @@ -4922,26 +4946,27 @@ wm_get_auto_rd_done(struct wm_softc *sc)
4922} 4946}
4923 4947
4924void 4948void
4925wm_lan_init_done(struct wm_softc *sc) 4949wm_lan_init_done(struct wm_softc *sc)
4926{ 4950{
4927 uint32_t reg = 0; 4951 uint32_t reg = 0;
4928 int i; 4952 int i;
4929 4953
4930 /* wait for eeprom to reload */ 4954 /* wait for eeprom to reload */
4931 switch (sc->sc_type) { 4955 switch (sc->sc_type) {
4932 case WM_T_ICH10: 4956 case WM_T_ICH10:
4933 case WM_T_PCH: 4957 case WM_T_PCH:
4934 case WM_T_PCH2: 4958 case WM_T_PCH2:
 4959 case WM_T_PCH_LPT:
4935 for (i = 0; i < WM_ICH8_LAN_INIT_TIMEOUT; i++) { 4960 for (i = 0; i < WM_ICH8_LAN_INIT_TIMEOUT; i++) {
4936 reg = CSR_READ(sc, WMREG_STATUS); 4961 reg = CSR_READ(sc, WMREG_STATUS);
4937 if ((reg & STATUS_LAN_INIT_DONE) != 0) 4962 if ((reg & STATUS_LAN_INIT_DONE) != 0)
4938 break; 4963 break;
4939 delay(100); 4964 delay(100);
4940 } 4965 }
4941 if (i >= WM_ICH8_LAN_INIT_TIMEOUT) { 4966 if (i >= WM_ICH8_LAN_INIT_TIMEOUT) {
4942 log(LOG_ERR, "%s: %s: lan_init_done failed to " 4967 log(LOG_ERR, "%s: %s: lan_init_done failed to "
4943 "complete\n", device_xname(sc->sc_dev), __func__); 4968 "complete\n", device_xname(sc->sc_dev), __func__);
4944 } 4969 }
4945 break; 4970 break;
4946 default: 4971 default:
4947 panic("%s: %s: unknown type\n", device_xname(sc->sc_dev), 4972 panic("%s: %s: unknown type\n", device_xname(sc->sc_dev),
@@ -5003,26 +5028,27 @@ wm_get_cfg_done(struct wm_softc *sc) @@ -5003,26 +5028,27 @@ wm_get_cfg_done(struct wm_softc *sc)
5003 break; 5028 break;
5004 delay(1000); 5029 delay(1000);
5005 } 5030 }
5006 if (i >= WM_PHY_CFG_TIMEOUT) { 5031 if (i >= WM_PHY_CFG_TIMEOUT) {
5007 DPRINTF(WM_DEBUG_GMII, ("%s: %s failed\n", 5032 DPRINTF(WM_DEBUG_GMII, ("%s: %s failed\n",
5008 device_xname(sc->sc_dev), __func__)); 5033 device_xname(sc->sc_dev), __func__));
5009 } 5034 }
5010 break; 5035 break;
5011 case WM_T_ICH8: 5036 case WM_T_ICH8:
5012 case WM_T_ICH9: 5037 case WM_T_ICH9:
5013 case WM_T_ICH10: 5038 case WM_T_ICH10:
5014 case WM_T_PCH: 5039 case WM_T_PCH:
5015 case WM_T_PCH2: 5040 case WM_T_PCH2:
 5041 case WM_T_PCH_LPT:
5016 if (sc->sc_type >= WM_T_PCH) { 5042 if (sc->sc_type >= WM_T_PCH) {
5017 reg = CSR_READ(sc, WMREG_STATUS); 5043 reg = CSR_READ(sc, WMREG_STATUS);
5018 if ((reg & STATUS_PHYRA) != 0) 5044 if ((reg & STATUS_PHYRA) != 0)
5019 CSR_WRITE(sc, WMREG_STATUS, 5045 CSR_WRITE(sc, WMREG_STATUS,
5020 reg & ~STATUS_PHYRA); 5046 reg & ~STATUS_PHYRA);
5021 } 5047 }
5022 delay(10*1000); 5048 delay(10*1000);
5023 break; 5049 break;
5024 default: 5050 default:
5025 panic("%s: %s: unknown type\n", device_xname(sc->sc_dev), 5051 panic("%s: %s: unknown type\n", device_xname(sc->sc_dev),
5026 __func__); 5052 __func__);
5027 break; 5053 break;
5028 } 5054 }
@@ -5287,104 +5313,131 @@ wm_read_eeprom_spi(struct wm_softc *sc,  @@ -5287,104 +5313,131 @@ wm_read_eeprom_spi(struct wm_softc *sc,
5287 for (i = 0; i < wordcnt; i++) { 5313 for (i = 0; i < wordcnt; i++) {
5288 wm_eeprom_recvbits(sc, &val, 16); 5314 wm_eeprom_recvbits(sc, &val, 16);
5289 data[i] = ((val >> 8) & 0xff) | ((val & 0xff) << 8); 5315 data[i] = ((val >> 8) & 0xff) | ((val & 0xff) << 8);
5290 } 5316 }
5291 5317
5292 /* Raise CS and clear SK. */ 5318 /* Raise CS and clear SK. */
5293 reg = (CSR_READ(sc, WMREG_EECD) & ~EECD_SK) | EECD_CS; 5319 reg = (CSR_READ(sc, WMREG_EECD) & ~EECD_SK) | EECD_CS;
5294 CSR_WRITE(sc, WMREG_EECD, reg); 5320 CSR_WRITE(sc, WMREG_EECD, reg);
5295 delay(2); 5321 delay(2);
5296 5322
5297 return 0; 5323 return 0;
5298} 5324}
5299 5325
5300#define EEPROM_CHECKSUM 0xBABA 5326#define NVM_CHECKSUM 0xBABA
5301#define EEPROM_SIZE 0x0040 5327#define EEPROM_SIZE 0x0040
 5328#define NVM_COMPAT 0x0003
 5329#define NVM_COMPAT_VALID_CHECKSUM 0x0001
 5330#define NVM_FUTURE_INIT_WORD1 0x0019
 5331#define NVM_FUTURE_INIT_WORD1_VALID_CHECKSUM 0x0040
5302 5332
5303/* 5333/*
5304 * wm_validate_eeprom_checksum 5334 * wm_validate_eeprom_checksum
5305 * 5335 *
5306 * The checksum is defined as the sum of the first 64 (16 bit) words. 5336 * The checksum is defined as the sum of the first 64 (16 bit) words.
5307 */ 5337 */
5308static int 5338static int
5309wm_validate_eeprom_checksum(struct wm_softc *sc) 5339wm_validate_eeprom_checksum(struct wm_softc *sc)
5310{ 5340{
5311 uint16_t checksum; 5341 uint16_t checksum, valid_checksum;
5312 uint16_t eeprom_data; 5342 uint16_t eeprom_data;
 5343 uint16_t csum_wordaddr;
5313 int i; 5344 int i;
5314 5345
5315 checksum = 0; 5346 checksum = 0;
5316 5347
5317 /* Don't check for I211 */ 5348 /* Don't check for I211 */
5318 if (sc->sc_type == WM_T_I211) 5349 if (sc->sc_type == WM_T_I211)
5319 return 0; 5350 return 0;
5320 5351
 5352 if (sc->sc_type == WM_T_PCH_LPT) {
 5353 printf("[PCH_LPT]");
 5354 csum_wordaddr = NVM_COMPAT;
 5355 valid_checksum = NVM_COMPAT_VALID_CHECKSUM;
 5356 } else {
 5357 csum_wordaddr = NVM_FUTURE_INIT_WORD1;
 5358 valid_checksum = NVM_FUTURE_INIT_WORD1_VALID_CHECKSUM;
 5359 }
 5360
5321#ifdef WM_DEBUG 5361#ifdef WM_DEBUG
5322 /* Dump EEPROM image for debug */ 5362 /* Dump EEPROM image for debug */
5323 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9) 5363 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
5324 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH) 5364 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
5325 || (sc->sc_type == WM_T_PCH2)) { 5365 || (sc->sc_type == WM_T_PCH2) || (sc->sc_type == WM_T_PCH_LPT)) {
5326 wm_read_eeprom(sc, 0x19, 1, &eeprom_data); 5366 wm_read_eeprom(sc, csum_wordaddr, 1, &eeprom_data);
5327 if ((eeprom_data & 0x40) == 0) { 5367 if ((eeprom_data & valid_checksum) == 0) {
5328 DPRINTF(WM_DEBUG_NVM,("%s: NVM need to be updated\n", 5368 DPRINTF(WM_DEBUG_NVM,
5329 device_xname(sc->sc_dev))); 5369 ("%s: NVM need to be updated (%04x != %04x)\n",
 5370 device_xname(sc->sc_dev), eeprom_data,
 5371 valid_checksum));
5330 } 5372 }
5331 } 5373 }
5332 5374
5333 if ((wm_debug & WM_DEBUG_NVM) != 0) { 5375 if ((wm_debug & WM_DEBUG_NVM) != 0) {
5334 printf("%s: NVM dump:\n", device_xname(sc->sc_dev)); 5376 printf("%s: NVM dump:\n", device_xname(sc->sc_dev));
5335 for (i = 0; i < EEPROM_SIZE; i++) { 5377 for (i = 0; i < EEPROM_SIZE; i++) {
5336 if (wm_read_eeprom(sc, i, 1, &eeprom_data)) 5378 if (wm_read_eeprom(sc, i, 1, &eeprom_data))
5337 printf("XX "); 5379 printf("XX ");
5338 else 5380 else
5339 printf("%04x ", eeprom_data); 5381 printf("%04x ", eeprom_data);
5340 if (i % 8 == 7) 5382 if (i % 8 == 7)
5341 printf("\n"); 5383 printf("\n");
5342 } 5384 }
5343 } 5385 }
5344 5386
5345#endif /* WM_DEBUG */ 5387#endif /* WM_DEBUG */
5346 5388
5347 for (i = 0; i < EEPROM_SIZE; i++) { 5389 for (i = 0; i < EEPROM_SIZE; i++) {
5348 if (wm_read_eeprom(sc, i, 1, &eeprom_data)) 5390 if (wm_read_eeprom(sc, i, 1, &eeprom_data))
5349 return 1; 5391 return 1;
5350 checksum += eeprom_data; 5392 checksum += eeprom_data;
5351 } 5393 }
5352 5394
5353 if (checksum != (uint16_t) EEPROM_CHECKSUM) 5395 if (checksum != (uint16_t) NVM_CHECKSUM) {
5354 return 1; 5396#ifdef WM_DEBUG
 5397 printf("%s: NVM checksum mismatch (%04x != %04x)\n",
 5398 device_xname(sc->sc_dev), checksum, NVM_CHECKSUM);
 5399#endif
 5400 /*
 5401 * XXX quick hack for non-updated NVM.
 5402 * Check only last 12bit until wm_write_eeprom() will be
 5403 * implemented.
 5404 */
 5405 if ((checksum & 0x0fff) != ((uint16_t)NVM_CHECKSUM & 0x0fff))
 5406 return 1;
 5407 }
5355 5408
5356 return 0; 5409 return 0;
5357} 5410}
5358 5411
5359/* 5412/*
5360 * wm_read_eeprom: 5413 * wm_read_eeprom:
5361 * 5414 *
5362 * Read data from the serial EEPROM. 5415 * Read data from the serial EEPROM.
5363 */ 5416 */
5364static int 5417static int
5365wm_read_eeprom(struct wm_softc *sc, int word, int wordcnt, uint16_t *data) 5418wm_read_eeprom(struct wm_softc *sc, int word, int wordcnt, uint16_t *data)
5366{ 5419{
5367 int rv; 5420 int rv;
5368 5421
5369 if (sc->sc_flags & WM_F_EEPROM_INVALID) 5422 if (sc->sc_flags & WM_F_EEPROM_INVALID)
5370 return 1; 5423 return 1;
5371 5424
5372 if (wm_acquire_eeprom(sc)) 5425 if (wm_acquire_eeprom(sc))
5373 return 1; 5426 return 1;
5374 5427
5375 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9) 5428 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
5376 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH) 5429 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
5377 || (sc->sc_type == WM_T_PCH2)) 5430 || (sc->sc_type == WM_T_PCH2) || (sc->sc_type == WM_T_PCH_LPT))
5378 rv = wm_read_eeprom_ich8(sc, word, wordcnt, data); 5431 rv = wm_read_eeprom_ich8(sc, word, wordcnt, data);
5379 else if (sc->sc_flags & WM_F_EEPROM_EERDEEWR) 5432 else if (sc->sc_flags & WM_F_EEPROM_EERDEEWR)
5380 rv = wm_read_eeprom_eerd(sc, word, wordcnt, data); 5433 rv = wm_read_eeprom_eerd(sc, word, wordcnt, data);
5381 else if (sc->sc_flags & WM_F_EEPROM_SPI) 5434 else if (sc->sc_flags & WM_F_EEPROM_SPI)
5382 rv = wm_read_eeprom_spi(sc, word, wordcnt, data); 5435 rv = wm_read_eeprom_spi(sc, word, wordcnt, data);
5383 else 5436 else
5384 rv = wm_read_eeprom_uwire(sc, word, wordcnt, data); 5437 rv = wm_read_eeprom_uwire(sc, word, wordcnt, data);
5385 5438
5386 wm_release_eeprom(sc); 5439 wm_release_eeprom(sc);
5387 return rv; 5440 return rv;
5388} 5441}
5389 5442
5390static int 5443static int
@@ -5644,27 +5697,27 @@ wm_set_ral(struct wm_softc *sc, const ui @@ -5644,27 +5697,27 @@ wm_set_ral(struct wm_softc *sc, const ui
5644 * multicast filter. 5697 * multicast filter.
5645 */ 5698 */
5646static uint32_t 5699static uint32_t
5647wm_mchash(struct wm_softc *sc, const uint8_t *enaddr) 5700wm_mchash(struct wm_softc *sc, const uint8_t *enaddr)
5648{ 5701{
5649 static const int lo_shift[4] = { 4, 3, 2, 0 }; 5702 static const int lo_shift[4] = { 4, 3, 2, 0 };
5650 static const int hi_shift[4] = { 4, 5, 6, 8 }; 5703 static const int hi_shift[4] = { 4, 5, 6, 8 };
5651 static const int ich8_lo_shift[4] = { 6, 5, 4, 2 }; 5704 static const int ich8_lo_shift[4] = { 6, 5, 4, 2 };
5652 static const int ich8_hi_shift[4] = { 2, 3, 4, 6 }; 5705 static const int ich8_hi_shift[4] = { 2, 3, 4, 6 };
5653 uint32_t hash; 5706 uint32_t hash;
5654 5707
5655 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9) 5708 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
5656 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH) 5709 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
5657 || (sc->sc_type == WM_T_PCH2)) { 5710 || (sc->sc_type == WM_T_PCH2) || (sc->sc_type == WM_T_PCH_LPT)) {
5658 hash = (enaddr[4] >> ich8_lo_shift[sc->sc_mchash_type]) | 5711 hash = (enaddr[4] >> ich8_lo_shift[sc->sc_mchash_type]) |
5659 (((uint16_t) enaddr[5]) << ich8_hi_shift[sc->sc_mchash_type]); 5712 (((uint16_t) enaddr[5]) << ich8_hi_shift[sc->sc_mchash_type]);
5660 return (hash & 0x3ff); 5713 return (hash & 0x3ff);
5661 } 5714 }
5662 hash = (enaddr[4] >> lo_shift[sc->sc_mchash_type]) | 5715 hash = (enaddr[4] >> lo_shift[sc->sc_mchash_type]) |
5663 (((uint16_t) enaddr[5]) << hi_shift[sc->sc_mchash_type]); 5716 (((uint16_t) enaddr[5]) << hi_shift[sc->sc_mchash_type]);
5664 5717
5665 return (hash & 0xfff); 5718 return (hash & 0xfff);
5666} 5719}
5667 5720
5668/* 5721/*
5669 * wm_set_filter: 5722 * wm_set_filter:
5670 * 5723 *
@@ -5692,70 +5745,72 @@ wm_set_filter(struct wm_softc *sc) @@ -5692,70 +5745,72 @@ wm_set_filter(struct wm_softc *sc)
5692 sc->sc_rctl |= RCTL_BAM; 5745 sc->sc_rctl |= RCTL_BAM;
5693 if (ifp->if_flags & IFF_PROMISC) { 5746 if (ifp->if_flags & IFF_PROMISC) {
5694 sc->sc_rctl |= RCTL_UPE; 5747 sc->sc_rctl |= RCTL_UPE;
5695 goto allmulti; 5748 goto allmulti;
5696 } 5749 }
5697 5750
5698 /* 5751 /*
5699 * Set the station address in the first RAL slot, and 5752 * Set the station address in the first RAL slot, and
5700 * clear the remaining slots. 5753 * clear the remaining slots.
5701 */ 5754 */
5702 if (sc->sc_type == WM_T_ICH8) 5755 if (sc->sc_type == WM_T_ICH8)
5703 size = WM_RAL_TABSIZE_ICH8 -1; 5756 size = WM_RAL_TABSIZE_ICH8 -1;
5704 else if ((sc->sc_type == WM_T_ICH9) || (sc->sc_type == WM_T_ICH10) 5757 else if ((sc->sc_type == WM_T_ICH9) || (sc->sc_type == WM_T_ICH10)
5705 || (sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2)) 5758 || (sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2)
 5759 || (sc->sc_type == WM_T_PCH_LPT))
5706 size = WM_RAL_TABSIZE_ICH8; 5760 size = WM_RAL_TABSIZE_ICH8;
5707 else if (sc->sc_type == WM_T_82575) 5761 else if (sc->sc_type == WM_T_82575)
5708 size = WM_RAL_TABSIZE_82575; 5762 size = WM_RAL_TABSIZE_82575;
5709 else if ((sc->sc_type == WM_T_82576) || (sc->sc_type == WM_T_82580)) 5763 else if ((sc->sc_type == WM_T_82576) || (sc->sc_type == WM_T_82580))
5710 size = WM_RAL_TABSIZE_82576; 5764 size = WM_RAL_TABSIZE_82576;
5711 else if (sc->sc_type == WM_T_I350) 5765 else if (sc->sc_type == WM_T_I350)
5712 size = WM_RAL_TABSIZE_I350; 5766 size = WM_RAL_TABSIZE_I350;
5713 else 5767 else
5714 size = WM_RAL_TABSIZE; 5768 size = WM_RAL_TABSIZE;
5715 wm_set_ral(sc, CLLADDR(ifp->if_sadl), 0); 5769 wm_set_ral(sc, CLLADDR(ifp->if_sadl), 0);
5716 for (i = 1; i < size; i++) 5770 for (i = 1; i < size; i++)
5717 wm_set_ral(sc, NULL, i); 5771 wm_set_ral(sc, NULL, i);
5718 5772
5719 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9) 5773 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
5720 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH) 5774 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
5721 || (sc->sc_type == WM_T_PCH2)) 5775 || (sc->sc_type == WM_T_PCH2) || (sc->sc_type == WM_T_PCH_LPT))
5722 size = WM_ICH8_MC_TABSIZE; 5776 size = WM_ICH8_MC_TABSIZE;
5723 else 5777 else
5724 size = WM_MC_TABSIZE; 5778 size = WM_MC_TABSIZE;
5725 /* Clear out the multicast table. */ 5779 /* Clear out the multicast table. */
5726 for (i = 0; i < size; i++) 5780 for (i = 0; i < size; i++)
5727 CSR_WRITE(sc, mta_reg + (i << 2), 0); 5781 CSR_WRITE(sc, mta_reg + (i << 2), 0);
5728 5782
5729 ETHER_FIRST_MULTI(step, ec, enm); 5783 ETHER_FIRST_MULTI(step, ec, enm);
5730 while (enm != NULL) { 5784 while (enm != NULL) {
5731 if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) { 5785 if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
5732 /* 5786 /*
5733 * We must listen to a range of multicast addresses. 5787 * We must listen to a range of multicast addresses.
5734 * For now, just accept all multicasts, rather than 5788 * For now, just accept all multicasts, rather than
5735 * trying to set only those filter bits needed to match 5789 * trying to set only those filter bits needed to match
5736 * the range. (At this time, the only use of address 5790 * the range. (At this time, the only use of address
5737 * ranges is for IP multicast routing, for which the 5791 * ranges is for IP multicast routing, for which the
5738 * range is big enough to require all bits set.) 5792 * range is big enough to require all bits set.)
5739 */ 5793 */
5740 goto allmulti; 5794 goto allmulti;
5741 } 5795 }
5742 5796
5743 hash = wm_mchash(sc, enm->enm_addrlo); 5797 hash = wm_mchash(sc, enm->enm_addrlo);
5744 5798
5745 reg = (hash >> 5); 5799 reg = (hash >> 5);
5746 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9) 5800 if ((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
5747 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH) 5801 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
5748 || (sc->sc_type == WM_T_PCH2)) 5802 || (sc->sc_type == WM_T_PCH2)
 5803 || (sc->sc_type == WM_T_PCH_LPT))
5749 reg &= 0x1f; 5804 reg &= 0x1f;
5750 else 5805 else
5751 reg &= 0x7f; 5806 reg &= 0x7f;
5752 bit = hash & 0x1f; 5807 bit = hash & 0x1f;
5753 5808
5754 hash = CSR_READ(sc, mta_reg + (reg << 2)); 5809 hash = CSR_READ(sc, mta_reg + (reg << 2));
5755 hash |= 1U << bit; 5810 hash |= 1U << bit;
5756 5811
5757 /* XXX Hardware bug?? */ 5812 /* XXX Hardware bug?? */
5758 if (sc->sc_type == WM_T_82544 && (reg & 0xe) == 1) { 5813 if (sc->sc_type == WM_T_82544 && (reg & 0xe) == 1) {
5759 bit = CSR_READ(sc, mta_reg + ((reg - 1) << 2)); 5814 bit = CSR_READ(sc, mta_reg + ((reg - 1) << 2));
5760 CSR_WRITE(sc, mta_reg + (reg << 2), hash); 5815 CSR_WRITE(sc, mta_reg + (reg << 2), hash);
5761 CSR_WRITE(sc, mta_reg + ((reg - 1) << 2), bit); 5816 CSR_WRITE(sc, mta_reg + ((reg - 1) << 2), bit);
@@ -6088,26 +6143,27 @@ wm_gmii_reset(struct wm_softc *sc) @@ -6088,26 +6143,27 @@ wm_gmii_reset(struct wm_softc *sc)
6088 case WM_T_82580: 6143 case WM_T_82580:
6089 case WM_T_82580ER: 6144 case WM_T_82580ER:
6090 case WM_T_I350: 6145 case WM_T_I350:
6091 case WM_T_I210: 6146 case WM_T_I210:
6092 case WM_T_I211: 6147 case WM_T_I211:
6093 case WM_T_80003: 6148 case WM_T_80003:
6094 rv = wm_get_swfw_semaphore(sc, swfwphysem[sc->sc_funcid]); 6149 rv = wm_get_swfw_semaphore(sc, swfwphysem[sc->sc_funcid]);
6095 break; 6150 break;
6096 case WM_T_ICH8: 6151 case WM_T_ICH8:
6097 case WM_T_ICH9: 6152 case WM_T_ICH9:
6098 case WM_T_ICH10: 6153 case WM_T_ICH10:
6099 case WM_T_PCH: 6154 case WM_T_PCH:
6100 case WM_T_PCH2: 6155 case WM_T_PCH2:
 6156 case WM_T_PCH_LPT:
6101 rv = wm_get_swfwhw_semaphore(sc); 6157 rv = wm_get_swfwhw_semaphore(sc);
6102 break; 6158 break;
6103 default: 6159 default:
6104 /* nothing to do*/ 6160 /* nothing to do*/
6105 rv = 0; 6161 rv = 0;
6106 break; 6162 break;
6107 } 6163 }
6108 if (rv != 0) { 6164 if (rv != 0) {
6109 aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n", 6165 aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
6110 __func__); 6166 __func__);
6111 return; 6167 return;
6112 } 6168 }
6113 6169
@@ -6174,26 +6230,27 @@ wm_gmii_reset(struct wm_softc *sc) @@ -6174,26 +6230,27 @@ wm_gmii_reset(struct wm_softc *sc)
6174 if ((sc->sc_type == WM_T_82541) 6230 if ((sc->sc_type == WM_T_82541)
6175 || (sc->sc_type == WM_T_82541_2) 6231 || (sc->sc_type == WM_T_82541_2)
6176 || (sc->sc_type == WM_T_82547) 6232 || (sc->sc_type == WM_T_82547)
6177 || (sc->sc_type == WM_T_82547_2)) { 6233 || (sc->sc_type == WM_T_82547_2)) {
6178 /* workaround for igp are done in igp_reset() */ 6234 /* workaround for igp are done in igp_reset() */
6179 /* XXX add code to set LED after phy reset */ 6235 /* XXX add code to set LED after phy reset */
6180 } 6236 }
6181 break; 6237 break;
6182 case WM_T_ICH8: 6238 case WM_T_ICH8:
6183 case WM_T_ICH9: 6239 case WM_T_ICH9:
6184 case WM_T_ICH10: 6240 case WM_T_ICH10:
6185 case WM_T_PCH: 6241 case WM_T_PCH:
6186 case WM_T_PCH2: 6242 case WM_T_PCH2:
 6243 case WM_T_PCH_LPT:
6187 /* generic reset */ 6244 /* generic reset */
6188 CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_PHY_RESET); 6245 CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_PHY_RESET);
6189 delay(100); 6246 delay(100);
6190 CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl); 6247 CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl);
6191 delay(150); 6248 delay(150);
6192 break; 6249 break;
6193 default: 6250 default:
6194 panic("%s: %s: unknown type\n", device_xname(sc->sc_dev), 6251 panic("%s: %s: unknown type\n", device_xname(sc->sc_dev),
6195 __func__); 6252 __func__);
6196 break; 6253 break;
6197 } 6254 }
6198 6255
6199 /* release PHY semaphore */ 6256 /* release PHY semaphore */
@@ -6211,26 +6268,27 @@ wm_gmii_reset(struct wm_softc *sc) @@ -6211,26 +6268,27 @@ wm_gmii_reset(struct wm_softc *sc)
6211 case WM_T_82580: 6268 case WM_T_82580:
6212 case WM_T_82580ER: 6269 case WM_T_82580ER:
6213 case WM_T_I350: 6270 case WM_T_I350:
6214 case WM_T_I210: 6271 case WM_T_I210:
6215 case WM_T_I211: 6272 case WM_T_I211:
6216 case WM_T_80003: 6273 case WM_T_80003:
6217 wm_put_swfw_semaphore(sc, swfwphysem[sc->sc_funcid]); 6274 wm_put_swfw_semaphore(sc, swfwphysem[sc->sc_funcid]);
6218 break; 6275 break;
6219 case WM_T_ICH8: 6276 case WM_T_ICH8:
6220 case WM_T_ICH9: 6277 case WM_T_ICH9:
6221 case WM_T_ICH10: 6278 case WM_T_ICH10:
6222 case WM_T_PCH: 6279 case WM_T_PCH:
6223 case WM_T_PCH2: 6280 case WM_T_PCH2:
 6281 case WM_T_PCH_LPT:
6224 wm_put_swfwhw_semaphore(sc); 6282 wm_put_swfwhw_semaphore(sc);
6225 break; 6283 break;
6226 default: 6284 default:
6227 /* nothing to do*/ 6285 /* nothing to do*/
6228 rv = 0; 6286 rv = 0;
6229 break; 6287 break;
6230 } 6288 }
6231 6289
6232 /* get_cfg_done */ 6290 /* get_cfg_done */
6233 wm_get_cfg_done(sc); 6291 wm_get_cfg_done(sc);
6234 6292
6235 /* extra setup */ 6293 /* extra setup */
6236 switch (sc->sc_type) { 6294 switch (sc->sc_type) {
@@ -6259,26 +6317,27 @@ wm_gmii_reset(struct wm_softc *sc) @@ -6259,26 +6317,27 @@ wm_gmii_reset(struct wm_softc *sc)
6259 case WM_T_82583: 6317 case WM_T_82583:
6260 case WM_T_80003: 6318 case WM_T_80003:
6261 /* null */ 6319 /* null */
6262 break; 6320 break;
6263 case WM_T_82541: 6321 case WM_T_82541:
6264 case WM_T_82547: 6322 case WM_T_82547:
6265 /* XXX Configure actively LED after PHY reset */ 6323 /* XXX Configure actively LED after PHY reset */
6266 break; 6324 break;
6267 case WM_T_ICH8: 6325 case WM_T_ICH8:
6268 case WM_T_ICH9: 6326 case WM_T_ICH9:
6269 case WM_T_ICH10: 6327 case WM_T_ICH10:
6270 case WM_T_PCH: 6328 case WM_T_PCH:
6271 case WM_T_PCH2: 6329 case WM_T_PCH2:
 6330 case WM_T_PCH_LPT:
6272 /* Allow time for h/w to get to a quiescent state afer reset */ 6331 /* Allow time for h/w to get to a quiescent state afer reset */
6273 delay(10*1000); 6332 delay(10*1000);
6274 6333
6275 if (sc->sc_type == WM_T_PCH) 6334 if (sc->sc_type == WM_T_PCH)
6276 wm_hv_phy_workaround_ich8lan(sc); 6335 wm_hv_phy_workaround_ich8lan(sc);
6277 6336
6278 if (sc->sc_type == WM_T_PCH2) 6337 if (sc->sc_type == WM_T_PCH2)
6279 wm_lv_phy_workaround_ich8lan(sc); 6338 wm_lv_phy_workaround_ich8lan(sc);
6280 6339
6281 if ((sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2)) { 6340 if ((sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2)) {
6282 /* 6341 /*
6283 * dummy read to clear the phy wakeup bit after lcd 6342 * dummy read to clear the phy wakeup bit after lcd
6284 * reset 6343 * reset
@@ -6440,30 +6499,30 @@ wm_gmii_mediainit(struct wm_softc *sc, p @@ -6440,30 +6499,30 @@ wm_gmii_mediainit(struct wm_softc *sc, p
6440 for (i = 1; i < 8; i++) 6499 for (i = 1; i < 8; i++)
6441 mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, 6500 mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
6442 i, MII_OFFSET_ANY, MIIF_DOPAUSE); 6501 i, MII_OFFSET_ANY, MIIF_DOPAUSE);
6443 6502
6444 /* restore previous sfp cage power state */ 6503 /* restore previous sfp cage power state */
6445 CSR_WRITE(sc, WMREG_CTRL_EXT, ctrl_ext); 6504 CSR_WRITE(sc, WMREG_CTRL_EXT, ctrl_ext);
6446 } 6505 }
6447 } else { 6506 } else {
6448 mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, 6507 mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
6449 MII_OFFSET_ANY, MIIF_DOPAUSE); 6508 MII_OFFSET_ANY, MIIF_DOPAUSE);
6450 } 6509 }
6451 6510
6452 /* 6511 /*
6453 * If the MAC is PCH2 and failed to detect MII PHY, call 6512 * If the MAC is PCH2 or PCH_LPT and failed to detect MII PHY, call
6454 * wm_set_mdio_slow_mode_hv() for a workaround and retry. 6513 * wm_set_mdio_slow_mode_hv() for a workaround and retry.
6455 */ 6514 */
6456 if ((sc->sc_type == WM_T_PCH2) && 6515 if (((sc->sc_type == WM_T_PCH2) || (sc->sc_type == WM_T_PCH_LPT)) &&
6457 (LIST_FIRST(&mii->mii_phys) == NULL)) { 6516 (LIST_FIRST(&mii->mii_phys) == NULL)) {
6458 wm_set_mdio_slow_mode_hv(sc); 6517 wm_set_mdio_slow_mode_hv(sc);
6459 mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, 6518 mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
6460 MII_OFFSET_ANY, MIIF_DOPAUSE); 6519 MII_OFFSET_ANY, MIIF_DOPAUSE);
6461 } 6520 }
6462 6521
6463 /* 6522 /*
6464 * (For ICH8 variants) 6523 * (For ICH8 variants)
6465 * If PHY detection failed, use BM's r/w function and retry. 6524 * If PHY detection failed, use BM's r/w function and retry.
6466 */ 6525 */
6467 if (LIST_FIRST(&mii->mii_phys) == NULL) { 6526 if (LIST_FIRST(&mii->mii_phys) == NULL) {
6468 /* if failed, retry with *_bm_* */ 6527 /* if failed, retry with *_bm_* */
6469 mii->mii_readreg = wm_gmii_bm_readreg; 6528 mii->mii_readreg = wm_gmii_bm_readreg;
@@ -7759,26 +7818,27 @@ wm_read_ich8_word(struct wm_softc *sc, u @@ -7759,26 +7818,27 @@ wm_read_ich8_word(struct wm_softc *sc, u
7759} 7818}
7760 7819
7761static int 7820static int
7762wm_check_mng_mode(struct wm_softc *sc) 7821wm_check_mng_mode(struct wm_softc *sc)
7763{ 7822{
7764 int rv; 7823 int rv;
7765 7824
7766 switch (sc->sc_type) { 7825 switch (sc->sc_type) {
7767 case WM_T_ICH8: 7826 case WM_T_ICH8:
7768 case WM_T_ICH9: 7827 case WM_T_ICH9:
7769 case WM_T_ICH10: 7828 case WM_T_ICH10:
7770 case WM_T_PCH: 7829 case WM_T_PCH:
7771 case WM_T_PCH2: 7830 case WM_T_PCH2:
 7831 case WM_T_PCH_LPT:
7772 rv = wm_check_mng_mode_ich8lan(sc); 7832 rv = wm_check_mng_mode_ich8lan(sc);
7773 break; 7833 break;
7774 case WM_T_82574: 7834 case WM_T_82574:
7775 case WM_T_82583: 7835 case WM_T_82583:
7776 rv = wm_check_mng_mode_82574(sc); 7836 rv = wm_check_mng_mode_82574(sc);
7777 break; 7837 break;
7778 case WM_T_82571: 7838 case WM_T_82571:
7779 case WM_T_82572: 7839 case WM_T_82572:
7780 case WM_T_82573: 7840 case WM_T_82573:
7781 case WM_T_80003: 7841 case WM_T_80003:
7782 rv = wm_check_mng_mode_generic(sc); 7842 rv = wm_check_mng_mode_generic(sc);
7783 break; 7843 break;
7784 default: 7844 default:
@@ -7860,26 +7920,27 @@ wm_enable_mng_pass_thru(struct wm_softc  @@ -7860,26 +7920,27 @@ wm_enable_mng_pass_thru(struct wm_softc
7860} 7920}
7861 7921
7862static int 7922static int
7863wm_check_reset_block(struct wm_softc *sc) 7923wm_check_reset_block(struct wm_softc *sc)
7864{ 7924{
7865 uint32_t reg; 7925 uint32_t reg;
7866 7926
7867 switch (sc->sc_type) { 7927 switch (sc->sc_type) {
7868 case WM_T_ICH8: 7928 case WM_T_ICH8:
7869 case WM_T_ICH9: 7929 case WM_T_ICH9:
7870 case WM_T_ICH10: 7930 case WM_T_ICH10:
7871 case WM_T_PCH: 7931 case WM_T_PCH:
7872 case WM_T_PCH2: 7932 case WM_T_PCH2:
 7933 case WM_T_PCH_LPT:
7873 reg = CSR_READ(sc, WMREG_FWSM); 7934 reg = CSR_READ(sc, WMREG_FWSM);
7874 if ((reg & FWSM_RSPCIPHY) != 0) 7935 if ((reg & FWSM_RSPCIPHY) != 0)
7875 return 0; 7936 return 0;
7876 else 7937 else
7877 return -1; 7938 return -1;
7878 break; 7939 break;
7879 case WM_T_82571: 7940 case WM_T_82571:
7880 case WM_T_82572: 7941 case WM_T_82572:
7881 case WM_T_82573: 7942 case WM_T_82573:
7882 case WM_T_82574: 7943 case WM_T_82574:
7883 case WM_T_82583: 7944 case WM_T_82583:
7884 case WM_T_80003: 7945 case WM_T_80003:
7885 reg = CSR_READ(sc, WMREG_MANC); 7946 reg = CSR_READ(sc, WMREG_MANC);
@@ -7906,26 +7967,27 @@ wm_get_hw_control(struct wm_softc *sc) @@ -7906,26 +7967,27 @@ wm_get_hw_control(struct wm_softc *sc)
7906 reg = CSR_READ(sc, WMREG_SWSM); 7967 reg = CSR_READ(sc, WMREG_SWSM);
7907 CSR_WRITE(sc, WMREG_SWSM, reg | SWSM_DRV_LOAD); 7968 CSR_WRITE(sc, WMREG_SWSM, reg | SWSM_DRV_LOAD);
7908 break; 7969 break;
7909 case WM_T_82571: 7970 case WM_T_82571:
7910 case WM_T_82572: 7971 case WM_T_82572:
7911 case WM_T_82574: 7972 case WM_T_82574:
7912 case WM_T_82583: 7973 case WM_T_82583:
7913 case WM_T_80003: 7974 case WM_T_80003:
7914 case WM_T_ICH8: 7975 case WM_T_ICH8:
7915 case WM_T_ICH9: 7976 case WM_T_ICH9:
7916 case WM_T_ICH10: 7977 case WM_T_ICH10:
7917 case WM_T_PCH: 7978 case WM_T_PCH:
7918 case WM_T_PCH2: 7979 case WM_T_PCH2:
 7980 case WM_T_PCH_LPT:
7919 reg = CSR_READ(sc, WMREG_CTRL_EXT); 7981 reg = CSR_READ(sc, WMREG_CTRL_EXT);
7920 CSR_WRITE(sc, WMREG_CTRL_EXT, reg | CTRL_EXT_DRV_LOAD); 7982 CSR_WRITE(sc, WMREG_CTRL_EXT, reg | CTRL_EXT_DRV_LOAD);
7921 break; 7983 break;
7922 default: 7984 default:
7923 break; 7985 break;
7924 } 7986 }
7925} 7987}
7926 7988
7927static void 7989static void
7928wm_release_hw_control(struct wm_softc *sc) 7990wm_release_hw_control(struct wm_softc *sc)
7929{ 7991{
7930 uint32_t reg; 7992 uint32_t reg;
7931 7993
@@ -8371,26 +8433,27 @@ wm_get_wakeup(struct wm_softc *sc) @@ -8371,26 +8433,27 @@ wm_get_wakeup(struct wm_softc *sc)
8371 case WM_T_82580: 8433 case WM_T_82580:
8372 case WM_T_82580ER: 8434 case WM_T_82580ER:
8373 case WM_T_I350: 8435 case WM_T_I350:
8374#endif 8436#endif
8375 if ((CSR_READ(sc, WMREG_FWSM) & FWSM_MODE_MASK) != 0) 8437 if ((CSR_READ(sc, WMREG_FWSM) & FWSM_MODE_MASK) != 0)
8376 sc->sc_flags |= WM_F_ARC_SUBSYS_VALID; 8438 sc->sc_flags |= WM_F_ARC_SUBSYS_VALID;
8377 sc->sc_flags |= WM_F_ASF_FIRMWARE_PRES; 8439 sc->sc_flags |= WM_F_ASF_FIRMWARE_PRES;
8378 break; 8440 break;
8379 case WM_T_ICH8: 8441 case WM_T_ICH8:
8380 case WM_T_ICH9: 8442 case WM_T_ICH9:
8381 case WM_T_ICH10: 8443 case WM_T_ICH10:
8382 case WM_T_PCH: 8444 case WM_T_PCH:
8383 case WM_T_PCH2: 8445 case WM_T_PCH2:
 8446 case WM_T_PCH_LPT:
8384 sc->sc_flags |= WM_F_HAS_AMT; 8447 sc->sc_flags |= WM_F_HAS_AMT;
8385 sc->sc_flags |= WM_F_ASF_FIRMWARE_PRES; 8448 sc->sc_flags |= WM_F_ASF_FIRMWARE_PRES;
8386 break; 8449 break;
8387 default: 8450 default:
8388 break; 8451 break;
8389 } 8452 }
8390 8453
8391 /* 1: HAS_MANAGE */ 8454 /* 1: HAS_MANAGE */
8392 if (wm_enable_mng_pass_thru(sc) != 0) 8455 if (wm_enable_mng_pass_thru(sc) != 0)
8393 sc->sc_flags |= WM_F_HAS_MANAGE; 8456 sc->sc_flags |= WM_F_HAS_MANAGE;
8394 8457
8395#ifdef WM_DEBUG 8458#ifdef WM_DEBUG
8396 printf("\n"); 8459 printf("\n");
@@ -8446,26 +8509,27 @@ wm_enable_wakeup(struct wm_softc *sc) @@ -8446,26 +8509,27 @@ wm_enable_wakeup(struct wm_softc *sc)
8446 8509
8447 /* Advertise the wakeup capability */ 8510 /* Advertise the wakeup capability */
8448 CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_SWDPIN(2) 8511 CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl | CTRL_SWDPIN(2)
8449 | CTRL_SWDPIN(3)); 8512 | CTRL_SWDPIN(3));
8450 CSR_WRITE(sc, WMREG_WUC, WUC_APME); 8513 CSR_WRITE(sc, WMREG_WUC, WUC_APME);
8451 8514
8452 /* ICH workaround */ 8515 /* ICH workaround */
8453 switch (sc->sc_type) { 8516 switch (sc->sc_type) {
8454 case WM_T_ICH8: 8517 case WM_T_ICH8:
8455 case WM_T_ICH9: 8518 case WM_T_ICH9:
8456 case WM_T_ICH10: 8519 case WM_T_ICH10:
8457 case WM_T_PCH: 8520 case WM_T_PCH:
8458 case WM_T_PCH2: 8521 case WM_T_PCH2:
 8522 case WM_T_PCH_LPT:
8459 /* Disable gig during WOL */ 8523 /* Disable gig during WOL */
8460 reg = CSR_READ(sc, WMREG_PHY_CTRL); 8524 reg = CSR_READ(sc, WMREG_PHY_CTRL);
8461 reg |= PHY_CTRL_D0A_LPLU | PHY_CTRL_GBE_DIS; 8525 reg |= PHY_CTRL_D0A_LPLU | PHY_CTRL_GBE_DIS;
8462 CSR_WRITE(sc, WMREG_PHY_CTRL, reg); 8526 CSR_WRITE(sc, WMREG_PHY_CTRL, reg);
8463 if (sc->sc_type == WM_T_PCH) 8527 if (sc->sc_type == WM_T_PCH)
8464 wm_gmii_reset(sc); 8528 wm_gmii_reset(sc);
8465 8529
8466 /* Power down workaround */ 8530 /* Power down workaround */
8467 if (sc->sc_phytype == WMPHY_82577) { 8531 if (sc->sc_phytype == WMPHY_82577) {
8468 struct mii_softc *child; 8532 struct mii_softc *child;
8469 8533
8470 /* Assume that the PHY is copper */ 8534 /* Assume that the PHY is copper */
8471 child = LIST_FIRST(&sc->sc_mii.mii_phys); 8535 child = LIST_FIRST(&sc->sc_mii.mii_phys);

cvs diff -r1.15 -r1.16 src/sys/dev/pci/if_wmvar.h (expand / switch to unified diff)

--- src/sys/dev/pci/if_wmvar.h 2013/04/18 12:42:03 1.15
+++ src/sys/dev/pci/if_wmvar.h 2013/06/02 09:36:22 1.16
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_wmvar.h,v 1.15 2013/04/18 12:42:03 msaitoh Exp $ */ 1/* $NetBSD: if_wmvar.h,v 1.16 2013/06/02 09:36:22 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. 4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -119,29 +119,27 @@ typedef enum { @@ -119,29 +119,27 @@ typedef enum {
119 WM_T_82575, /* i82575 */ 119 WM_T_82575, /* i82575 */
120 WM_T_82576, /* i82576 */ 120 WM_T_82576, /* i82576 */
121 WM_T_82580, /* i82580 */ 121 WM_T_82580, /* i82580 */
122 WM_T_82580ER, /* i82580ER */ 122 WM_T_82580ER, /* i82580ER */
123 WM_T_I350, /* I350 */ 123 WM_T_I350, /* I350 */
124 WM_T_I210, /* I210 */ 124 WM_T_I210, /* I210 */
125 WM_T_I211, /* I211 */ 125 WM_T_I211, /* I211 */
126 WM_T_80003, /* i80003 */ 126 WM_T_80003, /* i80003 */
127 WM_T_ICH8, /* ICH8 LAN */ 127 WM_T_ICH8, /* ICH8 LAN */
128 WM_T_ICH9, /* ICH9 LAN */ 128 WM_T_ICH9, /* ICH9 LAN */
129 WM_T_ICH10, /* ICH10 LAN */ 129 WM_T_ICH10, /* ICH10 LAN */
130 WM_T_PCH, /* PCH LAN */ 130 WM_T_PCH, /* PCH LAN */
131 WM_T_PCH2, /* PCH2 LAN */ 131 WM_T_PCH2, /* PCH2 LAN */
132#if 0 
133 WM_T_PCH_LPT, /* PCH LPT LAN (I21[78]) */ 132 WM_T_PCH_LPT, /* PCH LPT LAN (I21[78]) */
134#endif 
135} wm_chip_type; 133} wm_chip_type;
136 134
137typedef enum { 135typedef enum {
138 WMPHY_UNKNOWN = 0, 136 WMPHY_UNKNOWN = 0,
139 WMPHY_NONE, 137 WMPHY_NONE,
140 WMPHY_M88, 138 WMPHY_M88,
141 WMPHY_IGP, 139 WMPHY_IGP,
142 WMPHY_IGP_2, 140 WMPHY_IGP_2,
143 WMPHY_GG82563, 141 WMPHY_GG82563,
144 WMPHY_IGP_3, 142 WMPHY_IGP_3,
145 WMPHY_IFE, 143 WMPHY_IFE,
146 WMPHY_BM, 144 WMPHY_BM,
147 WMPHY_82577, 145 WMPHY_82577,