xref: /dflybsd-src/sys/dev/drm/amd/include/cgs_common.h (revision d78d3a2272f5ecf9e0b570e362128240417a1b85)
1c59a5c48SFrançois Tigeot /*
2c59a5c48SFrançois Tigeot  * Copyright 2015 Advanced Micro Devices, Inc.
3c59a5c48SFrançois Tigeot  *
4c59a5c48SFrançois Tigeot  * Permission is hereby granted, free of charge, to any person obtaining a
5c59a5c48SFrançois Tigeot  * copy of this software and associated documentation files (the "Software"),
6c59a5c48SFrançois Tigeot  * to deal in the Software without restriction, including without limitation
7c59a5c48SFrançois Tigeot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8c59a5c48SFrançois Tigeot  * and/or sell copies of the Software, and to permit persons to whom the
9c59a5c48SFrançois Tigeot  * Software is furnished to do so, subject to the following conditions:
10c59a5c48SFrançois Tigeot  *
11c59a5c48SFrançois Tigeot  * The above copyright notice and this permission notice shall be included in
12c59a5c48SFrançois Tigeot  * all copies or substantial portions of the Software.
13c59a5c48SFrançois Tigeot  *
14c59a5c48SFrançois Tigeot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c59a5c48SFrançois Tigeot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c59a5c48SFrançois Tigeot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17c59a5c48SFrançois Tigeot  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18c59a5c48SFrançois Tigeot  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19c59a5c48SFrançois Tigeot  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20c59a5c48SFrançois Tigeot  * OTHER DEALINGS IN THE SOFTWARE.
21c59a5c48SFrançois Tigeot  *
22c59a5c48SFrançois Tigeot  *
23c59a5c48SFrançois Tigeot  */
24c59a5c48SFrançois Tigeot #ifndef _CGS_COMMON_H
25c59a5c48SFrançois Tigeot #define _CGS_COMMON_H
26c59a5c48SFrançois Tigeot 
27c59a5c48SFrançois Tigeot #include "amd_shared.h"
28c59a5c48SFrançois Tigeot 
29*d78d3a22SFrançois Tigeot struct cgs_device;
30*d78d3a22SFrançois Tigeot 
31c59a5c48SFrançois Tigeot /**
32c59a5c48SFrançois Tigeot  * enum cgs_gpu_mem_type - GPU memory types
33c59a5c48SFrançois Tigeot  */
34c59a5c48SFrançois Tigeot enum cgs_gpu_mem_type {
35c59a5c48SFrançois Tigeot 	CGS_GPU_MEM_TYPE__VISIBLE_FB,
36c59a5c48SFrançois Tigeot 	CGS_GPU_MEM_TYPE__INVISIBLE_FB,
37c59a5c48SFrançois Tigeot 	CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB,
38c59a5c48SFrançois Tigeot 	CGS_GPU_MEM_TYPE__INVISIBLE_CONTIG_FB,
39c59a5c48SFrançois Tigeot 	CGS_GPU_MEM_TYPE__GART_CACHEABLE,
40c59a5c48SFrançois Tigeot 	CGS_GPU_MEM_TYPE__GART_WRITECOMBINE
41c59a5c48SFrançois Tigeot };
42c59a5c48SFrançois Tigeot 
43c59a5c48SFrançois Tigeot /**
44c59a5c48SFrançois Tigeot  * enum cgs_ind_reg - Indirect register spaces
45c59a5c48SFrançois Tigeot  */
46c59a5c48SFrançois Tigeot enum cgs_ind_reg {
47c59a5c48SFrançois Tigeot 	CGS_IND_REG__MMIO,
48c59a5c48SFrançois Tigeot 	CGS_IND_REG__PCIE,
49c59a5c48SFrançois Tigeot 	CGS_IND_REG__SMC,
50c59a5c48SFrançois Tigeot 	CGS_IND_REG__UVD_CTX,
51c59a5c48SFrançois Tigeot 	CGS_IND_REG__DIDT,
52c59a5c48SFrançois Tigeot 	CGS_IND_REG__AUDIO_ENDPT
53c59a5c48SFrançois Tigeot };
54c59a5c48SFrançois Tigeot 
55c59a5c48SFrançois Tigeot /**
56c59a5c48SFrançois Tigeot  * enum cgs_clock - Clocks controlled by the SMU
57c59a5c48SFrançois Tigeot  */
58c59a5c48SFrançois Tigeot enum cgs_clock {
59c59a5c48SFrançois Tigeot 	CGS_CLOCK__SCLK,
60c59a5c48SFrançois Tigeot 	CGS_CLOCK__MCLK,
61c59a5c48SFrançois Tigeot 	CGS_CLOCK__VCLK,
62c59a5c48SFrançois Tigeot 	CGS_CLOCK__DCLK,
63c59a5c48SFrançois Tigeot 	CGS_CLOCK__ECLK,
64c59a5c48SFrançois Tigeot 	CGS_CLOCK__ACLK,
65c59a5c48SFrançois Tigeot 	CGS_CLOCK__ICLK,
66c59a5c48SFrançois Tigeot 	/* ... */
67c59a5c48SFrançois Tigeot };
68c59a5c48SFrançois Tigeot 
69c59a5c48SFrançois Tigeot /**
70c59a5c48SFrançois Tigeot  * enum cgs_engine - Engines that can be statically power-gated
71c59a5c48SFrançois Tigeot  */
72c59a5c48SFrançois Tigeot enum cgs_engine {
73c59a5c48SFrançois Tigeot 	CGS_ENGINE__UVD,
74c59a5c48SFrançois Tigeot 	CGS_ENGINE__VCE,
75c59a5c48SFrançois Tigeot 	CGS_ENGINE__VP8,
76c59a5c48SFrançois Tigeot 	CGS_ENGINE__ACP_DMA,
77c59a5c48SFrançois Tigeot 	CGS_ENGINE__ACP_DSP0,
78c59a5c48SFrançois Tigeot 	CGS_ENGINE__ACP_DSP1,
79c59a5c48SFrançois Tigeot 	CGS_ENGINE__ISP,
80c59a5c48SFrançois Tigeot 	/* ... */
81c59a5c48SFrançois Tigeot };
82c59a5c48SFrançois Tigeot 
83c59a5c48SFrançois Tigeot /**
84c59a5c48SFrançois Tigeot  * enum cgs_voltage_planes - Voltage planes for external camera HW
85c59a5c48SFrançois Tigeot  */
86c59a5c48SFrançois Tigeot enum cgs_voltage_planes {
87c59a5c48SFrançois Tigeot 	CGS_VOLTAGE_PLANE__SENSOR0,
88c59a5c48SFrançois Tigeot 	CGS_VOLTAGE_PLANE__SENSOR1,
89c59a5c48SFrançois Tigeot 	/* ... */
90c59a5c48SFrançois Tigeot };
91c59a5c48SFrançois Tigeot 
92c59a5c48SFrançois Tigeot /*
93c59a5c48SFrançois Tigeot  * enum cgs_ucode_id - Firmware types for different IPs
94c59a5c48SFrançois Tigeot  */
95c59a5c48SFrançois Tigeot enum cgs_ucode_id {
96c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_SMU = 0,
97*d78d3a22SFrançois Tigeot 	CGS_UCODE_ID_SMU_SK,
98c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_SDMA0,
99c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_SDMA1,
100c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_CP_CE,
101c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_CP_PFP,
102c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_CP_ME,
103c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_CP_MEC,
104c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_CP_MEC_JT1,
105c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_CP_MEC_JT2,
106c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_GMCON_RENG,
107c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_RLC_G,
108c59a5c48SFrançois Tigeot 	CGS_UCODE_ID_MAXIMUM,
109c59a5c48SFrançois Tigeot };
110c59a5c48SFrançois Tigeot 
111*d78d3a22SFrançois Tigeot enum cgs_system_info_id {
112*d78d3a22SFrançois Tigeot 	CGS_SYSTEM_INFO_ADAPTER_BDF_ID = 1,
113*d78d3a22SFrançois Tigeot 	CGS_SYSTEM_INFO_PCIE_GEN_INFO,
114*d78d3a22SFrançois Tigeot 	CGS_SYSTEM_INFO_PCIE_MLW,
115*d78d3a22SFrançois Tigeot 	CGS_SYSTEM_INFO_CG_FLAGS,
116*d78d3a22SFrançois Tigeot 	CGS_SYSTEM_INFO_PG_FLAGS,
117*d78d3a22SFrançois Tigeot 	CGS_SYSTEM_INFO_GFX_CU_INFO,
118*d78d3a22SFrançois Tigeot 	CGS_SYSTEM_INFO_ID_MAXIMUM,
119*d78d3a22SFrançois Tigeot };
120*d78d3a22SFrançois Tigeot 
121*d78d3a22SFrançois Tigeot struct cgs_system_info {
122*d78d3a22SFrançois Tigeot 	uint64_t       size;
123*d78d3a22SFrançois Tigeot 	uint64_t       info_id;
124*d78d3a22SFrançois Tigeot 	union {
125*d78d3a22SFrançois Tigeot 		void           *ptr;
126*d78d3a22SFrançois Tigeot 		uint64_t        value;
127*d78d3a22SFrançois Tigeot 	};
128*d78d3a22SFrançois Tigeot 	uint64_t               padding[13];
129*d78d3a22SFrançois Tigeot };
130*d78d3a22SFrançois Tigeot 
131*d78d3a22SFrançois Tigeot /*
132*d78d3a22SFrançois Tigeot  * enum cgs_resource_type - GPU resource type
133*d78d3a22SFrançois Tigeot  */
134*d78d3a22SFrançois Tigeot enum cgs_resource_type {
135*d78d3a22SFrançois Tigeot 	CGS_RESOURCE_TYPE_MMIO = 0,
136*d78d3a22SFrançois Tigeot 	CGS_RESOURCE_TYPE_FB,
137*d78d3a22SFrançois Tigeot 	CGS_RESOURCE_TYPE_IO,
138*d78d3a22SFrançois Tigeot 	CGS_RESOURCE_TYPE_DOORBELL,
139*d78d3a22SFrançois Tigeot 	CGS_RESOURCE_TYPE_ROM,
140*d78d3a22SFrançois Tigeot };
141*d78d3a22SFrançois Tigeot 
142c59a5c48SFrançois Tigeot /**
143c59a5c48SFrançois Tigeot  * struct cgs_clock_limits - Clock limits
144c59a5c48SFrançois Tigeot  *
145c59a5c48SFrançois Tigeot  * Clocks are specified in 10KHz units.
146c59a5c48SFrançois Tigeot  */
147c59a5c48SFrançois Tigeot struct cgs_clock_limits {
148c59a5c48SFrançois Tigeot 	unsigned min;		/**< Minimum supported frequency */
149c59a5c48SFrançois Tigeot 	unsigned max;		/**< Maxumim supported frequency */
150c59a5c48SFrançois Tigeot 	unsigned sustainable;	/**< Thermally sustainable frequency */
151c59a5c48SFrançois Tigeot };
152c59a5c48SFrançois Tigeot 
153c59a5c48SFrançois Tigeot /**
154c59a5c48SFrançois Tigeot  * struct cgs_firmware_info - Firmware information
155c59a5c48SFrançois Tigeot  */
156c59a5c48SFrançois Tigeot struct cgs_firmware_info {
157c59a5c48SFrançois Tigeot 	uint16_t		version;
158c59a5c48SFrançois Tigeot 	uint16_t		feature_version;
159c59a5c48SFrançois Tigeot 	uint32_t		image_size;
160c59a5c48SFrançois Tigeot 	uint64_t		mc_addr;
161c59a5c48SFrançois Tigeot 	void			*kptr;
162c59a5c48SFrançois Tigeot };
163c59a5c48SFrançois Tigeot 
164*d78d3a22SFrançois Tigeot struct cgs_mode_info {
165*d78d3a22SFrançois Tigeot 	uint32_t		refresh_rate;
166*d78d3a22SFrançois Tigeot 	uint32_t		ref_clock;
167*d78d3a22SFrançois Tigeot 	uint32_t		vblank_time_us;
168*d78d3a22SFrançois Tigeot };
169*d78d3a22SFrançois Tigeot 
170*d78d3a22SFrançois Tigeot struct cgs_display_info {
171*d78d3a22SFrançois Tigeot 	uint32_t		display_count;
172*d78d3a22SFrançois Tigeot 	uint32_t		active_display_mask;
173*d78d3a22SFrançois Tigeot 	struct cgs_mode_info *mode_info;
174*d78d3a22SFrançois Tigeot };
175*d78d3a22SFrançois Tigeot 
176c59a5c48SFrançois Tigeot typedef unsigned long cgs_handle_t;
177c59a5c48SFrançois Tigeot 
178*d78d3a22SFrançois Tigeot #define CGS_ACPI_METHOD_ATCS          0x53435441
179*d78d3a22SFrançois Tigeot #define CGS_ACPI_METHOD_ATIF          0x46495441
180*d78d3a22SFrançois Tigeot #define CGS_ACPI_METHOD_ATPX          0x58505441
181*d78d3a22SFrançois Tigeot #define CGS_ACPI_FIELD_METHOD_NAME                      0x00000001
182*d78d3a22SFrançois Tigeot #define CGS_ACPI_FIELD_INPUT_ARGUMENT_COUNT             0x00000002
183*d78d3a22SFrançois Tigeot #define CGS_ACPI_MAX_BUFFER_SIZE     256
184*d78d3a22SFrançois Tigeot #define CGS_ACPI_TYPE_ANY                      0x00
185*d78d3a22SFrançois Tigeot #define CGS_ACPI_TYPE_INTEGER               0x01
186*d78d3a22SFrançois Tigeot #define CGS_ACPI_TYPE_STRING                0x02
187*d78d3a22SFrançois Tigeot #define CGS_ACPI_TYPE_BUFFER                0x03
188*d78d3a22SFrançois Tigeot #define CGS_ACPI_TYPE_PACKAGE               0x04
189*d78d3a22SFrançois Tigeot 
190*d78d3a22SFrançois Tigeot struct cgs_acpi_method_argument {
191*d78d3a22SFrançois Tigeot 	uint32_t type;
192*d78d3a22SFrançois Tigeot 	uint32_t method_length;
193*d78d3a22SFrançois Tigeot 	uint32_t data_length;
194*d78d3a22SFrançois Tigeot 	union{
195*d78d3a22SFrançois Tigeot 		uint32_t value;
196*d78d3a22SFrançois Tigeot 		void *pointer;
197*d78d3a22SFrançois Tigeot 	};
198*d78d3a22SFrançois Tigeot };
199*d78d3a22SFrançois Tigeot 
200*d78d3a22SFrançois Tigeot struct cgs_acpi_method_info {
201*d78d3a22SFrançois Tigeot 	uint32_t size;
202*d78d3a22SFrançois Tigeot 	uint32_t field;
203*d78d3a22SFrançois Tigeot 	uint32_t input_count;
204*d78d3a22SFrançois Tigeot 	uint32_t name;
205*d78d3a22SFrançois Tigeot 	struct cgs_acpi_method_argument *pinput_argument;
206*d78d3a22SFrançois Tigeot 	uint32_t output_count;
207*d78d3a22SFrançois Tigeot 	struct cgs_acpi_method_argument *poutput_argument;
208*d78d3a22SFrançois Tigeot 	uint32_t padding[9];
209*d78d3a22SFrançois Tigeot };
210*d78d3a22SFrançois Tigeot 
211c59a5c48SFrançois Tigeot /**
212c59a5c48SFrançois Tigeot  * cgs_gpu_mem_info() - Return information about memory heaps
213c59a5c48SFrançois Tigeot  * @cgs_device: opaque device handle
214c59a5c48SFrançois Tigeot  * @type:	memory type
215c59a5c48SFrançois Tigeot  * @mc_start:	Start MC address of the heap (output)
216c59a5c48SFrançois Tigeot  * @mc_size:	MC address space size (output)
217c59a5c48SFrançois Tigeot  * @mem_size:	maximum amount of memory available for allocation (output)
218c59a5c48SFrançois Tigeot  *
219c59a5c48SFrançois Tigeot  * This function returns information about memory heaps. The type
220c59a5c48SFrançois Tigeot  * parameter is used to select the memory heap. The mc_start and
221c59a5c48SFrançois Tigeot  * mc_size for GART heaps may be bigger than the memory available for
222c59a5c48SFrançois Tigeot  * allocation.
223c59a5c48SFrançois Tigeot  *
224c59a5c48SFrançois Tigeot  * mc_start and mc_size are undefined for non-contiguous FB memory
225c59a5c48SFrançois Tigeot  * types, since buffers allocated with these types may or may not be
226c59a5c48SFrançois Tigeot  * GART mapped.
227c59a5c48SFrançois Tigeot  *
228c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
229c59a5c48SFrançois Tigeot  */
230*d78d3a22SFrançois Tigeot typedef int (*cgs_gpu_mem_info_t)(struct cgs_device *cgs_device, enum cgs_gpu_mem_type type,
231c59a5c48SFrançois Tigeot 				  uint64_t *mc_start, uint64_t *mc_size,
232c59a5c48SFrançois Tigeot 				  uint64_t *mem_size);
233c59a5c48SFrançois Tigeot 
234c59a5c48SFrançois Tigeot /**
235c59a5c48SFrançois Tigeot  * cgs_gmap_kmem() - map kernel memory to GART aperture
236c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
237c59a5c48SFrançois Tigeot  * @kmem:	pointer to kernel memory
238c59a5c48SFrançois Tigeot  * @size:	size to map
239c59a5c48SFrançois Tigeot  * @min_offset: minimum offset from start of GART aperture
240c59a5c48SFrançois Tigeot  * @max_offset: maximum offset from start of GART aperture
241c59a5c48SFrançois Tigeot  * @kmem_handle: kernel memory handle (output)
242c59a5c48SFrançois Tigeot  * @mcaddr:	MC address (output)
243c59a5c48SFrançois Tigeot  *
244c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
245c59a5c48SFrançois Tigeot  */
246*d78d3a22SFrançois Tigeot typedef int (*cgs_gmap_kmem_t)(struct cgs_device *cgs_device, void *kmem, uint64_t size,
247c59a5c48SFrançois Tigeot 			       uint64_t min_offset, uint64_t max_offset,
248c59a5c48SFrançois Tigeot 			       cgs_handle_t *kmem_handle, uint64_t *mcaddr);
249c59a5c48SFrançois Tigeot 
250c59a5c48SFrançois Tigeot /**
251c59a5c48SFrançois Tigeot  * cgs_gunmap_kmem() - unmap kernel memory
252c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
253c59a5c48SFrançois Tigeot  * @kmem_handle: kernel memory handle returned by gmap_kmem
254c59a5c48SFrançois Tigeot  *
255c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
256c59a5c48SFrançois Tigeot  */
257*d78d3a22SFrançois Tigeot typedef int (*cgs_gunmap_kmem_t)(struct cgs_device *cgs_device, cgs_handle_t kmem_handle);
258c59a5c48SFrançois Tigeot 
259c59a5c48SFrançois Tigeot /**
260c59a5c48SFrançois Tigeot  * cgs_alloc_gpu_mem() - Allocate GPU memory
261c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
262c59a5c48SFrançois Tigeot  * @type:	memory type
263c59a5c48SFrançois Tigeot  * @size:	size in bytes
264c59a5c48SFrançois Tigeot  * @align:	alignment in bytes
265c59a5c48SFrançois Tigeot  * @min_offset: minimum offset from start of heap
266c59a5c48SFrançois Tigeot  * @max_offset: maximum offset from start of heap
267c59a5c48SFrançois Tigeot  * @handle:	memory handle (output)
268c59a5c48SFrançois Tigeot  *
269c59a5c48SFrançois Tigeot  * The memory types CGS_GPU_MEM_TYPE_*_CONTIG_FB force contiguous
270c59a5c48SFrançois Tigeot  * memory allocation. This guarantees that the MC address returned by
271c59a5c48SFrançois Tigeot  * cgs_gmap_gpu_mem is not mapped through the GART. The non-contiguous
272c59a5c48SFrançois Tigeot  * FB memory types may be GART mapped depending on memory
273c59a5c48SFrançois Tigeot  * fragmentation and memory allocator policies.
274c59a5c48SFrançois Tigeot  *
275c59a5c48SFrançois Tigeot  * If min/max_offset are non-0, the allocation will be forced to
276c59a5c48SFrançois Tigeot  * reside between these offsets in its respective memory heap. The
277c59a5c48SFrançois Tigeot  * base address that the offset relates to, depends on the memory
278c59a5c48SFrançois Tigeot  * type.
279c59a5c48SFrançois Tigeot  *
280c59a5c48SFrançois Tigeot  * - CGS_GPU_MEM_TYPE__*_CONTIG_FB: FB MC base address
281c59a5c48SFrançois Tigeot  * - CGS_GPU_MEM_TYPE__GART_*:	    GART aperture base address
282c59a5c48SFrançois Tigeot  * - others:			    undefined, don't use with max_offset
283c59a5c48SFrançois Tigeot  *
284c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
285c59a5c48SFrançois Tigeot  */
286*d78d3a22SFrançois Tigeot typedef int (*cgs_alloc_gpu_mem_t)(struct cgs_device *cgs_device, enum cgs_gpu_mem_type type,
287c59a5c48SFrançois Tigeot 				   uint64_t size, uint64_t align,
288c59a5c48SFrançois Tigeot 				   uint64_t min_offset, uint64_t max_offset,
289c59a5c48SFrançois Tigeot 				   cgs_handle_t *handle);
290c59a5c48SFrançois Tigeot 
291c59a5c48SFrançois Tigeot /**
292c59a5c48SFrançois Tigeot  * cgs_free_gpu_mem() - Free GPU memory
293c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
294c59a5c48SFrançois Tigeot  * @handle:	memory handle returned by alloc or import
295c59a5c48SFrançois Tigeot  *
296c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
297c59a5c48SFrançois Tigeot  */
298*d78d3a22SFrançois Tigeot typedef int (*cgs_free_gpu_mem_t)(struct cgs_device *cgs_device, cgs_handle_t handle);
299c59a5c48SFrançois Tigeot 
300c59a5c48SFrançois Tigeot /**
301c59a5c48SFrançois Tigeot  * cgs_gmap_gpu_mem() - GPU-map GPU memory
302c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
303c59a5c48SFrançois Tigeot  * @handle:	memory handle returned by alloc or import
304c59a5c48SFrançois Tigeot  * @mcaddr:	MC address (output)
305c59a5c48SFrançois Tigeot  *
306c59a5c48SFrançois Tigeot  * Ensures that a buffer is GPU accessible and returns its MC address.
307c59a5c48SFrançois Tigeot  *
308c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
309c59a5c48SFrançois Tigeot  */
310*d78d3a22SFrançois Tigeot typedef int (*cgs_gmap_gpu_mem_t)(struct cgs_device *cgs_device, cgs_handle_t handle,
311c59a5c48SFrançois Tigeot 				  uint64_t *mcaddr);
312c59a5c48SFrançois Tigeot 
313c59a5c48SFrançois Tigeot /**
314c59a5c48SFrançois Tigeot  * cgs_gunmap_gpu_mem() - GPU-unmap GPU memory
315c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
316c59a5c48SFrançois Tigeot  * @handle:	memory handle returned by alloc or import
317c59a5c48SFrançois Tigeot  *
318c59a5c48SFrançois Tigeot  * Allows the buffer to be migrated while it's not used by the GPU.
319c59a5c48SFrançois Tigeot  *
320c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
321c59a5c48SFrançois Tigeot  */
322*d78d3a22SFrançois Tigeot typedef int (*cgs_gunmap_gpu_mem_t)(struct cgs_device *cgs_device, cgs_handle_t handle);
323c59a5c48SFrançois Tigeot 
324c59a5c48SFrançois Tigeot /**
325c59a5c48SFrançois Tigeot  * cgs_kmap_gpu_mem() - Kernel-map GPU memory
326c59a5c48SFrançois Tigeot  *
327c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
328c59a5c48SFrançois Tigeot  * @handle:	memory handle returned by alloc or import
329c59a5c48SFrançois Tigeot  * @map:	Kernel virtual address the memory was mapped to (output)
330c59a5c48SFrançois Tigeot  *
331c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
332c59a5c48SFrançois Tigeot  */
333*d78d3a22SFrançois Tigeot typedef int (*cgs_kmap_gpu_mem_t)(struct cgs_device *cgs_device, cgs_handle_t handle,
334c59a5c48SFrançois Tigeot 				  void **map);
335c59a5c48SFrançois Tigeot 
336c59a5c48SFrançois Tigeot /**
337c59a5c48SFrançois Tigeot  * cgs_kunmap_gpu_mem() - Kernel-unmap GPU memory
338c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
339c59a5c48SFrançois Tigeot  * @handle:	memory handle returned by alloc or import
340c59a5c48SFrançois Tigeot  *
341c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
342c59a5c48SFrançois Tigeot  */
343*d78d3a22SFrançois Tigeot typedef int (*cgs_kunmap_gpu_mem_t)(struct cgs_device *cgs_device, cgs_handle_t handle);
344c59a5c48SFrançois Tigeot 
345c59a5c48SFrançois Tigeot /**
346c59a5c48SFrançois Tigeot  * cgs_read_register() - Read an MMIO register
347c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
348c59a5c48SFrançois Tigeot  * @offset:	register offset
349c59a5c48SFrançois Tigeot  *
350c59a5c48SFrançois Tigeot  * Return:  register value
351c59a5c48SFrançois Tigeot  */
352*d78d3a22SFrançois Tigeot typedef uint32_t (*cgs_read_register_t)(struct cgs_device *cgs_device, unsigned offset);
353c59a5c48SFrançois Tigeot 
354c59a5c48SFrançois Tigeot /**
355c59a5c48SFrançois Tigeot  * cgs_write_register() - Write an MMIO register
356c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
357c59a5c48SFrançois Tigeot  * @offset:	register offset
358c59a5c48SFrançois Tigeot  * @value:	register value
359c59a5c48SFrançois Tigeot  */
360*d78d3a22SFrançois Tigeot typedef void (*cgs_write_register_t)(struct cgs_device *cgs_device, unsigned offset,
361c59a5c48SFrançois Tigeot 				     uint32_t value);
362c59a5c48SFrançois Tigeot 
363c59a5c48SFrançois Tigeot /**
364c59a5c48SFrançois Tigeot  * cgs_read_ind_register() - Read an indirect register
365c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
366c59a5c48SFrançois Tigeot  * @offset:	register offset
367c59a5c48SFrançois Tigeot  *
368c59a5c48SFrançois Tigeot  * Return:  register value
369c59a5c48SFrançois Tigeot  */
370*d78d3a22SFrançois Tigeot typedef uint32_t (*cgs_read_ind_register_t)(struct cgs_device *cgs_device, enum cgs_ind_reg space,
371c59a5c48SFrançois Tigeot 					    unsigned index);
372c59a5c48SFrançois Tigeot 
373c59a5c48SFrançois Tigeot /**
374c59a5c48SFrançois Tigeot  * cgs_write_ind_register() - Write an indirect register
375c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
376c59a5c48SFrançois Tigeot  * @offset:	register offset
377c59a5c48SFrançois Tigeot  * @value:	register value
378c59a5c48SFrançois Tigeot  */
379*d78d3a22SFrançois Tigeot typedef void (*cgs_write_ind_register_t)(struct cgs_device *cgs_device, enum cgs_ind_reg space,
380c59a5c48SFrançois Tigeot 					 unsigned index, uint32_t value);
381c59a5c48SFrançois Tigeot 
382c59a5c48SFrançois Tigeot /**
383c59a5c48SFrançois Tigeot  * cgs_read_pci_config_byte() - Read byte from PCI configuration space
384c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
385c59a5c48SFrançois Tigeot  * @addr:	address
386c59a5c48SFrançois Tigeot  *
387c59a5c48SFrançois Tigeot  * Return:  Value read
388c59a5c48SFrançois Tigeot  */
389*d78d3a22SFrançois Tigeot typedef uint8_t (*cgs_read_pci_config_byte_t)(struct cgs_device *cgs_device, unsigned addr);
390c59a5c48SFrançois Tigeot 
391c59a5c48SFrançois Tigeot /**
392c59a5c48SFrançois Tigeot  * cgs_read_pci_config_word() - Read word from PCI configuration space
393c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
394c59a5c48SFrançois Tigeot  * @addr:	address, must be word-aligned
395c59a5c48SFrançois Tigeot  *
396c59a5c48SFrançois Tigeot  * Return:  Value read
397c59a5c48SFrançois Tigeot  */
398*d78d3a22SFrançois Tigeot typedef uint16_t (*cgs_read_pci_config_word_t)(struct cgs_device *cgs_device, unsigned addr);
399c59a5c48SFrançois Tigeot 
400c59a5c48SFrançois Tigeot /**
401c59a5c48SFrançois Tigeot  * cgs_read_pci_config_dword() - Read dword from PCI configuration space
402c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
403c59a5c48SFrançois Tigeot  * @addr:	address, must be dword-aligned
404c59a5c48SFrançois Tigeot  *
405c59a5c48SFrançois Tigeot  * Return:  Value read
406c59a5c48SFrançois Tigeot  */
407*d78d3a22SFrançois Tigeot typedef uint32_t (*cgs_read_pci_config_dword_t)(struct cgs_device *cgs_device,
408c59a5c48SFrançois Tigeot 						unsigned addr);
409c59a5c48SFrançois Tigeot 
410c59a5c48SFrançois Tigeot /**
411c59a5c48SFrançois Tigeot  * cgs_write_pci_config_byte() - Write byte to PCI configuration space
412c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
413c59a5c48SFrançois Tigeot  * @addr:	address
414c59a5c48SFrançois Tigeot  * @value:	value to write
415c59a5c48SFrançois Tigeot  */
416*d78d3a22SFrançois Tigeot typedef void (*cgs_write_pci_config_byte_t)(struct cgs_device *cgs_device, unsigned addr,
417c59a5c48SFrançois Tigeot 					    uint8_t value);
418c59a5c48SFrançois Tigeot 
419c59a5c48SFrançois Tigeot /**
420c59a5c48SFrançois Tigeot  * cgs_write_pci_config_word() - Write byte to PCI configuration space
421c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
422c59a5c48SFrançois Tigeot  * @addr:	address, must be word-aligned
423c59a5c48SFrançois Tigeot  * @value:	value to write
424c59a5c48SFrançois Tigeot  */
425*d78d3a22SFrançois Tigeot typedef void (*cgs_write_pci_config_word_t)(struct cgs_device *cgs_device, unsigned addr,
426c59a5c48SFrançois Tigeot 					    uint16_t value);
427c59a5c48SFrançois Tigeot 
428c59a5c48SFrançois Tigeot /**
429c59a5c48SFrançois Tigeot  * cgs_write_pci_config_dword() - Write byte to PCI configuration space
430c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
431c59a5c48SFrançois Tigeot  * @addr:	address, must be dword-aligned
432c59a5c48SFrançois Tigeot  * @value:	value to write
433c59a5c48SFrançois Tigeot  */
434*d78d3a22SFrançois Tigeot typedef void (*cgs_write_pci_config_dword_t)(struct cgs_device *cgs_device, unsigned addr,
435c59a5c48SFrançois Tigeot 					     uint32_t value);
436c59a5c48SFrançois Tigeot 
437*d78d3a22SFrançois Tigeot 
438*d78d3a22SFrançois Tigeot /**
439*d78d3a22SFrançois Tigeot  * cgs_get_pci_resource() - provide access to a device resource (PCI BAR)
440*d78d3a22SFrançois Tigeot  * @cgs_device:	opaque device handle
441*d78d3a22SFrançois Tigeot  * @resource_type:	Type of Resource (MMIO, IO, ROM, FB, DOORBELL)
442*d78d3a22SFrançois Tigeot  * @size:	size of the region
443*d78d3a22SFrançois Tigeot  * @offset:	offset from the start of the region
444*d78d3a22SFrançois Tigeot  * @resource_base:	base address (not including offset) returned
445*d78d3a22SFrançois Tigeot  *
446*d78d3a22SFrançois Tigeot  * Return: 0 on success, -errno otherwise
447*d78d3a22SFrançois Tigeot  */
448*d78d3a22SFrançois Tigeot typedef int (*cgs_get_pci_resource_t)(struct cgs_device *cgs_device,
449*d78d3a22SFrançois Tigeot 				      enum cgs_resource_type resource_type,
450*d78d3a22SFrançois Tigeot 				      uint64_t size,
451*d78d3a22SFrançois Tigeot 				      uint64_t offset,
452*d78d3a22SFrançois Tigeot 				      uint64_t *resource_base);
453*d78d3a22SFrançois Tigeot 
454c59a5c48SFrançois Tigeot /**
455c59a5c48SFrançois Tigeot  * cgs_atom_get_data_table() - Get a pointer to an ATOM BIOS data table
456c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
457c59a5c48SFrançois Tigeot  * @table:	data table index
458c59a5c48SFrançois Tigeot  * @size:	size of the table (output, may be NULL)
459c59a5c48SFrançois Tigeot  * @frev:	table format revision (output, may be NULL)
460c59a5c48SFrançois Tigeot  * @crev:	table content revision (output, may be NULL)
461c59a5c48SFrançois Tigeot  *
462c59a5c48SFrançois Tigeot  * Return: Pointer to start of the table, or NULL on failure
463c59a5c48SFrançois Tigeot  */
464c59a5c48SFrançois Tigeot typedef const void *(*cgs_atom_get_data_table_t)(
465*d78d3a22SFrançois Tigeot 	struct cgs_device *cgs_device, unsigned table,
466c59a5c48SFrançois Tigeot 	uint16_t *size, uint8_t *frev, uint8_t *crev);
467c59a5c48SFrançois Tigeot 
468c59a5c48SFrançois Tigeot /**
469c59a5c48SFrançois Tigeot  * cgs_atom_get_cmd_table_revs() - Get ATOM BIOS command table revisions
470c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
471c59a5c48SFrançois Tigeot  * @table:	data table index
472c59a5c48SFrançois Tigeot  * @frev:	table format revision (output, may be NULL)
473c59a5c48SFrançois Tigeot  * @crev:	table content revision (output, may be NULL)
474c59a5c48SFrançois Tigeot  *
475c59a5c48SFrançois Tigeot  * Return: 0 on success, -errno otherwise
476c59a5c48SFrançois Tigeot  */
477*d78d3a22SFrançois Tigeot typedef int (*cgs_atom_get_cmd_table_revs_t)(struct cgs_device *cgs_device, unsigned table,
478c59a5c48SFrançois Tigeot 					     uint8_t *frev, uint8_t *crev);
479c59a5c48SFrançois Tigeot 
480c59a5c48SFrançois Tigeot /**
481c59a5c48SFrançois Tigeot  * cgs_atom_exec_cmd_table() - Execute an ATOM BIOS command table
482c59a5c48SFrançois Tigeot  * @cgs_device: opaque device handle
483c59a5c48SFrançois Tigeot  * @table:	command table index
484c59a5c48SFrançois Tigeot  * @args:	arguments
485c59a5c48SFrançois Tigeot  *
486c59a5c48SFrançois Tigeot  * Return: 0 on success, -errno otherwise
487c59a5c48SFrançois Tigeot  */
488*d78d3a22SFrançois Tigeot typedef int (*cgs_atom_exec_cmd_table_t)(struct cgs_device *cgs_device,
489c59a5c48SFrançois Tigeot 					 unsigned table, void *args);
490c59a5c48SFrançois Tigeot 
491c59a5c48SFrançois Tigeot /**
492c59a5c48SFrançois Tigeot  * cgs_create_pm_request() - Create a power management request
493c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
494c59a5c48SFrançois Tigeot  * @request:	handle of created PM request (output)
495c59a5c48SFrançois Tigeot  *
496c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
497c59a5c48SFrançois Tigeot  */
498*d78d3a22SFrançois Tigeot typedef int (*cgs_create_pm_request_t)(struct cgs_device *cgs_device, cgs_handle_t *request);
499c59a5c48SFrançois Tigeot 
500c59a5c48SFrançois Tigeot /**
501c59a5c48SFrançois Tigeot  * cgs_destroy_pm_request() - Destroy a power management request
502c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
503c59a5c48SFrançois Tigeot  * @request:	handle of created PM request
504c59a5c48SFrançois Tigeot  *
505c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
506c59a5c48SFrançois Tigeot  */
507*d78d3a22SFrançois Tigeot typedef int (*cgs_destroy_pm_request_t)(struct cgs_device *cgs_device, cgs_handle_t request);
508c59a5c48SFrançois Tigeot 
509c59a5c48SFrançois Tigeot /**
510c59a5c48SFrançois Tigeot  * cgs_set_pm_request() - Activate or deactiveate a PM request
511c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
512c59a5c48SFrançois Tigeot  * @request:	PM request handle
513c59a5c48SFrançois Tigeot  * @active:	0 = deactivate, non-0 = activate
514c59a5c48SFrançois Tigeot  *
515c59a5c48SFrançois Tigeot  * While a PM request is active, its minimum clock requests are taken
516c59a5c48SFrançois Tigeot  * into account as the requested engines are powered up. When the
517c59a5c48SFrançois Tigeot  * request is inactive, the engines may be powered down and clocks may
518c59a5c48SFrançois Tigeot  * be lower, depending on other PM requests by other driver
519c59a5c48SFrançois Tigeot  * components.
520c59a5c48SFrançois Tigeot  *
521c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
522c59a5c48SFrançois Tigeot  */
523*d78d3a22SFrançois Tigeot typedef int (*cgs_set_pm_request_t)(struct cgs_device *cgs_device, cgs_handle_t request,
524c59a5c48SFrançois Tigeot 				    int active);
525c59a5c48SFrançois Tigeot 
526c59a5c48SFrançois Tigeot /**
527c59a5c48SFrançois Tigeot  * cgs_pm_request_clock() - Request a minimum frequency for a specific clock
528c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
529c59a5c48SFrançois Tigeot  * @request:	PM request handle
530c59a5c48SFrançois Tigeot  * @clock:	which clock?
531c59a5c48SFrançois Tigeot  * @freq:	requested min. frequency in 10KHz units (0 to clear request)
532c59a5c48SFrançois Tigeot  *
533c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
534c59a5c48SFrançois Tigeot  */
535*d78d3a22SFrançois Tigeot typedef int (*cgs_pm_request_clock_t)(struct cgs_device *cgs_device, cgs_handle_t request,
536c59a5c48SFrançois Tigeot 				      enum cgs_clock clock, unsigned freq);
537c59a5c48SFrançois Tigeot 
538c59a5c48SFrançois Tigeot /**
539c59a5c48SFrançois Tigeot  * cgs_pm_request_engine() - Request an engine to be powered up
540c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
541c59a5c48SFrançois Tigeot  * @request:	PM request handle
542c59a5c48SFrançois Tigeot  * @engine:	which engine?
543c59a5c48SFrançois Tigeot  * @powered:	0 = powered down, non-0 = powered up
544c59a5c48SFrançois Tigeot  *
545c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
546c59a5c48SFrançois Tigeot  */
547*d78d3a22SFrançois Tigeot typedef int (*cgs_pm_request_engine_t)(struct cgs_device *cgs_device, cgs_handle_t request,
548c59a5c48SFrançois Tigeot 				       enum cgs_engine engine, int powered);
549c59a5c48SFrançois Tigeot 
550c59a5c48SFrançois Tigeot /**
551c59a5c48SFrançois Tigeot  * cgs_pm_query_clock_limits() - Query clock frequency limits
552c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
553c59a5c48SFrançois Tigeot  * @clock:	which clock?
554c59a5c48SFrançois Tigeot  * @limits:	clock limits
555c59a5c48SFrançois Tigeot  *
556c59a5c48SFrançois Tigeot  * Return:  0 on success, -errno otherwise
557c59a5c48SFrançois Tigeot  */
558*d78d3a22SFrançois Tigeot typedef int (*cgs_pm_query_clock_limits_t)(struct cgs_device *cgs_device,
559c59a5c48SFrançois Tigeot 					   enum cgs_clock clock,
560c59a5c48SFrançois Tigeot 					   struct cgs_clock_limits *limits);
561c59a5c48SFrançois Tigeot 
562c59a5c48SFrançois Tigeot /**
563c59a5c48SFrançois Tigeot  * cgs_set_camera_voltages() - Apply specific voltages to PMIC voltage planes
564c59a5c48SFrançois Tigeot  * @cgs_device:	opaque device handle
565c59a5c48SFrançois Tigeot  * @mask:	bitmask of voltages to change (1<<CGS_VOLTAGE_PLANE__xyz|...)
566c59a5c48SFrançois Tigeot  * @voltages:	pointer to array of voltage values in 1mV units
567c59a5c48SFrançois Tigeot  *
568c59a5c48SFrançois Tigeot  * Return: 0 on success, -errno otherwise
569c59a5c48SFrançois Tigeot  */
570*d78d3a22SFrançois Tigeot typedef int (*cgs_set_camera_voltages_t)(struct cgs_device *cgs_device, uint32_t mask,
571c59a5c48SFrançois Tigeot 					 const uint32_t *voltages);
572c59a5c48SFrançois Tigeot /**
573c59a5c48SFrançois Tigeot  * cgs_get_firmware_info - Get the firmware information from core driver
574c59a5c48SFrançois Tigeot  * @cgs_device: opaque device handle
575c59a5c48SFrançois Tigeot  * @type: the firmware type
576c59a5c48SFrançois Tigeot  * @info: returend firmware information
577c59a5c48SFrançois Tigeot  *
578c59a5c48SFrançois Tigeot  * Return: 0 on success, -errno otherwise
579c59a5c48SFrançois Tigeot  */
580*d78d3a22SFrançois Tigeot typedef int (*cgs_get_firmware_info)(struct cgs_device *cgs_device,
581c59a5c48SFrançois Tigeot 				     enum cgs_ucode_id type,
582c59a5c48SFrançois Tigeot 				     struct cgs_firmware_info *info);
583c59a5c48SFrançois Tigeot 
584*d78d3a22SFrançois Tigeot typedef int (*cgs_rel_firmware)(struct cgs_device *cgs_device,
585*d78d3a22SFrançois Tigeot 					 enum cgs_ucode_id type);
586*d78d3a22SFrançois Tigeot 
587*d78d3a22SFrançois Tigeot typedef int(*cgs_set_powergating_state)(struct cgs_device *cgs_device,
588c59a5c48SFrançois Tigeot 				  enum amd_ip_block_type block_type,
589c59a5c48SFrançois Tigeot 				  enum amd_powergating_state state);
590c59a5c48SFrançois Tigeot 
591*d78d3a22SFrançois Tigeot typedef int(*cgs_set_clockgating_state)(struct cgs_device *cgs_device,
592c59a5c48SFrançois Tigeot 				  enum amd_ip_block_type block_type,
593c59a5c48SFrançois Tigeot 				  enum amd_clockgating_state state);
594c59a5c48SFrançois Tigeot 
595*d78d3a22SFrançois Tigeot typedef int(*cgs_get_active_displays_info)(
596*d78d3a22SFrançois Tigeot 					struct cgs_device *cgs_device,
597*d78d3a22SFrançois Tigeot 					struct cgs_display_info *info);
598*d78d3a22SFrançois Tigeot 
599*d78d3a22SFrançois Tigeot typedef int (*cgs_notify_dpm_enabled)(struct cgs_device *cgs_device, bool enabled);
600*d78d3a22SFrançois Tigeot 
601*d78d3a22SFrançois Tigeot typedef int (*cgs_call_acpi_method)(struct cgs_device *cgs_device,
602*d78d3a22SFrançois Tigeot 					uint32_t acpi_method,
603*d78d3a22SFrançois Tigeot 					uint32_t acpi_function,
604*d78d3a22SFrançois Tigeot 					void *pinput, void *poutput,
605*d78d3a22SFrançois Tigeot 					uint32_t output_count,
606*d78d3a22SFrançois Tigeot 					uint32_t input_size,
607*d78d3a22SFrançois Tigeot 					uint32_t output_size);
608*d78d3a22SFrançois Tigeot 
609*d78d3a22SFrançois Tigeot typedef int (*cgs_query_system_info)(struct cgs_device *cgs_device,
610*d78d3a22SFrançois Tigeot 				struct cgs_system_info *sys_info);
611*d78d3a22SFrançois Tigeot 
612c59a5c48SFrançois Tigeot struct cgs_ops {
613c59a5c48SFrançois Tigeot 	/* memory management calls (similar to KFD interface) */
614c59a5c48SFrançois Tigeot 	cgs_gpu_mem_info_t gpu_mem_info;
615c59a5c48SFrançois Tigeot 	cgs_gmap_kmem_t gmap_kmem;
616c59a5c48SFrançois Tigeot 	cgs_gunmap_kmem_t gunmap_kmem;
617c59a5c48SFrançois Tigeot 	cgs_alloc_gpu_mem_t alloc_gpu_mem;
618c59a5c48SFrançois Tigeot 	cgs_free_gpu_mem_t free_gpu_mem;
619c59a5c48SFrançois Tigeot 	cgs_gmap_gpu_mem_t gmap_gpu_mem;
620c59a5c48SFrançois Tigeot 	cgs_gunmap_gpu_mem_t gunmap_gpu_mem;
621c59a5c48SFrançois Tigeot 	cgs_kmap_gpu_mem_t kmap_gpu_mem;
622c59a5c48SFrançois Tigeot 	cgs_kunmap_gpu_mem_t kunmap_gpu_mem;
623c59a5c48SFrançois Tigeot 	/* MMIO access */
624c59a5c48SFrançois Tigeot 	cgs_read_register_t read_register;
625c59a5c48SFrançois Tigeot 	cgs_write_register_t write_register;
626c59a5c48SFrançois Tigeot 	cgs_read_ind_register_t read_ind_register;
627c59a5c48SFrançois Tigeot 	cgs_write_ind_register_t write_ind_register;
628c59a5c48SFrançois Tigeot 	/* PCI configuration space access */
629c59a5c48SFrançois Tigeot 	cgs_read_pci_config_byte_t read_pci_config_byte;
630c59a5c48SFrançois Tigeot 	cgs_read_pci_config_word_t read_pci_config_word;
631c59a5c48SFrançois Tigeot 	cgs_read_pci_config_dword_t read_pci_config_dword;
632c59a5c48SFrançois Tigeot 	cgs_write_pci_config_byte_t write_pci_config_byte;
633c59a5c48SFrançois Tigeot 	cgs_write_pci_config_word_t write_pci_config_word;
634c59a5c48SFrançois Tigeot 	cgs_write_pci_config_dword_t write_pci_config_dword;
635*d78d3a22SFrançois Tigeot 	/* PCI resources */
636*d78d3a22SFrançois Tigeot 	cgs_get_pci_resource_t get_pci_resource;
637c59a5c48SFrançois Tigeot 	/* ATOM BIOS */
638c59a5c48SFrançois Tigeot 	cgs_atom_get_data_table_t atom_get_data_table;
639c59a5c48SFrançois Tigeot 	cgs_atom_get_cmd_table_revs_t atom_get_cmd_table_revs;
640c59a5c48SFrançois Tigeot 	cgs_atom_exec_cmd_table_t atom_exec_cmd_table;
641c59a5c48SFrançois Tigeot 	/* Power management */
642c59a5c48SFrançois Tigeot 	cgs_create_pm_request_t create_pm_request;
643c59a5c48SFrançois Tigeot 	cgs_destroy_pm_request_t destroy_pm_request;
644c59a5c48SFrançois Tigeot 	cgs_set_pm_request_t set_pm_request;
645c59a5c48SFrançois Tigeot 	cgs_pm_request_clock_t pm_request_clock;
646c59a5c48SFrançois Tigeot 	cgs_pm_request_engine_t pm_request_engine;
647c59a5c48SFrançois Tigeot 	cgs_pm_query_clock_limits_t pm_query_clock_limits;
648c59a5c48SFrançois Tigeot 	cgs_set_camera_voltages_t set_camera_voltages;
649c59a5c48SFrançois Tigeot 	/* Firmware Info */
650c59a5c48SFrançois Tigeot 	cgs_get_firmware_info get_firmware_info;
651*d78d3a22SFrançois Tigeot 	cgs_rel_firmware rel_firmware;
652c59a5c48SFrançois Tigeot 	/* cg pg interface*/
653c59a5c48SFrançois Tigeot 	cgs_set_powergating_state set_powergating_state;
654c59a5c48SFrançois Tigeot 	cgs_set_clockgating_state set_clockgating_state;
655*d78d3a22SFrançois Tigeot 	/* display manager */
656*d78d3a22SFrançois Tigeot 	cgs_get_active_displays_info get_active_displays_info;
657*d78d3a22SFrançois Tigeot 	/* notify dpm enabled */
658*d78d3a22SFrançois Tigeot 	cgs_notify_dpm_enabled notify_dpm_enabled;
659*d78d3a22SFrançois Tigeot 	/* ACPI */
660*d78d3a22SFrançois Tigeot 	cgs_call_acpi_method call_acpi_method;
661*d78d3a22SFrançois Tigeot 	/* get system info */
662*d78d3a22SFrançois Tigeot 	cgs_query_system_info query_system_info;
663c59a5c48SFrançois Tigeot };
664c59a5c48SFrançois Tigeot 
665c59a5c48SFrançois Tigeot struct cgs_os_ops; /* To be define in OS-specific CGS header */
666c59a5c48SFrançois Tigeot 
667c59a5c48SFrançois Tigeot struct cgs_device
668c59a5c48SFrançois Tigeot {
669c59a5c48SFrançois Tigeot 	const struct cgs_ops *ops;
670c59a5c48SFrançois Tigeot 	const struct cgs_os_ops *os_ops;
671c59a5c48SFrançois Tigeot 	/* to be embedded at the start of driver private structure */
672c59a5c48SFrançois Tigeot };
673c59a5c48SFrançois Tigeot 
674c59a5c48SFrançois Tigeot /* Convenience macros that make CGS indirect function calls look like
675c59a5c48SFrançois Tigeot  * normal function calls */
676c59a5c48SFrançois Tigeot #define CGS_CALL(func,dev,...) \
677c59a5c48SFrançois Tigeot 	(((struct cgs_device *)dev)->ops->func(dev, ##__VA_ARGS__))
678c59a5c48SFrançois Tigeot #define CGS_OS_CALL(func,dev,...) \
679c59a5c48SFrançois Tigeot 	(((struct cgs_device *)dev)->os_ops->func(dev, ##__VA_ARGS__))
680c59a5c48SFrançois Tigeot 
681c59a5c48SFrançois Tigeot #define cgs_gpu_mem_info(dev,type,mc_start,mc_size,mem_size)		\
682c59a5c48SFrançois Tigeot 	CGS_CALL(gpu_mem_info,dev,type,mc_start,mc_size,mem_size)
683c59a5c48SFrançois Tigeot #define cgs_gmap_kmem(dev,kmem,size,min_off,max_off,kmem_handle,mcaddr)	\
684c59a5c48SFrançois Tigeot 	CGS_CALL(gmap_kmem,dev,kmem,size,min_off,max_off,kmem_handle,mcaddr)
685c59a5c48SFrançois Tigeot #define cgs_gunmap_kmem(dev,kmem_handle)	\
686c59a5c48SFrançois Tigeot 	CGS_CALL(gunmap_kmem,dev,keme_handle)
687c59a5c48SFrançois Tigeot #define cgs_alloc_gpu_mem(dev,type,size,align,min_off,max_off,handle)	\
688c59a5c48SFrançois Tigeot 	CGS_CALL(alloc_gpu_mem,dev,type,size,align,min_off,max_off,handle)
689c59a5c48SFrançois Tigeot #define cgs_free_gpu_mem(dev,handle)		\
690c59a5c48SFrançois Tigeot 	CGS_CALL(free_gpu_mem,dev,handle)
691c59a5c48SFrançois Tigeot #define cgs_gmap_gpu_mem(dev,handle,mcaddr)	\
692c59a5c48SFrançois Tigeot 	CGS_CALL(gmap_gpu_mem,dev,handle,mcaddr)
693c59a5c48SFrançois Tigeot #define cgs_gunmap_gpu_mem(dev,handle)		\
694c59a5c48SFrançois Tigeot 	CGS_CALL(gunmap_gpu_mem,dev,handle)
695c59a5c48SFrançois Tigeot #define cgs_kmap_gpu_mem(dev,handle,map)	\
696c59a5c48SFrançois Tigeot 	CGS_CALL(kmap_gpu_mem,dev,handle,map)
697c59a5c48SFrançois Tigeot #define cgs_kunmap_gpu_mem(dev,handle)		\
698c59a5c48SFrançois Tigeot 	CGS_CALL(kunmap_gpu_mem,dev,handle)
699c59a5c48SFrançois Tigeot 
700c59a5c48SFrançois Tigeot #define cgs_read_register(dev,offset)		\
701c59a5c48SFrançois Tigeot 	CGS_CALL(read_register,dev,offset)
702c59a5c48SFrançois Tigeot #define cgs_write_register(dev,offset,value)		\
703c59a5c48SFrançois Tigeot 	CGS_CALL(write_register,dev,offset,value)
704c59a5c48SFrançois Tigeot #define cgs_read_ind_register(dev,space,index)		\
705c59a5c48SFrançois Tigeot 	CGS_CALL(read_ind_register,dev,space,index)
706c59a5c48SFrançois Tigeot #define cgs_write_ind_register(dev,space,index,value)		\
707c59a5c48SFrançois Tigeot 	CGS_CALL(write_ind_register,dev,space,index,value)
708c59a5c48SFrançois Tigeot 
709c59a5c48SFrançois Tigeot #define cgs_read_pci_config_byte(dev,addr)	\
710c59a5c48SFrançois Tigeot 	CGS_CALL(read_pci_config_byte,dev,addr)
711c59a5c48SFrançois Tigeot #define cgs_read_pci_config_word(dev,addr)	\
712c59a5c48SFrançois Tigeot 	CGS_CALL(read_pci_config_word,dev,addr)
713c59a5c48SFrançois Tigeot #define cgs_read_pci_config_dword(dev,addr)		\
714c59a5c48SFrançois Tigeot 	CGS_CALL(read_pci_config_dword,dev,addr)
715c59a5c48SFrançois Tigeot #define cgs_write_pci_config_byte(dev,addr,value)	\
716c59a5c48SFrançois Tigeot 	CGS_CALL(write_pci_config_byte,dev,addr,value)
717c59a5c48SFrançois Tigeot #define cgs_write_pci_config_word(dev,addr,value)	\
718c59a5c48SFrançois Tigeot 	CGS_CALL(write_pci_config_word,dev,addr,value)
719c59a5c48SFrançois Tigeot #define cgs_write_pci_config_dword(dev,addr,value)	\
720c59a5c48SFrançois Tigeot 	CGS_CALL(write_pci_config_dword,dev,addr,value)
721c59a5c48SFrançois Tigeot 
722c59a5c48SFrançois Tigeot #define cgs_atom_get_data_table(dev,table,size,frev,crev)	\
723c59a5c48SFrançois Tigeot 	CGS_CALL(atom_get_data_table,dev,table,size,frev,crev)
724c59a5c48SFrançois Tigeot #define cgs_atom_get_cmd_table_revs(dev,table,frev,crev)	\
725c59a5c48SFrançois Tigeot 	CGS_CALL(atom_get_cmd_table_revs,dev,table,frev,crev)
726c59a5c48SFrançois Tigeot #define cgs_atom_exec_cmd_table(dev,table,args)		\
727c59a5c48SFrançois Tigeot 	CGS_CALL(atom_exec_cmd_table,dev,table,args)
728c59a5c48SFrançois Tigeot 
729c59a5c48SFrançois Tigeot #define cgs_create_pm_request(dev,request)	\
730c59a5c48SFrançois Tigeot 	CGS_CALL(create_pm_request,dev,request)
731c59a5c48SFrançois Tigeot #define cgs_destroy_pm_request(dev,request)		\
732c59a5c48SFrançois Tigeot 	CGS_CALL(destroy_pm_request,dev,request)
733c59a5c48SFrançois Tigeot #define cgs_set_pm_request(dev,request,active)		\
734c59a5c48SFrançois Tigeot 	CGS_CALL(set_pm_request,dev,request,active)
735c59a5c48SFrançois Tigeot #define cgs_pm_request_clock(dev,request,clock,freq)		\
736c59a5c48SFrançois Tigeot 	CGS_CALL(pm_request_clock,dev,request,clock,freq)
737c59a5c48SFrançois Tigeot #define cgs_pm_request_engine(dev,request,engine,powered)	\
738c59a5c48SFrançois Tigeot 	CGS_CALL(pm_request_engine,dev,request,engine,powered)
739c59a5c48SFrançois Tigeot #define cgs_pm_query_clock_limits(dev,clock,limits)		\
740c59a5c48SFrançois Tigeot 	CGS_CALL(pm_query_clock_limits,dev,clock,limits)
741c59a5c48SFrançois Tigeot #define cgs_set_camera_voltages(dev,mask,voltages)	\
742c59a5c48SFrançois Tigeot 	CGS_CALL(set_camera_voltages,dev,mask,voltages)
743c59a5c48SFrançois Tigeot #define cgs_get_firmware_info(dev, type, info)	\
744c59a5c48SFrançois Tigeot 	CGS_CALL(get_firmware_info, dev, type, info)
745*d78d3a22SFrançois Tigeot #define cgs_rel_firmware(dev, type)	\
746*d78d3a22SFrançois Tigeot 	CGS_CALL(rel_firmware, dev, type)
747c59a5c48SFrançois Tigeot #define cgs_set_powergating_state(dev, block_type, state)	\
748c59a5c48SFrançois Tigeot 	CGS_CALL(set_powergating_state, dev, block_type, state)
749c59a5c48SFrançois Tigeot #define cgs_set_clockgating_state(dev, block_type, state)	\
750c59a5c48SFrançois Tigeot 	CGS_CALL(set_clockgating_state, dev, block_type, state)
751*d78d3a22SFrançois Tigeot #define cgs_notify_dpm_enabled(dev, enabled)	\
752*d78d3a22SFrançois Tigeot 	CGS_CALL(notify_dpm_enabled, dev, enabled)
753*d78d3a22SFrançois Tigeot 
754*d78d3a22SFrançois Tigeot #define cgs_get_active_displays_info(dev, info)	\
755*d78d3a22SFrançois Tigeot 	CGS_CALL(get_active_displays_info, dev, info)
756*d78d3a22SFrançois Tigeot 
757*d78d3a22SFrançois Tigeot #define cgs_call_acpi_method(dev, acpi_method, acpi_function, pintput, poutput, output_count, input_size, output_size)	\
758*d78d3a22SFrançois Tigeot 	CGS_CALL(call_acpi_method, dev, acpi_method, acpi_function, pintput, poutput, output_count, input_size, output_size)
759*d78d3a22SFrançois Tigeot #define cgs_query_system_info(dev, sys_info)	\
760*d78d3a22SFrançois Tigeot 	CGS_CALL(query_system_info, dev, sys_info)
761*d78d3a22SFrançois Tigeot #define cgs_get_pci_resource(cgs_device, resource_type, size, offset, \
762*d78d3a22SFrançois Tigeot 	resource_base) \
763*d78d3a22SFrançois Tigeot 	CGS_CALL(get_pci_resource, cgs_device, resource_type, size, offset, \
764*d78d3a22SFrançois Tigeot 	resource_base)
765c59a5c48SFrançois Tigeot 
766c59a5c48SFrançois Tigeot #endif /* _CGS_COMMON_H */
767