From nobody Thu Aug 11 14:53:09 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M3VD620jGz4Y7Z3; Thu, 11 Aug 2022 14:53:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M3VD61VCXz3Sfl; Thu, 11 Aug 2022 14:53:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660229590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3T6Fv55EhTy4K12CxJZTVXcon4AR4QaDxdxmQ+ec2sY=; b=axRmopruFT6TP6iooGbxF44UIHvFE60HUyiSGsXrhStTzxsGVcbZbKhMikTHDHSGH56wSj dDuIlxVmOtboGHIwFpInzOcLoYhkJ4D5rE09FWMZUCGxq/WjfbC+NArG10ItOrtwhug8cc TZ6KCwECrmNQ4EhZPeO70G/wRhtP4eKINfjor075g/+h4FTtvpi/PbsEcwSOeNIv45BJFn 5RID6qnuiBQG9FXHuIID7Z02XThuEvzzykc0RU7JSi/k02GlYdE69eGqx86q9zqkGNqhD6 4GY6YAskKawljgPXoyA5WcEzE5BYDpkkTFaK9MiSl3EOl+7LhsAGJ3h9+fyzWQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M3VD60XPdzw96; Thu, 11 Aug 2022 14:53:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27BEr9tT032329; Thu, 11 Aug 2022 14:53:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BEr958032328; Thu, 11 Aug 2022 14:53:09 GMT (envelope-from git) Date: Thu, 11 Aug 2022 14:53:09 GMT Message-Id: <202208111453.27BEr958032328@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 104d385fed2e - stable/12 - if_dwc: Split init code into sub function List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 104d385fed2e2959dbae8b7a8ddbcae7f28c95f0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660229590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3T6Fv55EhTy4K12CxJZTVXcon4AR4QaDxdxmQ+ec2sY=; b=gZYBFsUfex9tUd2NJeLeVfifRCLZZjGhld0KZWgl4csqCRwDSFNV2ptCeHLS8X+sx6UFjB N3RToH/i3Yt3hs3N9QKveDsj3v7vsonmnvCE2VWaYPjjsVRMWEvfBsCi8Pj2kHpmokjOUj Q/stWpOQisxxDgViWsxufVk2gt+9mrA3OgmxJiIdT8wBDpWdpNsXoBWWC+exl5Y0Hk51HC zrK1/wq7WUkQY08FPgP/OTICyUypOLW6uQNvYdl4nZTtjAyunbodUiTfnq+iRz7nB0J6df 71LwiBKRG8BUpVBFDDuebAZFZ1bhMi5zatbsteBMCSlsVvbuqjeqzwaES1DOPw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660229590; a=rsa-sha256; cv=none; b=nrvWpXcn2fLjpIdk8ONfmzJrN1A7Rog9BzHnm1LeGWgETrcR6J1Upij0NMa4hhNJ5uQFx0 VCXuG+q4iktJJofY9qPk3+Y7FxiPpPlYwPHyh1VLQi10hpGtCsUikDDtQUFZUgNxTd2QkR dMJREr07tG2PRpL2USJmixGiP3fNA9svN+gogJHBofQ9FKebhnOv/F+89f5aAXmAvckM20 hRoEYprJWSiNBAcJAKeycf0gP4AKct2+iTTslsmJ3IjaChygh/hBoPGQmF10fxlT2vntT4 jFiOyvr3uf6nDBG6pGgKilVU1EdqdHMPh34qUicm46RDVRpykFT8rB72/ukI4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=104d385fed2e2959dbae8b7a8ddbcae7f28c95f0 commit 104d385fed2e2959dbae8b7a8ddbcae7f28c95f0 Author: Emmanuel Vadot AuthorDate: 2020-11-20 11:26:46 +0000 Commit: Mitchell Horne CommitDate: 2022-08-11 14:52:02 +0000 if_dwc: Split init code into sub function Be clear of what we enable or init. No functional changes intended (cherry picked from commit 158ce7ba0ed04fc65f6f09381ab924f10b7e96a0) --- sys/dev/dwc/if_dwc.c | 61 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c index 0b38439b3e12..6c15bf9e71df 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -211,6 +211,8 @@ static void dwc_txfinish_locked(struct dwc_softc *sc); static void dwc_rxfinish_locked(struct dwc_softc *sc); static void dwc_stop_locked(struct dwc_softc *sc); static void dwc_setup_rxfilter(struct dwc_softc *sc); +static void dwc_setup_core(struct dwc_softc *sc); +static void dwc_init_dma(struct dwc_softc *sc); static inline uint32_t next_rxidx(struct dwc_softc *sc, uint32_t curidx) @@ -473,7 +475,6 @@ static void dwc_init_locked(struct dwc_softc *sc) { struct ifnet *ifp = sc->ifp; - uint32_t reg; DWC_ASSERT_LOCKED(sc); @@ -483,26 +484,8 @@ dwc_init_locked(struct dwc_softc *sc) ifp->if_drv_flags |= IFF_DRV_RUNNING; dwc_setup_rxfilter(sc); - - /* Initializa DMA and enable transmitters */ - reg = READ4(sc, OPERATION_MODE); - reg |= (MODE_TSF | MODE_OSF | MODE_FUF); - reg &= ~(MODE_RSF); - reg |= (MODE_RTC_LEV32 << MODE_RTC_SHIFT); - WRITE4(sc, OPERATION_MODE, reg); - - WRITE4(sc, INTERRUPT_ENABLE, INT_EN_DEFAULT); - - /* Start DMA */ - reg = READ4(sc, OPERATION_MODE); - reg |= (MODE_ST | MODE_SR); - WRITE4(sc, OPERATION_MODE, reg); - - /* Enable transmitters */ - reg = READ4(sc, MAC_CONFIGURATION); - reg |= (CONF_JD | CONF_ACS | CONF_BE); - reg |= (CONF_TE | CONF_RE); - WRITE4(sc, MAC_CONFIGURATION, reg); + dwc_setup_core(sc); + dwc_init_dma(sc); /* * Call mii_mediachg() which will call back into dwc_miibus_statchg() @@ -788,6 +771,42 @@ dwc_setup_rxfilter(struct dwc_softc *sc) } } +static void +dwc_setup_core(struct dwc_softc *sc) +{ + uint32_t reg; + + DWC_ASSERT_LOCKED(sc); + + /* Enable transmitters */ + reg = READ4(sc, MAC_CONFIGURATION); + reg |= (CONF_JD | CONF_ACS | CONF_BE); + reg |= (CONF_TE | CONF_RE); + WRITE4(sc, MAC_CONFIGURATION, reg); +} + +static void +dwc_init_dma(struct dwc_softc *sc) +{ + uint32_t reg; + + DWC_ASSERT_LOCKED(sc); + + /* Initializa DMA and enable transmitters */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_TSF | MODE_OSF | MODE_FUF); + reg &= ~(MODE_RSF); + reg |= (MODE_RTC_LEV32 << MODE_RTC_SHIFT); + WRITE4(sc, OPERATION_MODE, reg); + + WRITE4(sc, INTERRUPT_ENABLE, INT_EN_DEFAULT); + + /* Start DMA */ + reg = READ4(sc, OPERATION_MODE); + reg |= (MODE_ST | MODE_SR); + WRITE4(sc, OPERATION_MODE, reg); +} + static int dwc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) {