Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 1 | #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 Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame^] | 7 | #include <drm/drmP.h> |
| 8 | #include <drm/drm_crtc_helper.h> |
Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 9 | #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 | */ |
| 17 | static 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 Delvare | bc96f94 | 2011-11-30 17:26:36 +0100 | [diff] [blame] | 36 | DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n", |
| 37 | acpi_format_exception(status)); |
Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 38 | kfree(buffer.pointer); |
| 39 | return 1; |
| 40 | } |
| 41 | |
| 42 | kfree(buffer.pointer); |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | /* Call all ACPI methods here */ |
| 47 | int radeon_acpi_init(struct radeon_device *rdev) |
| 48 | { |
| 49 | acpi_handle handle; |
| 50 | int ret; |
| 51 | |
Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 52 | /* Get the device handle */ |
| 53 | handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); |
| 54 | |
Jean Delvare | 48cc9b2 | 2011-11-30 17:36:39 +0100 | [diff] [blame] | 55 | /* 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 Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 59 | /* Call the ATIF method */ |
| 60 | ret = radeon_atif_call(handle); |
| 61 | if (ret) |
| 62 | return ret; |
| 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |