summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/include/mach/thermal.h
blob: 6ff525264bc759fa307ba5bff2757f263d8a483c (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
/*
 * arch/arm/mach-tegra/thermal.h
 *
 * Copyright (C) 2010-2012 NVIDIA Corporation.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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 __MACH_THERMAL_H
#define __MACH_THERMAL_H

#include <linux/therm_est.h>
#include <linux/thermal.h>

#ifndef CONFIG_THERMAL
#endif

enum thermal_device_id {
	THERMAL_DEVICE_ID_NULL = 0x0,
	THERMAL_DEVICE_ID_NCT_EXT = 0x1,
	THERMAL_DEVICE_ID_NCT_INT = 0x2,
	THERMAL_DEVICE_ID_TSENSOR = 0x4,
	THERMAL_DEVICE_ID_THERM_EST_SKIN = 0x8,
};

#define THERMAL_DEVICE_MAX	(4)

enum cooling_device_id {
	CDEV_BTHROT_ID_TJ      = 0x00010000,
	CDEV_BTHROT_ID_SKIN    = 0x00020000,
	CDEV_EDPTABLE_ID_EDP   = 0x00030000,
	CDEV_EDPTABLE_ID_EDP_0 = 0x00030000,
	CDEV_EDPTABLE_ID_EDP_1 = 0x00030001,
	CDEV_EDPTABLE_ID_EDP_2 = 0x00030002,
	CDEV_EDPTABLE_ID_EDP_3 = 0x00030003,
	CDEV_EDPTABLE_ID_EDP_4 = 0x00030004,
};

struct tegra_thermal_bind {
	enum thermal_device_id tdev_id;
	enum cooling_device_id cdev_id;
	int type;
	int (*get_trip_temp) (void *, long);
	int (*get_trip_size) (void);
	struct passive_params {
		long trip_temp;
		int tc1;
		int tc2;
		long passive_delay;
	} passive;
};

struct skin_therm_est_subdevice {
	enum thermal_device_id id;
	long coeffs[HIST_LEN];
};

struct tegra_skin_data {
	enum thermal_device_id skin_device_id;

	long skin_temp_offset;
	long skin_period;
	int skin_devs_size;
	struct skin_therm_est_subdevice skin_devs[];
};

struct tegra_thermal_device {
	char *name;
	enum thermal_device_id id;
	void *data;
	long offset;
	int (*get_temp) (void *, long *);
	int (*get_temp_low)(void *, long *);
	int (*set_limits) (void *, long, long);
	int (*set_alert)(void *, void (*)(void *), void *);
	int (*set_shutdown_temp)(void *, long);
	struct thermal_zone_device *thz;
	struct list_head node;
};

struct tegra_cooling_device {
	enum cooling_device_id id;
};

struct throttle_table {
	unsigned int cpu_freq;
	int core_cap_level;
};

#define MAX_THROT_TABLE_SIZE	(32)

struct balanced_throttle {
	struct tegra_cooling_device tegra_cdev;
	struct thermal_cooling_device *cdev;
	struct list_head node;
	int is_throttling;
	int throttle_index;
	int throt_tab_size;
	struct throttle_table throt_tab[MAX_THROT_TABLE_SIZE];
};

#ifdef CONFIG_TEGRA_THERMAL_THROTTLE
int balanced_throttle_register(struct balanced_throttle *bthrot);
#else
static inline int balanced_throttle_register(struct balanced_throttle *bthrot)
{ return 0; }
#endif

#ifdef CONFIG_TEGRA_THERMAL
int tegra_thermal_init(struct tegra_thermal_bind *thermal_binds,
				struct tegra_skin_data *skin_data,
				struct balanced_throttle *throttle_list,
				int throttle_list_size);
int tegra_thermal_device_register(struct tegra_thermal_device *device);
int tegra_thermal_exit(void);
#else
static inline int tegra_thermal_init(struct tegra_thermal_bind *thermal_binds,
					struct tegra_skin_data *skin_data,
					struct balanced_throttle *throttle_list,
					int throttle_list_size)
{ return 0; }
static inline int tegra_thermal_device_register(struct tegra_thermal_device *device)
{ return 0; }
static inline int tegra_thermal_exit(void)
{ return 0; }
#endif

#endif	/* __MACH_THERMAL_H */