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 6E48BC7EE22 for ; Tue, 9 May 2023 12:45:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B60A6858CE; Tue, 9 May 2023 14:45:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject 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="iJimG8qA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A2E2857D5; Tue, 9 May 2023 14:45:50 +0200 (CEST) Received: from s.wrqvtbkv.outbound-mail.sendgrid.net (s.wrqvtbkv.outbound-mail.sendgrid.net [149.72.123.24]) (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 5B48284734 for ; Tue, 9 May 2023 14:45:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject 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=mime-version:subject:references:from:in-reply-to:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=CX654M5BLaI/ZkzkgCxSANrkBMP9VERogGGUMD+MlUs=; b=iJimG8qAbXX6dfLi/SH0tL0LFSWV/TWZjb4g+BKOq3in5OBhEq1NXjZuwNZURQDPTan4 rCYCRHO1piHkopqc29R7WhUdOVCqryd2h/A+sBdoqUeLzVLlmTe5HDxncpWnJtmGjKEQdi 0WkI+f3/BGLPV+1SKVJ8Z1CcVZZ1RRKfa/P1YfZ24t3bUBxuTjUNIvWKuAKfVzWW9kpc9M fjn7+y8BIuyrDD0BIaboqDs2W727I3WgtdZQRohHDciblVECWpEF+FK6LmUIRO3JtpshtL H5x7dDL4bDwX/XxL9iwKuqoR/2C9Dpld8/5JTkqCHRhlziOZ6axvt2hhmVISThNw== Received: by filterdrecv-7946957d94-8w8qz with SMTP id filterdrecv-7946957d94-8w8qz-1-645A4073-77 2023-05-09 12:45:39.948231448 +0000 UTC m=+1207676.405571738 Received: from [192.168.1.50] (unknown) by geopod-ismtpd-9 (SG) with ESMTP id RUQ4x-dTTlq0oIO0oNEr2A Tue, 09 May 2023 12:45:39.492 +0000 (UTC) Message-ID: <36afd60e-2724-bdc7-930a-bde0a60871da@kwiboo.se> Date: Tue, 09 May 2023 12:45:40 +0000 (UTC) MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 2/8] pci: pcie_dw_rockchip: Use regulator_set_enable_if_allowed References: <20230422181943.889436-1-jonas@kwiboo.se> <20230422181943.889436-3-jonas@kwiboo.se> <87577214-1b2b-286c-9f5d-31bbcef018b6@rock-chips.com> Content-Language: en-US From: Jonas Karlman In-Reply-To: <87577214-1b2b-286c-9f5d-31bbcef018b6@rock-chips.com> X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h3+44q9n0BDUHo=2Fa=2F?= =?us-ascii?Q?bjv6Hw8KSLDhZ8m0fC36DcHnvnKocGdlXErqNqK?= =?us-ascii?Q?aK+Um7CkOTsgIK4ZiT=2Fs3kB7WYcxD3VPEobZKce?= =?us-ascii?Q?nmpuaQ+Z9ONNDaGGXfq6dHFZg2ABldO0bcNEd08?= =?us-ascii?Q?r39PTg8Bhsupkt1VXRjI1GJKq=2Fn0cqISluR74A?= To: Kever Yang , Simon Glass , Philipp Tomsich Cc: Eugen Hristev , u-boot@lists.denx.de X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Hi Kever, On 2023-05-09 13:58, Kever Yang wrote: > Hi Jonas, > > On 2023/4/23 02:19, Jonas Karlman wrote: >> The vpcie3v3 regulator is typically a fixed regulator controlled using >> gpio. Change to use enable and disable calls on the regulator instead >> of trying to set a voltage value. >> >> Signed-off-by: Jonas Karlman >> --- >> drivers/pci/pcie_dw_rockchip.c | 17 +++++++---------- >> 1 file changed, 7 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c >> index 225af400ba70..a5b900f95981 100644 >> --- a/drivers/pci/pcie_dw_rockchip.c >> +++ b/drivers/pci/pcie_dw_rockchip.c >> @@ -288,21 +288,16 @@ static int rockchip_pcie_init_port(struct udevice *dev) >> struct rk_pcie *priv = dev_get_priv(dev); >> >> /* Set power and maybe external ref clk input */ >> - if (priv->vpcie3v3) { >> - ret = regulator_set_value(priv->vpcie3v3, 3300000); >> - if (ret) { >> - dev_err(priv->dw.dev, "failed to enable vpcie3v3 (ret=%d)\n", >> - ret); >> - return ret; >> - } >> + ret = regulator_set_enable_if_allowed(priv->vpcie3v3, true); >> + if (ret && ret != -ENOSYS) { >> + dev_err(dev, "failed to enable vpcie3v3 (ret=%d)\n", ret); >> + return ret; >> } >> >> - udelay(MACRO_US * 1000); > > Why remove this udelay? > > This may help the power stable before we can access pcie phy. I removed this to closer match the linux driver, if a delay is needed it can be added using e.g. the startup-delay-us prop of a fixed regulator. startup-delay-us: description: startup time in microseconds Based on testing on Rock 3A, CM3, Quartz64, SoQuartz, Odroid-M1 and Rock 5B a delay using startup-delay-us did not seem necessary. Regards, Jonas > > Thanks, > > - Kever > >> - >> ret = generic_phy_init(&priv->phy); >> if (ret) { >> dev_err(dev, "failed to init phy (ret=%d)\n", ret); >> - return ret; >> + goto err_disable_regulator; >> } >> >> ret = generic_phy_power_on(&priv->phy); >> @@ -345,6 +340,8 @@ err_power_off_phy: >> generic_phy_power_off(&priv->phy); >> err_exit_phy: >> generic_phy_exit(&priv->phy); >> +err_disable_regulator: >> + regulator_set_enable_if_allowed(priv->vpcie3v3, false); >> >> return ret; >> }