From owner-svn-src-all@freebsd.org Mon Jun 11 18:44:57 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F5571005F24; Mon, 11 Jun 2018 18:44:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5414775DBE; Mon, 11 Jun 2018 18:44:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 35E851F4DC; Mon, 11 Jun 2018 18:44:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BIivuL020864; Mon, 11 Jun 2018 18:44:57 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5BIiuIO020862; Mon, 11 Jun 2018 18:44:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201806111844.w5BIiuIO020862@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 11 Jun 2018 18:44:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334964 - in head: share/man/man4 sys/dev/usb/net X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in head: share/man/man4 sys/dev/usb/net X-SVN-Commit-Revision: 334964 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 18:44:57 -0000 Author: emaste Date: Mon Jun 11 18:44:56 2018 New Revision: 334964 URL: https://svnweb.freebsd.org/changeset/base/334964 Log: if_muge: add LAN7850 support Differences between LAN7800 and LAN7850 from the driver's perspective: * The LAN7800 muxes EEPROM signals with LEDs, so LED mode needs to be disabled when reading/writing EEPROM. The EEPROM is not muxed on the LAN7850. * The Linux driver enables automatic duplex and speed detection when there is no EEPROM, for the LAN7800 only. With this FreeBSD driver LAN7850-based adapters without a configuration EEPROM fail to link (with or without the automatic duplex and speed detection code), so I have just followed the example of the Linux driver for now. Sponsored by: The FreeBSD Foundation Sponsored by: Microchip (hardware) Modified: head/share/man/man4/muge.4 head/sys/dev/usb/net/if_muge.c Modified: head/share/man/man4/muge.4 ============================================================================== --- head/share/man/man4/muge.4 Mon Jun 11 17:22:27 2018 (r334963) +++ head/share/man/man4/muge.4 Mon Jun 11 18:44:56 2018 (r334964) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 17, 2018 +.Dd June 11, 2018 .Dt MUGE 4 .Os .Sh NAME @@ -56,6 +56,8 @@ driver supports: .It Microchip LAN7800 USB 3.1 Gigabit Ethernet controller with PHY .It +Microchip LAN7850 USB 2.0 Gigabit Ethernet controller with PHY +.It Microchip LAN7515 USB 2 hub and Gigabit Ethernet controller with PHY .El .Sh SEE ALSO @@ -68,3 +70,6 @@ The .Nm device driver first appeared in .Fx 12.0 . +.Sh BUGS +USB-Ethernet adapters that use the LAN7850 without a configuration EEPROM +will not work. Modified: head/sys/dev/usb/net/if_muge.c ============================================================================== --- head/sys/dev/usb/net/if_muge.c Mon Jun 11 17:22:27 2018 (r334963) +++ head/sys/dev/usb/net/if_muge.c Mon Jun 11 18:44:56 2018 (r334964) @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); * USB 3.1 to 10/100/1000 Mbps Ethernet * LAN7800 http://www.microchip.com/wwwproducts/en/LAN7800 * + * USB 2.0 to 10/100/1000 Mbps Ethernet + * LAN7850 http://www.microchip.com/wwwproducts/en/LAN7850 + * * USB 2 to 10/100/1000 Mbps Ethernet with built-in USB hub * LAN7515 (no datasheet available, but probes and functions as LAN7800) * @@ -386,11 +389,14 @@ lan78xx_eeprom_read_raw(struct muge_softc *sc, uint16_ if (!locked) MUGE_LOCK(sc); - err = lan78xx_read_reg(sc, ETH_HW_CFG, &val); - saved = val; + if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_) { + /* EEDO/EECLK muxed with LED0/LED1 on LAN7800. */ + err = lan78xx_read_reg(sc, ETH_HW_CFG, &val); + saved = val; - val &= ~(ETH_HW_CFG_LEDO_EN_ | ETH_HW_CFG_LED1_EN_); - err = lan78xx_write_reg(sc, ETH_HW_CFG, val); + val &= ~(ETH_HW_CFG_LEDO_EN_ | ETH_HW_CFG_LED1_EN_); + err = lan78xx_write_reg(sc, ETH_HW_CFG, val); + } err = lan78xx_wait_for_bits(sc, ETH_E2P_CMD, ETH_E2P_CMD_BUSY_); if (err != 0) { @@ -432,7 +438,10 @@ lan78xx_eeprom_read_raw(struct muge_softc *sc, uint16_ done: if (!locked) MUGE_UNLOCK(sc); - lan78xx_write_reg(sc, ETH_HW_CFG, saved); + if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_) { + /* Restore saved LED configuration. */ + lan78xx_write_reg(sc, ETH_HW_CFG, saved); + } return (err); } @@ -982,7 +991,11 @@ lan78xx_chip_init(struct muge_softc *sc) } sc->chipid = (buf & ETH_ID_REV_CHIP_ID_MASK_) >> 16; sc->chiprev = buf & ETH_ID_REV_CHIP_REV_MASK_; - if (sc->chipid != ETH_ID_REV_CHIP_ID_7800_) { + switch (sc->chipid) { + case ETH_ID_REV_CHIP_ID_7800_: + case ETH_ID_REV_CHIP_ID_7850_: + break; + default: muge_warn_printf(sc, "Chip ID 0x%04x not yet supported\n", sc->chipid); goto init_failed; @@ -1078,9 +1091,12 @@ lan78xx_chip_init(struct muge_softc *sc) goto init_failed; } - /* Enable automatic duplex detection and automatic speed detection. */ err = lan78xx_read_reg(sc, ETH_MAC_CR, &buf); - buf |= ETH_MAC_CR_AUTO_DUPLEX_ | ETH_MAC_CR_AUTO_SPEED_; + if (sc->chipid == ETH_ID_REV_CHIP_ID_7800_ && + !lan78xx_eeprom_present(sc)) { + /* Set automatic duplex and speed on LAN7800 without EEPROM. */ + buf |= ETH_MAC_CR_AUTO_DUPLEX_ | ETH_MAC_CR_AUTO_SPEED_; + } err = lan78xx_write_reg(sc, ETH_MAC_CR, buf); /*