From patchwork Tue Mar 28 12:42:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 9649159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41F94601E9 for ; Tue, 28 Mar 2017 12:44:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 221E926419 for ; Tue, 28 Mar 2017 12:44:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16FFE27F81; Tue, 28 Mar 2017 12:44:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7B9F026419 for ; Tue, 28 Mar 2017 12:44:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iUkNaT/YCxdH+zdOuMbj6TS9nLIEfGJElIdUv9IFrMg=; b=IXswlAuMgGCmHe 5MiLLprqvKUOVSSDWosEgtAD2ZFzlAv9sth/7ZG7LXdD4QCpcbvqB8MC4YvZ9h6bcZcSfkHsJjnoE d+UYwEP7dQqmvCXlAqx2aBLhLc68sII9nNAzT+7mWOYoXXp774d3AXCDtii7qC4HMYXz/7iz+h7gi O7jLONWwzjNd9JjxIkN4HaiIJaqX1ZFkt2GJQmsL5aJiDbSygsU4Zap5BPCCS+K8vxV2PMLxfRaoA ta7Lqp6rTgrbUz9GXheQ3P2abfzdx0/IW9DBA+VfKHJyaMnf3Jw9NH6a8rpem2bQGKa8/lcNSbV/l JQGyi47OQr0dvkhNgGJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1csqUF-0001Po-LS; Tue, 28 Mar 2017 12:44:35 +0000 Received: from hqemgate15.nvidia.com ([216.228.121.64]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1csqTB-0008Mq-Tk for linux-arm-kernel@lists.infradead.org; Tue, 28 Mar 2017 12:43:39 +0000 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Tue, 28 Mar 2017 05:57:07 -0700 Received: from HQMAIL103.nvidia.com ([172.20.13.39]) by hqnvupgp08.nvidia.com (PGP Universal service); Tue, 28 Mar 2017 05:39:55 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Tue, 28 Mar 2017 05:39:55 -0700 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Tue, 28 Mar 2017 12:43:08 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1263.5 via Frontend Transport; Tue, 28 Mar 2017 12:43:08 +0000 Received: from goldfinger.nvidia.com (Not Verified[10.21.132.162]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7, 5, 5, 8150) id ; Tue, 28 Mar 2017 05:43:08 -0700 From: Jon Hunter To: Thierry Reding Subject: [PATCH V3 3/6] soc/tegra: flowctrl: Add basic platform driver Date: Tue, 28 Mar 2017 13:42:55 +0100 Message-ID: <1490704978-22906-4-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490704978-22906-1-git-send-email-jonathanh@nvidia.com> References: <1490704978-22906-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170328_054330_424331_29E94AFE X-CRM114-Status: GOOD ( 17.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Stephen Warren , Russell King , Jon Hunter , Rob Herring , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a simple platform driver for the flowctrl module so that it gets registered as a proper device. Signed-off-by: Jon Hunter --- drivers/soc/tegra/flowctrl.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/soc/tegra/flowctrl.c b/drivers/soc/tegra/flowctrl.c index 3a5a1cb9ae90..25eddfc8475d 100644 --- a/drivers/soc/tegra/flowctrl.c +++ b/drivers/soc/tegra/flowctrl.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ static void __iomem *tegra_flowctrl_base; static void flowctrl_update(u8 offset, u32 value) { - if (WARN_ONCE(!tegra_flowctrl_base, + if (WARN_ONCE(IS_ERR_OR_NULL(tegra_flowctrl_base), "Tegra flowctrl not initialised!\n")) return; @@ -62,7 +63,7 @@ u32 flowctrl_read_cpu_csr(unsigned int cpuid) { u8 offset = flowctrl_offset_cpu_csr[cpuid]; - if (WARN_ONCE(!tegra_flowctrl_base, + if (WARN_ONCE(IS_ERR_OR_NULL(tegra_flowctrl_base), "Tegra flowctrl not initialised!\n")) return 0; @@ -148,7 +149,22 @@ void flowctrl_cpu_suspend_exit(unsigned int cpuid) flowctrl_write_cpu_csr(cpuid, reg); } -static const struct of_device_id matches[] __initconst = { +static int tegra_flowctrl_probe(struct platform_device *pdev) +{ + void __iomem *base = tegra_flowctrl_base; + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + tegra_flowctrl_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(tegra_flowctrl_base)) + return PTR_ERR(base); + + iounmap(base); + + return 0; +} + +static const struct of_device_id tegra_flowctrl_match[] = { { .compatible = "nvidia,tegra124-flowctrl" }, { .compatible = "nvidia,tegra114-flowctrl" }, { .compatible = "nvidia,tegra30-flowctrl" }, @@ -156,6 +172,16 @@ static const struct of_device_id matches[] __initconst = { { } }; +static struct platform_driver tegra_flowctrl_driver = { + .driver = { + .name = "tegra-flowctrl", + .suppress_bind_attrs = true, + .of_match_table = tegra_flowctrl_match, + }, + .probe = tegra_flowctrl_probe, +}; +builtin_platform_driver(tegra_flowctrl_driver); + static int __init tegra_flowctrl_init(void) { /* hardcoded fallback if device tree node is missing */ @@ -166,7 +192,7 @@ static int __init tegra_flowctrl_init(void) if (!soc_is_tegra()) return 0; - np = of_find_matching_node(NULL, matches); + np = of_find_matching_node(NULL, tegra_flowctrl_match); if (np) { struct resource res;