From patchwork Tue Feb 2 13:29:54 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: 12061631 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=-14.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY,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 41AFCC433E6 for ; Tue, 2 Feb 2021 13:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0076564F51 for ; Tue, 2 Feb 2021 13:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231778AbhBBNap (ORCPT ); Tue, 2 Feb 2021 08:30:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:59330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbhBBNam (ORCPT ); Tue, 2 Feb 2021 08:30:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C7BBC64F45; Tue, 2 Feb 2021 13:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612272602; bh=AH432J4B7ZDZZSd0PksUuJcGVmlwemb+J6aFQtCeJ8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=urcf2yeHU1lygxszS/epnxF/w1NsCkpIfUSIzGodkmWwz/CJqrbqu85px6M1tSB+T xHfYq0dIsT0cLXTvypR4U8ZC7VTEpc2jfQQJCBzPe/gebS8atBZiM1TN3bOhSva4aM r02krnYVvuCiu2NKrywlLbIpFMMsWY1yjiANu787bL8Xlx8NY0oFKDAMZOq2xqSwIy Sl37NraJTwaHv4ZY40jfmdBMflvKKule2AxYJJwYIcQJaH26rYwOaHmK1iEgFAMKJx vgcXBLUObG3FHj92rwKoSHt+LixBVAJTVeik6k4aPJdVLwXT7OQ3xcDggAjE2suOAL ZwNtqjK+a9Bew== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1l6vkl-0011z5-P5; Tue, 02 Feb 2021 14:29:59 +0100 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Binghui Wang , Bjorn Helgaas , Liam Girdwood , Lorenzo Pieralisi , Mark Brown , Rob Herring , Xiaowei Song , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 09/13] pci: dwc: pcie-kirin: allow to optionally require a regulator Date: Tue, 2 Feb 2021 14:29:54 +0100 Message-Id: <7f4abd1ba9f4b33fe6f66213f56aa4269db74317.1612271903.git.mchehab+huawei@kernel.org> 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 Hikey 970, there's a power supply controlled by Hi6421v600 regulator that turns on the PCI devices on the board. Without that, no PCI hardware would work. As this is device-dependent, such regulator line should be optional. Signed-off-by: Mauro Carvalho Chehab --- drivers/pci/controller/dwc/pcie-kirin.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index 2bce6e3750d4..42aea34dff4d 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" @@ -295,6 +296,22 @@ static void kirin970_pcie_set_eyeparam(struct kirin_pcie *kirin_pcie) static long kirin_common_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_optional(dev, "pci"); + 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; + } + } + kirin_pcie->apb_base = devm_platform_ioremap_resource_byname(pdev, "apb"); if (IS_ERR(kirin_pcie->apb_base))