From patchwork Fri Aug 16 04:03:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 19208 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F41BA25A1B for ; Fri, 16 Aug 2013 04:03:43 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id ox1sf1960744veb.4 for ; Thu, 15 Aug 2013 21:03:43 -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=qX1Tox4pO5F4UKxZpas3uk1IakEgCfImDHPc4BjTNq4=; b=oG92dAVO2jzedhAHMYpdvYoJk8vneDtY5ksyg4GomkC+CkcDRL+Q3hhbMoi8LBEwsX S1DebxZWbxcNIfOvbgFwg+rd4K0nFZSaKp6LY2QpWntim2sjHQPAkrc4QxO+2QJSrBVo rkquV0962DZRw2dP30sPWt8+CKdqgz+eXc7SGNUlSH+PMC+spp2hsWg8Rc3fAvaXb5VI iQP8ZPM+FBTrtiDDXCoorEWQhKeVKHZMAMEFouDC0+MIK+Ss1+7ICG5RDip5lcZ+IW50 FmBBJKlBFUfJaaFsNyUu0cIU8WsFmbwthERZ3Yzc5FliOM0G5herfQf03an8MiFj+XCz VzGw== X-Received: by 10.236.80.42 with SMTP id j30mr512902yhe.29.1376625823314; Thu, 15 Aug 2013 21:03:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.5.197 with SMTP id u5ls719712qeu.84.gmail; Thu, 15 Aug 2013 21:03:43 -0700 (PDT) X-Received: by 10.52.24.4 with SMTP id q4mr14459602vdf.6.1376625823203; Thu, 15 Aug 2013 21:03:43 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id xu8si776386vcb.80.2013.08.15.21.03.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 21:03:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 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.175; Received: by mail-vc0-f175.google.com with SMTP id ia10so1112313vcb.34 for ; Thu, 15 Aug 2013 21:03:43 -0700 (PDT) X-Gm-Message-State: ALoCoQnO/h7VFDYicoez71lVS5+gger5aDF8s7g7QDJ+dgYyIXDvj/YFVUxbqGLpnFkOJ1ccCvjM X-Received: by 10.52.34.40 with SMTP id w8mr14942065vdi.7.1376625823085; Thu, 15 Aug 2013 21:03:43 -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 u4csp48346vcz; Thu, 15 Aug 2013 21:03:42 -0700 (PDT) X-Received: by 10.14.4.1 with SMTP id 1mr9875939eei.21.1376625822076; Thu, 15 Aug 2013 21:03:42 -0700 (PDT) Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com [209.85.215.181]) by mx.google.com with ESMTPS id x43si1983538eep.310.2013.08.15.21.03.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 21:03:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.181 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.215.181; Received: by mail-ea0-f181.google.com with SMTP id d10so734579eaj.26 for ; Thu, 15 Aug 2013 21:03:41 -0700 (PDT) X-Received: by 10.14.122.69 with SMTP id s45mr1141916eeh.58.1376625821324; Thu, 15 Aug 2013 21:03:41 -0700 (PDT) Received: from localhost.localdomain ([213.122.173.130]) by mx.google.com with ESMTPSA id d8sm4049031eeh.8.2013.08.15.21.03.36 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 21:03:40 -0700 (PDT) From: Zhangfei Gao To: Mike Turquette , James Hogan Cc: linaro-kernel@lists.linaro.org, Zhangfei Gao Subject: [RFC][PATCH] clk: debugfs add clk_rate_fops to debugfs mux Date: Fri, 16 Aug 2013 12:03:28 +0800 Message-Id: <1376625809-522-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.220.175 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: , MUX could choose parent accordingly when set_rate. Add clk_rate_fops to debug whether mux choose correct parent Example: 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 | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 373cd54..327b698 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -226,6 +226,33 @@ static const struct file_operations clk_dump_fops = { .release = single_release, }; +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"); + /* caller must hold prepare_lock */ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry) { @@ -243,8 +270,8 @@ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry) clk->dentry = d; - d = debugfs_create_u32("clk_rate", S_IRUGO, clk->dentry, - (u32 *)&clk->rate); + d = debugfs_create_file("clk_rate", S_IWUSR | S_IRUGO, clk->dentry, + clk, &clk_rate_fops); if (!d) goto err_out;