cgs_common.h 22 KB

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