summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/la_priv.h
blob: b16211e34dbca43a9361f0262f0bb907234802cf (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
 * arch/arm/mach-tegra/la_priv.h
 *
 * Copyright (C) 2012-2014, NVIDIA CORPORATION.  All rights reserved.
 *
 * 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_TEGRA_LA_PRIV_H_
#define _MACH_TEGRA_LA_PRIV_H_

#define ENABLE_LA_DEBUG		0

#define la_debug(fmt, ...) \
do { \
	if (ENABLE_LA_DEBUG) { \
		printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__); \
	} \
} while (0)

#define MASK(x) \
	((0xFFFFFFFFUL >> (31 - (1 ? x) + (0 ? x))) << (0 ? x))
#define SHIFT(x) \
	(0 ? x)
#define ID(id) \
	TEGRA_LA_##id

#define VALIDATE_ID(id, p) \
do { \
	if (id >= TEGRA_LA_MAX_ID || (p)->id_to_index[(id)] == 0xFFFF) { \
		WARN_ONCE(1, "%s: invalid Id=%d", __func__, (id)); \
		return -EINVAL; \
	} \
	BUG_ON((p)->la_info_array[(p)->id_to_index[(id)]].id != (id)); \
} while (0)

#define VALIDATE_BW(bw_in_mbps) \
do { \
	if (bw_in_mbps >= 4096) \
		return -EINVAL; \
} while (0)

#define VALIDATE_THRESHOLDS(tl, tm, th) \
do { \
	if ((tl) > 100 || (tm) > 100 || (th) > 100) \
		return -EINVAL; \
} while (0)

#define LAST_DISP_CLIENT_ID	ID(DISPLAYD)
#define NUM_DISP_CLIENTS	(LAST_DISP_CLIENT_ID - FIRST_DISP_CLIENT_ID + 1)
#define DISP_CLIENT_ID(id)	(ID(id) - FIRST_DISP_CLIENT_ID)

#define FIRST_CAMERA_CLIENT_ID	ID(VI_W)
#define LAST_CAMERA_CLIENT_ID	ID(ISP_WBB)
#define NUM_CAMERA_CLIENTS	(LAST_CAMERA_CLIENT_ID - \
				FIRST_CAMERA_CLIENT_ID + \
				1)
#define CAMERA_IDX(id)		(ID(id) - FIRST_CAMERA_CLIENT_ID)
#define CAMERA_LA_IDX(id)	(id - FIRST_CAMERA_CLIENT_ID)
#define AGG_CAMERA_ID(id)	TEGRA_LA_AGG_CAMERA_##id

#define T12X_MC_LA_MAX_VALUE	255


/* The following enum defines IDs for aggregated camera clients. In some cases
   we have to deal with groups of camera clients rather than individual
   clients. */
enum agg_camera_client_id {
	TEGRA_LA_AGG_CAMERA_VE = 0,
	TEGRA_LA_AGG_CAMERA_VE2,
	TEGRA_LA_AGG_CAMERA_ISP,
	TEGRA_LA_AGG_CAMERA_NUM_CLIENTS
};

struct la_client_info {
	unsigned int fifo_size_in_atoms;
	unsigned int expiration_in_ns;	/* worst case expiration value */
	void *reg_addr;
	unsigned long mask;
	unsigned long shift;
	enum tegra_la_id id;
	char *name;
	bool scaling_supported;
	unsigned int init_la;		/* initial la to set for client */
	unsigned int la_set;
	unsigned int la_ref_clk_mhz;
};

struct agg_camera_client_info {
	unsigned int bw_fp;
	unsigned int frac_fp;
	unsigned int ptsa_min;
	unsigned int ptsa_max;
	bool is_hiso;
};

struct la_scaling_info {
	unsigned int threshold_low;
	unsigned int threshold_mid;
	unsigned int threshold_high;
	int scaling_ref_count;
	int actual_la_to_set;
	int la_set;
};

struct la_scaling_reg_info {
	enum tegra_la_id id;
	void *tl_reg_addr;
	unsigned int tl_mask;
	unsigned int tl_shift;
	void *tm_reg_addr;
	unsigned int tm_mask;
	unsigned int tm_shift;
	void *th_reg_addr;
	unsigned int th_mask;
	unsigned int th_shift;
};

