From patchwork Fri Aug 31 12:21:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11131 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A0C5823E02 for ; Fri, 31 Aug 2012 12:22:13 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id DCB67A1846B for ; Fri, 31 Aug 2012 12:21:34 +0000 (UTC) Received: by ieak11 with SMTP id k11so1616760iea.11 for ; Fri, 31 Aug 2012 05:22:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:x-gm-message-state; bh=zfqCtU9vbdQVRBKWwgghb/+XXRtOcVd4l5At+7gDzB4=; b=UHaDdtQGNGg7d1cVcuTv1I7YgsW6ZnqLJ/Z1bPkMHsyGm5QWNym2II4UbD6KecuLOD 9sOPPqGkChPmL0duRA5Cd76xzp/zuclTuxtKC3vf0loiujYtxx1lcLXE473e07k3XgMf gZ+mBSBnyGtQq1nIctdp7V3JabvkD7UTho9A/IdbAYNnOcgo9vsovhGHK0BC15qLZcQn s3HaOKfHA8CfwwqX9ux9zyNMRZdTVCLO4xWVi1Mm/i+Sy1Fd9KJucOBWJcvwm9ynBqJ1 rFOVc63TFw1osq9MFpVGQrLxcbZJX6dfVRV0JIhd4W4mObX6H1OCOHkqwg77yzybwCCR S6bA== Received: by 10.50.207.106 with SMTP id lv10mr2542187igc.0.1346415732229; Fri, 31 Aug 2012 05:22:12 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp8423igc; Fri, 31 Aug 2012 05:22:11 -0700 (PDT) Received: by 10.14.182.69 with SMTP id n45mr10807473eem.28.1346415730916; Fri, 31 Aug 2012 05:22:10 -0700 (PDT) Received: from eu1sys200aog119.obsmtp.com (eu1sys200aog119.obsmtp.com [207.126.144.147]) by mx.google.com with SMTP id m5si3217001een.51.2012.08.31.05.22.02 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 31 Aug 2012 05:22:10 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.147; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKUECsap7Tdpm5gbeSDX1WzJFkFC5rmv2O@postini.com; Fri, 31 Aug 2012 12:22:10 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3497D184; Fri, 31 Aug 2012 12:22:00 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8B2715159; Fri, 31 Aug 2012 12:22:00 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 1709BA8083; Fri, 31 Aug 2012 14:21:55 +0200 (CEST) Received: from steludxu1397.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 31 Aug 2012 14:21:59 +0200 From: Ulf Hansson To: , Mike Turquette , Mike Turquette , Samuel Ortiz , Cc: Linus Walleij , Lee Jones , Philippe Begnic , Srinidhi Kasagar , Ulf Hansson Subject: [PATCH 1/4] clk: Provide option for clk_get_rate to issue hw for new rate Date: Fri, 31 Aug 2012 14:21:28 +0200 Message-ID: <1346415691-13371-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1346415691-13371-1-git-send-email-ulf.hansson@stericsson.com> References: <1346415691-13371-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQk7cUsdrhcgeL2OWKMXp4v+gOPBLdjNOT6ifoYhYS7aadcXuTzjLwgnhkms9Rv0c+J9STdP From: Ulf Hansson By using CLK_GET_RATE_NOCACHE flag, we tell the clk_get_rate API to issue the hw for an updated clock rate. This can be used for a clock which rate may be updated without a client necessary modifying it. Signed-off-by: Ulf Hansson --- drivers/clk/clk.c | 43 +++++++++++++++++++++++------------------- include/linux/clk-provider.h | 1 + 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index efdfd00..d9cbae0 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -558,25 +558,6 @@ int clk_enable(struct clk *clk) EXPORT_SYMBOL_GPL(clk_enable); /** - * clk_get_rate - return the rate of clk - * @clk: the clk whose rate is being returned - * - * Simply returns the cached rate of the clk. Does not query the hardware. If - * clk is NULL then returns 0. - */ -unsigned long clk_get_rate(struct clk *clk) -{ - unsigned long rate; - - mutex_lock(&prepare_lock); - rate = __clk_get_rate(clk); - mutex_unlock(&prepare_lock); - - return rate; -} -EXPORT_SYMBOL_GPL(clk_get_rate); - -/** * __clk_round_rate - round the given rate for a clk * @clk: round the rate of this clock * @@ -702,6 +683,30 @@ static void __clk_recalc_rates(struct clk *clk, unsigned long msg) } /** + * clk_get_rate - return the rate of clk + * @clk: the clk whose rate is being returned + * + * Simply returns the cached rate of the clk, unless CLK_GET_RATE_NOCACHE flag + * is set, which means a recalc_rate will be issued. + * If clk is NULL then returns 0. + */ +unsigned long clk_get_rate(struct clk *clk) +{ + unsigned long rate; + + mutex_lock(&prepare_lock); + + if (clk && (clk->flags & CLK_GET_RATE_NOCACHE)) + __clk_recalc_rates(clk, 0); + + rate = __clk_get_rate(clk); + mutex_unlock(&prepare_lock); + + return rate; +} +EXPORT_SYMBOL_GPL(clk_get_rate); + +/** * __clk_speculate_rates * @clk: first clk in the subtree * @parent_rate: the "future" rate of clk's parent diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 77335fa..1b15307 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -26,6 +26,7 @@ #define CLK_IGNORE_UNUSED BIT(3) /* do not gate even if unused */ #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 */ struct clk_hw;