summaryrefslogtreecommitdiff
path: root/include/asm-arm/arch-mxc/pm_api.h
blob: 5e9a1f5435301e11774ce7ac4bb0f47d98fd5ded (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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/*
 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

/*!
 * @defgroup PM_MX27 Dynamic Process Temperature Compensation (DPTC) for i.MX27
 */
/*!
 * @defgroup PM_MX31 Dynamic Process Temperature Compensation (DPTC) & Dynamic Voltage Frequency Scaling (DVFS) Drivers for i.MX31
 */
/*!
 * @defgroup PM_MXC91321 Dynamic Process Temperature Compensation (DPTC) for MXC91321
 */

/*!
 * @file arch-mxc/pm_api.h
 *
 * @brief MXC PM API header file.
 *
 * @ingroup PM_MX27 PM_MX31 PM_MXC91321
 */
#ifndef __ASM_ARCH_MXC_PM_API_H__
#define __ASM_ARCH_MXC_PM_API_H__

#include <linux/ioctl.h>

/*!
 * PM IOCTL Magic Number
 */
#define PM_MAGIC  0xDC

/*!
 * PM IOCTL update PM translation table command.\n
 * This command changes the current DPTC table used by the driver. \n
 * The command receives a string pointer to a new DPTC table, parses
 * it and swiches the table.
 */
#define PM_IOCSTABLE		         _IOW(PM_MAGIC, 0, char*)

/*!
 * PM IOCTL get DPTC table command.\n
 * This command returns DPTC table used by the driver. \n
 * The command receives a string pointer for DPTC table,
 * and dumps the current working table.
 */
#define PM_IOCGTABLE		        _IOR(PM_MAGIC, 1, char*)

/*!
 * DPTC IOCTL enable command.\n
 * This command enables the dptc module.
 */
#define DPTC_IOCTENABLE			_IO(PM_MAGIC, 2)

/*!
 * DPTC IOCTL disable command.\n
 * This command disables the dptc module.
 */
#define DPTC_IOCTDISABLE		 _IO(PM_MAGIC, 3)

/*!
 * DPTC IOCTL enable reference circuit command.\n
 * This command enables the dptc reference circuits.
 */
#define DPTC_IOCSENABLERC			_IOW(PM_MAGIC, 4, unsigned char)

/*!
 * DPTC IOCTL disable reference circuit command.\n
 * This command disables the dptc reference circuits.
 */
#define DPTC_IOCSDISABLERC			_IOW(PM_MAGIC, 5, unsigned char)

/*!
 * DPTC IOCTL get current state command.\n
 * This command returns the current dptc module state (Enabled/Disabled).
 */
#define DPTC_IOCGSTATE         		_IO(PM_MAGIC, 6)

/*!
 * DPTC IOCTL set working point command.\n
 * This command sets working point according to parameter.
 */
#define DPTC_IOCSWP         		_IOW(PM_MAGIC, 7, unsigned int)

/*!
 * DVFS IOCTL enable command.\n
 * This command enables the dvfs module.
 */
#define DVFS_IOCTENABLE			_IO(PM_MAGIC, 8)

/*!
 * DVFS IOCTL disable command.\n
 * This command disables the dvfs module.
 */
#define DVFS_IOCTDISABLE		 _IO(PM_MAGIC, 9)

/*!
 * DVFS IOCTL get current state command.\n
 * This command returns the current dvfs module state (Enabled/Disabled).
 */
#define DVFS_IOCGSTATE         		_IO(PM_MAGIC, 10)

/*!
 * DVFS IOCTL set SW general purpose bits
 */
#define DVFS_IOCSSWGP         		_IOW(PM_MAGIC, 11, unsigned char)

/*!
 * DVFS IOCTL set wait-for-interrupt state
 */
#define DVFS_IOCSWFI         		_IOW(PM_MAGIC, 12, unsigned char)

/*!
 * PM IOCTL get current frequency command.\n
 * This command returns the current frequency in Hz
 */
#define PM_IOCGFREQ         		_IO(PM_MAGIC, 13)

/*!
 * DVFS IOCTL set frequency command.\n
 * This command sets frequency according to parameter. The parameter
 * is the index of required frequency in current table.
 */
#define DVFS_IOCSFREQ         		_IOW(PM_MAGIC, 14, unsigned int)

/*!
 * DVFS IOCTL set mode command.\n
 * This command sets DVFS mode.
 * 0 - HW mode, 1 - SW predictive mode
 */
#define DVFS_IOCSMODE         		_IOW(PM_MAGIC, 15, unsigned int)

#ifdef CONFIG_ARCH_MXC91321
/*!
 * This defines refercence circuits default status
 */
#define DPTC_REF_CIRCUITS_STATUS  0xE

/*!
 * DCVR register structure
 */
typedef struct {
	/*!
	 * Emergency limit threshold
	 */
	unsigned long EmergencyLimit:10;

	/*!
	 * Lower limit threshold
	 */
	unsigned long LowerLimit:11;

	/*!
	 * Upper limit threshold
	 */
	unsigned long UpperLimit:11;
} dcvr_reg_s;
#else
/*!
 * This defines refercence circuits default status
 */
#define DPTC_REF_CIRCUITS_STATUS  0xA

/*!
 * DCVR register structure
 */
typedef struct {
	/*!
	 * Reserved bits
	 */
	unsigned long Reserved:2;

	/*!
	 * Emergency limit threshold
	 */
	unsigned long EmergencyLimit:10;

	/*!
	 * Lower limit threshold
	 */
	unsigned long LowerLimit:10;

	/*!
	 * Upper limit threshold
	 */
	unsigned long UpperLimit:10;
} dcvr_reg_s;
#endif

/*!
 * DCVR register represented as a union between a 32 bit word and a bit field
 */
typedef union {

	/*!
	 * DCVR register as a 32 bit word
	 */
	unsigned int AsInt;

	/*!
	 * DCVR register as a bit field
	 */
	dcvr_reg_s AsStruct;
} dcvr_reg_u;

/*!
 * This struct represents DCVR registers state
 */
typedef struct {
	/*!
	 * dcvr registers values
	 */
	dcvr_reg_u dcvr_reg[4];
} dcvr_state;

/*!
 * This struct defines DPTC working point
 */
typedef struct {
	/*!
	 * Working point index
	 */
	int wp_index;
	/*!
	 * PMIC regulators values
	 */
	unsigned long pmic_values[4];
} dptc_wp;

/*!
 * This struct defines DVFS state
 */
typedef struct {
	/*!
	 * Flag for pll change when frequency should be decreased
	 */
	unsigned long pll_sw_down;
	/*!
	 * pdr0 register decrease value
	 */
	unsigned long pdr0_down;
	/*!
	 * pll register deccrease value
	 */
	unsigned long pll_down;
	/*!
	 * Flag for pll change when frequency should be increased
	 */
	unsigned long pll_sw_up;
	/*!
	 * pdr0 register increase value
	 */
	unsigned long pdr0_up;
	/*!
	 * pll register increase value
	 */
	unsigned long pll_up;
	/*!
	 * vscnt increase value
	 */
	unsigned long vscnt;
} dvfs_state;

/*!
 * This structure holds the dptc translation table.\n
 * This structure is used to translate a working point and frequency index to
 * voltage value and DPTC thresholds.\n
 * This structure is also used in the driver read and write operations.\n
 * During read operation this structure is received from the dptc driver,
 * and during write operation this structure should be sent to the driver.
 */
typedef struct {
	/*!
	 * Number of working points in dptc table
	 */
	int wp_num;

	/*!
	 * This variable holds the current working point
	 */
	int curr_wp;

	/*!
	 * DVFS translation table entries
	 */
	dvfs_state *table;

	/*!
	 * DCVR table
	 */
	dcvr_state **dcvr;

	/*!
	 * DPTC translation table entries
	 */
	dptc_wp *wp;

	/*
	 * Boolean flag. If it is 0 - uses 4 levels of frequency, 1 - uses 2 levels of frequency
	 */
	int use_four_freq;

	/*!
	 * Number of frequencies for each working point
	 */
	int dvfs_state_num;
} dvfs_dptc_tables_s;

/*!
 * DPTC log buffer entry structure
 */
typedef struct {

	/*!
	 * Log entry time in jiffies
	 */
	unsigned long jiffies;

	/*!
	 * Log entry working point value
	 */
	int wp;

	/*!
	 * Log entry voltage index
	 */
	int voltage;

	/*!
	 * Log entry frequency index
	 */
	int freq;
} dptc_log_entry_s;

/*!
 * This defines DVFS HW mode
 */
#define DVFS_HW_MODE   0

/*!
 * This defines DVFS predictive mode
 */
#define DVFS_PRED_MODE 1

#endif