linux/drivers/gpu/drm/amd/include/amd_acpi.h

/*
 * Copyright 2012 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef AMD_ACPI_H
#define AMD_ACPI_H

#define ACPI_AC_CLASS

struct atif_verify_interface {} __packed;

struct atif_system_params {} __packed;

struct atif_sbios_requests {} __packed;

struct atif_qbtc_arguments {} __packed;

#define ATIF_QBTC_MAX_DATA_POINTS

struct atif_qbtc_data_point {} __packed;

struct atif_qbtc_output {} __packed;

#define ATIF_NOTIFY_MASK
#define ATIF_NOTIFY_NONE
#define ATIF_NOTIFY_81
#define ATIF_NOTIFY_N

struct atcs_verify_interface {} __packed;

#define ATCS_VALID_FLAGS_MASK

struct atcs_pref_req_input {} __packed;

struct atcs_pref_req_output {} __packed;

struct atcs_pwr_shift_input {} __packed;

/* AMD hw uses four ACPI control methods:
 * 1. ATIF
 * ARG0: (ACPI_INTEGER) function code
 * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
 * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
 * ATIF provides an entry point for the gfx driver to interact with the sbios.
 * The AMD ACPI notification mechanism uses Notify (VGA, 0x81) or a custom
 * notification. Which notification is used as indicated by the ATIF Control
 * Method GET_SYSTEM_PARAMETERS. When the driver receives Notify (VGA, 0x81) or
 * a custom notification it invokes ATIF Control Method GET_SYSTEM_BIOS_REQUESTS
 * to identify pending System BIOS requests and associated parameters. For
 * example, if one of the pending requests is DISPLAY_SWITCH_REQUEST, the driver
 * will perform display device detection and invoke ATIF Control Method
 * SELECT_ACTIVE_DISPLAYS.
 *
 * 2. ATPX
 * ARG0: (ACPI_INTEGER) function code
 * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
 * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
 * ATPX methods are used on PowerXpress systems to handle mux switching and
 * discrete GPU power control.
 *
 * 3. ATRM
 * ARG0: (ACPI_INTEGER) offset of vbios rom data
 * ARG1: (ACPI_BUFFER) size of the buffer to fill (up to 4K).
 * OUTPUT: (ACPI_BUFFER) output buffer
 * ATRM provides an interfacess to access the discrete GPU vbios image on
 * PowerXpress systems with multiple GPUs.
 *
 * 4. ATCS
 * ARG0: (ACPI_INTEGER) function code
 * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
 * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
 * ATCS provides an interface to AMD chipset specific functionality.
 *
 */
/* ATIF */
#define ATIF_FUNCTION_VERIFY_INTERFACE
/* ARG0: ATIF_FUNCTION_VERIFY_INTERFACE
 * ARG1: none
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - version
 * DWORD - supported notifications mask
 * DWORD - supported functions bit vector
 */
/* Notifications mask */
#define ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED
#define ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED
#define ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED
#define ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED
#define ATIF_DGPU_DISPLAY_EVENT_SUPPORTED
#define ATIF_GPU_PACKAGE_POWER_LIMIT_REQUEST_SUPPORTED
/* supported functions vector */
#define ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED
#define ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED
#define ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED
#define ATIF_QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS_SUPPORTED
#define ATIF_READY_TO_UNDOCK_NOTIFICATION_SUPPORTED
#define ATIF_GET_EXTERNAL_GPU_INFORMATION_SUPPORTED
#define ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
/* ARG0: ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
 * ARG1: none
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * DWORD - valid flags mask
 * DWORD - flags
 *
 * OR
 *
 * WORD  - structure size in bytes (includes size field)
 * DWORD - valid flags mask
 * DWORD - flags
 * BYTE  - notify command code
 *
 * flags
 * bits 1:0:
 * 0 - Notify(VGA, 0x81) is not used for notification
 * 1 - Notify(VGA, 0x81) is used for notification
 * 2 - Notify(VGA, n) is used for notification where
 * n (0xd0-0xd9) is specified in notify command code.
 * bit 2:
 * 1 - lid changes not reported though int10
 * bit 3:
 * 1 - system bios controls overclocking
 * bit 4:
 * 1 - enable overclocking
 */
