blob: 5b32e499903bc0762fe56f087711e0d52b36e2ce [file] [log] [blame]
Alberto Miloned7a29522010-07-06 11:40:24 -04001#include <linux/pci.h>
2#include <linux/acpi.h>
3#include <linux/slab.h>
4#include <acpi/acpi_drivers.h>
5#include <acpi/acpi_bus.h>
6
7#include "drmP.h"
8#include "drm.h"
9#include "drm_sarea.h"
10#include "drm_crtc_helper.h"
11#include "radeon.h"
Alex Deucher9e05b2f2012-07-18 13:28:52 -040012#include "radeon_acpi.h"
Alberto Miloned7a29522010-07-06 11:40:24 -040013
14#include <linux/vga_switcheroo.h>
15
16/* Call the ATIF method
17 *
18 * Note: currently we discard the output
19 */
20static int radeon_atif_call(acpi_handle handle)
21{
22 acpi_status status;
23 union acpi_object atif_arg_elements[2];
24 struct acpi_object_list atif_arg;
25 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
26
27 atif_arg.count = 2;
28 atif_arg.pointer = &atif_arg_elements[0];
29
30 atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
Alex Deucher9e05b2f2012-07-18 13:28:52 -040031 atif_arg_elements[0].integer.value = ATIF_FUNCTION_VERIFY_INTERFACE;
Alberto Miloned7a29522010-07-06 11:40:24 -040032 atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
33 atif_arg_elements[1].integer.value = 0;
34
35 status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer);
36
37 /* Fail only if calling the method fails and ATIF is supported */
38 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
Jean Delvarebc96f942011-11-30 17:26:36 +010039 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
40 acpi_format_exception(status));
Alberto Miloned7a29522010-07-06 11:40:24 -040041 kfree(buffer.pointer);
42 return 1;
43 }
44
45 kfree(buffer.pointer);
46 return 0;
47}
48
49/* Call all ACPI methods here */
50int radeon_acpi_init(struct radeon_device *rdev)
51{
52 acpi_handle handle;
53 int ret;
54
Alberto Miloned7a29522010-07-06 11:40:24 -040055 /* Get the device handle */
56 handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev);
57
Jean Delvare48cc9b22011-11-30 17:36:39 +010058 /* No need to proceed if we're sure that ATIF is not supported */
59 if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle)
60 return 0;
61
Alberto Miloned7a29522010-07-06 11:40:24 -040062 /* Call the ATIF method */
63 ret = radeon_atif_call(handle);
64 if (ret)
65 return ret;
66
67 return 0;
68}
69