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 66B63C001DF for ; Wed, 2 Aug 2023 19:06:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B359786875; Wed, 2 Aug 2023 21:06:09 +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="reSxrwBP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C241A868AD; Wed, 2 Aug 2023 21:06:07 +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 91F5886851 for ; Wed, 2 Aug 2023 21:06:05 +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=3jAF3MTIFh3T7QzvBqJF2fa24W1CpDJayh53Gq4YCQI=; b=reSxrwBPRgo/uBmMv2j2XqWGc0PWGleTq4Kyo40TqJnqxo2KuStCdlnCj1HE9t+FSmtz X+0aHSTyUPJx/TM+Dvpx0DxB9amHE/z3l5f6gRRyYmXJIc9exzT1uza6oXBWPxHJ3E2pDm stJ++6E1vXj5EQKaYla73p6cmSKChybWolOxYCN++wSPIP+yp/tecWv7jLQI9bLovjNUnj XBPD1aKez8YETVnFj0vPROXzZAv0KeE/zDlq/l6gUU8l2J6KoGa9OEXxjMY1LHIhKl0u4c J38a/DHGCii1Li0wr8mLHGqgUcRemse4M4lkiTHgY1dna1caOGD0n0/sF6rSj/Cw== Received: by filterdrecv-77869f68cc-qljt4 with SMTP id filterdrecv-77869f68cc-qljt4-1-64CAA8BD-46 2023-08-02 19:04:29.852034205 +0000 UTC m=+7241310.294990689 Received: from bionic.localdomain (unknown) by geopod-ismtpd-7 (SG) with ESMTP id 8eT4W-sISpiHtSA7ru02yA Wed, 02 Aug 2023 19:04:29.652 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v2 3/7] phy: rockchip: snps-pcie3: Refactor to use a phy_init ops Date: Wed, 02 Aug 2023 19:04:30 +0000 (UTC) Message-ID: <20230802190424.2963185-4-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802190424.2963185-1-jonas@kwiboo.se> References: <20230802190424.2963185-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h8i+lHru3FnhxHl9P?= =?us-ascii?Q?2ffCinSLR9nBc2SP6MgLLUzRJDsvAzloVp=2FNa1T?= =?us-ascii?Q?rmcNGAQa1L+AWArjmvBrxv8nmz50kmhZVNRrQbe?= =?us-ascii?Q?Qct90pPYZPDM2C=2FGu2Z=2F65mso0RB1QQOZW1qOTN?= =?us-ascii?Q?BRRoEBiVF5rgo=2FXs3f+TZQM1mvekFad0G7RJdZ?= To: Kever Yang , Simon Glass , Philipp Tomsich Cc: Eugen Hristev , Jon Lin , FUKAUMI Naoki , John Clark , 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 --- v2: - No change .../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