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