struct ptsa_info {
	unsigned int dis_ptsa_rate;
	unsigned int dis_ptsa_min;
	unsigned int dis_ptsa_max;
	unsigned int disb_ptsa_rate;
	unsigned int disb_ptsa_min;
	unsigned int disb_ptsa_max;
	unsigned int ve_ptsa_rate;
	unsigned int ve_ptsa_min;
	unsigned int ve_ptsa_max;
	unsigned int ve2_ptsa_rate;
	unsigned int ve2_ptsa_min;
	unsigned int ve2_ptsa_max;
	unsigned int ring2_ptsa_rate;
	unsigned int ring2_ptsa_min;
	unsigned int ring2_ptsa_max;
	unsigned int bbc_ptsa_rate;
	unsigned int bbc_ptsa_min;
	unsigned int bbc_ptsa_max;
	unsigned int mpcorer_ptsa_rate;
	unsigned int mpcorer_ptsa_min;
	unsigned int mpcorer_ptsa_max;
	unsigned int smmu_ptsa_rate;
	unsigned int smmu_ptsa_min;
	unsigned int smmu_ptsa_max;
	unsigned int ring1_ptsa_rate;
	unsigned int ring1_ptsa_min;
	unsigned int ring1_ptsa_max;

	unsigned int dis_extra_snap_level;
	unsigned int heg_extra_snap_level;
	unsigned int ptsa_grant_dec;
	unsigned int bbcll_earb_cfg;

	unsigned int isp_ptsa_rate;
	unsigned int isp_ptsa_min;
	unsigned int isp_ptsa_max;
	unsigned int a9avppc_ptsa_min;
	unsigned int a9avppc_ptsa_max;
	unsigned int avp_ptsa_min;
	unsigned int avp_ptsa_max;
	unsigned int r0_dis_ptsa_min;
	unsigned int r0_dis_ptsa_max;
	unsigned int r0_disb_ptsa_min;
	unsigned int r0_disb_ptsa_max;
	unsigned int vd_ptsa_min;
	unsigned int vd_ptsa_max;
	unsigned int mse_ptsa_min;
	unsigned int mse_ptsa_max;
	unsigned int gk_ptsa_min;
	unsigned int gk_ptsa_max;
	unsigned int vicpc_ptsa_min;
	unsigned int vicpc_ptsa_max;
	unsigned int apb_ptsa_min;
	unsigned int apb_ptsa_max;
	unsigned int pcx_ptsa_min;
	unsigned int pcx_ptsa_max;
	unsigned int host_ptsa_min;
	unsigned int host_ptsa_max;
	unsigned int ahb_ptsa_min;
	unsigned int ahb_ptsa_max;
	unsigned int sax_ptsa_min;
	unsigned int sax_ptsa_max;
	unsigned int aud_ptsa_min;
	unsigned int aud_ptsa_max;
	unsigned int sd_ptsa_min;
	unsigned int sd_ptsa_max;
	unsigned int usbx_ptsa_min;
	unsigned int usbx_ptsa_max;
	unsigned int usbd_ptsa_min;
	unsigned int usbd_ptsa_max;
	unsigned int ftop_ptsa_min;
	unsigned int ftop_ptsa_max;
};


struct la_chip_specific {
	int ns_per_tick;
	int atom_size;
	int la_max_value;
	spinlock_t lock;
	int la_info_array_size;
	struct la_client_info *la_info_array;
	unsigned short id_to_index[ID(MAX_ID) + 1];
	unsigned int disp_bw_array[NUM_DISP_CLIENTS];
	struct disp_client disp_clients[NUM_DISP_CLIENTS];
	unsigned int bbc_bw_array[ID(BBCLLR) - ID(BBCR) + 1];
	unsigned int camera_bw_array[NUM_CAMERA_CLIENTS];
	struct agg_camera_client_info
			agg_camera_array[TEGRA_LA_AGG_CAMERA_NUM_CLIENTS];
	struct la_scaling_info scaling_info[ID(MAX_ID)];
	int la_scaling_enable_count;
	struct dentry *latency_debug_dir;
	struct ptsa_info ptsa_info;
	bool disable_la;
	bool disable_ptsa;
	struct la_to_dc_params la_params;
	bool disable_disp_ptsa;
	bool disable_bbc_ptsa;

	void (*init_ptsa)(void);
	void (*update_display_ptsa_rate)(unsigned int *disp_bw_array);
	int (*update_camera_ptsa_rate)(enum tegra_la_id id,
					unsigned int bw_mbps,
					int is_hiso);
	int (*set_disp_la)(enum tegra_la_id id,
				unsigned long emc_freq_hz,
				unsigned int bw_mbps,
				struct dc_to_la_params disp_params);
	int (*set_la)(enum tegra_la_id id, unsigned int bw_mbps);
	int (*enable_la_scaling)(enum tegra_la_id id,
				unsigned int threshold_low,
				unsigned int threshold_mid,
				unsigned int threshold_high);
	void (*disable_la_scaling)(enum tegra_la_id id);
	int (*suspend)(void);
	void (*resume)(void);
};

void tegra_la_get_t3_specific(struct la_chip_specific *cs);
void tegra_la_get_t14x_specific(struct la_chip_specific *cs);
void tegra_la_get_t11x_specific(struct la_chip_specific *cs);
void tegra_la_get_t12x_specific(struct la_chip_specific *cs);

#endif /* _MACH_TEGRA_LA_PRIV_H_ */