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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3381FC04A6A for ; Tue, 1 Aug 2023 21:25:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78F6E867F7; Tue, 1 Aug 2023 23:25:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kwiboo.se header.i=@kwiboo.se header.b="CyroNDAl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E6FC86847; Tue, 1 Aug 2023 23:25:52 +0200 (CEST) Received: from wfbtzhsw.outbound-mail.sendgrid.net (wfbtzhsw.outbound-mail.sendgrid.net [159.183.224.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 19E078678A for ; Tue, 1 Aug 2023 23:25:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=Uj44MrSEyobVF3Y/V+GnzTdBgTjqBjBGulsl7FI+f/A=; b=CyroNDAlANU0oGUMckDc0CHWm7hTID5N9878sMAqiMJ5aQzPY10TVpRmRtnDAXGtp71q Xs1Q5T0smC0nS5FTPuVEM212pzc+RhIwI+A/CXnrVxPGOre3rVDJfWGTP6wMZcGR+hmPKx +TE8P7lBdD1xF0WH+j0U8Ep+8EUY0/5sJAG2Z7qneMy9MjPPbVScgK6kKymK5tHhJZBedS w2Sk5mjoLQRe5LdrtAHwY+XUcI6YGO1PN2MAX7v5TQL1xZ/A29FGCWtfVh9Eda7kb9uueh O50CuVPhMbXDWZX5iJ3Ieovog0ySnmtiAUvFiNH2j9ZFxZwEHzlJ9KHUlLklgKRA== Received: by filterdrecv-65f68489c8-k2rl8 with SMTP id filterdrecv-65f68489c8-k2rl8-1-64C9783C-2E 2023-08-01 21:25:16.782401099 +0000 UTC m=+5001912.052156128 Received: from bionic.localdomain (unknown) by geopod-ismtpd-4 (SG) with ESMTP id PPBBHIGRQQisdEu70HZ25A Tue, 01 Aug 2023 21:25:16.562 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 3/6] phy: rockchip: snps-pcie3: Refactor to use a phy_init ops Date: Tue, 01 Aug 2023 21:25:16 +0000 (UTC) Message-ID: <20230801212511.2123575-4-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230801212511.2123575-1-jonas@kwiboo.se> References: <20230801212511.2123575-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0hxFFY08OwcSGnvsYu?= =?us-ascii?Q?RrHT+Q7KnLMkShTzC9mr1bsVuD2wffdH8NHR9A4?= =?us-ascii?Q?3hn3DiPPbcBPNiFL0JgTlAzDwtoGxQYLWT2fslY?= =?us-ascii?Q?chVvKnc72QpDzaDA0s0C2Sz39TjkkyBctnpZs31?= =?us-ascii?Q?QJRS=2FFsBD=2FVUF5DWFKJoLOA7BT9D3o1kty5Bda?= To: Kever Yang , Simon Glass , Philipp Tomsich Cc: Eugen Hristev , Jon Lin , u-boot@lists.denx.de, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add a phy_init ops in preparation for upcoming support of a RK3588 variant in the driver. Signed-off-by: Jonas Karlman --- .../phy/rockchip/phy-rockchip-snps-pcie3.c | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c index 3053543a3329..b76b5386bef0 100644 --- a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c +++ b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c @@ -35,8 +35,32 @@ struct rockchip_p3phy_priv { struct clk_bulk clks; }; +struct rockchip_p3phy_ops { + int (*phy_init)(struct phy *phy); +}; + +static int rockchip_p3phy_rk3568_init(struct phy *phy) +{ + struct rockchip_p3phy_priv *priv = dev_get_priv(phy->dev); + + /* Deassert PCIe PMA output clamp mode */ + regmap_write(priv->phy_grf, GRF_PCIE30PHY_CON9, + (0x1 << 15) | (0x1 << 31)); + + reset_deassert(&priv->p30phy); + udelay(1); + + return 0; +} + +static const struct rockchip_p3phy_ops rk3568_ops = { + .phy_init = rockchip_p3phy_rk3568_init, +}; + static int rochchip_p3phy_init(struct phy *phy) { + struct rockchip_p3phy_ops *ops = + (struct rockchip_p3phy_ops *)dev_get_driver_data(phy->dev); struct rockchip_p3phy_priv *priv = dev_get_priv(phy->dev); int ret; @@ -47,14 +71,11 @@ static int rochchip_p3phy_init(struct phy *phy) reset_assert(&priv->p30phy); udelay(1); - /* Deassert PCIe PMA output clamp mode */ - regmap_write(priv->phy_grf, GRF_PCIE30PHY_CON9, - (0x1 << 15) | (0x1 << 31)); - - reset_deassert(&priv->p30phy); - udelay(1); + ret = ops->phy_init(phy); + if (ret) + clk_disable_bulk(&priv->clks); - return 0; + return ret; } static int rochchip_p3phy_exit(struct phy *phy) @@ -103,7 +124,10 @@ static struct phy_ops rochchip_p3phy_ops = { }; static const struct udevice_id rockchip_p3phy_of_match[] = { - { .compatible = "rockchip,rk3568-pcie3-phy" }, + { + .compatible = "rockchip,rk3568-pcie3-phy", + .data = (ulong)&rk3568_ops, + }, { }, }; -- 2.41.0