summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/pmu_api.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/pmu_api.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/pmu_api.h664
1 files changed, 664 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/pmu_api.h b/drivers/gpu/nvgpu/gk20a/pmu_api.h
new file mode 100644
index 00000000..aa10661c
--- /dev/null
+++ b/drivers/gpu/nvgpu/gk20a/pmu_api.h
@@ -0,0 +1,664 @@
1/*
2 * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 */
13
14#ifndef __PMU_API_H__
15#define __PMU_API_H__
16
17#include "pmu_common.h"
18
19/* PMU Command/Message Interfaces for Adaptive Power */
20/* Macro to get Histogram index */
21#define PMU_AP_HISTOGRAM(idx) (idx)
22#define PMU_AP_HISTOGRAM_CONT (4)
23
24/* Total number of histogram bins */
25#define PMU_AP_CFG_HISTOGRAM_BIN_N (16)
26
27/* Mapping between Idle counters and histograms */
28#define PMU_AP_IDLE_MASK_HIST_IDX_0 (2)
29#define PMU_AP_IDLE_MASK_HIST_IDX_1 (3)
30#define PMU_AP_IDLE_MASK_HIST_IDX_2 (5)
31#define PMU_AP_IDLE_MASK_HIST_IDX_3 (6)
32
33
34/* Mapping between AP_CTRLs and Histograms */
35#define PMU_AP_HISTOGRAM_IDX_GRAPHICS (PMU_AP_HISTOGRAM(1))
36
37/* Mapping between AP_CTRLs and Idle counters */
38#define PMU_AP_IDLE_MASK_GRAPHICS (PMU_AP_IDLE_MASK_HIST_IDX_1)
39
40/* Adaptive Power Controls (AP_CTRL) */
41enum {
42 PMU_AP_CTRL_ID_GRAPHICS = 0x0,
43 PMU_AP_CTRL_ID_MAX,
44};
45
46/* AP_CTRL Statistics */
47struct pmu_ap_ctrl_stat {
48 /*
49 * Represents whether AP is active or not
50 */
51 u8 b_active;
52
53 /* Idle filter represented by histogram bin index */
54 u8 idle_filter_x;
55 u8 rsvd[2];
56
57 /* Total predicted power saving cycles. */
58 s32 power_saving_h_cycles;
59
60 /* Counts how many times AP gave us -ve power benefits. */
61 u32 bad_decision_count;
62
63 /*
64 * Number of times ap structure needs to skip AP iterations
65 * KICK_CTRL from kernel updates this parameter.
66 */
67 u32 skip_count;
68 u8 bin[PMU_AP_CFG_HISTOGRAM_BIN_N];
69};
70
71/* Parameters initialized by INITn APCTRL command */
72struct pmu_ap_ctrl_init_params {
73 /* Minimum idle filter value in Us */
74 u32 min_idle_filter_us;
75
76 /*
77 * Minimum Targeted Saving in Us. AP will update idle thresholds only
78 * if power saving achieved by updating idle thresholds is greater than
79 * Minimum targeted saving.
80 */
81 u32 min_target_saving_us;
82
83 /* Minimum targeted residency of power feature in Us */
84 u32 power_break_even_us;
85
86 /*
87 * Maximum number of allowed power feature cycles per sample.
88 *
89 * We are allowing at max "pgPerSampleMax" cycles in one iteration of AP
90 * AKA pgPerSampleMax in original algorithm.
91 */
92 u32 cycles_per_sample_max;
93};
94
95/* AP Commands/Message structures */
96
97/*
98 * Structure for Generic AP Commands
99 */
100struct pmu_ap_cmd_common {
101 u8 cmd_type;
102 u16 cmd_id;
103};
104
105/*
106 * Structure for INIT AP command
107 */
108struct pmu_ap_cmd_init {
109 u8 cmd_type;
110 u16 cmd_id;
111 u8 rsvd;
112 u32 pg_sampling_period_us;
113};
114
115/*
116 * Structure for Enable/Disable ApCtrl Commands
117 */
118struct pmu_ap_cmd_enable_ctrl {
119 u8 cmd_type;
120 u16 cmd_id;
121
122 u8 ctrl_id;
123};
124
125struct pmu_ap_cmd_disable_ctrl {
126 u8 cmd_type;
127 u16 cmd_id;
128
129 u8 ctrl_id;
130};
131
132/*
133 * Structure for INIT command
134 */
135struct pmu_ap_cmd_init_ctrl {
136 u8 cmd_type;
137 u16 cmd_id;
138 u8 ctrl_id;
139 struct pmu_ap_ctrl_init_params params;
140};
141
142struct pmu_ap_cmd_init_and_enable_ctrl {
143 u8 cmd_type;
144 u16 cmd_id;
145 u8 ctrl_id;
146 struct pmu_ap_ctrl_init_params params;
147};
148
149/*
150 * Structure for KICK_CTRL command
151 */
152struct pmu_ap_cmd_kick_ctrl {
153 u8 cmd_type;
154 u16 cmd_id;
155 u8 ctrl_id;
156
157 u32 skip_count;
158};
159
160/*
161 * Structure for PARAM command
162 */
163struct pmu_ap_cmd_param {
164 u8 cmd_type;
165 u16 cmd_id;
166 u8 ctrl_id;
167
168 u32 data;
169};
170
171/*
172 * Defines for AP commands
173 */
174enum {
175 PMU_AP_CMD_ID_INIT = 0x0,
176 PMU_AP_CMD_ID_INIT_AND_ENABLE_CTRL,
177 PMU_AP_CMD_ID_ENABLE_CTRL,
178 PMU_AP_CMD_ID_DISABLE_CTRL,
179 PMU_AP_CMD_ID_KICK_CTRL,
180};
181
182/*
183 * AP Command
184 */
185union pmu_ap_cmd {
186 u8 cmd_type;
187 struct pmu_ap_cmd_common cmn;
188 struct pmu_ap_cmd_init init;
189 struct pmu_ap_cmd_init_and_enable_ctrl init_and_enable_ctrl;
190 struct pmu_ap_cmd_enable_ctrl enable_ctrl;
191 struct pmu_ap_cmd_disable_ctrl disable_ctrl;
192 struct pmu_ap_cmd_kick_ctrl kick_ctrl;
193};
194
195/*
196 * Structure for generic AP Message
197 */
198struct pmu_ap_msg_common {
199 u8 msg_type;
200 u16 msg_id;
201};
202
203/*
204 * Structure for INIT_ACK Message
205 */
206struct pmu_ap_msg_init_ack {
207 u8 msg_type;
208 u16 msg_id;
209 u8 ctrl_id;
210 u32 stats_dmem_offset;
211};
212
213/*
214 * Defines for AP messages
215 */
216enum {
217 PMU_AP_MSG_ID_INIT_ACK = 0x0,
218};
219
220/*
221 * AP Message
222 */
223union pmu_ap_msg {
224 u8 msg_type;
225 struct pmu_ap_msg_common cmn;
226 struct pmu_ap_msg_init_ack init_ack;
227};
228
229/* Default Sampling Period of AELPG */
230#define APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US (1000000)
231
232/* Default values of APCTRL parameters */
233#define APCTRL_MINIMUM_IDLE_FILTER_DEFAULT_US (100)
234#define APCTRL_MINIMUM_TARGET_SAVING_DEFAULT_US (10000)
235#define APCTRL_POWER_BREAKEVEN_DEFAULT_US (2000)
236#define APCTRL_CYCLES_PER_SAMPLE_MAX_DEFAULT (200)
237
238/*
239 * Disable reason for Adaptive Power Controller
240 */
241enum {
242 APCTRL_DISABLE_REASON_RM_UNLOAD,
243 APCTRL_DISABLE_REASON_RMCTRL,
244};
245
246/*
247 * Adaptive Power Controller
248 */
249struct ap_ctrl {
250 u32 stats_dmem_offset;
251 u32 disable_reason_mask;
252 struct pmu_ap_ctrl_stat stat_cache;
253 u8 b_ready;
254};
255
256/*
257 * Adaptive Power structure
258 *
259 * ap structure provides generic infrastructure to make any power feature
260 * adaptive.
261 */
262struct pmu_ap {
263 u32 supported_mask;
264 struct ap_ctrl ap_ctrl[PMU_AP_CTRL_ID_MAX];
265};
266/*---------------------------------------------------------*/
267
268/*perfmon task defines*/
269enum pmu_perfmon_cmd_start_fields {
270 COUNTER_ALLOC
271};
272
273enum {
274 PMU_PERFMON_CMD_ID_START = 0,
275 PMU_PERFMON_CMD_ID_STOP = 1,
276 PMU_PERFMON_CMD_ID_INIT = 2
277};
278
279struct pmu_perfmon_cmd_start_v3 {
280 u8 cmd_type;
281 u8 group_id;
282 u8 state_id;
283 u8 flags;
284 struct pmu_allocation_v3 counter_alloc;
285};
286
287struct pmu_perfmon_cmd_start_v2 {
288 u8 cmd_type;
289 u8 group_id;
290 u8 state_id;
291 u8 flags;
292 struct pmu_allocation_v2 counter_alloc;
293};
294
295struct pmu_perfmon_cmd_start_v1 {
296 u8 cmd_type;
297 u8 group_id;
298 u8 state_id;
299 u8 flags;
300 struct pmu_allocation_v1 counter_alloc;
301};
302
303struct pmu_perfmon_cmd_start_v0 {
304 u8 cmd_type;
305 u8 group_id;
306 u8 state_id;
307 u8 flags;
308 struct pmu_allocation_v0 counter_alloc;
309};
310
311struct pmu_perfmon_cmd_stop {
312 u8 cmd_type;
313};
314
315struct pmu_perfmon_cmd_init_v3 {
316 u8 cmd_type;
317 u8 to_decrease_count;
318 u8 base_counter_id;
319 u32 sample_period_us;
320 struct pmu_allocation_v3 counter_alloc;
321 u8 num_counters;
322 u8 samples_in_moving_avg;
323 u16 sample_buffer;
324};
325
326struct pmu_perfmon_cmd_init_v2 {
327 u8 cmd_type;
328 u8 to_decrease_count;
329 u8 base_counter_id;
330 u32 sample_period_us;
331 struct pmu_allocation_v2 counter_alloc;
332 u8 num_counters;
333 u8 samples_in_moving_avg;
334 u16 sample_buffer;
335};
336
337struct pmu_perfmon_cmd_init_v1 {
338 u8 cmd_type;
339 u8 to_decrease_count;
340 u8 base_counter_id;
341 u32 sample_period_us;
342 struct pmu_allocation_v1 counter_alloc;
343 u8 num_counters;
344 u8 samples_in_moving_avg;
345 u16 sample_buffer;
346};
347
348struct pmu_perfmon_cmd_init_v0 {
349 u8 cmd_type;
350 u8 to_decrease_count;
351 u8 base_counter_id;
352 u32 sample_period_us;
353 struct pmu_allocation_v0 counter_alloc;
354 u8 num_counters;
355 u8 samples_in_moving_avg;
356 u16 sample_buffer;
357};
358
359struct pmu_perfmon_cmd {
360 union {
361 u8 cmd_type;
362 struct pmu_perfmon_cmd_start_v0 start_v0;
363 struct pmu_perfmon_cmd_start_v1 start_v1;
364 struct pmu_perfmon_cmd_start_v2 start_v2;
365 struct pmu_perfmon_cmd_start_v3 start_v3;
366 struct pmu_perfmon_cmd_stop stop;
367 struct pmu_perfmon_cmd_init_v0 init_v0;
368 struct pmu_perfmon_cmd_init_v1 init_v1;
369 struct pmu_perfmon_cmd_init_v2 init_v2;
370 struct pmu_perfmon_cmd_init_v3 init_v3;
371 };
372};
373
374struct pmu_zbc_cmd {
375 u8 cmd_type;
376 u8 pad;
377 u16 entry_mask;
378};
379
380/* PERFMON MSG */
381enum {
382 PMU_PERFMON_MSG_ID_INCREASE_EVENT = 0,
383 PMU_PERFMON_MSG_ID_DECREASE_EVENT = 1,
384 PMU_PERFMON_MSG_ID_INIT_EVENT = 2,
385 PMU_PERFMON_MSG_ID_ACK = 3
386};
387
388struct pmu_perfmon_msg_generic {
389 u8 msg_type;
390 u8 state_id;
391 u8 group_id;
392 u8 data;
393};
394
395struct pmu_perfmon_msg {
396 union {
397 u8 msg_type;
398 struct pmu_perfmon_msg_generic gen;
399 };
400};
401/*---------------------------------------------------------*/
402/*ELPG/PG defines*/
403enum {
404 PMU_PG_ELPG_MSG_INIT_ACK,
405 PMU_PG_ELPG_MSG_DISALLOW_ACK,
406 PMU_PG_ELPG_MSG_ALLOW_ACK,
407 PMU_PG_ELPG_MSG_FREEZE_ACK,
408 PMU_PG_ELPG_MSG_FREEZE_ABORT,
409 PMU_PG_ELPG_MSG_UNFREEZE_ACK,
410};
411
412struct pmu_pg_msg_elpg_msg {
413 u8 msg_type;
414 u8 engine_id;
415 u16 msg;
416};
417
418enum {
419 PMU_PG_STAT_MSG_RESP_DMEM_OFFSET = 0,
420};
421
422struct pmu_pg_msg_stat {
423 u8 msg_type;
424 u8 engine_id;
425 u16 sub_msg_id;
426 u32 data;
427};
428
429enum {
430 PMU_PG_MSG_ENG_BUF_LOADED,
431 PMU_PG_MSG_ENG_BUF_UNLOADED,
432 PMU_PG_MSG_ENG_BUF_FAILED,
433};
434
435struct pmu_pg_msg_eng_buf_stat {
436 u8 msg_type;
437 u8 engine_id;
438 u8 buf_idx;
439 u8 status;
440};
441
442struct pmu_pg_msg {
443 union {
444 u8 msg_type;
445 struct pmu_pg_msg_elpg_msg elpg_msg;
446 struct pmu_pg_msg_stat stat;
447 struct pmu_pg_msg_eng_buf_stat eng_buf_stat;
448 /* TBD: other pg messages */
449 union pmu_ap_msg ap_msg;
450 };
451};
452
453enum {
454 PMU_PG_ELPG_CMD_INIT,
455 PMU_PG_ELPG_CMD_DISALLOW,
456 PMU_PG_ELPG_CMD_ALLOW,
457 PMU_PG_ELPG_CMD_FREEZE,
458 PMU_PG_ELPG_CMD_UNFREEZE,
459};
460
461struct pmu_pg_cmd_elpg_cmd {
462 u8 cmd_type;
463 u8 engine_id;
464 u16 cmd;
465};
466
467struct pmu_pg_cmd_eng_buf_load_v0 {
468 u8 cmd_type;
469 u8 engine_id;
470 u8 buf_idx;
471 u8 pad;
472 u16 buf_size;
473 u32 dma_base;
474 u8 dma_offset;
475 u8 dma_idx;
476};
477
478struct pmu_pg_cmd_eng_buf_load_v1 {
479 u8 cmd_type;
480 u8 engine_id;
481 u8 buf_idx;
482 u8 pad;
483 struct flcn_mem_desc {
484 struct falc_u64 dma_addr;
485 u16 dma_size;
486 u8 dma_idx;
487 } dma_desc;
488};
489
490struct pmu_pg_cmd_eng_buf_load_v2 {
491 u8 cmd_type;
492 u8 engine_id;
493 u8 buf_idx;
494 u8 pad;
495 struct flcn_mem_desc_v0 dma_desc;
496};
497
498enum {
499 PMU_PG_STAT_CMD_ALLOC_DMEM = 0,
500};
501
502#define PMU_PG_PARAM_CMD_GR_INIT_PARAM 0x0
503
504#define PMU_PG_FEATURE_GR_SDIV_SLOWDOWN_ENABLED (1 << 0)
505#define PMU_PG_FEATURE_GR_POWER_GATING_ENABLED (1 << 2)
506
507struct pmu_pg_cmd_gr_init_param {
508 u8 cmd_type;
509 u16 sub_cmd_id;
510 u8 featuremask;
511};
512
513struct pmu_pg_cmd_stat {
514 u8 cmd_type;
515 u8 engine_id;
516 u16 sub_cmd_id;
517 u32 data;
518};
519
520struct pmu_pg_cmd {
521 union {
522 u8 cmd_type;
523 struct pmu_pg_cmd_elpg_cmd elpg_cmd;
524 struct pmu_pg_cmd_eng_buf_load_v0 eng_buf_load_v0;
525 struct pmu_pg_cmd_eng_buf_load_v1 eng_buf_load_v1;
526 struct pmu_pg_cmd_eng_buf_load_v2 eng_buf_load_v2;
527 struct pmu_pg_cmd_stat stat;
528 struct pmu_pg_cmd_gr_init_param gr_init_param;
529 /* TBD: other pg commands */
530 union pmu_ap_cmd ap_cmd;
531 };
532};
533
534/*---------------------------------------------------------*/
535/* ACR Commands/Message structures */
536
537enum {
538 PMU_ACR_CMD_ID_INIT_WPR_REGION = 0x0,
539 PMU_ACR_CMD_ID_BOOTSTRAP_FALCON,
540 PMU_ACR_CMD_ID_RESERVED,
541 PMU_ACR_CMD_ID_BOOTSTRAP_MULTIPLE_FALCONS,
542};
543
544/*
545 * Initializes the WPR region details
546 */
547struct pmu_acr_cmd_init_wpr_details {
548 u8 cmd_type;
549 u32 regionid;
550 u32 wproffset;
551
552};
553
554/*
555 * falcon ID to bootstrap
556 */
557struct pmu_acr_cmd_bootstrap_falcon {
558 u8 cmd_type;
559 u32 flags;
560 u32 falconid;
561};
562
563/*
564 * falcon ID to bootstrap
565 */
566struct pmu_acr_cmd_bootstrap_multiple_falcons {
567 u8 cmd_type;
568 u32 flags;
569 u32 falconidmask;
570 u32 usevamask;
571 struct falc_u64 wprvirtualbase;
572};
573
574#define PMU_ACR_CMD_BOOTSTRAP_FALCON_FLAGS_RESET_NO 1
575#define PMU_ACR_CMD_BOOTSTRAP_FALCON_FLAGS_RESET_YES 0
576
577
578struct pmu_acr_cmd {
579 union {
580 u8 cmd_type;
581 struct pmu_acr_cmd_bootstrap_falcon bootstrap_falcon;
582 struct pmu_acr_cmd_init_wpr_details init_wpr;
583 struct pmu_acr_cmd_bootstrap_multiple_falcons boot_falcons;
584 };
585};
586
587/* acr messages */
588
589/*
590 * returns the WPR region init information
591 */
592#define PMU_ACR_MSG_ID_INIT_WPR_REGION 0
593
594/*
595 * Returns the Bootstrapped falcon ID to RM
596 */
597#define PMU_ACR_MSG_ID_BOOTSTRAP_FALCON 1
598
599/*
600 * Returns the WPR init status
601 */
602#define PMU_ACR_SUCCESS 0
603#define PMU_ACR_ERROR 1
604
605/*
606 * PMU notifies about bootstrap status of falcon
607 */
608struct pmu_acr_msg_bootstrap_falcon {
609 u8 msg_type;
610 union {
611 u32 errorcode;
612 u32 falconid;
613 };
614};
615
616struct pmu_acr_msg {
617 union {
618 u8 msg_type;
619 struct pmu_acr_msg_bootstrap_falcon acrmsg;
620 };
621};
622/*---------------------------------------------------------*/
623/* FECS mem override command*/
624
625#define PMU_LRF_TEX_LTC_DRAM_CMD_ID_EN_DIS 0
626
627/*!
628 * Enable/Disable FECS error feature
629 */
630struct pmu_cmd_lrf_tex_ltc_dram_en_dis {
631 /*Command type must be first*/
632 u8 cmd_type;
633 /*unit bitmask*/
634 u8 en_dis_mask;
635};
636
637struct pmu_lrf_tex_ltc_dram_cmd {
638 union {
639 u8 cmd_type;
640 struct pmu_cmd_lrf_tex_ltc_dram_en_dis en_dis;
641 };
642};
643
644/* FECS mem override messages*/
645#define PMU_LRF_TEX_LTC_DRAM_MSG_ID_EN_DIS 0
646
647struct pmu_msg_lrf_tex_ltc_dram_en_dis {
648 /*!
649 * Must be at start
650 */
651 u8 msg_type;
652 u8 en_fail_mask;
653 u8 dis_fail_mask;
654 u32 pmu_status;
655};
656
657struct pmu_lrf_tex_ltc_dram_msg {
658 union {
659 u8 msg_type;
660 struct pmu_msg_lrf_tex_ltc_dram_en_dis en_dis;
661 };
662};
663
664#endif /*__PMU_API_H__*/