From patchwork Wed Jun 8 10:20:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 9164147 X-Patchwork-Delegate: sboyd@codeaurora.org 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 B0D1860832 for ; Wed, 8 Jun 2016 10:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A209B28345 for ; Wed, 8 Jun 2016 10:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96D3928358; Wed, 8 Jun 2016 10:24:56 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BAA328345 for ; Wed, 8 Jun 2016 10:24:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424600AbcFHKYO (ORCPT ); Wed, 8 Jun 2016 06:24:14 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34187 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424660AbcFHKUJ (ORCPT ); Wed, 8 Jun 2016 06:20:09 -0400 Received: by mail-lf0-f66.google.com with SMTP id k192so359483lfb.1; Wed, 08 Jun 2016 03:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JCUIJjHMqUOheHB31ycUvJerngb5WYywvzSmJ+vBYtI=; b=KfOOaEgEv9M6EWzkLgrBfyCVZp+UTQKnmj1p8K0T4tGgXoa3ixOsXmx6Iqu3OWhnhM +Ux11JppqAnLChwRp13IgdUDmj+M2W3hgIsebhRsepeD6xYOAM3Azh+kHfPOiYKB6zqt 29MyJ9Khp4zMlUPpnfYC4lHXcg95dQ/zvGra9z6VSK92zCOQsv7pZUSB34xNY3DKRzos GGp7LNn7SoW7RKysLrWXGyNNsMG9JnfZihu2buVxQRsobhwyVWO2zPlXIXvrTWFVDUgV 9wriPootm4QPxRQNDUDzhEUz1Q8ERYIo5gLjlDz/OlfrwD1tQAZOYQvUsVbuk+atuA38 p8og== 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=JCUIJjHMqUOheHB31ycUvJerngb5WYywvzSmJ+vBYtI=; b=Yg6hmfX3AXFBkktxC59uWCYdObiQoAzlJEzSELjyyy8rrUN7uIeoQBJ9stydHgKjsb YExRPm71+CpeTLTGhpXdzIr9mWJ5Pxk1Cm/hPx+quEUQ8Juo8vpUPbuN5rPFSbdp7nh/ ZNvg11OQz9+14AO9hILNcUPRl1O0ElIIf4FdJW69q1J0A4SyAPwz8KzI9fbqohkSINDS soW3RP1+tuMSd1hGt0EnyVTzwfueJsJWPykZ+fRN6j94MsBXxQrYZn8EfUZXhOdM0YHz 3A+aKE7wBYGTEuUK0JbtXNFmoD0TpbgDB0jzWfzk/WdKM/AtuEoUlrM+xl0haZ1V8RbM 2ltQ== X-Gm-Message-State: ALyK8tLuokcQYelDXatZam/3K4/Rnaniymbr/l2e3wpgPOImTDB3HZt16jSF3xOWP6KwUg== X-Received: by 10.25.207.1 with SMTP id f1mr3506174lfg.39.1465381207653; Wed, 08 Jun 2016 03:20:07 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id m8sm66864lfe.15.2016.06.08.03.20.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jun 2016 03:20:06 -0700 (PDT) From: Ricardo Ribalda Delgado To: Michael Turquette , Stephen Boyd , s.hauer@pengutronix.de, jeremy.kerr@canonical.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH 3/3] clk: fixed-rate: Convert into a module platform driver Date: Wed, 8 Jun 2016 12:20:01 +0200 Message-Id: <1465381201-11537-4-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465381201-11537-1-git-send-email-ricardo.ribalda@gmail.com> References: <1465381201-11537-1-git-send-email-ricardo.ribalda@gmail.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds support for fixed-rate clock providers which have not been enabled via of_clk_init(). This is required by Device trees overlays that introduce clocks providers. Signed-off-by: Ricardo Ribalda Delgado --- drivers/clk/clk-fixed-rate.c | 62 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c index 8e4453eb54e8..190b1e8ea9ac 100644 --- a/drivers/clk/clk-fixed-rate.c +++ b/drivers/clk/clk-fixed-rate.c @@ -15,6 +15,7 @@ #include #include #include +#include /* * DOC: basic fixed-rate clock that cannot gate @@ -149,7 +150,7 @@ EXPORT_SYMBOL_GPL(clk_unregister_fixed_rate); /** * of_fixed_clk_setup() - Setup function for simple fixed rate clock */ -void of_fixed_clk_setup(struct device_node *node) +struct clk *_of_fixed_clk_setup(struct device_node *node) { struct clk *clk; const char *clk_name = node->name; @@ -157,7 +158,7 @@ void of_fixed_clk_setup(struct device_node *node) u32 accuracy = 0; if (of_property_read_u32(node, "clock-frequency", &rate)) - return; + return ERR_PTR(-EIO); of_property_read_u32(node, "clock-accuracy", &accuracy); @@ -167,7 +168,64 @@ void of_fixed_clk_setup(struct device_node *node) 0, rate, accuracy); if (!IS_ERR(clk)) of_clk_add_provider(node, of_clk_src_simple_get, clk); + + return clk; +} + +void of_fixed_clk_setup(struct device_node *node) +{ + _of_fixed_clk_setup(node); } EXPORT_SYMBOL_GPL(of_fixed_clk_setup); CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup); + +static int of_fixed_clk_remove(struct platform_device *pdev) +{ + struct clk *clk = platform_get_drvdata(pdev); + + if (clk) + clk_unregister_fixed_rate(clk); + + return 0; +} + +static int of_fixed_clk_probe(struct platform_device *pdev) +{ + struct clk *clk; + + /* + * Don't do anything if of_clk_init() has already + * added this clock to the provider list + */ + if (of_clk_is_provider(pdev->dev.of_node)) + return 0; + + clk = _of_fixed_clk_setup(pdev->dev.of_node); + + if (IS_ERR(clk)) + return PTR_ERR(clk); + + platform_set_drvdata(pdev, clk); + + return 0; +} + +static const struct of_device_id of_fixed_clk_ids[] = { + { + .compatible = "fixed-clock", + }, + { }, +}; +MODULE_DEVICE_TABLE(of, of_fixed_clk_ids); + +static struct platform_driver of_fixed_clk_driver = { + .driver = { + .name = "of_fixed_clk", + .of_match_table = of_fixed_clk_ids, + }, + .probe = of_fixed_clk_probe, + .remove = of_fixed_clk_remove, +}; + +module_platform_driver(of_fixed_clk_driver); #endif