diff mbox

[powerdebug,1/1] clock: support common clock framework

Message ID 1359043293-18480-1-git-send-email-sanjay.rawat@linaro.com
State New
Headers show

Commit Message

Sanjay Singh Rawat Jan. 24, 2013, 4:01 p.m. UTC
Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.com>
---
 clocks.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 56 insertions(+), 13 deletions(-)

Comments

Mike Turquette Jan. 24, 2013, 5:54 p.m. UTC | #1
Quoting Sanjay Singh Rawat (2013-01-24 08:01:33)
> Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.com>

Sanjay,

Have you seen the patch to dump the CCF tree from a single sysfs file,
in JSON format?

http://git.linaro.org/gitweb?p=people/mturquette/linux.git;a=commitdiff;h=bddca8944a7ab6699984c4b1b677261eb1c8d819;hp=1af599df6bdad9ee34ae9e50efcda273e12b9d4f

This is much nicer than parsing a directory structure.  It is faster and
most importantly the data is atomic.  A lock is held across the clock
framework while the data is accessed so you don't have to worry about
data changing in between reads like you do with the directory method.

Regards,
Mike

> ---
>  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;
>  
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> linaro-dev mailing list
> linaro-dev@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-dev
Sanjay Singh Rawat Jan. 25, 2013, 9:08 a.m. UTC | #2
On Thursday 24 January 2013 11:24 PM, Mike Turquette wrote:
> Quoting Sanjay Singh Rawat (2013-01-24 08:01:33)
>> Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.com>
>
> Sanjay,
>
> Have you seen the patch to dump the CCF tree from a single sysfs file,
> in JSON format?
>
> http://git.linaro.org/gitweb?p=people/mturquette/linux.git;a=commitdiff;h=bddca8944a7ab6699984c4b1b677261eb1c8d819;hp=1af599df6bdad9ee34ae9e50efcda273e12b9d4f
>
> This is much nicer than parsing a directory structure.  It is faster and
> most importantly the data is atomic.  A lock is held across the clock
> framework while the data is accessed so you don't have to worry about
> data changing in between reads like you do with the directory method.
>
> Regards,
> Mike
Thanks Mike, yes i remember your point. This change is for addressing 
the bug of clock entries not getting populated on CCF enabled kernel.

Will check for clock_tree_dump file implementation separately.
>
>> ---
>>   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;
>>
>> --
>> 1.7.9.5
>>
>>
>> _______________________________________________
>> linaro-dev mailing list
>> linaro-dev@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/linaro-dev
Amit Kucheria Jan. 25, 2013, 11:18 a.m. UTC | #3
On Fri, Jan 25, 2013 at 9:08 AM, Sanjay Singh Rawat
<sanjay.rawat@linaro.org> wrote:
> On Thursday 24 January 2013 11:24 PM, Mike Turquette wrote:
>>
>> Quoting Sanjay Singh Rawat (2013-01-24 08:01:33)


You're missing a changelog describing why this patch is required. :)

>>>
>>> Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.com>
>>
>>
>> Sanjay,
>>
>> Have you seen the patch to dump the CCF tree from a single sysfs file,
>> in JSON format?
>>
>>
>> http://git.linaro.org/gitweb?p=people/mturquette/linux.git;a=commitdiff;h=bddca8944a7ab6699984c4b1b677261eb1c8d819;hp=1af599df6bdad9ee34ae9e50efcda273e12b9d4f
>>
>> This is much nicer than parsing a directory structure.  It is faster and
>> most importantly the data is atomic.  A lock is held across the clock
>> framework while the data is accessed so you don't have to worry about
>> data changing in between reads like you do with the directory method.
>>
>> Regards,
>> Mike
>
> Thanks Mike, yes i remember your point. This change is for addressing the
> bug of clock entries not getting populated on CCF enabled kernel.
>
> Will check for clock_tree_dump file implementation separately.

I think what Mike is saying is that you could get rid of all the
directory parsing code and just read this one file for all of your
clock data.

But it wouldn't work for platforms that haven't converted over to CCF.
Mike, all member platforms converted over now?

/Amit

>>
>>> ---
>>>   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;
>>>
>>> --
>>> 1.7.9.5
>>>
>>>
>>> _______________________________________________
>>> linaro-dev mailing list
>>> linaro-dev@lists.linaro.org
>>> http://lists.linaro.org/mailman/listinfo/linaro-dev
>
>
>
> --
> Thanks & Regards,
> Sanjay
>
>
> _______________________________________________
> linaro-dev mailing list
> linaro-dev@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-dev
Mike Turquette Jan. 25, 2013, 10:48 p.m. UTC | #4
Quoting Amit Kucheria (2013-01-25 03:18:05)
> On Fri, Jan 25, 2013 at 9:08 AM, Sanjay Singh Rawat
> <sanjay.rawat@linaro.org> wrote:
> > On Thursday 24 January 2013 11:24 PM, Mike Turquette wrote:
> >>
> >> Quoting Sanjay Singh Rawat (2013-01-24 08:01:33)
> 
> 
> You're missing a changelog describing why this patch is required. :)
> 
> >>>
> >>> Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.com>
> >>
> >>
> >> Sanjay,
> >>
> >> Have you seen the patch to dump the CCF tree from a single sysfs file,
> >> in JSON format?
> >>
> >>
> >> http://git.linaro.org/gitweb?p=people/mturquette/linux.git;a=commitdiff;h=bddca8944a7ab6699984c4b1b677261eb1c8d819;hp=1af599df6bdad9ee34ae9e50efcda273e12b9d4f
> >>
> >> This is much nicer than parsing a directory structure.  It is faster and
> >> most importantly the data is atomic.  A lock is held across the clock
> >> framework while the data is accessed so you don't have to worry about
> >> data changing in between reads like you do with the directory method.
> >>
> >> Regards,
> >> Mike
> >
> > Thanks Mike, yes i remember your point. This change is for addressing the
> > bug of clock entries not getting populated on CCF enabled kernel.
> >
> > Will check for clock_tree_dump file implementation separately.
> 
> I think what Mike is saying is that you could get rid of all the
> directory parsing code and just read this one file for all of your
> clock data.
> 

I think leaving the legacy code in is fine.  The current powerdebug code
already checks to see if this is a CCF or legacy clk tree, so we could
leave the legacy code in and change the CCF method to use the clk-dump
sysfs file when CCF is detected.

>
> But it wouldn't work for platforms that haven't converted over to CCF.
> Mike, all member platforms converted over now?
> 

I'll have to check, but as stated above we don't need to remove the
legacy clk code.

Regards,
Mike
diff mbox

Patch

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;