From patchwork Sun May 24 20:32:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kettenis X-Patchwork-Id: 1296953 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=openbsd.org Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49VX461lvtz9sRW for ; Mon, 25 May 2020 06:33:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2D50480199; Sun, 24 May 2020 22:33:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=openbsd.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id B2C4B801D1; Sun, 24 May 2020 22:33:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from lb2-smtp-cloud8.xs4all.net (lb2-smtp-cloud8.xs4all.net [194.109.24.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4576C8006B for ; Sun, 24 May 2020 22:33:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=openbsd.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=kettenis@openbsd.org Received: from barber.sibelius.xs4all.nl ([83.163.83.176]) by smtp-cloud8.xs4all.net with ESMTP id cxIsj3r2ddPgTcxItjXOAY; Sun, 24 May 2020 22:33:04 +0200 From: Mark Kettenis To: u-boot@lists.denx.de Cc: jagan@amarulasolutions.com, kever.yang@rock-chips.com, patrick@blueri.se, sjg@chromium.org, philipp.tomsich@theobroma-systems.com, Mark Kettenis Subject: [PATCH] pci: Make Rockchip PCIe voltage regulators optional Date: Sun, 24 May 2020 22:32:51 +0200 Message-Id: <20200524203251.28260-1-kettenis@openbsd.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfIZPJSFxNmD0RI1Z70AX7Gnjbc2I6OTFX7988z7bLyp1uu9n8kv6Kc/2JmH0NssOKp5Tam73n7InOiTeNVtNEuucblxJc/4nOQXcL6RMeWv6cLrfE/gs kkak1q/zfUdpWhvAV2JEkkj+ak+agnqEtQgzgYLNOoUgmZ5vArbQjJLwQ1tpfJVOn6GKl9iUGPOdkYmS2CkbhvPyFb7pIymNf2TjBFtgUe5HMxIyjkFNd9hu /Y9zP6wAZyURO+cxlS8aOOjYxCAyNuKIvHJZgK8SSTBpwKJ4D38L+oPa+624rDJd9U+mUBvFaf5TW/w+i1oGcHnUhVe84JY9wJNssKJLgTfoW2XZmT1nreU+ FSukS4FrsZ4kaLeXKb7QH/1mqPcnmHq82km/rOWLyr6frLibo6E= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean The vpcie*-supply properties are optional and these are absent on boards like the ROCKPro64 and Firefly RK3399 where the voltage is supplied by always-on regulators that are already enabled upon boot. Make these regulators optional and properly check their presence before attempting to enable them. Makes PCIe work on un U-Boot on the boards mentioned above. Signed-off-by: Mark Kettenis Reviewed-by: Kever Yang Tested-by: Marcin Juszkiewicz --- drivers/pci/pcie_rockchip.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c index 82a8396e42..0edc2464a8 100644 --- a/drivers/pci/pcie_rockchip.c +++ b/drivers/pci/pcie_rockchip.c @@ -322,7 +322,7 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev) struct rockchip_pcie *priv = dev_get_priv(dev); int ret; - if (!IS_ERR(priv->vpcie3v3)) { + if (priv->vpcie3v3) { ret = regulator_set_enable(priv->vpcie3v3, true); if (ret) { dev_err(dev, "failed to enable vpcie3v3 (ret=%d)\n", @@ -331,24 +331,31 @@ static int rockchip_pcie_set_vpcie(struct udevice *dev) } } - ret = regulator_set_enable(priv->vpcie1v8, true); - if (ret) { - dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n", ret); - goto err_disable_3v3; + if (priv->vpcie1v8) { + ret = regulator_set_enable(priv->vpcie1v8, true); + if (ret) { + dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n", + ret); + goto err_disable_3v3; + } } - ret = regulator_set_enable(priv->vpcie0v9, true); - if (ret) { - dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n", ret); - goto err_disable_1v8; + if (priv->vpcie0v9) { + ret = regulator_set_enable(priv->vpcie0v9, true); + if (ret) { + dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n", + ret); + goto err_disable_1v8; + } } return 0; err_disable_1v8: - regulator_set_enable(priv->vpcie1v8, false); + if (priv->vpcie1v8) + regulator_set_enable(priv->vpcie1v8, false); err_disable_3v3: - if (!IS_ERR(priv->vpcie3v3)) + if (priv->vpcie3v3) regulator_set_enable(priv->vpcie3v3, false); return ret; } @@ -424,14 +431,14 @@ static int rockchip_pcie_parse_dt(struct udevice *dev) ret = device_get_supply_regulator(dev, "vpcie1v8-supply", &priv->vpcie1v8); - if (ret) { + if (ret && ret != -ENOENT) { dev_err(dev, "failed to get vpcie1v8 supply (ret=%d)\n", ret); return ret; } ret = device_get_supply_regulator(dev, "vpcie0v9-supply", &priv->vpcie0v9); - if (ret) { + if (ret && ret != -ENOENT) { dev_err(dev, "failed to get vpcie0v9 supply (ret=%d)\n", ret); return ret; }