From patchwork Tue Dec 18 23:16:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13648 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 BCE9C23E19 for ; Tue, 18 Dec 2012 23:16:47 +0000 (UTC) Received: from mail-ie0-f170.google.com (mail-ie0-f170.google.com [209.85.223.170]) by fiordland.canonical.com (Postfix) with ESMTP id 573C4A187EC for ; Tue, 18 Dec 2012 23:16:47 +0000 (UTC) Received: by mail-ie0-f170.google.com with SMTP id k10so1836932iea.15 for ; Tue, 18 Dec 2012 15:16:46 -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=ZWJRBWur1QchQO9JoLzPeHkUgkqdiIOwD87U6zA01xg=; b=MTtMoBKzBIAQCguaLiEnwJKhGEQOy1k6IjbzbRhY/mDYi+yy1yf2M+uWsV3SqiXuUk Vlh7QiBdZ+evdZmf65xXnVEaoh28qbr+MyLyCSFz4Sp/kDLBeaXFNQ9QSnr1R0c+IcMh 1JD32HBMnC4PnvfXovNl6zfPvDBzoc7dhIOjHhsT5QGIrSusbFFbIDVUs7XgVYG7lkmN feTKr9EWshmDKK53wOW+b/fNeorCC9sG422u/sDKbDTnb+XlYVaHpoNFl8JKiYx36+xi Qevphn9nCVWJmzlvG5lPN7IYRnNt7hDugdy63N11xLKwq84XXhz4SHYm5a7MyrjrHci9 VMNg== X-Received: by 10.50.220.166 with SMTP id px6mr5280512igc.8.1355872606459; Tue, 18 Dec 2012 15:16:46 -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.50.67.115 with SMTP id m19csp197642igt; Tue, 18 Dec 2012 15:16:46 -0800 (PST) X-Received: by 10.14.213.134 with SMTP id a6mr9370872eep.45.1355872605501; Tue, 18 Dec 2012 15:16:45 -0800 (PST) Received: from eu1sys200aog111.obsmtp.com (eu1sys200aog111.obsmtp.com [207.126.144.131]) by mx.google.com with SMTP id l8si7887162eep.68.2012.12.18.15.16.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 15:16:45 -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-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKUND5WK73qxXWQBIBQMrrk27BcNP8d4eG@postini.com; Tue, 18 Dec 2012 23:16:45 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 1701BF1; Tue, 18 Dec 2012 23:08:27 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 0EA1BAE9; Tue, 18 Dec 2012 23:16:37 +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 relay1.stm.gmessaging.net (Postfix) with ESMTPS id C783724C2E5; Wed, 19 Dec 2012 00:16:35 +0100 (CET) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 19 Dec 2012 00:16:35 +0100 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Philippe Begnic , Ulf Hansson Subject: [PATCH 1/3] clk: Introduce optional is_prepared callback Date: Wed, 19 Dec 2012 00:16:21 +0100 Message-ID: <1355872583-20928-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1355872583-20928-1-git-send-email-ulf.hansson@stericsson.com> References: <1355872583-20928-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQn0xMqex0JA+IITnNplk2K6LDSkneIow4loykZL1rCEX+7flCGtvrbwaylyhQhXOfqRR+er 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 --- 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 251e45d..5adf2bb 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -315,6 +315,27 @@ inline 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);