2 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
3 * JZ4740 SoC clock support debugfs entries
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
10 * You should have received a copy of the GNU General Public License along
11 * with this program; if not, write to the Free Software Foundation, Inc.,
12 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/clk.h>
19 #include <linux/err.h>
21 #include <linux/debugfs.h>
22 #include <linux/uaccess.h>
24 #include <asm/mach-jz4740/clock.h>
27 static struct dentry *jz4740_clock_debugfs;
29 static int jz4740_clock_debugfs_show_enabled(void *data, uint64_t *value)
31 struct clk *clk = data;
32 *value = clk_is_enabled(clk);
37 static int jz4740_clock_debugfs_set_enabled(void *data, uint64_t value)
39 struct clk *clk = data;
42 return clk_enable(clk);
49 DEFINE_SIMPLE_ATTRIBUTE(jz4740_clock_debugfs_ops_enabled,
50 jz4740_clock_debugfs_show_enabled,
51 jz4740_clock_debugfs_set_enabled,
54 static int jz4740_clock_debugfs_show_rate(void *data, uint64_t *value)
56 struct clk *clk = data;
57 *value = clk_get_rate(clk);
62 DEFINE_SIMPLE_ATTRIBUTE(jz4740_clock_debugfs_ops_rate,
63 jz4740_clock_debugfs_show_rate,
67 void jz4740_clock_debugfs_add_clk(struct clk *clk)
69 if (!jz4740_clock_debugfs)
72 clk->debugfs_entry = debugfs_create_dir(clk->name, jz4740_clock_debugfs);
73 debugfs_create_file("rate", S_IWUGO | S_IRUGO, clk->debugfs_entry, clk,
74 &jz4740_clock_debugfs_ops_rate);
75 debugfs_create_file("enabled", S_IRUGO, clk->debugfs_entry, clk,
76 &jz4740_clock_debugfs_ops_enabled);
79 char parent_path[100];
80 snprintf(parent_path, 100, "../%s", clk->parent->name);
81 clk->debugfs_parent_entry = debugfs_create_symlink("parent",
88 void jz4740_clock_debugfs_update_parent(struct clk *clk)
90 if (clk->debugfs_parent_entry)
91 debugfs_remove(clk->debugfs_parent_entry);
94 char parent_path[100];
95 snprintf(parent_path, 100, "../%s", clk->parent->name);
96 clk->debugfs_parent_entry = debugfs_create_symlink("parent",
100 clk->debugfs_parent_entry = NULL;
104 void jz4740_clock_debugfs_init(void)
106 jz4740_clock_debugfs = debugfs_create_dir("jz4740-clock", NULL);
107 if (IS_ERR(jz4740_clock_debugfs))
108 jz4740_clock_debugfs = NULL;