From patchwork Wed Feb 3 07:01:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12063521 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F2D6C433E0 for ; Wed, 3 Feb 2021 07:05:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC3D864F5D for ; Wed, 3 Feb 2021 07:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232118AbhBCHFa (ORCPT ); Wed, 3 Feb 2021 02:05:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:35558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232034AbhBCHD0 (ORCPT ); Wed, 3 Feb 2021 02:03:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 713CE64F7C; Wed, 3 Feb 2021 07:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612335721; bh=MMNo+h3HEqIoqHzAyjt4M5/YBbQxBfZXIFkLGwOoWfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZB4TT+DYLy810UDcivav4AxNXtzTUSCSHk+qpJ4JrjlhfHBlnePtsImAdPVSefl+ 94TMiVZhtsLeRsksWM1ucqBRfFlXHhuv6D8hd+tOP/9I3TRuMoT+mw4zgZnxdP2w4U XlIg+cyLwbw0flSutndMnhVtqp6pQ6YOt+qrEEODRktMbf0S0POrm3xw0Ufv2kFmGt x2Bs8YB1DfZ9GkuSdyVBwggSplPfvbUIxwOJS7a1s7uCy3yV1hSmL7Od4c93eDCilm cVbW6txQVlVgeWEzlKF2ILYs2T3jgjdafphb4BlFMAJnND7T9me2H/3SoClSUAZQir yZgPqx0MWvEvw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1l7CAo-001CAf-7r; Wed, 03 Feb 2021 08:01:58 +0100 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Binghui Wang , Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , Xiaowei Song , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v2 08/11] PCI: dwc: pcie-kirin: add support for a regulator Date: Wed, 3 Feb 2021 08:01:52 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Kirin 970 designs, a power supply is required to enable a PCI bridge and other components of the board. For instance, on HiKey 970, the Hi6421v600 regulator provides a power line (LDO33) which powers on the PCI bridge, the M.2 slot, the mini PCIe 1x slot and the Realtek 8169 Ethernet card. Without enabling such power supply, the PCI resource allocation fails. Signed-off-by: Mauro Carvalho Chehab --- drivers/pci/controller/dwc/pcie-kirin.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index 2bce6e3750d4..005fc4c2ad7f 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "pcie-designware.h" @@ -335,8 +336,21 @@ static long kirin970_pcie_get_resource(struct kirin_pcie *kirin_pcie, struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct regulator *reg; int ret; + reg = devm_regulator_get(dev, "pcie_vdd"); + if (IS_ERR_OR_NULL(reg)) { + if (PTR_ERR(reg) == -EPROBE_DEFER) + return PTR_ERR(reg); + } else { + ret = regulator_enable(reg); + if (ret) { + dev_err(dev, "Failed to enable regulator\n"); + return ret; + } + } + kirin970_pcie_get_eyeparam(kirin_pcie); kirin_pcie->gpio_id_reset[0] = of_get_named_gpio(dev->of_node,