2 * Copyright 2012 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #include <linux/pci.h>
25 #include <linux/acpi.h>
26 #include <linux/slab.h>
27 #include <linux/power_supply.h>
28 #include <linux/pm_runtime.h>
29 #include <acpi/video.h>
31 #include <drm/drm_crtc_helper.h>
33 #include "amdgpu_pm.h"
37 struct amdgpu_atif_notification_cfg
{
42 struct amdgpu_atif_notifications
{
44 bool expansion_mode_change
;
46 bool forced_power_state
;
47 bool system_power_state
;
48 bool display_conf_change
;
50 bool brightness_change
;
51 bool dgpu_display_event
;
54 struct amdgpu_atif_functions
{
57 bool select_active_disp
;
61 bool get_panel_expansion_mode
;
62 bool set_panel_expansion_mode
;
63 bool temperature_change
;
64 bool graphics_device_types
;
70 struct amdgpu_atif_notifications notifications
;
71 struct amdgpu_atif_functions functions
;
72 struct amdgpu_atif_notification_cfg notification_cfg
;
73 struct amdgpu_encoder
*encoder_for_bl
;
76 /* Call the ATIF method
79 * amdgpu_atif_call - call an ATIF method
81 * @handle: acpi handle
82 * @function: the ATIF function to execute
83 * @params: ATIF function params
85 * Executes the requested ATIF function (all asics).
86 * Returns a pointer to the acpi output buffer.
88 static union acpi_object
*amdgpu_atif_call(struct amdgpu_atif
*atif
,
90 struct acpi_buffer
*params
)
93 union acpi_object atif_arg_elements
[2];
94 struct acpi_object_list atif_arg
;
95 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
98 atif_arg
.pointer
= &atif_arg_elements
[0];
100 atif_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
101 atif_arg_elements
[0].integer
.value
= function
;
104 atif_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
105 atif_arg_elements
[1].buffer
.length
= params
->length
;
106 atif_arg_elements
[1].buffer
.pointer
= params
->pointer
;
108 /* We need a second fake parameter */
109 atif_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
110 atif_arg_elements
[1].integer
.value
= 0;
113 status
= acpi_evaluate_object(atif
->handle
, NULL
, &atif_arg
,
116 /* Fail only if calling the method fails and ATIF is supported */
117 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
118 DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
119 acpi_format_exception(status
));
120 kfree(buffer
.pointer
);
124 return buffer
.pointer
;
128 * amdgpu_atif_parse_notification - parse supported notifications
130 * @n: supported notifications struct
131 * @mask: supported notifications mask from ATIF
133 * Use the supported notifications mask from ATIF function
134 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what notifications
135 * are supported (all asics).
137 static void amdgpu_atif_parse_notification(struct amdgpu_atif_notifications
*n
, u32 mask
)
139 n
->display_switch
= mask
& ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED
;
140 n
->expansion_mode_change
= mask
& ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED
;
141 n
->thermal_state
= mask
& ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED
;
142 n
->forced_power_state
= mask
& ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED
;
143 n
->system_power_state
= mask
& ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED
;
144 n
->display_conf_change
= mask
& ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED
;
145 n
->px_gfx_switch
= mask
& ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED
;
146 n
->brightness_change
= mask
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED
;
147 n
->dgpu_display_event
= mask
& ATIF_DGPU_DISPLAY_EVENT_SUPPORTED
;
151 * amdgpu_atif_parse_functions - parse supported functions
153 * @f: supported functions struct
154 * @mask: supported functions mask from ATIF
156 * Use the supported functions mask from ATIF function
157 * ATIF_FUNCTION_VERIFY_INTERFACE to determine what functions
158 * are supported (all asics).
160 static void amdgpu_atif_parse_functions(struct amdgpu_atif_functions
*f
, u32 mask
)
162 f
->system_params
= mask
& ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED
;
163 f
->sbios_requests
= mask
& ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED
;
164 f
->select_active_disp
= mask
& ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED
;
165 f
->lid_state
= mask
& ATIF_GET_LID_STATE_SUPPORTED
;
166 f
->get_tv_standard
= mask
& ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED
;
167 f
->set_tv_standard
= mask
& ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED
;
168 f
->get_panel_expansion_mode
= mask
& ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED
;
169 f
->set_panel_expansion_mode
= mask
& ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED
;
170 f
->temperature_change
= mask
& ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED
;
171 f
->graphics_device_types
= mask
& ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED
;
175 * amdgpu_atif_verify_interface - verify ATIF
177 * @handle: acpi handle
178 * @atif: amdgpu atif struct
180 * Execute the ATIF_FUNCTION_VERIFY_INTERFACE ATIF function
181 * to initialize ATIF and determine what features are supported
183 * returns 0 on success, error on failure.
185 static int amdgpu_atif_verify_interface(struct amdgpu_atif
*atif
)
187 union acpi_object
*info
;
188 struct atif_verify_interface output
;
192 info
= amdgpu_atif_call(atif
, ATIF_FUNCTION_VERIFY_INTERFACE
, NULL
);
196 memset(&output
, 0, sizeof(output
));
198 size
= *(u16
*) info
->buffer
.pointer
;
200 DRM_INFO("ATIF buffer is too small: %zu\n", size
);
204 size
= min(sizeof(output
), size
);
206 memcpy(&output
, info
->buffer
.pointer
, size
);
208 /* TODO: check version? */
209 DRM_DEBUG_DRIVER("ATIF version %u\n", output
.version
);
211 amdgpu_atif_parse_notification(&atif
->notifications
, output
.notification_mask
);
212 amdgpu_atif_parse_functions(&atif
->functions
, output
.function_bits
);
219 static acpi_handle
amdgpu_atif_probe_handle(acpi_handle dhandle
)
221 acpi_handle handle
= NULL
;
222 char acpi_method_name
[255] = { 0 };
223 struct acpi_buffer buffer
= { sizeof(acpi_method_name
), acpi_method_name
};
226 /* For PX/HG systems, ATIF and ATPX are in the iGPU's namespace, on dGPU only
227 * systems, ATIF is in the dGPU's namespace.
229 status
= acpi_get_handle(dhandle
, "ATIF", &handle
);
230 if (ACPI_SUCCESS(status
))
233 if (amdgpu_has_atpx()) {
234 status
= acpi_get_handle(amdgpu_atpx_get_dhandle(), "ATIF",
236 if (ACPI_SUCCESS(status
))
240 DRM_DEBUG_DRIVER("No ATIF handle found\n");
243 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
244 DRM_DEBUG_DRIVER("Found ATIF handle %s\n", acpi_method_name
);
249 * amdgpu_atif_get_notification_params - determine notify configuration
251 * @handle: acpi handle
252 * @n: atif notification configuration struct
254 * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function
255 * to determine if a notifier is used and if so which one
256 * (all asics). This is either Notify(VGA, 0x81) or Notify(VGA, n)
257 * where n is specified in the result if a notifier is used.
258 * Returns 0 on success, error on failure.
260 static int amdgpu_atif_get_notification_params(struct amdgpu_atif
*atif
)
262 union acpi_object
*info
;
263 struct amdgpu_atif_notification_cfg
*n
= &atif
->notification_cfg
;
264 struct atif_system_params params
;
268 info
= amdgpu_atif_call(atif
, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
,
275 size
= *(u16
*) info
->buffer
.pointer
;
281 memset(¶ms
, 0, sizeof(params
));
282 size
= min(sizeof(params
), size
);
283 memcpy(¶ms
, info
->buffer
.pointer
, size
);
285 DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
286 params
.flags
, params
.valid_mask
);
287 params
.flags
= params
.flags
& params
.valid_mask
;
289 if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_NONE
) {
292 } else if ((params
.flags
& ATIF_NOTIFY_MASK
) == ATIF_NOTIFY_81
) {
294 n
->command_code
= 0x81;
301 n
->command_code
= params
.command_code
;
305 DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
306 (n
->enabled
? "enabled" : "disabled"),
313 * amdgpu_atif_get_sbios_requests - get requested sbios event
315 * @handle: acpi handle
316 * @req: atif sbios request struct
318 * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function
319 * to determine what requests the sbios is making to the driver
321 * Returns 0 on success, error on failure.
323 static int amdgpu_atif_get_sbios_requests(struct amdgpu_atif
*atif
,
324 struct atif_sbios_requests
*req
)
326 union acpi_object
*info
;
330 info
= amdgpu_atif_call(atif
, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
,
335 size
= *(u16
*)info
->buffer
.pointer
;
340 memset(req
, 0, sizeof(*req
));
342 size
= min(sizeof(*req
), size
);
343 memcpy(req
, info
->buffer
.pointer
, size
);
344 DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req
->pending
);
346 count
= hweight32(req
->pending
);
354 * amdgpu_atif_handler - handle ATIF notify requests
356 * @adev: amdgpu_device pointer
357 * @event: atif sbios request struct
359 * Checks the acpi event and if it matches an atif event,
363 * NOTIFY_BAD or NOTIFY_DONE, depending on the event.
365 static int amdgpu_atif_handler(struct amdgpu_device
*adev
,
366 struct acpi_bus_event
*event
)
368 struct amdgpu_atif
*atif
= adev
->atif
;
371 DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
372 event
->device_class
, event
->type
);
374 if (strcmp(event
->device_class
, ACPI_VIDEO_CLASS
) != 0)
377 /* Is this actually our event? */
379 !atif
->notification_cfg
.enabled
||
380 event
->type
!= atif
->notification_cfg
.command_code
) {
381 /* These events will generate keypresses otherwise */
382 if (event
->type
== ACPI_VIDEO_NOTIFY_PROBE
)
388 if (atif
->functions
.sbios_requests
) {
389 struct atif_sbios_requests req
;
391 /* Check pending SBIOS requests */
392 count
= amdgpu_atif_get_sbios_requests(atif
, &req
);
397 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count
);
399 /* todo: add DC handling */
400 if ((req
.pending
& ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST
) &&
401 !amdgpu_device_has_dc_support(adev
)) {
402 struct amdgpu_encoder
*enc
= atif
->encoder_for_bl
;
405 struct amdgpu_encoder_atom_dig
*dig
= enc
->enc_priv
;
407 DRM_DEBUG_DRIVER("Changing brightness to %d\n",
408 req
.backlight_level
);
410 amdgpu_display_backlight_set_level(adev
, enc
, req
.backlight_level
);
412 #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
413 backlight_force_update(dig
->bl_dev
,
414 BACKLIGHT_UPDATE_HOTKEY
);
418 if (req
.pending
& ATIF_DGPU_DISPLAY_EVENT
) {
419 if (adev
->flags
& AMD_IS_PX
) {
420 pm_runtime_get_sync(adev
->ddev
->dev
);
421 /* Just fire off a uevent and let userspace tell us what to do */
422 drm_helper_hpd_irq_event(adev
->ddev
);
423 pm_runtime_mark_last_busy(adev
->ddev
->dev
);
424 pm_runtime_put_autosuspend(adev
->ddev
->dev
);
427 /* TODO: check other events */
430 /* We've handled the event, stop the notifier chain. The ACPI interface
431 * overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to
432 * userspace if the event was generated only to signal a SBIOS
438 /* Call the ATCS method
441 * amdgpu_atcs_call - call an ATCS method
443 * @handle: acpi handle
444 * @function: the ATCS function to execute
445 * @params: ATCS function params
447 * Executes the requested ATCS function (all asics).
448 * Returns a pointer to the acpi output buffer.
450 static union acpi_object
*amdgpu_atcs_call(acpi_handle handle
, int function
,
451 struct acpi_buffer
*params
)
454 union acpi_object atcs_arg_elements
[2];
455 struct acpi_object_list atcs_arg
;
456 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
459 atcs_arg
.pointer
= &atcs_arg_elements
[0];
461 atcs_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
462 atcs_arg_elements
[0].integer
.value
= function
;
465 atcs_arg_elements
[1].type
= ACPI_TYPE_BUFFER
;
466 atcs_arg_elements
[1].buffer
.length
= params
->length
;
467 atcs_arg_elements
[1].buffer
.pointer
= params
->pointer
;
469 /* We need a second fake parameter */
470 atcs_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
471 atcs_arg_elements
[1].integer
.value
= 0;
474 status
= acpi_evaluate_object(handle
, "ATCS", &atcs_arg
, &buffer
);
476 /* Fail only if calling the method fails and ATIF is supported */
477 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
) {
478 DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
479 acpi_format_exception(status
));
480 kfree(buffer
.pointer
);
484 return buffer
.pointer
;
488 * amdgpu_atcs_parse_functions - parse supported functions
490 * @f: supported functions struct
491 * @mask: supported functions mask from ATCS
493 * Use the supported functions mask from ATCS function
494 * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions
495 * are supported (all asics).
497 static void amdgpu_atcs_parse_functions(struct amdgpu_atcs_functions
*f
, u32 mask
)
499 f
->get_ext_state
= mask
& ATCS_GET_EXTERNAL_STATE_SUPPORTED
;
500 f
->pcie_perf_req
= mask
& ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED
;
501 f
->pcie_dev_rdy
= mask
& ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED
;
502 f
->pcie_bus_width
= mask
& ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED
;
506 * amdgpu_atcs_verify_interface - verify ATCS
508 * @handle: acpi handle
509 * @atcs: amdgpu atcs struct
511 * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function
512 * to initialize ATCS and determine what features are supported
514 * returns 0 on success, error on failure.
516 static int amdgpu_atcs_verify_interface(acpi_handle handle
,
517 struct amdgpu_atcs
*atcs
)
519 union acpi_object
*info
;
520 struct atcs_verify_interface output
;
524 info
= amdgpu_atcs_call(handle
, ATCS_FUNCTION_VERIFY_INTERFACE
, NULL
);
528 memset(&output
, 0, sizeof(output
));
530 size
= *(u16
*) info
->buffer
.pointer
;
532 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
536 size
= min(sizeof(output
), size
);
538 memcpy(&output
, info
->buffer
.pointer
, size
);
540 /* TODO: check version? */
541 DRM_DEBUG_DRIVER("ATCS version %u\n", output
.version
);
543 amdgpu_atcs_parse_functions(&atcs
->functions
, output
.function_bits
);
551 * amdgpu_acpi_is_pcie_performance_request_supported
553 * @adev: amdgpu_device pointer
555 * Check if the ATCS pcie_perf_req and pcie_dev_rdy methods
556 * are supported (all asics).
557 * returns true if supported, false if not.
559 bool amdgpu_acpi_is_pcie_performance_request_supported(struct amdgpu_device
*adev
)
561 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
563 if (atcs
->functions
.pcie_perf_req
&& atcs
->functions
.pcie_dev_rdy
)
570 * amdgpu_acpi_pcie_notify_device_ready
572 * @adev: amdgpu_device pointer
574 * Executes the PCIE_DEVICE_READY_NOTIFICATION method
576 * returns 0 on success, error on failure.
578 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device
*adev
)
581 union acpi_object
*info
;
582 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
584 /* Get the device handle */
585 handle
= ACPI_HANDLE(&adev
->pdev
->dev
);
589 if (!atcs
->functions
.pcie_dev_rdy
)
592 info
= amdgpu_atcs_call(handle
, ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
, NULL
);
602 * amdgpu_acpi_pcie_performance_request
604 * @adev: amdgpu_device pointer
605 * @perf_req: requested perf level (pcie gen speed)
606 * @advertise: set advertise caps flag if set
608 * Executes the PCIE_PERFORMANCE_REQUEST method to
609 * change the pcie gen speed (all asics).
610 * returns 0 on success, error on failure.
612 int amdgpu_acpi_pcie_performance_request(struct amdgpu_device
*adev
,
613 u8 perf_req
, bool advertise
)
616 union acpi_object
*info
;
617 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
618 struct atcs_pref_req_input atcs_input
;
619 struct atcs_pref_req_output atcs_output
;
620 struct acpi_buffer params
;
624 if (amdgpu_acpi_pcie_notify_device_ready(adev
))
627 /* Get the device handle */
628 handle
= ACPI_HANDLE(&adev
->pdev
->dev
);
632 if (!atcs
->functions
.pcie_perf_req
)
635 atcs_input
.size
= sizeof(struct atcs_pref_req_input
);
636 /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
637 atcs_input
.client_id
= adev
->pdev
->devfn
| (adev
->pdev
->bus
->number
<< 8);
638 atcs_input
.valid_flags_mask
= ATCS_VALID_FLAGS_MASK
;
639 atcs_input
.flags
= ATCS_WAIT_FOR_COMPLETION
;
641 atcs_input
.flags
|= ATCS_ADVERTISE_CAPS
;
642 atcs_input
.req_type
= ATCS_PCIE_LINK_SPEED
;
643 atcs_input
.perf_req
= perf_req
;
645 params
.length
= sizeof(struct atcs_pref_req_input
);
646 params
.pointer
= &atcs_input
;
649 info
= amdgpu_atcs_call(handle
, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
, ¶ms
);
653 memset(&atcs_output
, 0, sizeof(atcs_output
));
655 size
= *(u16
*) info
->buffer
.pointer
;
657 DRM_INFO("ATCS buffer is too small: %zu\n", size
);
661 size
= min(sizeof(atcs_output
), size
);
663 memcpy(&atcs_output
, info
->buffer
.pointer
, size
);
667 switch (atcs_output
.ret_val
) {
668 case ATCS_REQUEST_REFUSED
:
671 case ATCS_REQUEST_COMPLETE
:
673 case ATCS_REQUEST_IN_PROGRESS
:
683 * amdgpu_acpi_event - handle notify events
685 * @nb: notifier block
689 * Calls relevant amdgpu functions in response to various
691 * Returns NOTIFY code
693 static int amdgpu_acpi_event(struct notifier_block
*nb
,
697 struct amdgpu_device
*adev
= container_of(nb
, struct amdgpu_device
, acpi_nb
);
698 struct acpi_bus_event
*entry
= (struct acpi_bus_event
*)data
;
700 if (strcmp(entry
->device_class
, ACPI_AC_CLASS
) == 0) {
701 if (power_supply_is_system_supplied() > 0)
702 DRM_DEBUG_DRIVER("pm: AC\n");
704 DRM_DEBUG_DRIVER("pm: DC\n");
706 amdgpu_pm_acpi_event_handler(adev
);
709 /* Check for pending SBIOS requests */
710 return amdgpu_atif_handler(adev
, entry
);
713 /* Call all ACPI methods here */
715 * amdgpu_acpi_init - init driver acpi support
717 * @adev: amdgpu_device pointer
719 * Verifies the AMD ACPI interfaces and registers with the acpi
720 * notifier chain (all asics).
721 * Returns 0 on success, error on failure.
723 int amdgpu_acpi_init(struct amdgpu_device
*adev
)
725 acpi_handle handle
, atif_handle
;
726 struct amdgpu_atif
*atif
;
727 struct amdgpu_atcs
*atcs
= &adev
->atcs
;
730 /* Get the device handle */
731 handle
= ACPI_HANDLE(&adev
->pdev
->dev
);
733 if (!adev
->bios
|| !handle
)
736 /* Call the ATCS method */
737 ret
= amdgpu_atcs_verify_interface(handle
, atcs
);
739 DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret
);
742 /* Probe for ATIF, and initialize it if found */
743 atif_handle
= amdgpu_atif_probe_handle(handle
);
747 atif
= kzalloc(sizeof(*atif
), GFP_KERNEL
);
749 DRM_WARN("Not enough memory to initialize ATIF\n");
752 atif
->handle
= atif_handle
;
754 /* Call the ATIF method */
755 ret
= amdgpu_atif_verify_interface(atif
);
757 DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret
);
763 if (atif
->notifications
.brightness_change
) {
764 struct drm_encoder
*tmp
;
766 /* Find the encoder controlling the brightness */
767 list_for_each_entry(tmp
, &adev
->ddev
->mode_config
.encoder_list
,
769 struct amdgpu_encoder
*enc
= to_amdgpu_encoder(tmp
);
771 if ((enc
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) &&
773 struct amdgpu_encoder_atom_dig
*dig
= enc
->enc_priv
;
775 atif
->encoder_for_bl
= enc
;
782 if (atif
->functions
.sbios_requests
&& !atif
->functions
.system_params
) {
783 /* XXX check this workraround, if sbios request function is
784 * present we have to see how it's configured in the system
787 atif
->functions
.system_params
= true;
790 if (atif
->functions
.system_params
) {
791 ret
= amdgpu_atif_get_notification_params(atif
);
793 DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
795 /* Disable notification */
796 atif
->notification_cfg
.enabled
= false;
801 adev
->acpi_nb
.notifier_call
= amdgpu_acpi_event
;
802 register_acpi_notifier(&adev
->acpi_nb
);
808 * amdgpu_acpi_fini - tear down driver acpi support
810 * @adev: amdgpu_device pointer
812 * Unregisters with the acpi notifier chain (all asics).
814 void amdgpu_acpi_fini(struct amdgpu_device
*adev
)
816 unregister_acpi_notifier(&adev
->acpi_nb
);