From owner-svn-src-head@freebsd.org Sun Nov 22 20:16:47 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D5C4C473292; Sun, 22 Nov 2020 20:16:47 +0000 (UTC) (envelope-from manu@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CfM4v5jN7z3vny; Sun, 22 Nov 2020 20:16:47 +0000 (UTC) (envelope-from manu@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 B271420288; Sun, 22 Nov 2020 20:16:47 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AMKGl0f018183; Sun, 22 Nov 2020 20:16:47 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AMKGlj3018182; Sun, 22 Nov 2020 20:16:47 GMT (envelope-from manu@FreeBSD.org) Message-Id: <202011222016.0AMKGlj3018182@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sun, 22 Nov 2020 20:16:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367940 - head/sys/dev/dwc X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/dwc X-SVN-Commit-Revision: 367940 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Nov 2020 20:16:47 -0000 Author: manu Date: Sun Nov 22 20:16:46 2020 New Revision: 367940 URL: https://svnweb.freebsd.org/changeset/base/367940 Log: if_dwc: Correctly configure the DMA engine based on the fdt properties Do not hardcode what we setup for the DMA engine configuration but lookup the fdt properties and configuring accordingly. Use a default value of 8 for the burst dma length for both TX and RX, this is what we used for TX before. Modified: head/sys/dev/dwc/if_dwc.c head/sys/dev/dwc/if_dwc.h Modified: head/sys/dev/dwc/if_dwc.c ============================================================================== --- head/sys/dev/dwc/if_dwc.c Sun Nov 22 18:54:14 2020 (r367939) +++ head/sys/dev/dwc/if_dwc.c Sun Nov 22 20:16:46 2020 (r367940) @@ -1496,6 +1496,9 @@ dwc_attach(device_t dev) uint32_t reg; char *phy_mode; phandle_t node; + uint32_t txpbl, rxpbl; + bool nopblx8 = false; + bool fixed_burst = false; sc = device_get_softc(dev); sc->dev = dev; @@ -1513,6 +1516,15 @@ dwc_attach(device_t dev) OF_prop_free(phy_mode); } + if (OF_getencprop(node, "snps,txpbl", &txpbl, sizeof(uint32_t)) <= 0) + txpbl = 8; + if (OF_getencprop(node, "snps,rxpbl", &rxpbl, sizeof(uint32_t)) <= 0) + rxpbl = 8; + if (OF_hasprop(node, "snps,no-pbl-x8") == 1) + nopblx8 = true; + if (OF_hasprop(node, "snps,fixed-burst") == 1) + fixed_burst = true; + if (IF_DWC_INIT(dev) != 0) return (ENXIO); @@ -1550,12 +1562,13 @@ dwc_attach(device_t dev) return (ENXIO); } - if (sc->mactype != DWC_GMAC_EXT_DESC) { - reg = BUS_MODE_FIXEDBURST; - reg |= (BUS_MODE_PRIORXTX_41 << BUS_MODE_PRIORXTX_SHIFT); - } else - reg = (BUS_MODE_EIGHTXPBL); - reg |= (BUS_MODE_PBL_BEATS_8 << BUS_MODE_PBL_SHIFT); + reg = BUS_MODE_USP; + if (!nopblx8) + reg |= BUS_MODE_EIGHTXPBL; + reg |= (txpbl << BUS_MODE_PBL_SHIFT); + reg |= (rxpbl << BUS_MODE_RPBL_SHIFT); + if (fixed_burst) + reg |= BUS_MODE_FIXEDBURST; WRITE4(sc, BUS_MODE, reg); /* Modified: head/sys/dev/dwc/if_dwc.h ============================================================================== --- head/sys/dev/dwc/if_dwc.h Sun Nov 22 18:54:14 2020 (r367939) +++ head/sys/dev/dwc/if_dwc.h Sun Nov 22 20:16:46 2020 (r367940) @@ -220,6 +220,8 @@ /* DMA */ #define BUS_MODE 0x1000 #define BUS_MODE_EIGHTXPBL (1 << 24) /* Multiplies PBL by 8 */ +#define BUS_MODE_USP (1 << 23) +#define BUS_MODE_RPBL_SHIFT 17 /* Single block transfer size */ #define BUS_MODE_FIXEDBURST (1 << 16) #define BUS_MODE_PRIORXTX_SHIFT 14 #define BUS_MODE_PRIORXTX_41 3