diff options
Diffstat (limited to 'drivers/gpu/nvgpu/pmuif')
-rw-r--r-- | drivers/gpu/nvgpu/pmuif/gpmuif_cmn.h | 121 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/pmuif/gpmuif_pmu.h | 215 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/pmuif/nvgpu_gpmu_cmdif.h | 85 |
3 files changed, 421 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/pmuif/gpmuif_cmn.h b/drivers/gpu/nvgpu/pmuif/gpmuif_cmn.h new file mode 100644 index 00000000..1d200129 --- /dev/null +++ b/drivers/gpu/nvgpu/pmuif/gpmuif_cmn.h | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, 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 | #ifndef _GPMUIFCMN_H_ | ||
14 | #define _GPMUIFCMN_H_ | ||
15 | |||
16 | /* | ||
17 | * Defines the logical queue IDs that must be used when submitting | ||
18 | * commands to the PMU | ||
19 | */ | ||
20 | /* write by sw, read by pmu, protected by sw mutex lock */ | ||
21 | #define PMU_COMMAND_QUEUE_HPQ 0 | ||
22 | /* write by sw, read by pmu, protected by sw mutex lock */ | ||
23 | #define PMU_COMMAND_QUEUE_LPQ 1 | ||
24 | /* read/write by sw/hw, protected by hw pmu mutex, id = 2 */ | ||
25 | #define PMU_COMMAND_QUEUE_BIOS 2 | ||
26 | /* read/write by sw/hw, protected by hw pmu mutex, id = 3 */ | ||
27 | #define PMU_COMMAND_QUEUE_SMI 3 | ||
28 | /* write by pmu, read by sw, accessed by interrupt handler, no lock */ | ||
29 | #define PMU_MESSAGE_QUEUE 4 | ||
30 | #define PMU_QUEUE_COUNT 5 | ||
31 | |||
32 | #define PMU_IS_COMMAND_QUEUE(id) \ | ||
33 | ((id) < PMU_MESSAGE_QUEUE) | ||
34 | |||
35 | #define PMU_IS_SW_COMMAND_QUEUE(id) \ | ||
36 | (((id) == PMU_COMMAND_QUEUE_HPQ) || \ | ||
37 | ((id) == PMU_COMMAND_QUEUE_LPQ)) | ||
38 | |||
39 | #define PMU_IS_MESSAGE_QUEUE(id) \ | ||
40 | ((id) == PMU_MESSAGE_QUEUE) | ||
41 | |||
42 | enum { | ||
43 | OFLAG_READ = 0, | ||
44 | OFLAG_WRITE | ||
45 | }; | ||
46 | |||
47 | #define QUEUE_SET (true) | ||
48 | #define QUEUE_GET (false) | ||
49 | |||
50 | #define QUEUE_ALIGNMENT (4) | ||
51 | |||
52 | /* An enumeration containing all valid logical mutex identifiers */ | ||
53 | enum { | ||
54 | PMU_MUTEX_ID_RSVD1 = 0, | ||
55 | PMU_MUTEX_ID_GPUSER, | ||
56 | PMU_MUTEX_ID_QUEUE_BIOS, | ||
57 | PMU_MUTEX_ID_QUEUE_SMI, | ||
58 | PMU_MUTEX_ID_GPMUTEX, | ||
59 | PMU_MUTEX_ID_I2C, | ||
60 | PMU_MUTEX_ID_RMLOCK, | ||
61 | PMU_MUTEX_ID_MSGBOX, | ||
62 | PMU_MUTEX_ID_FIFO, | ||
63 | PMU_MUTEX_ID_PG, | ||
64 | PMU_MUTEX_ID_GR, | ||
65 | PMU_MUTEX_ID_CLK, | ||
66 | PMU_MUTEX_ID_RSVD6, | ||
67 | PMU_MUTEX_ID_RSVD7, | ||
68 | PMU_MUTEX_ID_RSVD8, | ||
69 | PMU_MUTEX_ID_RSVD9, | ||
70 | PMU_MUTEX_ID_INVALID | ||
71 | }; | ||
72 | |||
73 | #define PMU_MUTEX_ID_IS_VALID(id) \ | ||
74 | ((id) < PMU_MUTEX_ID_INVALID) | ||
75 | |||
76 | #define PMU_INVALID_MUTEX_OWNER_ID (0) | ||
77 | |||
78 | /* | ||
79 | * The PMU's frame-buffer interface block has several slots/indices | ||
80 | * which can be bound to support DMA to various surfaces in memory | ||
81 | */ | ||
82 | enum { | ||
83 | PMU_DMAIDX_UCODE = 0, | ||
84 | PMU_DMAIDX_VIRT = 1, | ||
85 | PMU_DMAIDX_PHYS_VID = 2, | ||
86 | PMU_DMAIDX_PHYS_SYS_COH = 3, | ||
87 | PMU_DMAIDX_PHYS_SYS_NCOH = 4, | ||
88 | PMU_DMAIDX_RSVD = 5, | ||
89 | PMU_DMAIDX_PELPG = 6, | ||
90 | PMU_DMAIDX_END = 7 | ||
91 | }; | ||
92 | |||
93 | /* | ||
94 | * Falcon PMU DMA's minimum size in bytes. | ||
95 | */ | ||
96 | #define PMU_DMA_MIN_READ_SIZE_BYTES 16 | ||
97 | #define PMU_DMA_MIN_WRITE_SIZE_BYTES 4 | ||
98 | |||
99 | #define PMU_FB_COPY_RW_ALIGNMENT \ | ||
100 | ((PMU_DMA_MIN_READ_SIZE_BYTES > PMU_DMA_MIN_WRITE_SIZE_BYTES) ? \ | ||
101 | PMU_DMA_MIN_READ_SIZE_BYTES : PMU_DMA_MIN_WRITE_SIZE_BYTES) | ||
102 | |||
103 | /* | ||
104 | * Macros to make aligned versions of RM_PMU_XXX structures. PMU needs aligned | ||
105 | * data structures to issue DMA read/write operations. | ||
106 | */ | ||
107 | #define NV_PMU_MAKE_ALIGNED_STRUCT(name, size) \ | ||
108 | union name##_aligned { \ | ||
109 | struct name data; \ | ||
110 | u8 pad[ALIGN_UP(sizeof(struct name), \ | ||
111 | (PMU_FB_COPY_RW_ALIGNMENT))]; \ | ||
112 | } | ||
113 | |||
114 | #define NV_PMU_MAKE_ALIGNED_UNION(name, size) \ | ||
115 | union name##_aligned { \ | ||
116 | union name data; \ | ||
117 | u8 pad[ALIGN_UP(sizeof(union name), \ | ||
118 | (PMU_FB_COPY_RW_ALIGNMENT))]; \ | ||
119 | } | ||
120 | |||
121 | #endif /* _GPMUIFCMN_H_*/ | ||
diff --git a/drivers/gpu/nvgpu/pmuif/gpmuif_pmu.h b/drivers/gpu/nvgpu/pmuif/gpmuif_pmu.h new file mode 100644 index 00000000..f9ffb4b1 --- /dev/null +++ b/drivers/gpu/nvgpu/pmuif/gpmuif_pmu.h | |||
@@ -0,0 +1,215 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, 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 | #ifndef _GPMUIFPMU_H_ | ||
14 | #define _GPMUIFPMU_H_ | ||
15 | |||
16 | #include "gk20a/pmu_common.h" | ||
17 | #include "gpmuif_cmn.h" | ||
18 | |||
19 | /* Make sure size of this structure is a multiple of 4 bytes */ | ||
20 | struct pmu_cmdline_args_v0 { | ||
21 | u32 cpu_freq_hz; | ||
22 | u32 falc_trace_size; | ||
23 | u32 falc_trace_dma_base; | ||
24 | u32 falc_trace_dma_idx; | ||
25 | struct pmu_mem_v0 gc6_ctx; | ||
26 | }; | ||
27 | |||
28 | struct pmu_cmdline_args_v1 { | ||
29 | u32 cpu_freq_hz; | ||
30 | u32 falc_trace_size; | ||
31 | u32 falc_trace_dma_base; | ||
32 | u32 falc_trace_dma_idx; | ||
33 | u8 secure_mode; | ||
34 | struct pmu_mem_v1 gc6_ctx; | ||
35 | }; | ||
36 | |||
37 | struct pmu_cmdline_args_v2 { | ||
38 | u32 cpu_freq_hz; | ||
39 | u32 falc_trace_size; | ||
40 | u32 falc_trace_dma_base; | ||
41 | u32 falc_trace_dma_idx; | ||
42 | u8 secure_mode; | ||
43 | u8 raise_priv_sec; | ||
44 | struct pmu_mem_v1 gc6_ctx; | ||
45 | }; | ||
46 | |||
47 | struct pmu_cmdline_args_v3 { | ||
48 | u32 reserved; | ||
49 | u32 cpu_freq_hz; | ||
50 | u32 falc_trace_size; | ||
51 | u32 falc_trace_dma_base; | ||
52 | u32 falc_trace_dma_idx; | ||
53 | u8 secure_mode; | ||
54 | u8 raise_priv_sec; | ||
55 | struct pmu_mem_v1 gc6_ctx; | ||
56 | }; | ||
57 | |||
58 | struct pmu_cmdline_args_v4 { | ||
59 | u32 reserved; | ||
60 | u32 cpu_freq_hz; | ||
61 | u32 falc_trace_size; | ||
62 | struct falc_dma_addr dma_addr; | ||
63 | u32 falc_trace_dma_idx; | ||
64 | u8 secure_mode; | ||
65 | u8 raise_priv_sec; | ||
66 | struct pmu_mem_desc_v0 gc6_ctx; | ||
67 | u8 pad; | ||
68 | }; | ||
69 | |||
70 | struct pmu_cmdline_args_v5 { | ||
71 | u32 cpu_freq_hz; | ||
72 | struct flcn_mem_desc_v0 trace_buf; | ||
73 | u8 secure_mode; | ||
74 | u8 raise_priv_sec; | ||
75 | struct flcn_mem_desc_v0 gc6_ctx; | ||
76 | struct flcn_mem_desc_v0 init_data_dma_info; | ||
77 | u32 dummy; | ||
78 | }; | ||
79 | |||
80 | /* GPU ID */ | ||
81 | #define PMU_SHA1_GID_SIGNATURE 0xA7C66AD2 | ||
82 | #define PMU_SHA1_GID_SIGNATURE_SIZE 4 | ||
83 | |||
84 | #define PMU_SHA1_GID_SIZE 16 | ||
85 | |||
86 | struct pmu_sha1_gid { | ||
87 | bool valid; | ||
88 | u8 gid[PMU_SHA1_GID_SIZE]; | ||
89 | }; | ||
90 | |||
91 | struct pmu_sha1_gid_data { | ||
92 | u8 signature[PMU_SHA1_GID_SIGNATURE_SIZE]; | ||
93 | u8 gid[PMU_SHA1_GID_SIZE]; | ||
94 | }; | ||
95 | |||
96 | /* PMU INIT MSG */ | ||
97 | enum { | ||
98 | PMU_INIT_MSG_TYPE_PMU_INIT = 0, | ||
99 | }; | ||
100 | |||
101 | struct pmu_init_msg_pmu_v0 { | ||
102 | u8 msg_type; | ||
103 | u8 pad; | ||
104 | |||
105 | struct { | ||
106 | u16 size; | ||
107 | u16 offset; | ||
108 | u8 index; | ||
109 | u8 pad; | ||
110 | } queue_info[PMU_QUEUE_COUNT]; | ||
111 | |||
112 | u16 sw_managed_area_offset; | ||
113 | u16 sw_managed_area_size; | ||
114 | }; | ||
115 | |||
116 | struct pmu_init_msg_pmu_v1 { | ||
117 | u8 msg_type; | ||
118 | u8 pad; | ||
119 | u16 os_debug_entry_point; | ||
120 | |||
121 | struct { | ||
122 | u16 size; | ||
123 | u16 offset; | ||
124 | u8 index; | ||
125 | u8 pad; | ||
126 | } queue_info[PMU_QUEUE_COUNT]; | ||
127 | |||
128 | u16 sw_managed_area_offset; | ||
129 | u16 sw_managed_area_size; | ||
130 | }; | ||
131 | struct pmu_init_msg_pmu_v2 { | ||
132 | u8 msg_type; | ||
133 | u8 pad; | ||
134 | u16 os_debug_entry_point; | ||
135 | |||
136 | struct { | ||
137 | u16 size; | ||
138 | u16 offset; | ||
139 | u8 index; | ||
140 | u8 pad; | ||
141 | } queue_info[PMU_QUEUE_COUNT]; | ||
142 | |||
143 | u16 sw_managed_area_offset; | ||
144 | u16 sw_managed_area_size; | ||
145 | u8 dummy[18]; | ||
146 | }; | ||
147 | |||
148 | #define PMU_QUEUE_COUNT_FOR_V4 5 | ||
149 | #define PMU_QUEUE_COUNT_FOR_V3 3 | ||
150 | #define PMU_QUEUE_HPQ_IDX_FOR_V3 0 | ||
151 | #define PMU_QUEUE_LPQ_IDX_FOR_V3 1 | ||
152 | #define PMU_QUEUE_MSG_IDX_FOR_V3 2 | ||
153 | struct pmu_init_msg_pmu_v3 { | ||
154 | u8 msg_type; | ||
155 | u8 queue_index[PMU_QUEUE_COUNT_FOR_V3]; | ||
156 | u16 queue_size[PMU_QUEUE_COUNT_FOR_V3]; | ||
157 | u16 queue_offset; | ||
158 | |||
159 | u16 sw_managed_area_offset; | ||
160 | u16 sw_managed_area_size; | ||
161 | |||
162 | u16 os_debug_entry_point; | ||
163 | |||
164 | u8 dummy[18]; | ||
165 | }; | ||
166 | |||
167 | struct pmu_init_msg_pmu_v4 { | ||
168 | u8 msg_type; | ||
169 | u8 queue_index[PMU_QUEUE_COUNT_FOR_V4]; | ||
170 | u16 queue_size[PMU_QUEUE_COUNT_FOR_V4]; | ||
171 | u16 queue_offset; | ||
172 | |||
173 | u16 sw_managed_area_offset; | ||
174 | u16 sw_managed_area_size; | ||
175 | |||
176 | u16 os_debug_entry_point; | ||
177 | |||
178 | u8 dummy[18]; | ||
179 | }; | ||
180 | |||
181 | union pmu_init_msg_pmu { | ||
182 | struct pmu_init_msg_pmu_v0 v0; | ||
183 | struct pmu_init_msg_pmu_v1 v1; | ||
184 | struct pmu_init_msg_pmu_v2 v2; | ||
185 | struct pmu_init_msg_pmu_v3 v3; | ||
186 | struct pmu_init_msg_pmu_v4 v4; | ||
187 | }; | ||
188 | |||
189 | struct pmu_init_msg { | ||
190 | union { | ||
191 | u8 msg_type; | ||
192 | struct pmu_init_msg_pmu_v1 pmu_init_v1; | ||
193 | struct pmu_init_msg_pmu_v0 pmu_init_v0; | ||
194 | struct pmu_init_msg_pmu_v2 pmu_init_v2; | ||
195 | struct pmu_init_msg_pmu_v3 pmu_init_v3; | ||
196 | struct pmu_init_msg_pmu_v4 pmu_init_v4; | ||
197 | }; | ||
198 | }; | ||
199 | |||
200 | /* robust channel (RC) messages */ | ||
201 | enum { | ||
202 | PMU_RC_MSG_TYPE_UNHANDLED_CMD = 0, | ||
203 | }; | ||
204 | |||
205 | struct pmu_rc_msg_unhandled_cmd { | ||
206 | u8 msg_type; | ||
207 | u8 unit_id; | ||
208 | }; | ||
209 | |||
210 | struct pmu_rc_msg { | ||
211 | u8 msg_type; | ||
212 | struct pmu_rc_msg_unhandled_cmd unhandled_cmd; | ||
213 | }; | ||
214 | |||
215 | #endif /* _GPMUIFPMU_H_*/ | ||
diff --git a/drivers/gpu/nvgpu/pmuif/nvgpu_gpmu_cmdif.h b/drivers/gpu/nvgpu/pmuif/nvgpu_gpmu_cmdif.h new file mode 100644 index 00000000..b21b3981 --- /dev/null +++ b/drivers/gpu/nvgpu/pmuif/nvgpu_gpmu_cmdif.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, 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 | #ifndef _NVGPUGPMUCMDIF_H_ | ||
14 | #define _NVGPUGPMUCMDIF_H_ | ||
15 | |||
16 | #include "gk20a/pmu_api.h" | ||
17 | #include "gk20a/pmu_common.h" | ||
18 | #include "gpmuif_cmn.h" | ||
19 | #include "gpmuif_pmu.h" | ||
20 | #include "gpmuifboardobj.h" | ||
21 | #include "gpmuifclk.h" | ||
22 | #include "gpmuifperf.h" | ||
23 | #include "gpmuifpmgr.h" | ||
24 | #include "gpmuifvolt.h" | ||
25 | #include "gpmuiftherm.h" | ||
26 | |||
27 | struct pmu_cmd { | ||
28 | struct pmu_hdr hdr; | ||
29 | union { | ||
30 | struct pmu_perfmon_cmd perfmon; | ||
31 | struct pmu_pg_cmd pg; | ||
32 | struct pmu_zbc_cmd zbc; | ||
33 | struct pmu_acr_cmd acr; | ||
34 | struct pmu_lrf_tex_ltc_dram_cmd lrf_tex_ltc_dram; | ||
35 | struct nv_pmu_boardobj_cmd boardobj; | ||
36 | struct nv_pmu_perf_cmd perf; | ||
37 | struct nv_pmu_volt_cmd volt; | ||
38 | struct nv_pmu_clk_cmd clk; | ||
39 | struct nv_pmu_pmgr_cmd pmgr; | ||
40 | struct nv_pmu_therm_cmd therm; | ||
41 | } cmd; | ||
42 | }; | ||
43 | |||
44 | struct pmu_msg { | ||
45 | struct pmu_hdr hdr; | ||
46 | union { | ||
47 | struct pmu_init_msg init; | ||
48 | struct pmu_perfmon_msg perfmon; | ||
49 | struct pmu_pg_msg pg; | ||
50 | struct pmu_rc_msg rc; | ||
51 | struct pmu_acr_msg acr; | ||
52 | struct pmu_lrf_tex_ltc_dram_msg lrf_tex_ltc_dram; | ||
53 | struct nv_pmu_boardobj_msg boardobj; | ||
54 | struct nv_pmu_perf_msg perf; | ||
55 | struct nv_pmu_volt_msg volt; | ||
56 | struct nv_pmu_clk_msg clk; | ||
57 | struct nv_pmu_pmgr_msg pmgr; | ||
58 | struct nv_pmu_therm_msg therm; | ||
59 | } msg; | ||
60 | }; | ||
61 | |||
62 | #define PMU_UNIT_REWIND (0x00) | ||
63 | #define PMU_UNIT_PG (0x03) | ||
64 | #define PMU_UNIT_INIT (0x07) | ||
65 | #define PMU_UNIT_ACR (0x0A) | ||
66 | #define PMU_UNIT_PERFMON_T18X (0x11) | ||
67 | #define PMU_UNIT_PERFMON (0x12) | ||
68 | #define PMU_UNIT_PERF (0x13) | ||
69 | #define PMU_UNIT_RC (0x1F) | ||
70 | #define PMU_UNIT_FECS_MEM_OVERRIDE (0x1E) | ||
71 | #define PMU_UNIT_CLK (0x0D) | ||
72 | #define PMU_UNIT_THERM (0x14) | ||
73 | #define PMU_UNIT_PMGR (0x18) | ||
74 | #define PMU_UNIT_VOLT (0x0E) | ||
75 | |||
76 | #define PMU_UNIT_END (0x23) | ||
77 | |||
78 | #define PMU_UNIT_TEST_START (0xFE) | ||
79 | #define PMU_UNIT_END_SIM (0xFF) | ||
80 | #define PMU_UNIT_TEST_END (0xFF) | ||
81 | |||
82 | #define PMU_UNIT_ID_IS_VALID(id) \ | ||
83 | (((id) < PMU_UNIT_END) || ((id) >= PMU_UNIT_TEST_START)) | ||
84 | |||
85 | #endif /* _NVGPUGPMUCMDIF_H_*/ | ||