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: 19283 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f200.google.com (mail-gh0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E3AA25AC6 for ; Mon, 19 Aug 2013 05:34:31 +0000 (UTC) Received: by mail-gh0-f200.google.com with SMTP id 10sf3405107ghy.3 for ; Sun, 18 Aug 2013 22:34:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=5/w4pIG9ILbDHPVQ1n6cdeDHO1HXsN6JwboZxSEb1yA=; b=K297g1q67jvbnrHEWYGSeuTpNajiWbvyRFROqmLmlWP2kThlITOCdY+HpItStxNTht T7xMuW8tDz2zCGItGlSB1VimLoGWaC2rSMppJNMy/PQ/BxTxebH8gNvf8TjZiroS4Oab NdVvVrjCh8qjZT6zLfQkwzUf0P4143v9rWgxCm7HGpjaccXLq6ZUJZsI5jO+rYYX7I5m GNOrr8jFElkIUPQMQi0F/ywl/9RSNq+Boy2dfc5XIhJYWUjwxkt5uOwz5VLsuJ3S/3kC nyQG7WdabCBheaaJRGZ5jfm3QN1VwiwFLmXZWuaeX0WRNP8CXpzCzzKbDZyJK+fmtc79 R71w== X-Received: by 10.236.227.165 with SMTP id d35mr343203yhq.51.1376890470859; Sun, 18 Aug 2013 22:34:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.94.143 with SMTP id dc15ls760074qeb.72.gmail; Sun, 18 Aug 2013 22:34:30 -0700 (PDT) X-Received: by 10.220.249.67 with SMTP id mj3mr339877vcb.23.1376890470724; Sun, 18 Aug 2013 22:34:30 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id rl1si2059859vcb.74.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Aug 2013 22:34:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ht10so2678363vcb.38 for ; Sun, 18 Aug 2013 22:34:30 -0700 (PDT) X-Gm-Message-State: ALoCoQkIZrmnUgmZxuHwYbuHF/Kg2ppliXavJtK+aYDkvzVoWciavfu6N2FPONINJoXWgWBI5BGH X-Received: by 10.221.40.10 with SMTP id to10mr704685vcb.22.1376890470621; Sun, 18 Aug 2013 22:34:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp77151vcz; Sun, 18 Aug 2013 22:34:29 -0700 (PDT) X-Received: by 10.180.80.71 with SMTP id p7mr3668926wix.48.1376890468618; Sun, 18 Aug 2013 22:34:28 -0700 (PDT) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) by mx.google.com with ESMTPS id cq8si3443036wjc.61.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Aug 2013 22:34:28 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.53 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=74.125.82.53; Received: by mail-wg0-f53.google.com with SMTP id c11so3154815wgh.20 for ; Sun, 18 Aug 2013 22:34:28 -0700 (PDT) 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 Cc: linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Zhangfei Gao 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhangfei.gao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;