Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1681627imu; Wed, 12 Dec 2018 02:24:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/X+8nPwJRlacg3moF05/QzWtCuu3QjT6DKm020+4Gssrw0Vec6ATxUwVGL/xP2uhumgAfd6 X-Received: by 2002:a63:8ac4:: with SMTP id y187mr17825992pgd.446.1544610262143; Wed, 12 Dec 2018 02:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544610262; cv=none; d=google.com; s=arc-20160816; b=GtIF/qLVJwnl8gSCiJzPMO3wWknparprsXlI11dynktOyeLyIIWvFd+6O6nNzbvq5a 8wy7fXnm7UYWNp8O+3jElPAlk6JcVLEmFIcaddebf4SMi+zk5ywt7UTl4AKoYvN3SVDp YQggsARvFgBfFjbOB4QP9RVW3zjzFPMDO8g3ltoA5gzwIDJDsIBs2JPnRJfFbK6QXOel P+sSXFwVKNUyUjUihDRCJNxdN/NPJwkh7CWk97qnsm/mz4C1D8kwLPGtBBECJ6knKzQd HPOzXjINLYudjtViyEzb1fo5PKgQ+gTZh0UeFN3Sok3M7UWkq7wdHKkXKgsbJcdoH40+ /DTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OIZMvgujAxYr+TjY3QxPeKNA2CeX9WR7lcIX52lBkhM=; b=IcFoUMnFWrB0qeOtDXV5pMwmcUQO4Y7Go094WyIqzefh/EigbIPwCt6gNtmGh1xF+z AUfH/0KePAFcNjFBzY0FfFOQK4LuoisHlcYkYIq92/p/Tih7SXH5tJfMsvA76a7OBj+9 NMuTPCI0JmfhszQQnq4pC5Jxab05d/9a8sCeo+TwQR5dlcepuTIQvzHUtiJ/kkza7uGK Ke8Y7dVBQ7vbU14S8Q6BdPhM674M+Hiz90Plx3klCNcHM1Q55VD79rj1BrFWHlckBlfn 42yWFHjT4kLTzer1E180VRcAUyMmil70SJ6pH3c3If717j/aIscU/Z4VmhAbOTyVUTJU mDjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si13594455pgg.592.2018.12.12.02.24.07; Wed, 12 Dec 2018 02:24:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727171AbeLLKWH (ORCPT + 99 others); Wed, 12 Dec 2018 05:22:07 -0500 Received: from mail.bootlin.com ([62.4.15.54]:57465 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbeLLKWG (ORCPT ); Wed, 12 Dec 2018 05:22:06 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id B659220DC3; Wed, 12 Dec 2018 11:22:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-89-7.w90-88.abo.wanadoo.fr [90.88.30.7]) by mail.bootlin.com (Postfix) with ESMTPSA id 5298B2082C; Wed, 12 Dec 2018 11:21:45 +0100 (CET) From: Miquel Raynal To: Gregory Clement , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Thomas Petazzoni , Bjorn Helgaas Cc: , Rob Herring , Mark Rutland , Lorenzo Pieralisi , linux-pci@vger.kernel.org, , , Antoine Tenart , Maxime Chevallier , Nadav Haklai , Miquel Raynal Subject: [PATCH v2 04/12] PCI: aardvark: Add clock support Date: Wed, 12 Dec 2018 11:21:34 +0100 Message-Id: <20181212102142.16053-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181212102142.16053-1-miquel.raynal@bootlin.com> References: <20181212102142.16053-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IP relies on a gated clock. When we will add S2RAM support, this clock will need to be resumed before any PCIe registers are accessed. Add support for this clock. Signed-off-by: Miquel Raynal --- drivers/pci/controller/pci-aardvark.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index da695572a2ed..108b3f15c410 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -8,6 +8,7 @@ * Author: Hezi Shahmoon */ +#include #include #include #include @@ -190,6 +191,7 @@ struct advk_pcie { struct platform_device *pdev; + struct clk *clk; void __iomem *base; struct list_head resources; struct irq_domain *irq_domain; @@ -1083,6 +1085,29 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie) return ret; } +static int advk_pcie_setup_clk(struct advk_pcie *pcie) +{ + struct device *dev = &pcie->pdev->dev; + int ret; + + pcie->clk = devm_clk_get(dev, NULL); + if (IS_ERR(pcie->clk) && (PTR_ERR(pcie->clk) == -EPROBE_DEFER)) + return PTR_ERR(pcie->clk); + + /* Old bindings miss the clock handle */ + if (IS_ERR(pcie->clk)) { + dev_warn(dev, "Clock unavailable (%ld)\n", PTR_ERR(pcie->clk)); + pcie->clk = NULL; + return 0; + } + + ret = clk_prepare_enable(pcie->clk); + if (ret) + dev_err(dev, "Clock initialization failed (%d)\n", ret); + + return ret; +} + static int advk_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1118,6 +1143,10 @@ static int advk_pcie_probe(struct platform_device *pdev) return ret; } + ret = advk_pcie_setup_clk(pcie); + if (ret) + return ret; + ret = advk_pcie_setup_phy(pcie); if (ret) return ret; -- 2.19.1