ARM: rockchip: rk3228: add grf definition
[firefly-linux-kernel-4.4.55.git] / include / linux / cpuquiet.h
1 /*
2  * Copyright (c) 2012 NVIDIA CORPORATION.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16  *
17  */
18
19 #ifndef _LINUX_CPUONLINE_H
20 #define _LINUX_CPUONLINE_H
21
22 #include <linux/sysfs.h>
23 #include <linux/kobject.h>
24
25 #define CPUQUIET_NAME_LEN 16
26
27 struct cpuquiet_governor {
28         char                    name[CPUQUIET_NAME_LEN];
29         struct list_head        governor_list;
30         int (*start)            (void);
31         void (*stop)            (void);
32         int (*store_active)     (unsigned int cpu, bool active);
33         void (*device_free_notification) (void);
34         void (*device_busy_notification) (void);
35         struct module           *owner;
36 };
37
38 struct cpuquiet_driver {
39         char                    name[CPUQUIET_NAME_LEN];
40         int (*quiesence_cpu)    (unsigned int cpunumber, bool sync);
41         int (*wake_cpu)         (unsigned int cpunumber, bool sync);
42 };
43
44 extern int cpuquiet_register_governor(struct cpuquiet_governor *gov);
45 extern void cpuquiet_unregister_governor(struct cpuquiet_governor *gov);
46 extern int cpuquiet_quiesence_cpu(unsigned int cpunumber, bool sync);
47 extern int cpuquiet_wake_cpu(unsigned int cpunumber, bool sync);
48 extern int cpuquiet_register_driver(struct cpuquiet_driver *drv);
49 extern void cpuquiet_unregister_driver(struct cpuquiet_driver *drv);
50 extern int cpuquiet_add_group(struct attribute_group *attrs);
51 extern void cpuquiet_remove_group(struct attribute_group *attrs);
52 extern void cpuquiet_device_busy(void);
53 extern void cpuquiet_device_free(void);
54 int cpuquiet_kobject_init(struct kobject *kobj, struct kobj_type *type,
55                                 char *name);
56 extern unsigned int nr_cluster_ids;
57
58 /* Sysfs support */
59 struct cpuquiet_attribute {
60         struct attribute attr;
61         ssize_t (*show)(struct cpuquiet_attribute *attr, char *buf);
62         ssize_t (*store)(struct cpuquiet_attribute *attr, const char *buf,
63                                 size_t count);
64         /* Optional. Called after store is called */
65         void (*store_callback)(struct cpuquiet_attribute *attr);
66         void *param;
67 };
68
69 #define CPQ_ATTRIBUTE(_name, _mode, _type, _callback) \
70         static struct cpuquiet_attribute _name ## _attr = {             \
71                 .attr = {.name = __stringify(_name), .mode = _mode },   \
72                 .show = show_ ## _type ## _attribute,                   \
73                 .store = store_ ## _type ## _attribute,                 \
74                 .store_callback = _callback,                            \
75                 .param = &_name,                                        \
76 }
77
78 #define CPQ_BASIC_ATTRIBUTE(_name, _mode, _type)                        \
79         CPQ_ATTRIBUTE(_name, _mode, _type, NULL)
80
81 #define CPQ_ATTRIBUTE_CUSTOM(_name, _mode, _show, _store) \
82         static struct cpuquiet_attribute _name ## _attr = {             \
83                 .attr = {.name = __stringify(_name), .mode = _mode },   \
84                 .show = _show,                                          \
85                 .store = _store,                                        \
86                 .store_callback = NULL,                                 \
87                 .param = &_name,                                        \
88 }
89
90
91 extern ssize_t show_int_attribute(struct cpuquiet_attribute *cattr, char *buf);
92 extern ssize_t store_int_attribute(struct cpuquiet_attribute *cattr,
93                                         const char *buf, size_t count);
94 extern ssize_t show_bool_attribute(struct cpuquiet_attribute *cattr, char *buf);
95 extern ssize_t store_bool_attribute(struct cpuquiet_attribute *cattr,
96                                         const char *buf, size_t count);
97 extern ssize_t store_uint_attribute(struct cpuquiet_attribute *cattr,
98                                         const char *buf, size_t count);
99 extern ssize_t show_uint_attribute(struct cpuquiet_attribute *cattr, char *buf);
100 extern ssize_t store_ulong_attribute(struct cpuquiet_attribute *cattr,
101                                         const char *buf, size_t count);
102 extern ssize_t show_ulong_attribute(struct cpuquiet_attribute *cattr,
103                                         char *buf);
104 extern ssize_t cpuquiet_auto_sysfs_show(struct kobject *kobj,
105                                         struct attribute *attr, char *buf);
106 extern ssize_t cpuquiet_auto_sysfs_store(struct kobject *kobj,
107                                         struct attribute *attr, const char *buf,
108                                         size_t count);
109 #endif