#define ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
/* ARG0: ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
 * ARG1: none
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * DWORD - pending sbios requests
 * BYTE  - reserved (all zeroes)
 * BYTE  - thermal state: target gfx controller
 * BYTE  - thermal state: state id (0: exit state, non-0: state)
 * BYTE  - forced power state: target gfx controller
 * BYTE  - forced power state: state id (0: forced state, non-0: state)
 * BYTE  - system power source
 * BYTE  - panel backlight level (0-255)
 * BYTE  - GPU package power limit: target gfx controller
 * DWORD - GPU package power limit: value (24:8 fractional format, Watts)
 */
/* pending sbios requests */
#define ATIF_THERMAL_STATE_CHANGE_REQUEST
#define ATIF_FORCED_POWER_STATE_CHANGE_REQUEST
#define ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST
#define ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST
#define ATIF_DGPU_DISPLAY_EVENT
#define ATIF_GPU_PACKAGE_POWER_LIMIT_REQUEST
/* target gfx controller */
#define ATIF_TARGET_GFX_SINGLE
#define ATIF_TARGET_GFX_PX_IGPU
#define ATIF_TARGET_GFX_PX_DGPU
/* system power source */
#define ATIF_POWER_SOURCE_AC
#define ATIF_POWER_SOURCE_DC
#define ATIF_POWER_SOURCE_RESTRICTED_AC_1
#define ATIF_POWER_SOURCE_RESTRICTED_AC_2
#define ATIF_FUNCTION_TEMPERATURE_CHANGE_NOTIFICATION
/* ARG0: ATIF_FUNCTION_TEMPERATURE_CHANGE_NOTIFICATION
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - gfx controller id
 * BYTE  - current temperature (degress Celsius)
 * OUTPUT: none
 */
#define ATIF_FUNCTION_QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS
/* ARG0: ATIF_FUNCTION_QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * BYTE  - requested display
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - flags (currently all 16 bits are reserved)
 * BYTE  - error code (on failure, disregard all below fields)
 * BYTE  - AC level (default brightness in percent when machine has full power)
 * BYTE  - DC level (default brightness in percent when machine is on battery)
 * BYTE  - min input signal, in range 0-255, corresponding to 0% backlight
 * BYTE  - max input signal, in range 0-255, corresponding to 100% backlight
 * BYTE  - number of reported data points
 * BYTE  - luminance level in percent  \ repeated structure
 * BYTE  - input signal in range 0-255 / does not have entries for 0% and 100%
 */
/* requested display */
#define ATIF_QBTC_REQUEST_LCD1
#define ATIF_QBTC_REQUEST_CRT1
#define ATIF_QBTC_REQUEST_DFP1
#define ATIF_QBTC_REQUEST_CRT2
#define ATIF_QBTC_REQUEST_LCD2
#define ATIF_QBTC_REQUEST_DFP2
#define ATIF_QBTC_REQUEST_DFP3
#define ATIF_QBTC_REQUEST_DFP4
#define ATIF_QBTC_REQUEST_DFP5
#define ATIF_QBTC_REQUEST_DFP6
/* error code */
#define ATIF_QBTC_ERROR_CODE_SUCCESS
#define ATIF_QBTC_ERROR_CODE_FAILURE
#define ATIF_QBTC_ERROR_CODE_DEVICE_NOT_SUPPORTED
#define ATIF_FUNCTION_READY_TO_UNDOCK_NOTIFICATION
/* ARG0: ATIF_FUNCTION_READY_TO_UNDOCK_NOTIFICATION
 * ARG1: none
 * OUTPUT: none
 */
#define ATIF_FUNCTION_GET_EXTERNAL_GPU_INFORMATION
/* ARG0: ATIF_FUNCTION_GET_EXTERNAL_GPU_INFORMATION
 * ARG1: none
 * OUTPUT:
 * WORD  - number of reported external gfx devices
 * WORD  - device structure size in bytes (excludes device size field)
 * WORD  - flags         \
 * WORD  - bus number    / repeated structure
 */
