From nobody Tue Apr 12 22:52:11 2022 X-Original-To: dev-commits-src-all@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 12FDC1AF662B; Tue, 12 Apr 2022 22:52:12 +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 4KdLZg6Zw7z3NgP; Tue, 12 Apr 2022 22:52:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649803932; 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=bRcW6JbtRaom8bAta6ZNUI/wNNJjV0IMsQFzeiPxYXE=; b=Pf9zucpJH/UHq4ul3wXvViVbECdVCgQCaSDXHaK1ChFdNFoJV3FUYvlZEIAy1AGB/JvqMt zyrUQ4yahud2hjwuqlELNml8iHCCFuJoHycM4RWGUcSrzlNmbRxgxamRn9lHBg0ZLpSyfB VtwVSBRFXoOYOaDzsP4SSfs/TNdfMev1feX0Dn5V3nrKTlpiCoKzGs6spNldi+5j5LGPnX otuPGP6fvQ/Vlbe5nqdm7LgUZLkcWSzxFCBrphUunDnIdYzxlUNxuVeYsxsZ+DRimnWD54 ZAyvd85I976U5fjoXxOTs/hMOFVwrrZesndq88Wz/c6e6I0iYxqdHzHZV+92oA== 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 B94C42037A; Tue, 12 Apr 2022 22:52:11 +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 23CMqB6R015696; Tue, 12 Apr 2022 22:52:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23CMqBk0015695; Tue, 12 Apr 2022 22:52:11 GMT (envelope-from git) Date: Tue, 12 Apr 2022 22:52:11 GMT Message-Id: <202204122252.23CMqBk0015695@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 34f4c17a2b3d - main - cgem: support SGMII PHY connection mode List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 34f4c17a2b3df50e9badd030edba187d6acf3b87 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649803932; 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=bRcW6JbtRaom8bAta6ZNUI/wNNJjV0IMsQFzeiPxYXE=; b=onfDoRknEu/ww3pB1mvA//GCDyxTpx+YCmAdkaZyMhWKPuWs8ZHR+lfFlqdm00FStLej0g GbOrfvWkg1ePE5N+D5szRGLPMWfZWkMMjNzTTG4Wfib96N5qRhUcFYyUKG2efh0uCu7SjI hPQ4W5Oy/0PyxFFs8OxpZFtW9ywCBxoS1h+Ri/MCPiVpKApH06M28j/PxyFKPgFZgXkdX8 1cPY58ACV50UcE8Q6Ve0rLu2KKmlWBR4iczFJa+5aT4V87nOIppRGNZp2IvOIYo3UNMUUv KDakMwPDFibmg5LYQ31QXMT3oOAKc/dkMUjN2J/rhWMm4ZK/MOZQXyrwXd2n8A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649803932; a=rsa-sha256; cv=none; b=dik0UWgMr6sfSMcjA9lFiqS1GmrcRhNMD5scohFu2M3H8U5FckAvNlhuHMNxsqYIleAi+D 6cCMuIXcFgku93lsDrZLQxu+D4LfN57Tib+BHG86PvX16R1J5Very/CTZHTHBS9xdR9SHL ghc8QtRP7MH9NsbXDpUm+0rfQWIdYn8Ih0hLal8sIY5bks0F8l4i77mIOPpHW6Q+RRyB1U RVorkgSn/VZCv6HRaqEhWBcPAB8n1ml9YNus98ELGGvYTG3KHpKK4PU+pYFgpy0HeFb+gd dYsNSW6jcIf7BQEiQGfdjj/m7PlW3X36zPHABt/A8hrfHVOUfUvveH3nDfnjUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=34f4c17a2b3df50e9badd030edba187d6acf3b87 commit 34f4c17a2b3df50e9badd030edba187d6acf3b87 Author: Milan Obuch AuthorDate: 2022-04-07 13:04:18 +0000 Commit: Mitchell Horne CommitDate: 2022-04-12 22:51:17 +0000 cgem: support SGMII PHY connection mode As the PolarFire SoC needs SGMII to connect the PHY, check the 'phy-mode' property of device tree node for ethernet and act on it appropriately. Add the compatible strings for the PolarFire SoC device tree. 'microchip,mpfs-mss-gem" is not officially documented but has been observed in the available firmware for this platform, so it is included for now. Also, fix a typo in if_cgem_hw.h. Reviewed by: mhorne MFC after: 1 week Sponsored by: Conclusive Engineering Differential Revision: https://reviews.freebsd.org/D34764 --- sys/dev/cadence/if_cgem.c | 14 ++++++++++++++ sys/dev/cadence/if_cgem_hw.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/dev/cadence/if_cgem.c b/sys/dev/cadence/if_cgem.c index 979ca524c624..948e1c6b6c69 100644 --- a/sys/dev/cadence/if_cgem.c +++ b/sys/dev/cadence/if_cgem.c @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include @@ -109,9 +110,11 @@ __FBSDID("$FreeBSD$"); static struct ofw_compat_data compat_data[] = { { "cdns,zynq-gem", HWQUIRK_RXHANGWAR | HWQUIRK_TXCLK }, { "cdns,zynqmp-gem", HWQUIRK_NEEDNULLQS | HWQUIRK_TXCLK }, + { "microchip,mpfs-mss-gem", HWQUIRK_NEEDNULLQS | HWQUIRK_TXCLK }, { "sifive,fu540-c000-gem", HWQUIRK_PCLK }, { "sifive,fu740-c000-gem", HWQUIRK_PCLK }, { "cdns,gem", HWQUIRK_NONE }, + { "cdns,macb", HWQUIRK_NONE }, { "cadence,gem", HWQUIRK_NONE }, { NULL, 0 } }; @@ -131,6 +134,7 @@ struct cgem_softc { uint32_t net_cfg_shadow; clk_t ref_clk; int neednullqs; + int phy_contype; bus_dma_tag_t desc_dma_tag; bus_dma_tag_t mbuf_dma_tag; @@ -1084,6 +1088,12 @@ cgem_config(struct cgem_softc *sc) CGEM_NET_CFG_GIGE_EN | CGEM_NET_CFG_1536RXEN | CGEM_NET_CFG_FULL_DUPLEX | CGEM_NET_CFG_SPEED100); + /* Check connection type, enable SGMII bits if necessary. */ + if (sc->phy_contype == MII_CONTYPE_SGMII) { + sc->net_cfg_shadow |= CGEM_NET_CFG_SGMII_EN; + sc->net_cfg_shadow |= CGEM_NET_CFG_PCS_SEL; + } + /* Enable receive checksum offloading? */ if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0) sc->net_cfg_shadow |= CGEM_NET_CFG_RX_CHKSUM_OFFLD_EN; @@ -1728,6 +1738,7 @@ cgem_attach(device_t dev) int rid, err; u_char eaddr[ETHER_ADDR_LEN]; int hwquirks; + phandle_t node; sc->dev = dev; CGEM_LOCK_INIT(sc); @@ -1753,6 +1764,9 @@ cgem_attach(device_t dev) device_printf(dev, "could not enable clock.\n"); } + node = ofw_bus_get_node(dev); + sc->phy_contype = mii_fdt_get_contype(node); + /* Get memory resource. */ rid = 0; sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, diff --git a/sys/dev/cadence/if_cgem_hw.h b/sys/dev/cadence/if_cgem_hw.h index 784b131a885e..afba8f7dfcd7 100644 --- a/sys/dev/cadence/if_cgem_hw.h +++ b/sys/dev/cadence/if_cgem_hw.h @@ -63,7 +63,7 @@ #define CGEM_NET_CTRL_RX_EN (1 << 2) #define CGEM_NET_CTRL_LOOP_LOCAL (1 << 1) -#define CGEM_NET_CFG 0x004 /* Netowrk Configuration */ +#define CGEM_NET_CFG 0x004 /* Network Configuration */ #define CGEM_NET_CFG_UNIDIR_EN (1U << 31) #define CGEM_NET_CFG_IGNORE_IPG_RX_ER (1 << 30) #define CGEM_NET_CFG_RX_BAD_PREAMBLE (1 << 29)