radeon_acpi.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2012 Advanced Micro Devices, Inc.
  3. *
  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:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  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.
  21. *
  22. */
  23. #include <linux/pci.h>
  24. #include <linux/acpi.h>
  25. #include <linux/slab.h>
  26. #include <acpi/acpi_drivers.h>
  27. #include <acpi/acpi_bus.h>
  28. #include "drmP.h"
  29. #include "drm.h"
  30. #include "drm_sarea.h"
  31. #include "drm_crtc_helper.h"
  32. #include "radeon.h"
  33. #include "radeon_acpi.h"
  34. #include <linux/vga_switcheroo.h>
  35. /* Call the ATIF method
  36. *
  37. * Note: currently we discard the output
  38. */
  39. static int radeon_atif_call(acpi_handle handle)
  40. {
  41. acpi_status status;
  42. union acpi_object atif_arg_elements[2];
  43. struct acpi_object_list atif_arg;
  44. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
  45. atif_arg.count = 2;
  46. atif_arg.pointer = &atif_arg_elements[0];
  47. atif_arg_elements[0].type = ACPI_TYPE_INTEGER;
  48. atif_arg_elements[0].integer.value = ATIF_FUNCTION_VERIFY_INTERFACE;
  49. atif_arg_elements[1].type = ACPI_TYPE_INTEGER;
  50. atif_arg_elements[1].integer.value = 0;
  51. status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer);
  52. /* Fail only if calling the method fails and ATIF is supported */
  53. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  54. DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
  55. acpi_format_exception(status));
  56. kfree(buffer.pointer);
  57. return 1;
  58. }
  59. kfree(buffer.pointer);
  60. return 0;
  61. }
  62. /* Call all ACPI methods here */
  63. int radeon_acpi_init(struct radeon_device *rdev)
  64. {
  65. acpi_handle handle;
  66. int ret;
  67. /* Get the device handle */
  68. handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev);
  69. /* No need to proceed if we're sure that ATIF is not supported */
  70. if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle)
  71. return 0;
  72. /* Call the ATIF method */
  73. ret = radeon_atif_call(handle);
  74. if (ret)
  75. return ret;
  76. return 0;
  77. }