/* flags */
#define ATIF_EXTERNAL_GRAPHICS_PORT

/* ATPX */
#define ATPX_FUNCTION_VERIFY_INTERFACE
/* ARG0: ATPX_FUNCTION_VERIFY_INTERFACE
 * ARG1: none
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - version
 * DWORD - supported functions bit vector
 */
/* supported functions vector */
#define ATPX_GET_PX_PARAMETERS_SUPPORTED
#define ATPX_POWER_CONTROL_SUPPORTED
#define ATPX_DISPLAY_MUX_CONTROL_SUPPORTED
#define ATPX_I2C_MUX_CONTROL_SUPPORTED
#define ATPX_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION_SUPPORTED
#define ATPX_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION_SUPPORTED
#define ATPX_GET_DISPLAY_CONNECTORS_MAPPING_SUPPORTED
#define ATPX_GET_DISPLAY_DETECTION_PORTS_SUPPORTED
#define ATPX_FUNCTION_GET_PX_PARAMETERS
/* ARG0: ATPX_FUNCTION_GET_PX_PARAMETERS
 * ARG1: none
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * DWORD - valid flags mask
 * DWORD - flags
 */
/* flags */
#define ATPX_LVDS_I2C_AVAILABLE_TO_BOTH_GPUS
#define ATPX_CRT1_I2C_AVAILABLE_TO_BOTH_GPUS
#define ATPX_DVI1_I2C_AVAILABLE_TO_BOTH_GPUS
#define ATPX_CRT1_RGB_SIGNAL_MUXED
#define ATPX_TV_SIGNAL_MUXED
#define ATPX_DFP_SIGNAL_MUXED
#define ATPX_SEPARATE_MUX_FOR_I2C
#define ATPX_DYNAMIC_PX_SUPPORTED
#define ATPX_ACF_NOT_SUPPORTED
#define ATPX_FIXED_NOT_SUPPORTED
#define ATPX_DYNAMIC_DGPU_POWER_OFF_SUPPORTED
#define ATPX_DGPU_REQ_POWER_FOR_DISPLAYS
#define ATPX_DGPU_CAN_DRIVE_DISPLAYS
#define ATPX_MS_HYBRID_GFX_SUPPORTED
#define ATPX_FUNCTION_POWER_CONTROL
/* ARG0: ATPX_FUNCTION_POWER_CONTROL
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * BYTE  - dGPU power state (0: power off, 1: power on)
 * OUTPUT: none
 */
#define ATPX_FUNCTION_DISPLAY_MUX_CONTROL
/* ARG0: ATPX_FUNCTION_DISPLAY_MUX_CONTROL
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - display mux control (0: iGPU, 1: dGPU)
 * OUTPUT: none
 */
#define ATPX_INTEGRATED_GPU
#define ATPX_DISCRETE_GPU
#define ATPX_FUNCTION_I2C_MUX_CONTROL
/* ARG0: ATPX_FUNCTION_I2C_MUX_CONTROL
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - i2c/aux/hpd mux control (0: iGPU, 1: dGPU)
 * OUTPUT: none
 */
#define ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION
/* ARG0: ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - target gpu (0: iGPU, 1: dGPU)
 * OUTPUT: none
 */
#define ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION
/* ARG0: ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - target gpu (0: iGPU, 1: dGPU)
 * OUTPUT: none
 */
#define ATPX_FUNCTION_GET_DISPLAY_CONNECTORS_MAPPING
/* ARG0: ATPX_FUNCTION_GET_DISPLAY_CONNECTORS_MAPPING
 * ARG1: none
 * OUTPUT:
 * WORD  - number of display connectors
 * WORD  - connector structure size in bytes (excludes connector size field)
 * BYTE  - flags                                                     \
 * BYTE  - ATIF display vector bit position                           } repeated
 * BYTE  - adapter id (0: iGPU, 1-n: dGPU ordered by pcie bus number) } structure
 * WORD  - connector ACPI id                                         /
 */
/* flags */
#define ATPX_DISPLAY_OUTPUT_SUPPORTED_BY_ADAPTER_ID_DEVICE
#define ATPX_DISPLAY_HPD_SUPPORTED_BY_ADAPTER_ID_DEVICE
#define ATPX_DISPLAY_I2C_SUPPORTED_BY_ADAPTER_ID_DEVICE
#define ATPX_FUNCTION_GET_DISPLAY_DETECTION_PORTS
/* ARG0: ATPX_FUNCTION_GET_DISPLAY_DETECTION_PORTS
 * ARG1: none
 * OUTPUT:
 * WORD  - number of HPD/DDC ports
 * WORD  - port structure size in bytes (excludes port size field)
 * BYTE  - ATIF display vector bit position \
 * BYTE  - hpd id                            } reapeated structure
 * BYTE  - ddc id                           /
 *
 * available on A+A systems only
 */
/* hpd id */
#define ATPX_HPD_NONE
#define ATPX_HPD1
#define ATPX_HPD2
#define ATPX_HPD3
#define ATPX_HPD4
#define ATPX_HPD5
#define ATPX_HPD6
/* ddc id */
#define ATPX_DDC_NONE
#define ATPX_DDC1
#define ATPX_DDC2
#define ATPX_DDC3
#define ATPX_DDC4
#define ATPX_DDC5
#define ATPX_DDC6
#define ATPX_DDC7
#define ATPX_DDC8

/* ATCS */
#define ATCS_FUNCTION_VERIFY_INTERFACE
/* ARG0: ATCS_FUNCTION_VERIFY_INTERFACE
 * ARG1: none
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - version
 * DWORD - supported functions bit vector
 */
/* supported functions vector */
#define ATCS_GET_EXTERNAL_STATE_SUPPORTED
#define ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED
#define ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED
#define ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED
#define ATCS_SET_POWER_SHIFT_CONTROL_SUPPORTED
#define ATCS_FUNCTION_GET_EXTERNAL_STATE
/* ARG0: ATCS_FUNCTION_GET_EXTERNAL_STATE
 * ARG1: none
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * DWORD - valid flags mask
 * DWORD - flags (0: undocked, 1: docked)
 */
/* flags */
#define ATCS_DOCKED
#define ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
/* ARG0: ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
 * WORD  - valid flags mask
 * WORD  - flags
 * BYTE  - request type
 * BYTE  - performance request
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * BYTE  - return value
 */
/* flags */
#define ATCS_ADVERTISE_CAPS
#define ATCS_WAIT_FOR_COMPLETION
/* request type */
#define ATCS_PCIE_LINK_SPEED
/* performance request */
#define ATCS_REMOVE
#define ATCS_FORCE_LOW_POWER
#define ATCS_PERF_LEVEL_1
#define ATCS_PERF_LEVEL_2
#define ATCS_PERF_LEVEL_3
/* return value */
#define ATCS_REQUEST_REFUSED
#define ATCS_REQUEST_COMPLETE
#define ATCS_REQUEST_IN_PROGRESS
#define ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
/* ARG0: ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
 * ARG1: none
 * OUTPUT: none
 */
#define ATCS_FUNCTION_SET_PCIE_BUS_WIDTH
/* ARG0: ATCS_FUNCTION_SET_PCIE_BUS_WIDTH
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
 * BYTE  - number of active lanes
 * OUTPUT:
 * WORD  - structure size in bytes (includes size field)
 * BYTE  - number of active lanes
 */

#define ATCS_FUNCTION_POWER_SHIFT_CONTROL
/* ARG0: ATCS_FUNCTION_POWER_SHIFT_CONTROL
 * ARG1:
 * WORD  - structure size in bytes (includes size field)
 * WORD  - dGPU id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
 * BYTE  - Device ACPI state
 * BYTE  - Driver state
 * OUTPUT: none
 */

#endif