From patchwork Mon Aug 19 01:31:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 19282 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 322D925AC6 for ; Mon, 19 Aug 2013 01:31:53 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id e13sf4873444vbg.4 for ; Sun, 18 Aug 2013 18:31:52 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=5TtAgrTSDjXPd9BX/SvA/En4tXGnUtRSDZo0VqJJSe8=; b=A1BU++4FIOytpFYY1okNEhegFzFs6vUTYp6bDlF0RcIq+ovN6jn1yHLmxojIxPA+dc m2zoP9s7QdUor1mydry6i3BNNLGdPbW4DW+Gtt65MsZ3ircsSPD2hwBxKKzA521PD9q5 UZjiDGbLOZBXaxEEbOBJ9VwDBI0xV+rwfgYM/qhQmN9rnvyXc5/lQcdtoQFavlKi89lU ILmBV+mSZ1alZlrgmIgwIYDWxX6TUWuROFYOAh067MXVHbxRsopmeDJsD9LyG6CBq3uo xnrlu6bF5vuHh0rWn1u5li6vAqgjBDD+icy0+GLYmH8/7xzrtU8jyUOUjEDGx/q2n90m CXwQ== X-Received: by 10.236.45.102 with SMTP id o66mr1074128yhb.47.1376875912311; Sun, 18 Aug 2013 18:31:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.94.165 with SMTP id dd5ls190402qeb.87.gmail; Sun, 18 Aug 2013 18:31:52 -0700 (PDT) X-Received: by 10.52.232.165 with SMTP id tp5mr9016878vdc.11.1376875912172; Sun, 18 Aug 2013 18:31:52 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id jf10si1921194vdb.63.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Aug 2013 18:31:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id jz10so2691994veb.12 for ; Sun, 18 Aug 2013 18:31:52 -0700 (PDT) X-Gm-Message-State: ALoCoQn1TqQ89gfBpkbAamidqcCai2uyG+vwim2mDWjmbcKZ9avKwbx0pe/W//ZAxP7q0FU4Icpb X-Received: by 10.220.88.13 with SMTP id y13mr472851vcl.20.1376875912077; Sun, 18 Aug 2013 18:31:52 -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 u4csp69571vcz; Sun, 18 Aug 2013 18:31:51 -0700 (PDT) X-Received: by 10.66.179.143 with SMTP id dg15mr10691339pac.52.1376875911059; Sun, 18 Aug 2013 18:31:51 -0700 (PDT) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by mx.google.com with ESMTPS id y8si6750390pax.35.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Aug 2013 18:31:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.52 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.220.52; Received: by mail-pa0-f52.google.com with SMTP id kq13so3982707pab.11 for ; Sun, 18 Aug 2013 18:31:50 -0700 (PDT) X-Received: by 10.68.130.71 with SMTP id oc7mr10687375pbb.10.1376875910549; Sun, 18 Aug 2013 18:31:50 -0700 (PDT) Received: from localhost.localdomain ([124.73.88.119]) by mx.google.com with ESMTPSA id bg3sm11680278pbb.44.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Aug 2013 18:31:49 -0700 (PDT) From: Zhangfei Gao To: Mike Turquette , James Hogan Cc: linaro-kernel@lists.linaro.org, Zhangfei Gao Subject: [PATCH] clk: debugfs add clk_rate_fops with DEBUG Date: Mon, 19 Aug 2013 09:31:24 +0800 Message-Id: <1376875884-13459-1-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 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.128.181 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 1 1 4294967295 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 1 1 4294967295 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;