From nobody Tue Jan 3 09:21:36 2023 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 4NmS0d1LfWz2pFDd; Tue, 3 Jan 2023 09:21:37 +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 4NmS0d0vrxz4CmG; Tue, 3 Jan 2023 09:21:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672737697; 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=vUP6cK7VJDgtdTwHY3sZv6dqfrbmJeno88YmjYMc8Kc=; b=wHfNNYLmeeo8O/wDthUh133D0tR+/xSeirl6RKThWt0vPncB8DoG38bfVggYvSEaSR8gom BnplHW4hRFR4CHluW+pPDqwE9lazzhw1iQhLR7ZRN/C+kUZda8O5oGJk0leMwyISDmWZsJ 34zJAvDRGl5wKxqlkbjW0EMxN0WMiVuWsn0SfxOpcpP+2aZQ5KDiMTNmDBhT0+YztyFGBJ SIQ7fpFXssAWwnQyK8muh/rn9MN89IaM3wxb9W2hGIECal3R3GUMIqFnWwpQFSae1Uc5nX RvSkYXOwKAI8yPDq4I8LzbQCOuzp2TErMEoGJosAuON8WCpicM6FwZhvkm4OJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672737697; 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=vUP6cK7VJDgtdTwHY3sZv6dqfrbmJeno88YmjYMc8Kc=; b=w+hybIiKU01pidmN050OSFHe055G9oW4GhZionYaLge/OKjgL4F7oegUtsxIz1lfc9ixsN S0DAMmJLWli3eHEvu0JhzmwZJmfsaKhuL58f1QWIyTgFTmwemf2W/p/s1U4eD629xSgHel 1dw/dRpfRtPAVXCZedwikaw8aHk1joX2+3KJ8Pi6gb8Jr8mvw9Icp9HdFHC12GCbr2EPj9 0X0lynWm1WKryZRUAg4MG0dr5+08sM3YoU6f1n0OSxPFNOT3MPbbYaJdFROrT9+ZjEUuDB WaUYgXuYVnNjvW60UqFB87THO2ysImEBBsbcVdf7uAPGh0kAbNyPLDcqu6kYLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672737697; a=rsa-sha256; cv=none; b=NuQyUfbf8xFO/1dxz0ejly37UVQMa7RUOJkdrLaiPWBtCW9ZDr1E6e5Y9vUw/NFzeUz0Gu 40VvZxLGERxhqcPQVbVadzxQ/bxtvST4n7d8/Jy8zASfUWYnbFJd+WLssOjalQq8DuvSvF vIAcbAzJ7h4KFvfYRi6EFZ/l2eCJVt/F1bQIg68yAfW7K/2H+QT0vzF18saboPOwiIND4j StnvZ9c88y4Dr38GBr2z9iBq1/88YkvmXjE6BIO62FPsMpx9kBQnyGdDlQy2tukj1pWP2L /KJCYLE3aT+h9102lxmNfgwN0qksxdKyC1O0tqlOWI1Z+YcSPjYakZyZdPrl7A== 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 4NmS0c75LtzRKS; Tue, 3 Jan 2023 09:21:36 +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 3039LaV7083851; Tue, 3 Jan 2023 09:21:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3039LaGW083850; Tue, 3 Jan 2023 09:21:36 GMT (envelope-from git) Date: Tue, 3 Jan 2023 09:21:36 GMT Message-Id: <202301030921.3039LaGW083850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michal Meloun Subject: git: e4ef4c5d66c3 - main - extres/phy: Add mode setting function. 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: mmel X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e4ef4c5d66c3680ed32a8b77f960c728ecf2a1b7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=e4ef4c5d66c3680ed32a8b77f960c728ecf2a1b7 commit e4ef4c5d66c3680ed32a8b77f960c728ecf2a1b7 Author: Michal Meloun AuthorDate: 2021-02-03 08:51:45 +0000 Commit: Michal Meloun CommitDate: 2023-01-03 09:19:29 +0000 extres/phy: Add mode setting function. Modern multi-protocol phys are capable of supporting multiple different protocols. Add a method for mode (and/or its variants) setting. Discused with: ganbold, manu, andrew MFC after: 3 weeks --- sys/dev/extres/phy/phy.c | 34 +++++++++++++++++++-- sys/dev/extres/phy/phy.h | 66 ++++++++++++++++++++++++++++++++++++++--- sys/dev/extres/phy/phynode_if.m | 14 +++++++-- 3 files changed, 105 insertions(+), 9 deletions(-) diff --git a/sys/dev/extres/phy/phy.c b/sys/dev/extres/phy/phy.c index 0ed633ffbe41..8861102b8508 100644 --- a/sys/dev/extres/phy/phy.c +++ b/sys/dev/extres/phy/phy.c @@ -1,6 +1,5 @@ /*- * Copyright 2016 Michal Meloun - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,7 +24,6 @@ */ #include -__FBSDID("$FreeBSD$"); #include "opt_platform.h" #include @@ -271,6 +269,22 @@ phynode_disable(struct phynode *phynode) return (0); } +/* + * Set phy mode (protocol and its variant). + */ +int +phynode_set_mode(struct phynode *phynode, phy_mode_t mode, + phy_submode_t submode) +{ + int rv; + + PHY_TOPO_ASSERT(); + + PHYNODE_XLOCK(phynode); + rv = PHYNODE_SET_MODE(phynode, mode, submode); + PHYNODE_UNLOCK(phynode); + return (rv); +} /* * Get phy status. (PHY_STATUS_*) @@ -353,6 +367,22 @@ phy_disable(phy_t phy) return (rv); } +int +phy_set_mode(phy_t phy, phy_mode_t mode, phy_submode_t submode) +{ + int rv; + struct phynode *phynode; + + phynode = phy->phynode; + KASSERT(phynode->ref_cnt > 0, + ("Attempt to access unreferenced phy.\n")); + + PHY_TOPO_SLOCK(); + rv = phynode_set_mode(phynode, mode, submode); + PHY_TOPO_UNLOCK(); + return (rv); +} + int phy_status(phy_t phy, int *status) { diff --git a/sys/dev/extres/phy/phy.h b/sys/dev/extres/phy/phy.h index b0e5249e4246..a72904a10e2b 100644 --- a/sys/dev/extres/phy/phy.h +++ b/sys/dev/extres/phy/phy.h @@ -1,6 +1,5 @@ /*- * Copyright 2016 Michal Meloun - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -22,7 +21,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ */ #ifndef DEV_EXTRES_PHY_H @@ -33,10 +31,66 @@ #ifdef FDT #include #endif -#include "phynode_if.h" #define PHY_STATUS_ENABLED 0x00000001 +typedef enum phy_mode { + PHY_MODE_INVALID, + PHY_MODE_USB_HOST, + PHY_MODE_USB_DEVICE, + PHY_MODE_USB_OTG, + PHY_MODE_UFS, + PHY_MODE_PCIE, + PHY_MODE_ETHERNET, + PHY_MODE_MIPI_DPHY, + PHY_MODE_SATA, + PHY_MODE_LVDS, + PHY_MODE_DP +} phy_mode_t ; + +typedef enum phy_submode { + /* Common */ + PHY_SUBMODE_NA = 0, /* Not applicable */ + PHY_SUBMODE_INTERNAL, + + /* Ethernet */ + PHY_SUBMODE_ETH_MII = 1000, + PHY_SUBMODE_ETH_GMII, + PHY_SUBMODE_ETH_SGMII, + PHY_SUBMODE_ETH_TBI, + PHY_SUBMODE_ETH_REVMII, + PHY_SUBMODE_ETH_RMII, + PHY_SUBMODE_ETH_RGMII, + PHY_SUBMODE_ETH_RGMII_ID, + PHY_SUBMODE_ETH_RGMII_RXID, + PHY_SUBMODE_ETH_RGMII_TXID, + PHY_SUBMODE_ETH_RTBI, + PHY_SUBMODE_ETH_SMII, + PHY_SUBMODE_ETH_XGMII, + PHY_SUBMODE_ETH_XLGMII, + PHY_SUBMODE_ETH_MOCA, + PHY_SUBMODE_ETH_QSGMII, + PHY_SUBMODE_ETH_TRGMII, + PHY_SUBMODE_ETH_1000BASEX, + PHY_SUBMODE_ETH_2500BASEX, + PHY_SUBMODE_ETH_RXAUI, + PHY_SUBMODE_ETH_XAUI, + PHY_SUBMODE_ETH_10GBASER, + PHY_SUBMODE_ETH_USXGMII, + PHY_SUBMODE_ETH_10GKR, + + /* USB */ + PHY_SUBMODE_USB_LS = 2000, + PHY_SUBMODE_USB_FS, + PHY_SUBMODE_USB_HS, + PHY_SUBMODE_USB_SS, + + /* UFS */ + PHY_SUBMODE_UFS_HS_A = 3000, + PHY_SUBMODE_UFS_HS_B, + +} phy_submode_t; + typedef struct phy *phy_t; /* Initialization parameters. */ @@ -47,6 +101,8 @@ struct phynode_init_def { #endif }; +#include "phynode_if.h" + /* * Shorthands for constructing method tables. */ @@ -67,6 +123,8 @@ device_t phynode_get_device(struct phynode *phynode); intptr_t phynode_get_id(struct phynode *phynode); int phynode_enable(struct phynode *phynode); int phynode_disable(struct phynode *phynode); +int phynode_set_mode(struct phynode *phynode, phy_mode_t mode, + phy_submode_t submode); int phynode_status(struct phynode *phynode, int *status); #ifdef FDT phandle_t phynode_get_ofw_node(struct phynode *phynode); @@ -80,8 +138,8 @@ int phy_get_by_id(device_t consumer_dev, device_t provider_dev, intptr_t id, void phy_release(phy_t phy); int phy_enable(phy_t phy); int phy_disable(phy_t phy); +int phy_set_mode(phy_t phy, phy_mode_t mode, phy_submode_t submode); int phy_status(phy_t phy, int *value); - #ifdef FDT int phy_get_by_ofw_name(device_t consumer, phandle_t node, char *name, phy_t *phy); diff --git a/sys/dev/extres/phy/phynode_if.m b/sys/dev/extres/phy/phynode_if.m index cebfb9a5a163..18b798227109 100644 --- a/sys/dev/extres/phy/phynode_if.m +++ b/sys/dev/extres/phy/phynode_if.m @@ -1,6 +1,5 @@ #- # Copyright 2016 Michal Meloun -# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -23,12 +22,12 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD$ -# INTERFACE phynode; HEADER { + #include + struct phynode; } @@ -59,3 +58,12 @@ METHOD int status { }; +# +# Set mode/submode for multiprotocol phy +# Returns 0 on success or a standard errno value. +# +METHOD int set_mode { + struct phynode *phynode; + phy_mode_t mode; + phy_submode_t submode; +};