blob: 215063e1a29220f3e21ba231e926f1b527f5b321 [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
David Howells760285e2012-10-02 18:01:07 +01007#include <drm/drmP.h>
8#include <drm/drm_crtc_helper.h>
Alberto Miloned7a29522010-07-06 11:40:24 -04009#include "radeon.h"
10
11#include <linux/vga_switcheroo.h>
12
13/* Call the ATIF method
14 *
15 * Note: currently we discard the output
16 */
17static int radeon_atif_call(acpi_handle handle)
18{
19 acpi_status status;
20 union acpi_object atif_arg_elements[2];
21 struct acpi_object_list atif_arg;
22 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
23
24 atif_arg.count = 2;
25 atif_arg.pointer = &atif_arg_elements[0];
26
27 atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
28 atif_arg_elements[0].integer.value = 0;
29 atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
30 atif_arg_elements[1].integer.value = 0;
31
32 status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer);
33
34 /* Fail only if calling the method fails and ATIF is supported */
35 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
Jean Delvarebc96f942011-11-30 17:26:36 +010036 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
37 acpi_format_exception(status));
Alberto Miloned7a29522010-07-06 11:40:24 -040038 kfree(buffer.pointer);
39 return 1;
40 }
41
42 kfree(buffer.pointer);
43 return 0;
44}
45
46/* Call all ACPI methods here */
47int radeon_acpi_init(struct radeon_device *rdev)
48{
49 acpi_handle handle;
50 int ret;
51
Alberto Miloned7a29522010-07-06 11:40:24 -040052 /* Get the device handle */
53 handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev);
54
Jean Delvare48cc9b22011-11-30 17:36:39 +010055 /* No need to proceed if we're sure that ATIF is not supported */
56 if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle)
57 return 0;
58
Alberto Miloned7a29522010-07-06 11:40:24 -040059 /* Call the ATIF method */
60 ret = radeon_atif_call(handle);
61 if (ret)
62 return ret;
63
64 return 0;
65}
66