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"
30 bool acpi_atcs_functions_supported(void *device, uint32_t index)
33 struct atcs_verify_interface output_buf = {0};
35 int32_t temp_buffer = 1;
37 result = cgs_call_acpi_method(device, CGS_ACPI_METHOD_ATCS,
38 ATCS_FUNCTION_VERIFY_INTERFACE,
45 return result == 0 ? (output_buf.function_bits & (1 << (index - 1))) != 0 : false;
48 bool acpi_atcs_notify_pcie_device_ready(void *device)
50 int32_t temp_buffer = 1;
52 return cgs_call_acpi_method(device, CGS_ACPI_METHOD_ATCS,
53 ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION,
62 int acpi_pcie_perf_request(void *device, uint8_t perf_req, bool advertise)
64 struct atcs_pref_req_input atcs_input;
65 struct atcs_pref_req_output atcs_output;
68 struct cgs_system_info info = {0};
70 if (acpi_atcs_notify_pcie_device_ready(device))
73 info.size = sizeof(struct cgs_system_info);
74 info.info_id = CGS_SYSTEM_INFO_ADAPTER_BDF_ID;
75 result = cgs_query_system_info(device, &info);
78 atcs_input.client_id = (uint16_t)info.value;
79 atcs_input.size = sizeof(struct atcs_pref_req_input);
80 atcs_input.valid_flags_mask = ATCS_VALID_FLAGS_MASK;
81 atcs_input.flags = ATCS_WAIT_FOR_COMPLETION;
83 atcs_input.flags |= ATCS_ADVERTISE_CAPS;
84 atcs_input.req_type = ATCS_PCIE_LINK_SPEED;
85 atcs_input.perf_req = perf_req;
87 atcs_output.size = sizeof(struct atcs_pref_req_input);
90 result = cgs_call_acpi_method(device,
92 ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST,
101 switch (atcs_output.ret_val) {
102 case ATCS_REQUEST_REFUSED:
105 case ATCS_REQUEST_COMPLETE:
107 case ATCS_REQUEST_IN_PROGRESS: