2 * Copyright 2016 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #include <linux/errno.h>
25 #include "linux/delay.h"
29 bool acpi_atcs_functions_supported(void *device, uint32_t index)
32 struct atcs_verify_interface output_buf = {0};
34 int32_t temp_buffer = 1;
36 result = cgs_call_acpi_method(device, CGS_ACPI_METHOD_ATCS,
37 ATCS_FUNCTION_VERIFY_INTERFACE,
44 return result == 0 ? (output_buf.function_bits & (1 << (index - 1))) != 0 : false;
47 bool acpi_atcs_notify_pcie_device_ready(void *device)
49 int32_t temp_buffer = 1;
51 return cgs_call_acpi_method(device, CGS_ACPI_METHOD_ATCS,
52 ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION,
61 int acpi_pcie_perf_request(void *device, uint8_t perf_req, bool advertise)
63 struct atcs_pref_req_input atcs_input;
64 struct atcs_pref_req_output atcs_output;
67 struct cgs_system_info info = {0};
69 if( 0 != acpi_atcs_notify_pcie_device_ready(device))
72 info.size = sizeof(struct cgs_system_info);
73 info.info_id = CGS_SYSTEM_INFO_ADAPTER_BDF_ID;
74 result = cgs_query_system_info(device, &info);
77 atcs_input.client_id = (uint16_t)info.value;
78 atcs_input.size = sizeof(struct atcs_pref_req_input);
79 atcs_input.valid_flags_mask = ATCS_VALID_FLAGS_MASK;
80 atcs_input.flags = ATCS_WAIT_FOR_COMPLETION;
82 atcs_input.flags |= ATCS_ADVERTISE_CAPS;
83 atcs_input.req_type = ATCS_PCIE_LINK_SPEED;
84 atcs_input.perf_req = perf_req;
86 atcs_output.size = sizeof(struct atcs_pref_req_input);
89 result = cgs_call_acpi_method(device,
91 ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST,
100 switch (atcs_output.ret_val) {
101 case ATCS_REQUEST_REFUSED:
104 case ATCS_REQUEST_COMPLETE:
106 case ATCS_REQUEST_IN_PROGRESS: