summaryrefslogtreecommitdiff
path: root/include/soc/rockchip/rockchip_opp_select.h
blob: 1324feebbf39c123cbdc8fd3659c0f1484332c78 (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
174
175
176
177
178
/*
 * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd
 *
 * SPDX-License-Identifier: GPL-2.0+
 */
#ifndef __SOC_ROCKCHIP_OPP_SELECT_H
#define __SOC_ROCKCHIP_OPP_SELECT_H

struct thermal_opp_info;

enum thermal_opp_type {
	THERMAL_OPP_TPYE_CPU = 0,
	THERMAL_OPP_TPYE_DEV,
};

struct thermal_opp_device_data {
	enum thermal_opp_type type;
	void *data;
	int (*low_temp_adjust)(struct thermal_opp_info *info, bool is_low);
	int (*high_temp_adjust)(struct thermal_opp_info *info, bool is_low);
};

struct thermal_opp_table {
	unsigned long rate;
	unsigned long volt;
	unsigned long low_temp_volt;
};

struct thermal_opp_info {
	struct device *dev;
	struct thermal_zone_device *tz;
	struct notifier_block thermal_nb;
	struct sel_table *low_temp_table;
	struct thermal_opp_table *opp_table;
	struct thermal_opp_device_data *dev_data;
	unsigned int num_opps;
	unsigned long low_limit;
	unsigned long high_limit;
	int low_temp;
	int high_temp;
	int temp_hysteresis;
	int max_volt;
	int low_temp_min_volt;
	int high_temp_max_volt;
	bool is_low_temp;
	bool is_high_temp;
};

#ifdef CONFIG_ROCKCHIP_OPP
void rockchip_of_get_lkg_sel(struct device *dev, struct device_node *np,
			     char *lkg_name, int process,
			     int *volt_sel, int *scale_sel);
void rockchip_of_get_pvtm_sel(struct device *dev, struct device_node *np,
			      char *reg_name, int process,
			      int *volt_sel, int *scale_sel);
void rockchip_of_get_bin_sel(struct device *dev, struct device_node *np,
			     int bin, int *scale_sel);
int rockchip_get_efuse_value(struct device_node *np, char *porp_name,
			     int *value);
void rockchip_get_soc_info(struct device *dev,
			   const struct of_device_id *matches,
			   int *bin, int *process);
void rockchip_get_scale_volt_sel(struct device *dev, char *lkg_name,
				 char *reg_name, int bin, int process,
				 int *scale, int *volt_sel);
int rockchip_set_opp_info(struct device *dev, int process, int volt_sel);
int rockchip_adjust_power_scale(struct device *dev, int scale);
int rockchip_init_opp_table(struct device *dev,
			    const struct of_device_id *matches,
			    char *lkg_name, char *reg_name);
struct thermal_opp_info *
rockchip_register_thermal_notifier(struct device *dev,
				   struct thermal_opp_device_data *data);
void rockchip_unregister_thermal_notifier(struct thermal_opp_info *info);
int rockchip_cpu_low_temp_adjust(struct thermal_opp_info *info,
				 bool is_low);
int rockchip_cpu_high_temp_adjust(struct thermal_opp_info *info,
				  bool is_high);
int rockchip_dev_low_temp_adjust(struct thermal_opp_info *info,
				 bool is_low);
int rockchip_dev_high_temp_adjust(struct thermal_opp_info *info,
				  bool is_high);
#else
static inline void rockchip_of_get_lkg_sel(struct device *dev,
					   struct device_node *np,
					   char *lkg_name, int process,
					   int *volt_sel, int *scale_sel)
{
}

static inline void rockchip_of_get_pvtm_sel(struct device *dev,
					    struct device_node *np,
					    char *reg_name, int process,
					    int *volt_sel, int *scale_sel)
{
}

static inline void rockchip_of_get_bin_sel(struct device *dev,
					   struct device_node *np, int bin,
					   int *scale_sel)
{
}

static inline int rockchip_get_efuse_value(struct device_node *np,
					   char *porp_name, int *value)
{
	return -ENOTSUPP;
}

static inline void rockchip_get_soc_info(struct device *dev,
					 const struct of_device_id *matches,
					 int *bin, int *process)
{
}

static inline void rockchip_get_scale_volt_sel(struct device *dev,
					       char *lkg_name, char *reg_name,
					       int bin, int process, int *scale,
					       int *volt_sel)
{
}

static inline int rockchip_set_opp_info(struct device *dev, int process,
					int volt_sel)
{
	return -ENOTSUPP;
}

static inline int rockchip_adjust_power_scale(struct device *dev, int scale)
{
	return -ENOTSUPP;
}

static inline int rockchip_init_opp_table(struct device *dev,
					  const struct of_device_id *matches,
					  char *lkg_name, char *reg_name)
{
	return -ENOTSUPP;
}

static inline struct thermal_opp_info *
rockchip_register_thermal_notifier(struct device *dev,
				   struct thermal_opp_device_data *data)
{
	return ERR_PTR(-ENOTSUPP);
}

static inline void
rockchip_unregister_thermal_notifier(struct thermal_opp_info *info)
{
}

static inline int rockchip_cpu_low_temp_adjust(struct thermal_opp_info *info,
					       bool is_low)
{
	return -ENOTSUPP;
}

static inline int rockchip_cpu_high_temp_adjust(struct thermal_opp_info *info,
						bool is_high)
{
	return -ENOTSUPP;
}

static inline int rockchip_dev_low_temp_adjust(struct thermal_opp_info *info,
					       bool is_low)
{
	return -ENOTSUPP;
}

static inline int rockchip_dev_high_temp_adjust(struct thermal_opp_info *info,
						bool is_high)
{
	return -ENOTSUPP;
}
#endif /* CONFIG_ROCKCHIP_OPP */

#endif