summaryrefstree
path: root/kernel/include/linux/sec_nad_balancer.h
blob: 35e67f443ca6503a2a0e301cd11591988e16dd96 (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
/* sec_nadbalancer.h
 *
 * NAD Balancer Driver
 *
 * Copyright (C) 2017 Samsung Electronics
 *
 * Hyeokseon Yu <hyeokseon.yu@samsung.com>
 *
 * 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 SEC_NAD_BALANCER_H
#define SEC_NAD_BALANCER_H

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sec_class.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/pm_qos.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/random.h>
#include <linux/io.h>
#include <linux/alarmtimer.h>

#if defined(CONFIG_SEC_FACTORY)
#define BALANCER_CMD	6
#define NAD_BUFF_SIZE	256
#define MAX_TMU_COUNT	5

#define UPDATE_FIRST_TEMPERATURE	1
#define UPDATE_CONTI_TEMPERATURE	2
#define UPDATE_FINAL_TEMPERATURE	3

#define NAD_MIN_FREQ	0
#define NAD_MAX_FREQ	1

#define NAD_BALANCER_MODE_SINGLE	(1)
#define NAD_BALANCER_MODE_DUAL		(2)
#define NAD_BALANCER_MODE_QUAD		(4)

struct device *sec_nad_balancer;
static bool nad_balancer_enable;
static bool sleep_test_enable;

static DEFINE_MUTEX(nad_balancer_lock);

struct freq_table {
	unsigned int freq;
};

struct nad_balancer_pm_qos {
	const char *desc;
	struct task_struct *thread;
	struct freq_table *tables;
	int delay_time;
	int table_size;

	/* big turbo support - single / dual / quad */
	struct freq_table *single_tables;
	struct freq_table *dual_tables;
	struct freq_table *quad_tables;
	int current_mode;
	int big_turbo_enable;
	int single_table_size;
	int dual_table_size;
	int quad_table_size;

	int policy;

	struct pm_qos_request big_qos;
	struct pm_qos_request lit_qos;
	struct pm_qos_request mid_qos;
	struct pm_qos_request mif_qos;
	struct pm_qos_request int_qos;

	int temperature[MAX_TMU_COUNT];
};

struct nad_balancer_sleep_info {
	int suspend_threshold;
	int resume_threshold;
};

struct nad_balancer_platform_data {
	struct nad_balancer_pm_qos *qos_items;
	struct nad_balancer_sleep_info *sleep_items;

	unsigned int nItem;
	unsigned int nQos;

	unsigned int timeout;
	unsigned int nSleep;
};

struct nad_balancer_info {
	struct device *dev;
	struct nad_balancer_platform_data *pdata;
	struct delayed_work sec_nad_balancer_work;
};

static int sec_nad_balancer_probe(struct platform_device *pdev);
static int sec_nad_balancer_resume(struct device *dev);
static int sec_nad_balancer_remove(struct platform_device *pdev);
static int sec_nad_balancer_prepare(struct device *dev);

#define UPDATE_PM_QOS(req, class_id, arg) ({ \
if (arg) { \
	if (pm_qos_request_active(req)) \
		pm_qos_update_request(req, arg); \
	else \
		pm_qos_add_request(req, class_id, arg); \
} \
})

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