From patchwork Thu Jan 24 16:45:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 14276 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 7A08423F79 for ; Thu, 24 Jan 2013 16:46:19 +0000 (UTC) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by fiordland.canonical.com (Postfix) with ESMTP id 1AA6BA190FC for ; Thu, 24 Jan 2013 16:46:19 +0000 (UTC) Received: by mail-ve0-f178.google.com with SMTP id oz10so1582890veb.37 for ; Thu, 24 Jan 2013 08:46:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type:x-gm-message-state; bh=s5KdzKUz/O/Nvo7KkB1IPt0tU3emn7D2GKe0YnWjO8s=; b=QmJe++HiRypZ8YrzyW5imM5lhmDa5NpIxr8ILO+0X1S6uRfv/D74qWMZAcvNlRGoHy hHLm3uKlnhGpwOLY5qOhaxAi4wm0yB1ta5mUbyie7Lo1kb2Or2oboe4mtYnJ6/R7UchK QqbhnlXwLBJnF5X0B2I8q7W+mdKWYsbhssnN+kDtE/SlFgJ1+1vXIUIJGyIQUNXrPDrC eXTnC9tUm3tCko0hmxeNnqCw3BCY1Nn/VGpnZqH7SaSXYH383cxa7lGLdqvgCCzDpsBp mUA4pgkPBiBmyLEnxzowXF7xnDXCropGZtkHp838h5UDbAN2sx/8fGETXI5omZS7Mwm/ dFcA== X-Received: by 10.52.16.6 with SMTP id b6mr2294855vdd.40.1359045975920; Thu, 24 Jan 2013 08:46:15 -0800 (PST) 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.58.145.101 with SMTP id st5csp74436veb; Thu, 24 Jan 2013 08:46:15 -0800 (PST) X-Received: by 10.14.218.69 with SMTP id j45mr7873115eep.35.1359045974805; Thu, 24 Jan 2013 08:46:14 -0800 (PST) Received: from eu1sys200aog111.obsmtp.com (eu1sys200aog111.obsmtp.com [207.126.144.131]) by mx.google.com with SMTP id n5si42590595eeo.187.2013.01.24.08.46.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 08:46:14 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.131 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.131; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.131 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 eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKUQFlTmq3jHxsUsW6okQAbFYSjxhglbnW@postini.com; Thu, 24 Jan 2013 16:46:09 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 911D31B4; Thu, 24 Jan 2013 16:46:05 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 33753500E; Thu, 24 Jan 2013 16:46:05 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 49C91A8065; Thu, 24 Jan 2013 17:45:58 +0100 (CET) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 24 Jan 2013 17:46:04 +0100 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Philippe Begnic , Ulf Hansson Subject: [PATCH 1/4] clk: Introduce optional is_prepared callback Date: Thu, 24 Jan 2013 17:45:53 +0100 Message-ID: <1359045956-30741-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1359045956-30741-1-git-send-email-ulf.hansson@stericsson.com> References: <1359045956-30741-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkpjD/s8Gum6hf7XcZdKGRoI1sGpBV5DVc4lsIY9IjMwNTQCPOHP9pfPs1SiT4I7cAktGja From: Ulf Hansson To reflect whether a clk_hw is prepared the clk_hw may implement the optional is_prepared callback. If not implemented we fall back to use the software prepare counter. Signed-off-by: Ulf Hansson Acked-by: Linus Walleij --- drivers/clk/clk.c | 21 +++++++++++++++++++++ include/linux/clk-provider.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 593a2e4..deb259a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -458,6 +458,27 @@ unsigned long __clk_get_flags(struct clk *clk) return !clk ? 0 : clk->flags; } +bool __clk_is_prepared(struct clk *clk) +{ + int ret; + + if (!clk) + return false; + + /* + * .is_prepared is optional for clocks that can prepare + * fall back to software usage counter if it is missing + */ + if (!clk->ops->is_prepared) { + ret = clk->prepare_count ? 1 : 0; + goto out; + } + + ret = clk->ops->is_prepared(clk->hw); +out: + return !!ret; +} + bool __clk_is_enabled(struct clk *clk) { int ret; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 4989b8a..86ff6be 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -45,6 +45,10 @@ struct clk_hw; * undo any work done in the @prepare callback. Called with * prepare_lock held. * + * @is_prepared: Queries the hardware to determine if the clock is prepared. + * This function is allowed to sleep. Optional, if this op is not + * set then the prepare count will be used. + * * @enable: Enable the clock atomically. This must not return until the * clock is generating a valid clock signal, usable by consumer * devices. Called with enable_lock held. This function must not @@ -108,6 +112,7 @@ struct clk_hw; struct clk_ops { int (*prepare)(struct clk_hw *hw); void (*unprepare)(struct clk_hw *hw); + int (*is_prepared)(struct clk_hw *hw); int (*enable)(struct clk_hw *hw); void (*disable)(struct clk_hw *hw); int (*is_enabled)(struct clk_hw *hw); @@ -351,6 +356,7 @@ unsigned int __clk_get_enable_count(struct clk *clk); unsigned int __clk_get_prepare_count(struct clk *clk); unsigned long __clk_get_rate(struct clk *clk); unsigned long __clk_get_flags(struct clk *clk); +bool __clk_is_prepared(struct clk *clk); bool __clk_is_enabled(struct clk *clk); struct clk *__clk_lookup(const char *name);