From patchwork Tue Mar 12 19:26:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 15307 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 A306423E00 for ; Tue, 12 Mar 2013 19:26:20 +0000 (UTC) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3DFE0A18A35 for ; Tue, 12 Mar 2013 19:26:20 +0000 (UTC) Received: by mail-ve0-f180.google.com with SMTP id jx10so177723veb.11 for ; Tue, 12 Mar 2013 12:26:19 -0700 (PDT) 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=B/lgQj4PgBw3hNG6CMnH1DckHolTh1W85oqihaf1FSnJeOVRVRCohRrxODMH8ibzXH EVl/I0nm0xi9Kgvarv/v0XaS9DnNf7WLXxYtEiegtHUBUZ46KBgPLJ+n6kCcoHvQawHP iAaFT75/uay2nGeoED2KFsNOpMcPAzEpHYXD4RDIjwFnC/ZkV1z0h3LpNJzFcpz1WX6N GvX5gMK/Dx+kL2LszgvAkO7oyFMdcNcazp1Ni4Me/mekxgFLoRg9wtv4apoaRR1ixfOI cL1QpxiIsr/CCwSreZA6Et5/3GbS6Ku68foZsauRvaYL2cdYqEayoIm6VO/hJb2aGFhO UYxA== X-Received: by 10.52.29.18 with SMTP id f18mr6075520vdh.57.1363116379754; Tue, 12 Mar 2013 12:26:19 -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.58.127.98 with SMTP id nf2csp144575veb; Tue, 12 Mar 2013 12:26:19 -0700 (PDT) X-Received: by 10.194.171.74 with SMTP id as10mr29193939wjc.0.1363116378222; Tue, 12 Mar 2013 12:26:18 -0700 (PDT) Received: from eu1sys200aog104.obsmtp.com (eu1sys200aog104.obsmtp.com [207.126.144.117]) by mx.google.com with SMTP id r7si37339406eeo.210.2013.03.12.12.26.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Mar 2013 12:26:18 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.117; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.117 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 eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKUT+BVujP0L+eaj01925Qd3aWjcaP4b2w@postini.com; Tue, 12 Mar 2013 19:26:17 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 51CE979; Tue, 12 Mar 2013 19:26:13 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 17F2853FE; Tue, 12 Mar 2013 19:26:13 +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 84A0AA8074; Tue, 12 Mar 2013 20:26:05 +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; Tue, 12 Mar 2013 20:26:12 +0100 From: Ulf Hansson To: , Mike Turquette Cc: Linus Walleij , Par-Olof Hakansson , Ulf Hansson Subject: [RESEND PATCH 1/4] clk: Introduce optional is_prepared callback Date: Tue, 12 Mar 2013 20:26:02 +0100 Message-ID: <1363116365-3960-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1363116365-3960-1-git-send-email-ulf.hansson@stericsson.com> References: <1363116365-3960-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm8V1MYkw5GJYB76BkShng+JMxlrpCGJeyYh33E3+mWaEf7/iZhleau995WimSB61nAmC9a 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);