From nobody Mon May 16 13:51:22 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 9BAC81B354F9; Mon, 16 May 2022 13:51:23 +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 4L20yz03VGz3Ggc; Mon, 16 May 2022 13:51:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652709083; 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=3mH52TAknjPlVP8RpMoxRqnyk56rh8GNZWSSveNJJYo=; b=tglFUWVIVQN6dBlxuHUZp1EGHvOWr7JN4l4DisgQxMqpK7g7uot42XuYJJCagATSX1VmiO rXuQjtHTiH49U9DkwJIImDmuUkcVL6Ei25ppKSwaACI5bmVcPcQaHgCnqQHxTaOITZCFrq xrZYSKU+R1v4hjUi0aIo4CorIGPd1l2U6i5j7PbXkmHW4RKh4U+cIhKkDuJ+owZWr0+eFy MD2peJFExf1OyoFZKfM6i2LwVS/pPOZj/Xvzg5mXtSzjYjkoPELQ7NqZo5EXthig+fTyPR jLZgrHyqTw5co09smr4Zc7pN/TP1iR6vltUp6ZpJhr9RV8DTzjqAQSPlwRdhbw== 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 9EE062150D; Mon, 16 May 2022 13:51:22 +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 24GDpMm8079749; Mon, 16 May 2022 13:51:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24GDpM3n079748; Mon, 16 May 2022 13:51:22 GMT (envelope-from git) Date: Mon, 16 May 2022 13:51:22 GMT Message-Id: <202205161351.24GDpM3n079748@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: fe1c0e6d2af0 - stable/13 - cgem: support SGMII PHY connection mode 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/13 X-Git-Reftype: branch X-Git-Commit: fe1c0e6d2af0edf6c0353020d702a47caacf69ac Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652709083; 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=3mH52TAknjPlVP8RpMoxRqnyk56rh8GNZWSSveNJJYo=; b=kNq8+IMyMRoOyFBKHTl0L2yvh+jkR+midjBFr5nIFj5Tk4/cxPFS9RFf/n9iq960EJ3AT+ J0TqiTwOmCDh3AvkPiGSoT5FiQJwPGYu8qraOiYdKVjtmglRuCPtUbNsG0qPl2G9DJCAIC 6K/j2SPs/+DIF4/AqP4WUbog174ssuAmInIyTWojVHl6OF/C6Z5a1vKmAcxCxG21l/qLPm k2LXp6+cmEfUnxhyWrBu54cWJ2AWqDnojQgm/qwiwh9wn/qTDSoUvHaase4D0I8ib8mi6j LY0BIoCUHtyauM2jISsV/vHE9Tz2CEFcGI+xCy5mofc0+nrw+jaurozDXdAcTQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652709083; a=rsa-sha256; cv=none; b=M8kx9Cfg1q9TTH1dbQ24sM7Qz3LBZeZ3KfSrkGHQidOKJaRKUObrap6FpOx9I+7K7IIQeC gpfmX37A0ZXN0U/Aqn1yZwBD7JlAsFnwj0V2IvPCeMdmDcJIByXnKNFfy6Wx/cHjkVsjQG jkkUtzp77iwn02ycS5ZuV+kVfZEN1GTXd4Vk5PjYV/aI+dckjKcQvIk3i+SyWTgwItntWN h3Q3/LVAOSomAs8oX4xG7EbciUUNS1MC+vuLZgrhVZDi3OwtkoZ3pquiPnxENkHCtEt11S r8OK5sLcDccF7cP8iWjAxcnaepLzoFIyf3nCqOTlwEV4sySWw2yia81VC/gKSA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=fe1c0e6d2af0edf6c0353020d702a47caacf69ac commit fe1c0e6d2af0edf6c0353020d702a47caacf69ac Author: Milan Obuch AuthorDate: 2022-04-07 13:04:18 +0000 Commit: Mitchell Horne CommitDate: 2022-05-16 13:34:04 +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 (cherry picked from commit 34f4c17a2b3df50e9badd030edba187d6acf3b87) --- 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)