1 /* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/types.h>
17 #include <linux/device.h>
18 #include <linux/platform_device.h>
20 #include <linux/err.h>
22 #include "coresight.h"
27 CORESIGHT_CLK_ON_HSDBG,
30 struct coresight_ctx {
31 struct kobject *modulekobj;
35 static struct coresight_ctx coresight;
38 struct kobject *coresight_get_modulekobj(void)
40 return coresight.modulekobj;
43 #define CORESIGHT_ATTR(name) \
44 static struct kobj_attribute name##_attr = \
45 __ATTR(name, S_IRUGO | S_IWUSR, name##_show, name##_store)
47 static ssize_t max_clk_store(struct kobject *kobj,
48 struct kobj_attribute *attr,
49 const char *buf, size_t n)
53 if (sscanf(buf, "%lx", &val) != 1)
56 coresight.max_clk = val;
59 static ssize_t max_clk_show(struct kobject *kobj,
60 struct kobj_attribute *attr,
63 unsigned long val = coresight.max_clk;
64 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
66 CORESIGHT_ATTR(max_clk);
68 static int __init coresight_sysfs_init(void)
72 coresight.modulekobj = kset_find_obj(module_kset, KBUILD_MODNAME);
73 if (!coresight.modulekobj) {
74 pr_err("failed to find CORESIGHT sysfs module kobject\n");
79 ret = sysfs_create_file(coresight.modulekobj, &max_clk_attr.attr);
81 pr_err("failed to create CORESIGHT sysfs max_clk attribute\n");
90 static void coresight_sysfs_exit(void)
92 sysfs_remove_file(coresight.modulekobj, &max_clk_attr.attr);
95 static int __init coresight_init(void)
99 ret = coresight_sysfs_init();
115 pr_info("CORESIGHT initialized\n");
124 coresight_sysfs_exit();
126 pr_err("CORESIGHT init failed\n");
129 module_init(coresight_init);
131 static void __exit coresight_exit(void)
133 coresight_sysfs_exit();
139 module_exit(coresight_exit);
141 MODULE_LICENSE("GPL v2");
142 MODULE_DESCRIPTION("CoreSight ETM Debug System Driver");