From patchwork Wed Apr 13 22:54:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 1616977 X-Patchwork-Delegate: sbabic@denx.de 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KdybS49Xcz9sFr for ; Thu, 14 Apr 2022 08:54:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B564A839BD; Thu, 14 Apr 2022 00:54:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gateworks.com 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 0F4D583CE9; Thu, 14 Apr 2022 00:54:46 +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,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from finn.localdomain (finn.gateworks.com [108.161.129.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 568948209D for ; Thu, 14 Apr 2022 00:54:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gateworks.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tharvey@gateworks.com Received: from 068-189-091-139.biz.spectrum.com ([68.189.91.139] helo=tharvey.pdc.gateworks.com) by finn.localdomain with esmtp (Exim 4.93) (envelope-from ) id 1nelsl-00CQxI-PI; Wed, 13 Apr 2022 22:54:39 +0000 From: Tim Harvey To: Stefano Babic , Fabio Estevam , "NXP i . MX U-Boot Team" , u-boot@lists.denx.de Cc: Tim Harvey , Ian Ray , Sebastian Reichel , Marek Vasut Subject: [PATCH] pci: imx: use vpcie-supply if defined by device-tree Date: Wed, 13 Apr 2022 15:54:37 -0700 Message-Id: <20220413225437.26374-1-tharvey@gateworks.com> X-Mailer: git-send-email 2.17.1 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.5 at phobos.denx.de X-Virus-Status: Clean If vpcie-supply is defined by device-tree use that if CONFIG_PCIE_IMX_POWER_GPIO is not defined. Note that after this the following boards which define CONFIG_PCIE_IMX_POWER_GPIO in their board header file as well as their device-tree should be able to remove CONFIG_PCIE_IMX_PERST_GPIO without consequence: - mx6sabresd - mx6sxsabresd - novena Note that the ge_bx50v3 board uses CONFIG_PCIE_IMX_POWER_GPIO and does not have vpcie-supply defined in it's pcie node in the dt thus removing CONFIG_PCIE_IMX_POWER_GPIO globally can't be done until that board adds vpcie-supply. Cc: Ian Ray (maintainer:GE BX50V3 BOARD) Cc: Sebastian Reichel (maintainer:GE BX50V3 BOARD) Cc: Fabio Estevam (maintainer:MX6SABRESD BOARD) Cc: Marek Vasut (maintainer:NOVENA BOARD) Signed-off-by: Tim Harvey --- arch/arm/include/asm/arch-mx6/sys_proto.h | 2 +- drivers/pci/pcie_imx.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h index c49759af92d1..c7542e4b04e1 100644 --- a/arch/arm/include/asm/arch-mx6/sys_proto.h +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h @@ -18,7 +18,7 @@ #define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \ USBPHY_PWD_RXPWDRX)) -int imx6_pcie_toggle_power(void); +int imx6_pcie_toggle_power(struct udevice *vpcie); int imx6_pcie_toggle_reset(struct gpio_desc *gpio, bool active_high); enum ldo_reg { diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c index 2cec3900e9ad..f8daedbce359 100644 --- a/drivers/pci/pcie_imx.c +++ b/drivers/pci/pcie_imx.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -102,6 +103,7 @@ struct imx_pcie_priv { void __iomem *cfg_base; struct gpio_desc reset_gpio; bool reset_active_high; + struct udevice *vpcie; }; /* @@ -530,7 +532,7 @@ static int imx6_pcie_init_phy(void) return 0; } -__weak int imx6_pcie_toggle_power(void) +__weak int imx6_pcie_toggle_power(struct udevice *vpcie) { #ifdef CONFIG_PCIE_IMX_POWER_GPIO gpio_request(CONFIG_PCIE_IMX_POWER_GPIO, "pcie_power"); @@ -540,6 +542,15 @@ __weak int imx6_pcie_toggle_power(void) mdelay(20); gpio_free(CONFIG_PCIE_IMX_POWER_GPIO); #endif + +#if CONFIG_IS_ENABLED(DM_REGULATOR) + if (vpcie) { + regulator_set_enable(vpcie, false); + mdelay(20); + regulator_set_enable(vpcie, true); + mdelay(20); + } +#endif return 0; } @@ -598,7 +609,7 @@ static int imx6_pcie_deassert_core_reset(struct imx_pcie_priv *priv) { struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; - imx6_pcie_toggle_power(); + imx6_pcie_toggle_power(priv->vpcie); enable_pcie_clock(); @@ -717,6 +728,10 @@ static int imx_pcie_dm_probe(struct udevice *dev) { struct imx_pcie_priv *priv = dev_get_priv(dev); +#if CONFIG_IS_ENABLED(DM_REGULATOR) + device_get_supply_regulator(dev, "vpcie-supply", &priv->vpcie); +#endif + /* if PERST# valid from dt then assert it */ gpio_request_by_name(dev, "reset-gpio", 0, &priv->reset_gpio, GPIOD_IS_OUT);