From patchwork Fri Jun 10 00:27:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 9168659 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 15C3D604DB for ; Fri, 10 Jun 2016 00:28:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 087EF28364 for ; Fri, 10 Jun 2016 00:28:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F161428369; Fri, 10 Jun 2016 00:28:24 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A430A28364 for ; Fri, 10 Jun 2016 00:28:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBAJE-0003sh-17; Fri, 10 Jun 2016 00:28:24 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBAJA-0003hM-Oq for linux-amlogic@lists.infradead.org; Fri, 10 Jun 2016 00:28:22 +0000 Received: by mail-pf0-x234.google.com with SMTP id y124so17808952pfy.0 for ; Thu, 09 Jun 2016 17:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eYe/Y4nO8t2b4hEAKKD7eQIh0u4khT9RHvsGqKG3fsY=; b=u0SInnvMhgc3RCIayvdAPMUMvFGnpTpmHzGiw0rxfEWsNSBzNxFpJifc9s+CiuSiXn 1INHGRCYfRwH83DCEl3mot1pToF8uPaa2WPmpubuRTdWKFOqkzeJFfuJiZNQ6McgvGqr A7dH+5dTM7N3WCz077bvSzMtZeetjisw3k89f9EzO2M324XVe02HWBReiaKSr5j963TB kIF/AqMuE9v0kiQnFixwxnUXonWMaSvpe3gmnuDvpoENHdy0LKL69e9qTCJGBuaiVfjZ LnH9/GrPeEgkJsTIL1wwZ8qMTl4mZpib+ar7Z4ihC1ArHmZWoMksHmpoml6p9hDpIYdo O+QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eYe/Y4nO8t2b4hEAKKD7eQIh0u4khT9RHvsGqKG3fsY=; b=P1bRblRN4PXLN35A7mj+y8TGCTvhBO5yHerflK1u4d5GJAVOI+QcHvee8oEqLY+lt0 51aurW/qGfWDbXuMDfkw4QzduWZBmshmIX5IL0uCoEZ4L8rHtccZ0TlWNR4S9U/xVZmy gila203VT+a/f71w4a9/JSxT4BUmEaiDwwHGkC2SYVG4zXSWpyEYxzrY2h6IFmRiQLMa Ro4ug1geMBMf7dWiZfxxxY4vxUdBpVLI3Y4VGrwgNByBwvQ8OZhI0EcT/tr31t2hGp1j 6z1QDdCl51i0Zq09wWlYOjlrdXSg2yUQBqv4SqP2t3xIeYqQAZvR4xvuTY9bl1KmL8lk eoRg== X-Gm-Message-State: ALyK8tJaOiWtCTrrCGBvq9LJPIVQ4laUOvlskc1ZftrEzCdeuQ7EHErsJS8uaezxocCx3Ic/ X-Received: by 10.98.16.156 with SMTP id 28mr2064352pfq.82.1465518480009; Thu, 09 Jun 2016 17:28:00 -0700 (PDT) Received: from localhost (cpe-172-248-200-249.socal.res.rr.com. [172.248.200.249]) by smtp.gmail.com with ESMTPSA id qc6sm12775117pac.6.2016.06.09.17.27.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 17:27:59 -0700 (PDT) From: Michael Turquette To: linux-clk@vger.kernel.org Subject: [PATCH 08/10] clk: meson8b: convert to platform_driver Date: Thu, 9 Jun 2016 17:27:45 -0700 Message-Id: <1465518467-23939-9-git-send-email-mturquette@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465518467-23939-1-git-send-email-mturquette@baylibre.com> References: <1465518467-23939-1-git-send-email-mturquette@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160609_172821_005684_7A1DDD51 X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xing.xu@amlogic.com, victor.wan@amlogic.com, khilman@baylibre.com, carlo@endlessm.com, jerry.cao@amlogic.com, linux-amlogic@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch creates a proper platform_driver for the meson8b clock controller. Use of CLK_OF_DECLARE is removed, and can be added back in later if very early registration of some clocks is required. Signed-off-by: Michael Turquette --- drivers/clk/meson/meson8b-clkc.c | 67 +++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/drivers/clk/meson/meson8b-clkc.c b/drivers/clk/meson/meson8b-clkc.c index 57dea03..b1902e9 100644 --- a/drivers/clk/meson/meson8b-clkc.c +++ b/drivers/clk/meson/meson8b-clkc.c @@ -2,6 +2,9 @@ * Copyright (c) 2015 Endless Mobile, Inc. * Author: Carlo Caione * + * Copyright (c) 2016 BayLibre, Inc. + * Michael Turquette + * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. @@ -17,11 +20,10 @@ #include #include -#include -#include #include -#include #include +#include +#include #include "clkc.h" @@ -350,18 +352,19 @@ static struct meson_clk_pll *const meson8b_clk_plls[] = { &meson8b_sys_pll, }; -static void __init meson8b_clkc_init(struct device_node *np) +static int meson8b_clkc_probe(struct platform_device *pdev) { void __iomem *clk_base; int ret, clkid, i; struct clk_hw *parent_hw; struct clk *parent_clk; + struct device *dev = &pdev->dev; /* Generic clocks and PLLs */ - clk_base = of_iomap(np, 1); + clk_base = of_iomap(dev->of_node, 1); if (!clk_base) { pr_err("%s: Unable to map clk base\n", __func__); - return; + return -ENXIO; } /* Populate base address for PLLs */ @@ -386,9 +389,9 @@ static void __init meson8b_clkc_init(struct device_node *np) continue; /* FIXME convert to devm_clk_register */ - ret = clk_hw_register(NULL, meson8b_hw_onecell_data.hws[clkid]); + ret = devm_clk_hw_register(dev, meson8b_hw_onecell_data.hws[clkid]); if (ret) - goto unregister; + goto iounmap; } /* @@ -411,17 +414,45 @@ static void __init meson8b_clkc_init(struct device_node *np) if (ret) { pr_err("%s: failed to register clock notifier for cpu_clk\n", __func__); - goto unregister_clk_nb; + goto iounmap; } - of_clk_add_hw_provider(np, of_clk_hw_onecell_get, &meson8b_hw_onecell_data); - return; + return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, + &meson8b_hw_onecell_data); -/* FIXME remove after converting to platform_driver/devm_clk_register */ -unregister_clk_nb: - clk_notifier_unregister(parent_clk, &meson8b_a5_clk.clk_nb); -unregister: - for (clkid = CLK_NR_CLKS - 1; clkid >= 0; clkid--) - clk_hw_unregister(meson8b_hw_onecell_data.hws[clkid]); +iounmap: + iounmap(clk_base); + return ret; } -CLK_OF_DECLARE(meson8b_clock, "amlogic,meson8b-clkc", meson8b_clkc_init); + +static const struct of_device_id meson8b_clkc_match_table[] = { + { .compatible = "amlogic,meson8b-clkc" }, + { } +}; +MODULE_DEVICE_TABLE(of, meson8b_match_table); + +static struct platform_driver meson8b_driver = { + .probe = meson8b_clkc_probe, + .driver = { + .name = "meson8b-clkc", + .of_match_table = meson8b_clkc_match_table, + }, +}; + +static int __init meson8b_clkc_init(void) +{ + return platform_driver_register(&meson8b_driver); +} +module_init(meson8b_clkc_init); + +static void __exit meson8b_clkc_exit(void) +{ + platform_driver_unregister(&meson8b_driver); +} +module_exit(meson8b_clkc_exit); + +MODULE_DESCRIPTION("AmLogic S805 / Meson8b Clock Controller Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:meson8b-clkc"); +MODULE_AUTHOR("Michael Turquette "); +MODULE_AUTHOR("Carlo Caione ");