From patchwork Mon May 17 15:41:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 12262307 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 ABD96C433ED for ; Mon, 17 May 2021 15:44:59 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 752FE61108 for ; Mon, 17 May 2021 15:44:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 752FE61108 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lucaceresoli.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Y6t003bENHwj3YO+0CLdPkMMdqG9ttFNNYnZKPDqo5s=; b=FAwamEY6v6e52wJE61Q4wkQzT B2ngDUCMG3ZPv9z4g1aLe94OOdchCfQlnh+rAQPQWPnvul256ED/ljruC4sks9YV3NhhmNCzGXmyL vlfQCZs/vNsP89UJLKBAQevdvKUMlXKmIKfArdU3JgZQqsos6zRRY4oZJU++TwutZZ11EbyXAeXZ+ kCh6pRwC6ATMB3KB1NcnCqCjk4cGWjtHO7RXXOldlkt2fpMZorAZuptrBYFeGzvFafWlYT5w7C8H0 HBNaUMXuNjvD9Bu8OJP0Bo6cjYwkOjrv9uVbRP77W/0jxEU/c3Cmo5H0GEx+lqtHFaZyZIpqap6DG BTB7tF/UA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lifOH-00FRju-LI; Mon, 17 May 2021 15:42:45 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifNG-00FRY3-Qu for linux-arm-kernel@desiato.infradead.org; Mon, 17 May 2021 15:41:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=V2PPFuDXlh1HcRbxi2nRy0crdhXcgBq5FUOwt1UJAqU=; b=BNo+QUp2RhoHeFqGGvlo/nVIb+ 78meSMjALcDwtUgU4hjazgsyRNpSWr/Vi28NPwCtNZYGwXnDl/Fwp+SYX/K1fYf3Ti6GoAxuq/jWx tK9/jOeAvWhxvLNLwYEJP/6M4jVXiSaAbGvrYf6u085r34hJnqI1ht1Slm0IcWYhcUluFh4rF2l5x DAiSfIsA0o0KLzNfhExOWQbIRSt8uDwrD0gy7vsmRTT478EH3DQlAsar1/vRsICcAaUzpJYEsRt5f 3vn7OF7KGuCF5BYWjYm3TiLwoCAFw1CwkvdoR9tgDj+Qa5Y9R6ZjJJThWxiziNotwyfFRg6mUxkHn 9PtdIOrQ==; Received: from hostingweb31-40.netsons.net ([89.40.174.40]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lifNE-00Dw6Z-6U for linux-arm-kernel@lists.infradead.org; Mon, 17 May 2021 15:41:41 +0000 Received: from [77.244.183.192] (port=64722 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.94.2) (envelope-from ) id 1lifNC-000Exi-Ly; Mon, 17 May 2021 17:41:38 +0200 From: Luca Ceresoli To: linux-pci@vger.kernel.org Cc: Luca Ceresoli , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kishon Vijay Abraham I , Lorenzo Pieralisi , Rob Herring , Bjorn Helgaas , Jingoo Han , Gustavo Pimentel Subject: [PATCH 5/5] PCI: dwc: pci-dra7xx: get an optional clock Date: Mon, 17 May 2021 17:41:22 +0200 Message-Id: <20210517154122.430544-6-luca@lucaceresoli.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210517154122.430544-1-luca@lucaceresoli.net> References: <20210517154122.430544-1-luca@lucaceresoli.net> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_084140_433538_8805DB08 X-CRM114-Status: GOOD ( 10.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If the clock is provided externally we need to make sure it is enabled before starting PCI scan. Signed-off-by: Luca Ceresoli --- drivers/pci/controller/dwc/pci-dra7xx.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index 05d06806c300..8dd20b394d0c 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -7,6 +7,7 @@ * Authors: Kishon Vijay Abraham I */ +#include #include #include #include @@ -90,6 +91,7 @@ struct dra7xx_pcie { int phy_count; /* DT phy-names count */ struct phy **phy; struct irq_domain *irq_domain; + struct clk *clk; enum dw_pcie_device_mode mode; }; @@ -744,6 +746,15 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) if (!link) return -ENOMEM; + dra7xx->clk = devm_clk_get_optional(dev, NULL); + if (IS_ERR(dra7xx->clk)) + return dev_err_probe(dev, PTR_ERR(dra7xx->clk), + "clock request failed"); + + ret = clk_prepare_enable(dra7xx->clk); + if (ret) + return ret; + for (i = 0; i < phy_count; i++) { snprintf(name, sizeof(name), "pcie-phy%d", i); phy[i] = devm_phy_get(dev, name); @@ -931,6 +942,8 @@ static void dra7xx_pcie_shutdown(struct platform_device *pdev) pm_runtime_disable(dev); dra7xx_pcie_disable_phy(dra7xx); + + clk_disable_unprepare(dra7xx->clk); } static const struct dev_pm_ops dra7xx_pcie_pm_ops = {