From patchwork Thu Oct 28 18:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 12590885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CB12C433EF for ; Thu, 28 Oct 2021 18:42:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2484161040 for ; Thu, 28 Oct 2021 18:42:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2484161040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qtz6PTOs3p2b4jMOCLyPYS194ie6SGPuDs4lMo7LGaE=; b=Dab6WqkzI7LJLG DCMWlZH9E+wQrS0cXbif9rSsEGovTaATzHp8OpFSm3OWe0ZJRNOM0d+cG+OKKYB0zE/55gcRW5BoO AudtiM3Ds8HPw9Cdk+AnQe9Wt+pVhnf12vNQ99G8O0+dmSJMKSS6XTgU5i7hRmFRxHhS1bfAfH1sE Zg66ZmWvSEDWaI5u+zQsmzVwxB5Lhvyg3pQJaLX2jaNybiaPsnarOcU9f1WrlSf4TVONKXe1MJBSl VJYjekPR0W/FYZq3/+ff6ra3ztWbTSaN/qT5wfPId7f3m2WLktYKzXukHx+cVdAC8MYJwthrz7Q/9 OUqVVkJ9jVISvS4CAk5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgAMZ-008v38-HQ; Thu, 28 Oct 2021 18:42:55 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgAMT-008v0w-FU for linux-phy@lists.infradead.org; Thu, 28 Oct 2021 18:42:53 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 089A960FC0; Thu, 28 Oct 2021 18:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635446569; bh=GgYWB9+tEPJA1IilYhXqfNEpy2nKdtONdKg1IBtbjQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Itblq+ca6TN3iR50e5ERlbXK+1WpPpMdJlymgLO1mkf1PHkTrmQzpIQfGB+tXPId9 5pY0ksWRbTZ0Sg1CfDWP+1Za5IcWmKWL3NuYKksZXN4qjPY95KIS/4NZS3nA4Gc1p3 f0+eBw6LR5NAoipKmJeE6q/r065N7dYdDCB1mEX3rOdBM8eWlS16iC5uMCS56ET9T6 u6DylDggCCEkOc0sR6aXmVtGKq+zCBXY2kbZqRMzwAcdci8QrEtf3lgmQJ5J1ItqSP H2YXGzKmcwWiosLKi4ydZ2RIgwyoX8VLx4CJM3M7vD/rG5bCVIFq+AErEflxR9yqMN bnYU9sBGauO2A== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Miquel Raynal Cc: linux-phy@lists.infradead.org, Vinod Koul , Kishon Vijay Abraham I , pali@kernel.org, =?utf-8?q?Marek_Be?= =?utf-8?q?h=C3=BAn?= Subject: [PATCH phy 1/6] phy: marvell: phy-mvebu-a3700-comphy: Remove port from driver configuration Date: Thu, 28 Oct 2021 20:42:37 +0200 Message-Id: <20211028184242.22105-2-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211028184242.22105-1-kabel@kernel.org> References: <20211028184242.22105-1-kabel@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211028_114249_585548_908D097F X-CRM114-Status: GOOD ( 17.86 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org From: Pali Rohár Port number is encoded into argument for SMC call. It is zero for SATA, PCIe and also both USB 3.0 PHYs. It is non-zero only for Ethernet PHY (incorrectly called SGMII) on lane 0. Ethernet PHY on lane 1 also uses zero port number. So construct "port" bits for SMC call argument can be constructed directly from PHY type and lane number. Change driver code to always pass zero port number for non-ethernet PHYs and for ethernet PHYs determinate port number from lane number. This simplifies the driver. As port number from DT PHY configuration is not used anymore, remove whole driver code which parses it. This also simplifies the driver. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Reviewed-by: Miquel Raynal --- drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 62 +++++++++----------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c index 6781488cfc58..dbb2d4308851 100644 --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c @@ -20,7 +20,6 @@ #include #define MVEBU_A3700_COMPHY_LANES 3 -#define MVEBU_A3700_COMPHY_PORTS 2 /* COMPHY Fast SMC function identifiers */ #define COMPHY_SIP_POWER_ON 0x82000001 @@ -45,51 +44,47 @@ #define COMPHY_FW_NET(mode, idx, speed) (COMPHY_FW_MODE(mode) | \ ((idx) << 8) | \ ((speed) << 2)) -#define COMPHY_FW_PCIE(mode, idx, speed, width) (COMPHY_FW_NET(mode, idx, speed) | \ +#define COMPHY_FW_PCIE(mode, speed, width) (COMPHY_FW_NET(mode, 0, speed) | \ ((width) << 18)) struct mvebu_a3700_comphy_conf { unsigned int lane; enum phy_mode mode; int submode; - unsigned int port; u32 fw_mode; }; -#define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode, _port, _fw) \ +#define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode, _fw) \ { \ .lane = _lane, \ .mode = _mode, \ .submode = _smode, \ - .port = _port, \ .fw_mode = _fw, \ } -#define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode, _port, _fw) \ - MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA, _port, _fw) +#define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode, _fw) \ + MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA, _fw) -#define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode, _port, _fw) \ - MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode, _port, _fw) +#define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode, _fw) \ + MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode, _fw) static const struct mvebu_a3700_comphy_conf mvebu_a3700_comphy_modes[] = { /* lane 0 */ - MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS, 0, + MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS, COMPHY_FW_MODE_USB3H), - MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII, 1, + MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII, COMPHY_FW_MODE_SGMII), - MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX, 1, + MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX, COMPHY_FW_MODE_2500BASEX), /* lane 1 */ - MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE, 0, - COMPHY_FW_MODE_PCIE), - MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII, 0, + MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE, COMPHY_FW_MODE_PCIE), + MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII, COMPHY_FW_MODE_SGMII), - MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX, 0, + MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX, COMPHY_FW_MODE_2500BASEX), /* lane 2 */ - MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, 0, - COMPHY_FW_MODE_SATA), - MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS, 0, + MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, COMPHY_FW_MODE_SATA), + MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS, COMPHY_FW_MODE_USB3H), }; @@ -98,7 +93,6 @@ struct mvebu_a3700_comphy_lane { unsigned int id; enum phy_mode mode; int submode; - int port; }; static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane, @@ -120,7 +114,7 @@ static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane, } } -static int mvebu_a3700_comphy_get_fw_mode(int lane, int port, +static int mvebu_a3700_comphy_get_fw_mode(int lane, enum phy_mode mode, int submode) { @@ -132,7 +126,6 @@ static int mvebu_a3700_comphy_get_fw_mode(int lane, int port, for (i = 0; i < n; i++) { if (mvebu_a3700_comphy_modes[i].lane == lane && - mvebu_a3700_comphy_modes[i].port == port && mvebu_a3700_comphy_modes[i].mode == mode && mvebu_a3700_comphy_modes[i].submode == submode) break; @@ -153,7 +146,7 @@ static int mvebu_a3700_comphy_set_mode(struct phy *phy, enum phy_mode mode, if (submode == PHY_INTERFACE_MODE_1000BASEX) submode = PHY_INTERFACE_MODE_SGMII; - fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, mode, + fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, mode, submode); if (fw_mode < 0) { dev_err(lane->dev, "invalid COMPHY mode\n"); @@ -172,9 +165,10 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy) struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); u32 fw_param; int fw_mode; + int fw_port; int ret; - fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, + fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->mode, lane->submode); if (fw_mode < 0) { dev_err(lane->dev, "invalid COMPHY mode\n"); @@ -191,17 +185,18 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy) fw_param = COMPHY_FW_MODE(fw_mode); break; case PHY_MODE_ETHERNET: + fw_port = (lane->id == 0) ? 1 : 0; switch (lane->submode) { case PHY_INTERFACE_MODE_SGMII: dev_dbg(lane->dev, "set lane %d to SGMII mode\n", lane->id); - fw_param = COMPHY_FW_NET(fw_mode, lane->port, + fw_param = COMPHY_FW_NET(fw_mode, fw_port, COMPHY_FW_SPEED_1_25G); break; case PHY_INTERFACE_MODE_2500BASEX: dev_dbg(lane->dev, "set lane %d to 2500BASEX mode\n", lane->id); - fw_param = COMPHY_FW_NET(fw_mode, lane->port, + fw_param = COMPHY_FW_NET(fw_mode, fw_port, COMPHY_FW_SPEED_3_125G); break; default: @@ -212,8 +207,7 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy) break; case PHY_MODE_PCIE: dev_dbg(lane->dev, "set lane %d to PCIe mode\n", lane->id); - fw_param = COMPHY_FW_PCIE(fw_mode, lane->port, - COMPHY_FW_SPEED_5G, + fw_param = COMPHY_FW_PCIE(fw_mode, COMPHY_FW_SPEED_5G, phy->attrs.bus_width); break; default: @@ -247,17 +241,20 @@ static struct phy *mvebu_a3700_comphy_xlate(struct device *dev, struct of_phandle_args *args) { struct mvebu_a3700_comphy_lane *lane; + unsigned int port; struct phy *phy; - if (WARN_ON(args->args[0] >= MVEBU_A3700_COMPHY_PORTS)) - return ERR_PTR(-EINVAL); - phy = of_phy_simple_xlate(dev, args); if (IS_ERR(phy)) return phy; lane = phy_get_drvdata(phy); - lane->port = args->args[0]; + + port = args->args[0]; + if (port != 0 && (port != 1 || lane->id != 0)) { + dev_err(lane->dev, "invalid port number %u\n", port); + return ERR_PTR(-EINVAL); + } return phy; } @@ -302,7 +299,6 @@ static int mvebu_a3700_comphy_probe(struct platform_device *pdev) lane->mode = PHY_MODE_INVALID; lane->submode = PHY_INTERFACE_MODE_NA; lane->id = lane_id; - lane->port = -1; phy_set_drvdata(phy, lane); }