From patchwork Thu Jul 4 21:05:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luciano Coelho X-Patchwork-Id: 2823935 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E968DC0AB2 for ; Thu, 4 Jul 2013 21:05:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1663D2015B for ; Thu, 4 Jul 2013 21:05:50 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 11DB520145 for ; Thu, 4 Jul 2013 21:05:49 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uuqil-00056t-JM; Thu, 04 Jul 2013 21:05:43 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uuqij-0001Fx-0z; Thu, 04 Jul 2013 21:05:41 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uuqig-0001Fc-8R for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2013 21:05:39 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r64L5GBY001083; Thu, 4 Jul 2013 16:05:16 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r64L5F3F018218; Thu, 4 Jul 2013 16:05:15 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Thu, 4 Jul 2013 16:05:15 -0500 Received: from cumari.coelho.fi (h78-4.vpn.ti.com [172.24.78.4]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r64L5Dfm014894; Thu, 4 Jul 2013 16:05:14 -0500 From: Luciano Coelho To: Subject: [RFC] clk: add flags to distinguish xtal clocks Date: Fri, 5 Jul 2013 00:05:12 +0300 Message-ID: <1372971912-10877-1-git-send-email-coelho@ti.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130704_170538_639112_C0675CE1 X-CRM114-Status: GOOD ( 16.16 ) X-Spam-Score: -7.1 (-------) Cc: coelho@ti.com, balbi@ti.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a flag that indicate whether the clock is a crystal or not. Since no clocks set this flag right now, include an additional flag that indicates whether the type is set or not. If the CLK_IS_TYPE_DEFINED flag is not set, the value of the CLK_IS_TYPE_XTAL flag is undefined. This ensures backwards compatibility. Additionally, parse a new device tree binding in clk-fixed-rate to set this flag. Signed-off-by: Luciano Coelho --- I'm not familiar with the common clock framework and I'm not entirely sure the flags can be used in such a way, but to me it looks reasonable, since some clock consumers may need to know what type of clock is being provided. Specifically, the wl12xx firmware needs to know if the clock is XTAL or not to handle the stabilization and boosts properly. My main idea is that I need to pass this information in the device tree definition of the clocks, so that the driver can pass this information on to the firmware. Please let me know if this looks ok or not. If not, please let me know if you have any other ideas on how to solve my problem (of knowing whether the clock attached to the WiLink chip is XTAL or not). drivers/clk/clk-fixed-rate.c | 6 +++++- include/linux/clk-provider.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c index dc58fbd..4003a82 100644 --- a/drivers/clk/clk-fixed-rate.c +++ b/drivers/clk/clk-fixed-rate.c @@ -90,13 +90,17 @@ void of_fixed_clk_setup(struct device_node *node) struct clk *clk; const char *clk_name = node->name; u32 rate; + unsigned long flags = CLK_IS_ROOT; if (of_property_read_u32(node, "clock-frequency", &rate)) return; + if (of_property_read_bool(node, "clock-xtal")) + flags |= CLK_IS_TYPE_DEFINED | CLK_IS_TYPE_XTAL; + of_property_read_string(node, "clock-output-names", &clk_name); - clk = clk_register_fixed_rate(NULL, clk_name, NULL, CLK_IS_ROOT, rate); + clk = clk_register_fixed_rate(NULL, clk_name, NULL, flags, rate); if (!IS_ERR(clk)) of_clk_add_provider(node, of_clk_src_simple_get, clk); } diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 1186098..034320b 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -27,6 +27,8 @@ #define CLK_IS_ROOT BIT(4) /* root clk, has no parent */ #define CLK_IS_BASIC BIT(5) /* Basic clk, can't do a to_clk_foo() */ #define CLK_GET_RATE_NOCACHE BIT(6) /* do not use the cached clk rate */ +#define CLK_IS_TYPE_DEFINED BIT(7) /* the clock type is defined */ +#define CLK_IS_TYPE_XTAL BIT(8) /* this is a crystal clock */ struct clk_hw;