diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 212 |
1 files changed, 0 insertions, 212 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index 9d6e1b08e148..795be958cf5e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
27 | #include <linux/acpi.h> | ||
28 | #include <drm/drmP.h> | 27 | #include <drm/drmP.h> |
29 | #include <linux/firmware.h> | 28 | #include <linux/firmware.h> |
30 | #include <drm/amdgpu_drm.h> | 29 | #include <drm/amdgpu_drm.h> |
@@ -964,216 +963,6 @@ static int amdgpu_cgs_notify_dpm_enabled(struct cgs_device *cgs_device, bool ena | |||
964 | return 0; | 963 | return 0; |
965 | } | 964 | } |
966 | 965 | ||
967 | /** \brief evaluate acpi namespace object, handle or pathname must be valid | ||
968 | * \param cgs_device | ||
969 | * \param info input/output arguments for the control method | ||
970 | * \return status | ||
971 | */ | ||
972 | |||
973 | #if defined(CONFIG_ACPI) | ||
974 | static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, | ||
975 | struct cgs_acpi_method_info *info) | ||
976 | { | ||
977 | CGS_FUNC_ADEV; | ||
978 | acpi_handle handle; | ||
979 | struct acpi_object_list input; | ||
980 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
981 | union acpi_object *params, *obj; | ||
982 | uint8_t name[5] = {'\0'}; | ||
983 | struct cgs_acpi_method_argument *argument; | ||
984 | uint32_t i, count; | ||
985 | acpi_status status; | ||
986 | int result; | ||
987 | |||
988 | handle = ACPI_HANDLE(&adev->pdev->dev); | ||
989 | if (!handle) | ||
990 | return -ENODEV; | ||
991 | |||
992 | memset(&input, 0, sizeof(struct acpi_object_list)); | ||
993 | |||
994 | /* validate input info */ | ||
995 | if (info->size != sizeof(struct cgs_acpi_method_info)) | ||
996 | return -EINVAL; | ||
997 | |||
998 | input.count = info->input_count; | ||
999 | if (info->input_count > 0) { | ||
1000 | if (info->pinput_argument == NULL) | ||
1001 | return -EINVAL; | ||
1002 | argument = info->pinput_argument; | ||
1003 | for (i = 0; i < info->input_count; i++) { | ||
1004 | if (((argument->type == ACPI_TYPE_STRING) || | ||
1005 | (argument->type == ACPI_TYPE_BUFFER)) && | ||
1006 | (argument->pointer == NULL)) | ||
1007 | return -EINVAL; | ||
1008 | argument++; | ||
1009 | } | ||
1010 | } | ||
1011 | |||
1012 | if (info->output_count > 0) { | ||
1013 | if (info->poutput_argument == NULL) | ||
1014 | return -EINVAL; | ||
1015 | argument = info->poutput_argument; | ||
1016 | for (i = 0; i < info->output_count; i++) { | ||
1017 | if (((argument->type == ACPI_TYPE_STRING) || | ||
1018 | (argument->type == ACPI_TYPE_BUFFER)) | ||
1019 | && (argument->pointer == NULL)) | ||
1020 | return -EINVAL; | ||
1021 | argument++; | ||
1022 | } | ||
1023 | } | ||
1024 | |||
1025 | /* The path name passed to acpi_evaluate_object should be null terminated */ | ||
1026 | if ((info->field & CGS_ACPI_FIELD_METHOD_NAME) != 0) { | ||
1027 | strncpy(name, (char *)&(info->name), sizeof(uint32_t)); | ||
1028 | name[4] = '\0'; | ||
1029 | } | ||
1030 | |||
1031 | /* parse input parameters */ | ||
1032 | if (input.count > 0) { | ||
1033 | input.pointer = params = | ||
1034 | kzalloc(sizeof(union acpi_object) * input.count, GFP_KERNEL); | ||
1035 | if (params == NULL) | ||
1036 | return -EINVAL; | ||
1037 | |||
1038 | argument = info->pinput_argument; | ||
1039 | |||
1040 | for (i = 0; i < input.count; i++) { | ||
1041 | params->type = argument->type; | ||
1042 | switch (params->type) { | ||
1043 | case ACPI_TYPE_INTEGER: | ||
1044 | params->integer.value = argument->value; | ||
1045 | break; | ||
1046 | case ACPI_TYPE_STRING: | ||
1047 | params->string.length = argument->data_length; | ||
1048 | params->string.pointer = argument->pointer; | ||
1049 | break; | ||
1050 | case ACPI_TYPE_BUFFER: | ||
1051 | params->buffer.length = argument->data_length; | ||
1052 | params->buffer.pointer = argument->pointer; | ||
1053 | break; | ||
1054 | default: | ||
1055 | break; | ||
1056 | } | ||
1057 | params++; | ||
1058 | argument++; | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | /* parse output info */ | ||
1063 | count = info->output_count; | ||
1064 | argument = info->poutput_argument; | ||
1065 | |||
1066 | /* evaluate the acpi method */ | ||
1067 | status = acpi_evaluate_object(handle, name, &input, &output); | ||
1068 | |||
1069 | if (ACPI_FAILURE(status)) { | ||
1070 | result = -EIO; | ||
1071 | goto free_input; | ||
1072 | } | ||
1073 | |||
1074 | /* return the output info */ | ||
1075 | obj = output.pointer; | ||
1076 | |||
1077 | if (count > 1) { | ||
1078 | if ((obj->type != ACPI_TYPE_PACKAGE) || | ||
1079 | (obj->package.count != count)) { | ||
1080 | result = -EIO; | ||
1081 | goto free_obj; | ||
1082 | } | ||
1083 | params = obj->package.elements; | ||
1084 | } else | ||
1085 | params = obj; | ||
1086 | |||
1087 | if (params == NULL) { | ||
1088 | result = -EIO; | ||
1089 | goto free_obj; | ||
1090 | } | ||
1091 | |||
1092 | for (i = 0; i < count; i++) { | ||
1093 | if (argument->type != params->type) { | ||
1094 | result = -EIO; | ||
1095 | goto free_obj; | ||
1096 | } | ||
1097 | switch (params->type) { | ||
1098 | case ACPI_TYPE_INTEGER: | ||
1099 | argument->value = params->integer.value; | ||
1100 | break; | ||
1101 | case ACPI_TYPE_STRING: | ||
1102 | if ((params->string.length != argument->data_length) || | ||
1103 | (params->string.pointer == NULL)) { | ||
1104 | result = -EIO; | ||
1105 | goto free_obj; | ||
1106 | } | ||
1107 | strncpy(argument->pointer, | ||
1108 | params->string.pointer, | ||
1109 | params->string.length); | ||
1110 | break; | ||
1111 | case ACPI_TYPE_BUFFER: | ||
1112 | if (params->buffer.pointer == NULL) { | ||
1113 | result = -EIO; | ||
1114 | goto free_obj; | ||
1115 | } | ||
1116 | memcpy(argument->pointer, | ||
1117 | params->buffer.pointer, | ||
1118 | argument->data_length); | ||
1119 | break; | ||
1120 | default: | ||
1121 | break; | ||
1122 | } | ||
1123 | argument++; | ||
1124 | params++; | ||
1125 | } | ||
1126 | |||
1127 | result = 0; | ||
1128 | free_obj: | ||
1129 | kfree(obj); | ||
1130 | free_input: | ||
1131 | kfree((void *)input.pointer); | ||
1132 | return result; | ||
1133 | } | ||
1134 | #else | ||
1135 | static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, | ||
1136 | struct cgs_acpi_method_info *info) | ||
1137 | { | ||
1138 | return -EIO; | ||
1139 | } | ||
1140 | #endif | ||
1141 | |||
1142 | static int amdgpu_cgs_call_acpi_method(struct cgs_device *cgs_device, | ||
1143 | uint32_t acpi_method, | ||
1144 | uint32_t acpi_function, | ||
1145 | void *pinput, void *poutput, | ||
1146 | uint32_t output_count, | ||
1147 | uint32_t input_size, | ||
1148 | uint32_t output_size) | ||
1149 | { | ||
1150 | struct cgs_acpi_method_argument acpi_input[2] = { {0}, {0} }; | ||
1151 | struct cgs_acpi_method_argument acpi_output = {0}; | ||
1152 | struct cgs_acpi_method_info info = {0}; | ||
1153 | |||
1154 | acpi_input[0].type = CGS_ACPI_TYPE_INTEGER; | ||
1155 | acpi_input[0].data_length = sizeof(uint32_t); | ||
1156 | acpi_input[0].value = acpi_function; | ||
1157 | |||
1158 | acpi_input[1].type = CGS_ACPI_TYPE_BUFFER; | ||
1159 | acpi_input[1].data_length = input_size; | ||
1160 | acpi_input[1].pointer = pinput; | ||
1161 | |||
1162 | acpi_output.type = CGS_ACPI_TYPE_BUFFER; | ||
1163 | acpi_output.data_length = output_size; | ||
1164 | acpi_output.pointer = poutput; | ||
1165 | |||
1166 | info.size = sizeof(struct cgs_acpi_method_info); | ||
1167 | info.field = CGS_ACPI_FIELD_METHOD_NAME | CGS_ACPI_FIELD_INPUT_ARGUMENT_COUNT; | ||
1168 | info.input_count = 2; | ||
1169 | info.name = acpi_method; | ||
1170 | info.pinput_argument = acpi_input; | ||
1171 | info.output_count = output_count; | ||
1172 | info.poutput_argument = &acpi_output; | ||
1173 | |||
1174 | return amdgpu_cgs_acpi_eval_object(cgs_device, &info); | ||
1175 | } | ||
1176 | |||
1177 | static int amdgpu_cgs_set_temperature_range(struct cgs_device *cgs_device, | 966 | static int amdgpu_cgs_set_temperature_range(struct cgs_device *cgs_device, |
1178 | int min_temperature, | 967 | int min_temperature, |
1179 | int max_temperature) | 968 | int max_temperature) |
@@ -1207,7 +996,6 @@ static const struct cgs_ops amdgpu_cgs_ops = { | |||
1207 | .set_clockgating_state = amdgpu_cgs_set_clockgating_state, | 996 | .set_clockgating_state = amdgpu_cgs_set_clockgating_state, |
1208 | .get_active_displays_info = amdgpu_cgs_get_active_displays_info, | 997 | .get_active_displays_info = amdgpu_cgs_get_active_displays_info, |
1209 | .notify_dpm_enabled = amdgpu_cgs_notify_dpm_enabled, | 998 | .notify_dpm_enabled = amdgpu_cgs_notify_dpm_enabled, |
1210 | .call_acpi_method = amdgpu_cgs_call_acpi_method, | ||
1211 | .query_system_info = amdgpu_cgs_query_system_info, | 999 | .query_system_info = amdgpu_cgs_query_system_info, |
1212 | .is_virtualization_enabled = amdgpu_cgs_is_virtualization_enabled, | 1000 | .is_virtualization_enabled = amdgpu_cgs_is_virtualization_enabled, |
1213 | .enter_safe_mode = amdgpu_cgs_enter_safe_mode, | 1001 | .enter_safe_mode = amdgpu_cgs_enter_safe_mode, |