From patchwork Thu Jan 24 16:01:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 14271 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 0B80D23E1A for ; Thu, 24 Jan 2013 16:01:56 +0000 (UTC) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by fiordland.canonical.com (Postfix) with ESMTP id 970C2A183F8 for ; Thu, 24 Jan 2013 16:01:55 +0000 (UTC) Received: by mail-vb0-f50.google.com with SMTP id ft2so8220229vbb.37 for ; Thu, 24 Jan 2013 08:01:55 -0800 (PST) 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:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=DeNsOxSMOVjOVBiiaSD9f8fa0lskopz4xJxY7DhI1a8=; b=MOXEEK+rXtE9Xh+U4qSHHJvgtUQVDCVlD59itdpikfTsIUGbvynMxyluGr8bVyN6Tr b1EeN49hUSOgRawsMFCzuTf13Yd0azqsoeobfGgKZfa0E+FQtK4mlqV1rcSJBuyretbT BQdo1n0+pYCODMbbvLocTVV1eDCt8OaYu307eR+rJW/6k6eL4vjjZvXYBUyGtkDWS5c0 u4rHsXg+Qttedq+Q3uKyGtRfe06Amd2JOVXFlegP5OdXLZQYaCwaNOLDUl/3/yO2q3MW 6WIn/iyZnwX8+V8HBhmkbDeSasWbWRE5smblC8N/YRh8rWiIGD9Tt2CZ+C8p3cYhtrj6 SR6A== X-Received: by 10.52.18.147 with SMTP id w19mr2086660vdd.94.1359043315017; Thu, 24 Jan 2013 08:01:55 -0800 (PST) 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.145.101 with SMTP id st5csp71998veb; Thu, 24 Jan 2013 08:01:54 -0800 (PST) X-Received: by 10.68.231.40 with SMTP id td8mr6171778pbc.48.1359043313825; Thu, 24 Jan 2013 08:01:53 -0800 (PST) Received: from mail-da0-f43.google.com (mail-da0-f43.google.com [209.85.210.43]) by mx.google.com with ESMTPS id e2si24706871paz.63.2013.01.24.08.01.53 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jan 2013 08:01:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.43 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=209.85.210.43; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.43 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) smtp.mail=sanjay.rawat@linaro.org Received: by mail-da0-f43.google.com with SMTP id u36so4339370dak.30 for ; Thu, 24 Jan 2013 08:01:53 -0800 (PST) X-Received: by 10.68.236.100 with SMTP id ut4mr6229144pbc.92.1359043313016; Thu, 24 Jan 2013 08:01:53 -0800 (PST) Received: from localhost.localdomain ([223.239.136.30]) by mx.google.com with ESMTPS id nt5sm15088311pbb.59.2013.01.24.08.01.50 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jan 2013 08:01:52 -0800 (PST) From: Sanjay Singh Rawat To: linaro-dev@lists.linaro.org Cc: patches@linaro.org, Sanjay Singh Rawat Subject: [powerdebug,1/1] clock: support common clock framework Date: Thu, 24 Jan 2013 21:31:33 +0530 Message-Id: <1359043293-18480-1-git-send-email-sanjay.rawat@linaro.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQn3AEAsdUy3/hviuxUHg4tK2UQ0XsMVe1SNnILlPc4zNj+H+ffqLgXwT+NBnNH17BOw+8tE Signed-off-by: Sanjay Singh Rawat --- clocks.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/clocks.c b/clocks.c index 2611a0d..95acf57 100644 --- a/clocks.c +++ b/clocks.c @@ -42,9 +42,19 @@ struct clock_info { int usecount; bool expanded; char *prefix; + int preparecount; + int enablecount; + int notifiercount; } *clocks_info; +enum clock_fw_type{ + CCF, /* common clock framework */ + OCF, /* old clock framework */ + MAX, +}; + static struct tree *clock_tree = NULL; +static int clock_fw; static int locate_debugfs(char *clk_path) { @@ -144,9 +154,18 @@ static inline int read_clock_cb(struct tree *t, void *data) { struct clock_info *clk = t->private; - file_read_value(t->path, "flags", "%x", &clk->flags); - file_read_value(t->path, "rate", "%d", &clk->rate); - file_read_value(t->path, "usecount", "%d", &clk->usecount); + if(clock_fw == CCF) { + file_read_value(t->path, "clk_flags", "%x", &clk->flags); + file_read_value(t->path, "clk_rate", "%d", &clk->rate); + file_read_value(t->path, "clk_prepare_count", "%d", &clk->preparecount); + file_read_value(t->path, "clk_enable_count", "%d", &clk->enablecount); + file_read_value(t->path, "clk_notifier_count", "%d", &clk->notifiercount); + } + else { + file_read_value(t->path, "flags", "%x", &clk->flags); + file_read_value(t->path, "rate", "%d", &clk->rate); + file_read_value(t->path, "usecount", "%d", &clk->usecount); + } return 0; } @@ -206,9 +225,17 @@ static char *clock_line(struct tree *t) if (asprintf(&clkrate, "%d%s", rate, clkunit) < 0) goto free_clkname; - if (asprintf(&clkline, "%-55s 0x%-16x %-12s %-9d %-8d", clkname, - clk->flags, clkrate, clk->usecount, t->nrchild) < 0) - goto free_clkrate; + if(clock_fw == CCF) { + if (asprintf(&clkline, "%-35s 0x%-8x %-12s %-10d %-11d %-15d %-14d %-10d", + clkname, clk->flags, clkrate, clk->usecount, t->nrchild, + clk->preparecount, clk->enablecount, clk->notifiercount) < 0) + goto free_clkrate; + } + else { + if (asprintf(&clkline, "%-55s 0x%-16x %-12s %-9d %-8d", + clkname, clk->flags, clkrate, clk->usecount, t->nrchild) < 0) + goto free_clkrate; + } free_clkrate: free(clkrate); @@ -259,9 +286,17 @@ static int clock_print_header(void) char *buf; int ret; - if (asprintf(&buf, "%-55s %-16s %-12s %-9s %-8s", + if(clock_fw == CCF) { + if (asprintf(&buf, "%-35s %-10s %-12s %-10s %-11s %-15s %-14s %-14s", + "Name", "Flags", "Rate", "Usecount", "Children", "Prepare_Count", + "Enable_Count", "Notifier_Count") < 0) + return -1; + } + else { + if (asprintf(&buf, "%-55s %-16s %-12s %-9s %-8s", "Name", "Flags", "Rate", "Usecount", "Children") < 0) return -1; + } ret = display_column_name(buf); @@ -384,17 +419,25 @@ static struct display_ops clock_ops = { */ int clock_init(void) { - char clk_dir_path[PATH_MAX]; + char clk_dir_path[MAX+1][PATH_MAX]; - if (locate_debugfs(clk_dir_path)) + if (locate_debugfs(clk_dir_path[CCF]) || locate_debugfs(clk_dir_path[OCF])) return -1; - sprintf(clk_dir_path, "%s/clock", clk_dir_path); - - if (access(clk_dir_path, F_OK)) + sprintf(clk_dir_path[CCF], "%s/clk", clk_dir_path[CCF]); + sprintf(clk_dir_path[OCF], "%s/clock", clk_dir_path[OCF]); + if (!access(clk_dir_path[CCF], F_OK)) { + clock_fw = CCF; + strcpy(clk_dir_path[MAX],clk_dir_path[CCF]); + } + else if(!access(clk_dir_path[OCF], F_OK)) { + clock_fw = OCF; + strcpy(clk_dir_path[MAX],clk_dir_path[OCF]); + } + else return -1; - clock_tree = tree_load(clk_dir_path, NULL, false); + clock_tree = tree_load(clk_dir_path[MAX], NULL, false); if (!clock_tree) return -1;