summaryrefstree
path: root/kernel/drivers/input/misc/input_booster.h
blob: 6a632cc27e61c315c46152ae54520b7d09b924da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 *  Copyright (C) 2013, Samsung Electronics Co. Ltd. All Rights Reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 */

#ifndef _INPUT_BOOSTER_H_
#define _INPUT_BOOSTER_H_

#include <linux/input.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/input/input_booster.h>
#include <linux/pm_qos.h>
#include <linux/of.h>

#ifdef CONFIG_SCHED_HMP
#include <linux/sched.h>
#define USE_HMP_BOOST
#endif

#define BOOSTER_EVENT_BUFFER_SIZE	10

/* Feature define */
#define BOOSTER_SYSFS
#define USE_WORKQUEUING

#ifdef BOOSTER_SYSFS
extern struct class *sec_class;
#endif

#define set_qos(req, pm_qos_class, value) { \
	if (value) { \
		if (pm_qos_request_active(req)) \
			pm_qos_update_request(req, value); \
		else \
			pm_qos_add_request(req, pm_qos_class, value); \
	} \
}

#define remove_qos(req) { \
	if (pm_qos_request_active(req)) \
		pm_qos_remove_request(req); \
}

#ifdef USE_HMP_BOOST
#define SET_HMP(data, device_type, enable)	\
	input_booster_set_hmp_boost(data, device_type, enable);
#else
#define SET_HMP(data, device_type, enable)
#endif

#define DECLARE_DVFS_DELAYED_WORK_FUNC(mode, device)	\
	static void	input_booster_##mode##_dvfs_work_func_##device	\
			(struct work_struct *work)

#define DECLARE_DVFS_WORK_FUNC(mode, device)	\
	static void	input_booster_##mode##_dvfs_work_func_##device	\
			(void *booster_data, enum booster_mode booster_mode)

#define DVFS_WORK_FUNC(mode, device)		\
	input_booster_##mode##_dvfs_work_func_##device

enum booster_dbg_level {
	DBG_DVFS = 1,
	DBG_EVENT,
	DBG_MISC,
};

#define DVFS_DEV_DBG(level, dev, fmt, args...)	\
{											\
	if (level <= dbg_level)					\
		dev_info(dev, fmt, ## args);		\
	else									\
		dev_dbg(dev, fmt, ## args);			\
}

/*
 * struct booster_dvfs - struct for booster.
 * @name :
 * @initialized :
 * @lock_status :
 * @level :
 * @off_time_ms :
 * @chg_time_ms :
 * @lock :
 * @dvfs_chg_work :
 * @dvfs_off_work :
 * @cpu_qos :
 * @mif_qos :
 * @int_qos :
 * @set_dvfs_lock :
 * @phase_excuted : To check phase timer excuted or not.
 * @parent_dev :
 */
struct booster_dvfs {
	enum booster_device_type device_type;
	const char *name;
#ifdef BOOSTER_SYSFS
	struct device *sysfs_dev;
#endif
	bool initialized;
	bool lock_status;
	bool short_press;
	enum booster_level level;
	struct mutex lock;
	struct delayed_work	dvfs_chg_work;
	struct delayed_work	dvfs_off_work;
	struct dvfs_freq freqs[BOOSTER_LEVEL_MAX];
	struct dvfs_time times[BOOSTER_LEVEL_MAX];
	struct pm_qos_request	cpu_qos;
	struct pm_qos_request	kfc_qos;
	struct pm_qos_request	mif_qos;
	struct pm_qos_request	int_qos;
	void (*set_dvfs_lock) (void *booster_data, enum booster_mode mode);
#ifdef USE_HMP_BOOST
	bool hmp_boosted;
#endif
	bool phase_excuted;
	struct device *parent_dev;
};

/*
 * struct booster_event - struct for booster.
 * @type :
 * @mode :
 */
struct booster_event {
	enum booster_device_type device_type;
	enum booster_mode mode;
};

/*
 * struct input_booster - struct for booster.
 * @dev :
 * @input_handler :
 * @dev_bit :
 * @dvfses :
 * @ndevicess :
 * @dvfs_off_work :
 * @devices :
 */
struct input_booster {
	struct device *dev;
#ifdef BOOSTER_SYSFS
	struct class *class;
#endif
	unsigned long dev_bit[BITS_TO_LONGS(BOOSTER_DEVICE_MAX)];
	struct booster_dvfs *dvfses[BOOSTER_DEVICE_MAX];

	unsigned int rear;
	unsigned int front;
	spinlock_t buffer_lock; /* protects access to buffer, front and rear */
	unsigned int buffer_size;
	struct booster_event buffer[BOOSTER_EVENT_BUFFER_SIZE];
	struct work_struct event_work;

	int ndevices;
	struct booster_device devices[];
};

#endif