From patchwork Mon Aug 19 05:34:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 2846351 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 77D4ABF546 for ; Mon, 19 Aug 2013 05:35:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89B7620219 for ; Mon, 19 Aug 2013 05:35:04 +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 1EF1D20214 for ; Mon, 19 Aug 2013 05:35:03 +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 1VBI7H-0001lX-1s; Mon, 19 Aug 2013 05:34:59 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBI7E-0004GZ-RA; Mon, 19 Aug 2013 05:34:56 +0000 Received: from mail-we0-f171.google.com ([74.125.82.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBI7B-0004GE-5D for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2013 05:34:54 +0000 Received: by mail-we0-f171.google.com with SMTP id q55so3360746wes.16 for ; Sun, 18 Aug 2013 22:34:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5/w4pIG9ILbDHPVQ1n6cdeDHO1HXsN6JwboZxSEb1yA=; b=Ul34tHosXEbsDY7oroqm42bRoh5fjWL3BXTp+gXhHNDLlwn1tqX0AkkuvcW5xuR/uP 8eRI4+D56eHf0Yx0dFMNI8thymLr/nEao4QsTbTpVwAfiP7CAW5RDg8kWhlL7mu3QGJx MlwFRX8kZ/fP80i2+lFYuxnQrrAKv6MvPadOHy0PGc1Anux0QXNz+vePOuWw2KS7HXrB 032AQlVrOY90bm7mRHo3p2t0DpSpPXIQ06hIC+C9xTjUxn8EVk57qvLCvY4q+2cPQ5zt Z8bh/BGr3T5mN3wO7cSHQ5gtpyzCeihjswelpgB+TWUHL+WRc10TAsUzFma7Btnr4IHs EgIA== X-Gm-Message-State: ALoCoQmn3ZvFYoxWEGyFfoBZ3jMm+A3st7Z9nYM652J0oQWDdA5e/kym6SuX0WfOKXnnH99LW5m+ X-Received: by 10.180.109.10 with SMTP id ho10mr6772758wib.14.1376890468109; Sun, 18 Aug 2013 22:34:28 -0700 (PDT) Received: from localhost.localdomain ([213.122.173.130]) by mx.google.com with ESMTPSA id l5sm13743257wia.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Aug 2013 22:34:27 -0700 (PDT) From: Zhangfei Gao To: Mike Turquette , James Hogan Subject: [PATCH] clk: debugfs add clk_rate_fops with DEBUG Date: Mon, 19 Aug 2013 13:34:17 +0800 Message-Id: <1376890457-17871-1-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1376875884-13459-1-git-send-email-zhangfei.gao@linaro.org> References: <1376875884-13459-1-git-send-email-zhangfei.gao@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130819_013453_315052_96BEFBE0 X-CRM114-Status: GOOD ( 11.67 ) X-Spam-Score: -2.6 (--) Cc: Zhangfei Gao , linaro-kernel@lists.linaro.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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 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 clk_rate_fops is added to debug 1. set_rate (e.g. PLL) 2. Choose mux parent, since mux could choose parent accordingly when set_rate. Causion: set_rate can be called directly from user space Example: sfc_mux have two parents: 24M and 200M cat clk_summary clock enable_cnt prepare_cnt rate --------------------------------------------------------------------- osc24mhz 3 3 24000000 bpll_fout3 0 0 200000000 sfc_mux 0 0 200000000 sfc 0 0 200000000 cat osc24mhz/bpll/bpll_fout3/sfc_mux/sfc/clk_rate 200000000 echo 24000000 > osc24mhz/bpll/bpll_fout3/sfc_mux/sfc/clk_rate cat clk_summary clock enable_cnt prepare_cnt rate --------------------------------------------------------------------- osc24mhz 3 3 24000000 sfc_mux 0 0 24000000 sfc 0 0 24000000 bpll_fout3 0 0 200000000 cat osc24mhz/sfc_mux/sfc/clk_rate 24000000 Signed-off-by: Zhangfei Gao --- drivers/clk/clk.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 373cd54..6b582f7 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -226,6 +226,35 @@ static const struct file_operations clk_dump_fops = { .release = single_release, }; +#ifdef DEBUG +static int clk_rate_fops_get(void *data, u64 *rate) +{ + struct clk *clk = data; + + *rate = clk->rate; + + return 0; +}; + +static int clk_rate_fops_set(void *data, u64 rate) +{ + struct clk *clk = data; + int ret = 0; + + ret = clk_prepare_enable(clk); + if (ret) + goto out; + clk_set_rate(clk, rate); + clk_disable_unprepare(clk); + +out: + return ret; +}; + +DEFINE_SIMPLE_ATTRIBUTE(clk_rate_fops, clk_rate_fops_get, + clk_rate_fops_set, "%llu\n"); +#endif + /* caller must hold prepare_lock */ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry) { @@ -243,8 +272,13 @@ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry) clk->dentry = d; +#ifdef DEBUG + d = debugfs_create_file("clk_rate", S_IWUSR | S_IRUGO, clk->dentry, + clk, &clk_rate_fops); +#else d = debugfs_create_u32("clk_rate", S_IRUGO, clk->dentry, (u32 *)&clk->rate); +#endif if (!d) goto err_out;