162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2012 Advanced Micro Devices, Inc.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
1262306a36Sopenharmony_ci * all copies or substantial portions of the Software.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#ifndef AMD_ACPI_H
2562306a36Sopenharmony_ci#define AMD_ACPI_H
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#define ACPI_AC_CLASS           "ac_adapter"
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_cistruct atif_verify_interface {
3062306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
3162306a36Sopenharmony_ci	u16 version;		/* version */
3262306a36Sopenharmony_ci	u32 notification_mask;	/* supported notifications mask */
3362306a36Sopenharmony_ci	u32 function_bits;	/* supported functions bit vector */
3462306a36Sopenharmony_ci} __packed;
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistruct atif_system_params {
3762306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
3862306a36Sopenharmony_ci	u32 valid_mask;		/* valid flags mask */
3962306a36Sopenharmony_ci	u32 flags;		/* flags */
4062306a36Sopenharmony_ci	u8 command_code;	/* notify command code */
4162306a36Sopenharmony_ci} __packed;
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_cistruct atif_sbios_requests {
4462306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
4562306a36Sopenharmony_ci	u32 pending;		/* pending sbios requests */
4662306a36Sopenharmony_ci	u8 panel_exp_mode;	/* panel expansion mode */
4762306a36Sopenharmony_ci	u8 thermal_gfx;		/* thermal state: target gfx controller */
4862306a36Sopenharmony_ci	u8 thermal_state;	/* thermal state: state id (0: exit state, non-0: state) */
4962306a36Sopenharmony_ci	u8 forced_power_gfx;	/* forced power state: target gfx controller */
5062306a36Sopenharmony_ci	u8 forced_power_state;	/* forced power state: state id */
5162306a36Sopenharmony_ci	u8 system_power_src;	/* system power source */
5262306a36Sopenharmony_ci	u8 backlight_level;	/* panel backlight level (0-255) */
5362306a36Sopenharmony_ci} __packed;
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_cistruct atif_qbtc_arguments {
5662306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
5762306a36Sopenharmony_ci	u8 requested_display;	/* which display is requested */
5862306a36Sopenharmony_ci} __packed;
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define ATIF_QBTC_MAX_DATA_POINTS 99
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistruct atif_qbtc_data_point {
6362306a36Sopenharmony_ci	u8 luminance;		/* luminance in percent */
6462306a36Sopenharmony_ci	u8 ipnut_signal;	/* input signal in range 0-255 */
6562306a36Sopenharmony_ci} __packed;
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cistruct atif_qbtc_output {
6862306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
6962306a36Sopenharmony_ci	u16 flags;		/* all zeroes */
7062306a36Sopenharmony_ci	u8 error_code;		/* error code */
7162306a36Sopenharmony_ci	u8 ac_level;		/* default brightness on AC power */
7262306a36Sopenharmony_ci	u8 dc_level;		/* default brightness on DC power */
7362306a36Sopenharmony_ci	u8 min_input_signal;	/* max input signal in range 0-255 */
7462306a36Sopenharmony_ci	u8 max_input_signal;	/* min input signal in range 0-255 */
7562306a36Sopenharmony_ci	u8 number_of_points;	/* number of data points */
7662306a36Sopenharmony_ci	struct atif_qbtc_data_point data_points[ATIF_QBTC_MAX_DATA_POINTS];
7762306a36Sopenharmony_ci} __packed;
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#define ATIF_NOTIFY_MASK	0x3
8062306a36Sopenharmony_ci#define ATIF_NOTIFY_NONE	0
8162306a36Sopenharmony_ci#define ATIF_NOTIFY_81		1
8262306a36Sopenharmony_ci#define ATIF_NOTIFY_N		2
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_cistruct atcs_verify_interface {
8562306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
8662306a36Sopenharmony_ci	u16 version;		/* version */
8762306a36Sopenharmony_ci	u32 function_bits;	/* supported functions bit vector */
8862306a36Sopenharmony_ci} __packed;
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define ATCS_VALID_FLAGS_MASK	0x3
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_cistruct atcs_pref_req_input {
9362306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
9462306a36Sopenharmony_ci	u16 client_id;		/* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
9562306a36Sopenharmony_ci	u16 valid_flags_mask;	/* valid flags mask */
9662306a36Sopenharmony_ci	u16 flags;		/* flags */
9762306a36Sopenharmony_ci	u8 req_type;		/* request type */
9862306a36Sopenharmony_ci	u8 perf_req;		/* performance request */
9962306a36Sopenharmony_ci} __packed;
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistruct atcs_pref_req_output {
10262306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
10362306a36Sopenharmony_ci	u8 ret_val;		/* return value */
10462306a36Sopenharmony_ci} __packed;
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_cistruct atcs_pwr_shift_input {
10762306a36Sopenharmony_ci	u16 size;		/* structure size in bytes (includes size field) */
10862306a36Sopenharmony_ci	u16 dgpu_id;		/* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
10962306a36Sopenharmony_ci	u8 dev_acpi_state;	/* D0 = 0, D3 hot = 3 */
11062306a36Sopenharmony_ci	u8 drv_state;	/* 0 = operational, 1 = not operational */
11162306a36Sopenharmony_ci} __packed;
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci/* AMD hw uses four ACPI control methods:
11462306a36Sopenharmony_ci * 1. ATIF
11562306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) function code
11662306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
11762306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
11862306a36Sopenharmony_ci * ATIF provides an entry point for the gfx driver to interact with the sbios.
11962306a36Sopenharmony_ci * The AMD ACPI notification mechanism uses Notify (VGA, 0x81) or a custom
12062306a36Sopenharmony_ci * notification. Which notification is used as indicated by the ATIF Control
12162306a36Sopenharmony_ci * Method GET_SYSTEM_PARAMETERS. When the driver receives Notify (VGA, 0x81) or
12262306a36Sopenharmony_ci * a custom notification it invokes ATIF Control Method GET_SYSTEM_BIOS_REQUESTS
12362306a36Sopenharmony_ci * to identify pending System BIOS requests and associated parameters. For
12462306a36Sopenharmony_ci * example, if one of the pending requests is DISPLAY_SWITCH_REQUEST, the driver
12562306a36Sopenharmony_ci * will perform display device detection and invoke ATIF Control Method
12662306a36Sopenharmony_ci * SELECT_ACTIVE_DISPLAYS.
12762306a36Sopenharmony_ci *
12862306a36Sopenharmony_ci * 2. ATPX
12962306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) function code
13062306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
13162306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
13262306a36Sopenharmony_ci * ATPX methods are used on PowerXpress systems to handle mux switching and
13362306a36Sopenharmony_ci * discrete GPU power control.
13462306a36Sopenharmony_ci *
13562306a36Sopenharmony_ci * 3. ATRM
13662306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) offset of vbios rom data
13762306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) size of the buffer to fill (up to 4K).
13862306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer
13962306a36Sopenharmony_ci * ATRM provides an interfacess to access the discrete GPU vbios image on
14062306a36Sopenharmony_ci * PowerXpress systems with multiple GPUs.
14162306a36Sopenharmony_ci *
14262306a36Sopenharmony_ci * 4. ATCS
14362306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) function code
14462306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
14562306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
14662306a36Sopenharmony_ci * ATCS provides an interface to AMD chipset specific functionality.
14762306a36Sopenharmony_ci *
14862306a36Sopenharmony_ci */
14962306a36Sopenharmony_ci/* ATIF */
15062306a36Sopenharmony_ci#define ATIF_FUNCTION_VERIFY_INTERFACE                             0x0
15162306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_VERIFY_INTERFACE
15262306a36Sopenharmony_ci * ARG1: none
15362306a36Sopenharmony_ci * OUTPUT:
15462306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
15562306a36Sopenharmony_ci * WORD  - version
15662306a36Sopenharmony_ci * DWORD - supported notifications mask
15762306a36Sopenharmony_ci * DWORD - supported functions bit vector
15862306a36Sopenharmony_ci */
15962306a36Sopenharmony_ci/* Notifications mask */
16062306a36Sopenharmony_ci#       define ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED         (1 << 2)
16162306a36Sopenharmony_ci#       define ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED    (1 << 3)
16262306a36Sopenharmony_ci#       define ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED   (1 << 4)
16362306a36Sopenharmony_ci#       define ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED      (1 << 7)
16462306a36Sopenharmony_ci#       define ATIF_DGPU_DISPLAY_EVENT_SUPPORTED                   (1 << 8)
16562306a36Sopenharmony_ci#       define ATIF_GPU_PACKAGE_POWER_LIMIT_REQUEST_SUPPORTED      (1 << 12)
16662306a36Sopenharmony_ci/* supported functions vector */
16762306a36Sopenharmony_ci#       define ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED               (1 << 0)
16862306a36Sopenharmony_ci#       define ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED            (1 << 1)
16962306a36Sopenharmony_ci#       define ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED     (1 << 12)
17062306a36Sopenharmony_ci#       define ATIF_QUERY_BACKLIGHT_TRANSFER_CHARACTERISTICS_SUPPORTED (1 << 15)
17162306a36Sopenharmony_ci#       define ATIF_READY_TO_UNDOCK_NOTIFICATION_SUPPORTED        (1 << 16)
17262306a36Sopenharmony_ci#       define ATIF_GET_EXTERNAL_GPU_INFORMATION_SUPPORTED        (1 << 20)
17362306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_SYSTEM_PARAMETERS                        0x1
17462306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
17562306a36Sopenharmony_ci * ARG1: none
17662306a36Sopenharmony_ci * OUTPUT:
17762306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
17862306a36Sopenharmony_ci * DWORD - valid flags mask
17962306a36Sopenharmony_ci * DWORD - flags
18062306a36Sopenharmony_ci *
18162306a36Sopenharmony_ci * OR
18262306a36Sopenharmony_ci *
18362306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
18462306a36Sopenharmony_ci * DWORD - valid flags mask
18562306a36Sopenharmony_ci * DWORD - flags
18662306a36Sopenharmony_ci * BYTE  - notify command code
18762306a36Sopenharmony_ci *
18862306a36Sopenharmony_ci * flags
18962306a36Sopenharmony_ci * bits 1:0:
19062306a36Sopenharmony_ci * 0 - Notify(VGA, 0x81) is not used for notification
19162306a36Sopenharmony_ci * 1 - Notify(VGA, 0x81) is used for notification
19262306a36Sopenharmony_ci * 2 - Notify(VGA, n) is used for notification where
19362306a36Sopenharmony_ci * n (0xd0-0xd9) is specified in notify command code.
19462306a36Sopenharmony_ci * bit 2:
19562306a36Sopenharmony_ci * 1 - lid changes not reported though int10
19662306a36Sopenharmony_ci * bit 3:
19762306a36Sopenharmony_ci * 1 - system bios controls overclocking
19862306a36Sopenharmony_ci * bit 4:
19962306a36Sopenharmony_ci * 1 - enable overclocking
20062306a36Sopenharmony_ci */
20162306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS                     0x2
20262306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
20362306a36Sopenharmony_ci * ARG1: none
20462306a36Sopenharmony_ci * OUTPUT:
20562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
20662306a36Sopenharmony_ci * DWORD - pending sbios requests
20762306a36Sopenharmony_ci * BYTE  - reserved (all zeroes)
20862306a36Sopenharmony_ci * BYTE  - thermal state: target gfx controller
20962306a36Sopenharmony_ci * BYTE  - thermal state: state id (0: exit state, non-0: state)
21062306a36Sopenharmony_ci * BYTE  - forced power state: target gfx controller
21162306a36Sopenharmony_ci * BYTE  - forced power state: state id (0: forced state, non-0: state)
21262306a36Sopenharmony_ci * BYTE  - system power source
21362306a36Sopenharmony_ci * BYTE  - panel backlight level (0-255)
21462306a36Sopenharmony_ci * BYTE  - GPU package power limit: target gfx controller
21562306a36Sopenharmony_ci * DWORD - GPU package power limit: value (24:8 fractional format, Watts)
21662306a36Sopenharmony_ci */
21762306a36Sopenharmony_ci/* pending sbios requests */
21862306a36Sopenharmony_ci#       define ATIF_THERMAL_STATE_CHANGE_REQUEST                   (1 << 2)
21962306a36Sopenharmony_ci#       define ATIF_FORCED_POWER_STATE_CHANGE_REQUEST              (1 << 3)
22062306a36Sopenharmony_ci#       define ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST             (1 << 4)
22162306a36Sopenharmony_ci#       define ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST                (1 << 7)
22262306a36Sopenharmony_ci#       define ATIF_DGPU_DISPLAY_EVENT                             (1 << 8)
22362306a36Sopenharmony_ci#       define ATIF_GPU_PACKAGE_POWER_LIMIT_REQUEST                (1 << 12)
22462306a36Sopenharmony_ci/* target gfx controller */
22562306a36Sopenharmony_ci#       define ATIF_TARGET_GFX_SINGLE                              0
22662306a36Sopenharmony_ci#       define ATIF_TARGET_GFX_PX_IGPU                             1
22762306a36Sopenharmony_ci#       define ATIF_TARGET_GFX_PX_DGPU                             2
22862306a36Sopenharmony_ci/* system power source */
22962306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_AC                                1
23062306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_DC                                2
23162306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_RESTRICTED_AC_1                   3
23262306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_RESTRICTED_AC_2                   4
23362306a36Sopenharmony_ci#define ATIF_FUNCTION_TEMPERATURE_CHANGE_NOTIFICATION              0xD
23462306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_TEMPERATURE_CHANGE_NOTIFICATION
23562306a36Sopenharmony_ci * ARG1:
23662306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
23762306a36Sopenharmony_ci * WORD  - gfx controller id
23862306a36Sopenharmony_ci * BYTE  - current temperature (degress Celsius)
23962306a36Sopenharmony_ci * OUTPUT: none
24062306a36Sopenharmony_ci */
24162306a36Sopenharmony_ci#define ATIF_FUNCTION_QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS    0x10
24262306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_QUERY_BRIGHTNESS_TRANSFER_CHARACTERISTICS
24362306a36Sopenharmony_ci * ARG1:
24462306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
24562306a36Sopenharmony_ci * BYTE  - requested display
24662306a36Sopenharmony_ci * OUTPUT:
24762306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
24862306a36Sopenharmony_ci * WORD  - flags (currently all 16 bits are reserved)
24962306a36Sopenharmony_ci * BYTE  - error code (on failure, disregard all below fields)
25062306a36Sopenharmony_ci * BYTE  - AC level (default brightness in percent when machine has full power)
25162306a36Sopenharmony_ci * BYTE  - DC level (default brightness in percent when machine is on battery)
25262306a36Sopenharmony_ci * BYTE  - min input signal, in range 0-255, corresponding to 0% backlight
25362306a36Sopenharmony_ci * BYTE  - max input signal, in range 0-255, corresponding to 100% backlight
25462306a36Sopenharmony_ci * BYTE  - number of reported data points
25562306a36Sopenharmony_ci * BYTE  - luminance level in percent  \ repeated structure
25662306a36Sopenharmony_ci * BYTE  - input signal in range 0-255 / does not have entries for 0% and 100%
25762306a36Sopenharmony_ci */
25862306a36Sopenharmony_ci/* requested display */
25962306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_LCD1                              0
26062306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_CRT1                              1
26162306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_DFP1                              3
26262306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_CRT2                              4
26362306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_LCD2                              5
26462306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_DFP2                              7
26562306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_DFP3                              9
26662306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_DFP4                              10
26762306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_DFP5                              11
26862306a36Sopenharmony_ci#       define ATIF_QBTC_REQUEST_DFP6                              12
26962306a36Sopenharmony_ci/* error code */
27062306a36Sopenharmony_ci#       define ATIF_QBTC_ERROR_CODE_SUCCESS                        0
27162306a36Sopenharmony_ci#       define ATIF_QBTC_ERROR_CODE_FAILURE                        1
27262306a36Sopenharmony_ci#       define ATIF_QBTC_ERROR_CODE_DEVICE_NOT_SUPPORTED           2
27362306a36Sopenharmony_ci#define ATIF_FUNCTION_READY_TO_UNDOCK_NOTIFICATION                 0x11
27462306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_READY_TO_UNDOCK_NOTIFICATION
27562306a36Sopenharmony_ci * ARG1: none
27662306a36Sopenharmony_ci * OUTPUT: none
27762306a36Sopenharmony_ci */
27862306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_EXTERNAL_GPU_INFORMATION                 0x15
27962306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_EXTERNAL_GPU_INFORMATION
28062306a36Sopenharmony_ci * ARG1: none
28162306a36Sopenharmony_ci * OUTPUT:
28262306a36Sopenharmony_ci * WORD  - number of reported external gfx devices
28362306a36Sopenharmony_ci * WORD  - device structure size in bytes (excludes device size field)
28462306a36Sopenharmony_ci * WORD  - flags         \
28562306a36Sopenharmony_ci * WORD  - bus number    / repeated structure
28662306a36Sopenharmony_ci */
28762306a36Sopenharmony_ci/* flags */
28862306a36Sopenharmony_ci#       define ATIF_EXTERNAL_GRAPHICS_PORT                         (1 << 0)
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci/* ATPX */
29162306a36Sopenharmony_ci#define ATPX_FUNCTION_VERIFY_INTERFACE                             0x0
29262306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_VERIFY_INTERFACE
29362306a36Sopenharmony_ci * ARG1: none
29462306a36Sopenharmony_ci * OUTPUT:
29562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
29662306a36Sopenharmony_ci * WORD  - version
29762306a36Sopenharmony_ci * DWORD - supported functions bit vector
29862306a36Sopenharmony_ci */
29962306a36Sopenharmony_ci/* supported functions vector */
30062306a36Sopenharmony_ci#       define ATPX_GET_PX_PARAMETERS_SUPPORTED                    (1 << 0)
30162306a36Sopenharmony_ci#       define ATPX_POWER_CONTROL_SUPPORTED                        (1 << 1)
30262306a36Sopenharmony_ci#       define ATPX_DISPLAY_MUX_CONTROL_SUPPORTED                  (1 << 2)
30362306a36Sopenharmony_ci#       define ATPX_I2C_MUX_CONTROL_SUPPORTED                      (1 << 3)
30462306a36Sopenharmony_ci#       define ATPX_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION_SUPPORTED (1 << 4)
30562306a36Sopenharmony_ci#       define ATPX_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION_SUPPORTED   (1 << 5)
30662306a36Sopenharmony_ci#       define ATPX_GET_DISPLAY_CONNECTORS_MAPPING_SUPPORTED       (1 << 7)
30762306a36Sopenharmony_ci#       define ATPX_GET_DISPLAY_DETECTION_PORTS_SUPPORTED          (1 << 8)
30862306a36Sopenharmony_ci#define ATPX_FUNCTION_GET_PX_PARAMETERS                            0x1
30962306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GET_PX_PARAMETERS
31062306a36Sopenharmony_ci * ARG1: none
31162306a36Sopenharmony_ci * OUTPUT:
31262306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
31362306a36Sopenharmony_ci * DWORD - valid flags mask
31462306a36Sopenharmony_ci * DWORD - flags
31562306a36Sopenharmony_ci */
31662306a36Sopenharmony_ci/* flags */
31762306a36Sopenharmony_ci#       define ATPX_LVDS_I2C_AVAILABLE_TO_BOTH_GPUS                (1 << 0)
31862306a36Sopenharmony_ci#       define ATPX_CRT1_I2C_AVAILABLE_TO_BOTH_GPUS                (1 << 1)
31962306a36Sopenharmony_ci#       define ATPX_DVI1_I2C_AVAILABLE_TO_BOTH_GPUS                (1 << 2)
32062306a36Sopenharmony_ci#       define ATPX_CRT1_RGB_SIGNAL_MUXED                          (1 << 3)
32162306a36Sopenharmony_ci#       define ATPX_TV_SIGNAL_MUXED                                (1 << 4)
32262306a36Sopenharmony_ci#       define ATPX_DFP_SIGNAL_MUXED                               (1 << 5)
32362306a36Sopenharmony_ci#       define ATPX_SEPARATE_MUX_FOR_I2C                           (1 << 6)
32462306a36Sopenharmony_ci#       define ATPX_DYNAMIC_PX_SUPPORTED                           (1 << 7)
32562306a36Sopenharmony_ci#       define ATPX_ACF_NOT_SUPPORTED                              (1 << 8)
32662306a36Sopenharmony_ci#       define ATPX_FIXED_NOT_SUPPORTED                            (1 << 9)
32762306a36Sopenharmony_ci#       define ATPX_DYNAMIC_DGPU_POWER_OFF_SUPPORTED               (1 << 10)
32862306a36Sopenharmony_ci#       define ATPX_DGPU_REQ_POWER_FOR_DISPLAYS                    (1 << 11)
32962306a36Sopenharmony_ci#       define ATPX_DGPU_CAN_DRIVE_DISPLAYS                        (1 << 12)
33062306a36Sopenharmony_ci#       define ATPX_MS_HYBRID_GFX_SUPPORTED                        (1 << 14)
33162306a36Sopenharmony_ci#define ATPX_FUNCTION_POWER_CONTROL                                0x2
33262306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_POWER_CONTROL
33362306a36Sopenharmony_ci * ARG1:
33462306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
33562306a36Sopenharmony_ci * BYTE  - dGPU power state (0: power off, 1: power on)
33662306a36Sopenharmony_ci * OUTPUT: none
33762306a36Sopenharmony_ci */
33862306a36Sopenharmony_ci#define ATPX_FUNCTION_DISPLAY_MUX_CONTROL                          0x3
33962306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_DISPLAY_MUX_CONTROL
34062306a36Sopenharmony_ci * ARG1:
34162306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
34262306a36Sopenharmony_ci * WORD  - display mux control (0: iGPU, 1: dGPU)
34362306a36Sopenharmony_ci * OUTPUT: none
34462306a36Sopenharmony_ci */
34562306a36Sopenharmony_ci#       define ATPX_INTEGRATED_GPU                                 0
34662306a36Sopenharmony_ci#       define ATPX_DISCRETE_GPU                                   1
34762306a36Sopenharmony_ci#define ATPX_FUNCTION_I2C_MUX_CONTROL                              0x4
34862306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_I2C_MUX_CONTROL
34962306a36Sopenharmony_ci * ARG1:
35062306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
35162306a36Sopenharmony_ci * WORD  - i2c/aux/hpd mux control (0: iGPU, 1: dGPU)
35262306a36Sopenharmony_ci * OUTPUT: none
35362306a36Sopenharmony_ci */
35462306a36Sopenharmony_ci#define ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION    0x5
35562306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION
35662306a36Sopenharmony_ci * ARG1:
35762306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
35862306a36Sopenharmony_ci * WORD  - target gpu (0: iGPU, 1: dGPU)
35962306a36Sopenharmony_ci * OUTPUT: none
36062306a36Sopenharmony_ci */
36162306a36Sopenharmony_ci#define ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION      0x6
36262306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION
36362306a36Sopenharmony_ci * ARG1:
36462306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
36562306a36Sopenharmony_ci * WORD  - target gpu (0: iGPU, 1: dGPU)
36662306a36Sopenharmony_ci * OUTPUT: none
36762306a36Sopenharmony_ci */
36862306a36Sopenharmony_ci#define ATPX_FUNCTION_GET_DISPLAY_CONNECTORS_MAPPING               0x8
36962306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GET_DISPLAY_CONNECTORS_MAPPING
37062306a36Sopenharmony_ci * ARG1: none
37162306a36Sopenharmony_ci * OUTPUT:
37262306a36Sopenharmony_ci * WORD  - number of display connectors
37362306a36Sopenharmony_ci * WORD  - connector structure size in bytes (excludes connector size field)
37462306a36Sopenharmony_ci * BYTE  - flags                                                     \
37562306a36Sopenharmony_ci * BYTE  - ATIF display vector bit position                           } repeated
37662306a36Sopenharmony_ci * BYTE  - adapter id (0: iGPU, 1-n: dGPU ordered by pcie bus number) } structure
37762306a36Sopenharmony_ci * WORD  - connector ACPI id                                         /
37862306a36Sopenharmony_ci */
37962306a36Sopenharmony_ci/* flags */
38062306a36Sopenharmony_ci#       define ATPX_DISPLAY_OUTPUT_SUPPORTED_BY_ADAPTER_ID_DEVICE  (1 << 0)
38162306a36Sopenharmony_ci#       define ATPX_DISPLAY_HPD_SUPPORTED_BY_ADAPTER_ID_DEVICE     (1 << 1)
38262306a36Sopenharmony_ci#       define ATPX_DISPLAY_I2C_SUPPORTED_BY_ADAPTER_ID_DEVICE     (1 << 2)
38362306a36Sopenharmony_ci#define ATPX_FUNCTION_GET_DISPLAY_DETECTION_PORTS                  0x9
38462306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GET_DISPLAY_DETECTION_PORTS
38562306a36Sopenharmony_ci * ARG1: none
38662306a36Sopenharmony_ci * OUTPUT:
38762306a36Sopenharmony_ci * WORD  - number of HPD/DDC ports
38862306a36Sopenharmony_ci * WORD  - port structure size in bytes (excludes port size field)
38962306a36Sopenharmony_ci * BYTE  - ATIF display vector bit position \
39062306a36Sopenharmony_ci * BYTE  - hpd id                            } reapeated structure
39162306a36Sopenharmony_ci * BYTE  - ddc id                           /
39262306a36Sopenharmony_ci *
39362306a36Sopenharmony_ci * available on A+A systems only
39462306a36Sopenharmony_ci */
39562306a36Sopenharmony_ci/* hpd id */
39662306a36Sopenharmony_ci#       define ATPX_HPD_NONE                                       0
39762306a36Sopenharmony_ci#       define ATPX_HPD1                                           1
39862306a36Sopenharmony_ci#       define ATPX_HPD2                                           2
39962306a36Sopenharmony_ci#       define ATPX_HPD3                                           3
40062306a36Sopenharmony_ci#       define ATPX_HPD4                                           4
40162306a36Sopenharmony_ci#       define ATPX_HPD5                                           5
40262306a36Sopenharmony_ci#       define ATPX_HPD6                                           6
40362306a36Sopenharmony_ci/* ddc id */
40462306a36Sopenharmony_ci#       define ATPX_DDC_NONE                                       0
40562306a36Sopenharmony_ci#       define ATPX_DDC1                                           1
40662306a36Sopenharmony_ci#       define ATPX_DDC2                                           2
40762306a36Sopenharmony_ci#       define ATPX_DDC3                                           3
40862306a36Sopenharmony_ci#       define ATPX_DDC4                                           4
40962306a36Sopenharmony_ci#       define ATPX_DDC5                                           5
41062306a36Sopenharmony_ci#       define ATPX_DDC6                                           6
41162306a36Sopenharmony_ci#       define ATPX_DDC7                                           7
41262306a36Sopenharmony_ci#       define ATPX_DDC8                                           8
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci/* ATCS */
41562306a36Sopenharmony_ci#define ATCS_FUNCTION_VERIFY_INTERFACE                             0x0
41662306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_VERIFY_INTERFACE
41762306a36Sopenharmony_ci * ARG1: none
41862306a36Sopenharmony_ci * OUTPUT:
41962306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
42062306a36Sopenharmony_ci * WORD  - version
42162306a36Sopenharmony_ci * DWORD - supported functions bit vector
42262306a36Sopenharmony_ci */
42362306a36Sopenharmony_ci/* supported functions vector */
42462306a36Sopenharmony_ci#       define ATCS_GET_EXTERNAL_STATE_SUPPORTED                   (1 << 0)
42562306a36Sopenharmony_ci#       define ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED             (1 << 1)
42662306a36Sopenharmony_ci#       define ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED       (1 << 2)
42762306a36Sopenharmony_ci#       define ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED                   (1 << 3)
42862306a36Sopenharmony_ci#       define ATCS_SET_POWER_SHIFT_CONTROL_SUPPORTED		   (1 << 7)
42962306a36Sopenharmony_ci#define ATCS_FUNCTION_GET_EXTERNAL_STATE                           0x1
43062306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_GET_EXTERNAL_STATE
43162306a36Sopenharmony_ci * ARG1: none
43262306a36Sopenharmony_ci * OUTPUT:
43362306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
43462306a36Sopenharmony_ci * DWORD - valid flags mask
43562306a36Sopenharmony_ci * DWORD - flags (0: undocked, 1: docked)
43662306a36Sopenharmony_ci */
43762306a36Sopenharmony_ci/* flags */
43862306a36Sopenharmony_ci#       define ATCS_DOCKED                                         (1 << 0)
43962306a36Sopenharmony_ci#define ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST                     0x2
44062306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
44162306a36Sopenharmony_ci * ARG1:
44262306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
44362306a36Sopenharmony_ci * WORD  - client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
44462306a36Sopenharmony_ci * WORD  - valid flags mask
44562306a36Sopenharmony_ci * WORD  - flags
44662306a36Sopenharmony_ci * BYTE  - request type
44762306a36Sopenharmony_ci * BYTE  - performance request
44862306a36Sopenharmony_ci * OUTPUT:
44962306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
45062306a36Sopenharmony_ci * BYTE  - return value
45162306a36Sopenharmony_ci */
45262306a36Sopenharmony_ci/* flags */
45362306a36Sopenharmony_ci#       define ATCS_ADVERTISE_CAPS                                 (1 << 0)
45462306a36Sopenharmony_ci#       define ATCS_WAIT_FOR_COMPLETION                            (1 << 1)
45562306a36Sopenharmony_ci/* request type */
45662306a36Sopenharmony_ci#       define ATCS_PCIE_LINK_SPEED                                1
45762306a36Sopenharmony_ci/* performance request */
45862306a36Sopenharmony_ci#       define ATCS_REMOVE                                         0
45962306a36Sopenharmony_ci#       define ATCS_FORCE_LOW_POWER                                1
46062306a36Sopenharmony_ci#       define ATCS_PERF_LEVEL_1                                   2 /* PCIE Gen 1 */
46162306a36Sopenharmony_ci#       define ATCS_PERF_LEVEL_2                                   3 /* PCIE Gen 2 */
46262306a36Sopenharmony_ci#       define ATCS_PERF_LEVEL_3                                   4 /* PCIE Gen 3 */
46362306a36Sopenharmony_ci/* return value */
46462306a36Sopenharmony_ci#       define ATCS_REQUEST_REFUSED                                1
46562306a36Sopenharmony_ci#       define ATCS_REQUEST_COMPLETE                               2
46662306a36Sopenharmony_ci#       define ATCS_REQUEST_IN_PROGRESS                            3
46762306a36Sopenharmony_ci#define ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION               0x3
46862306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
46962306a36Sopenharmony_ci * ARG1: none
47062306a36Sopenharmony_ci * OUTPUT: none
47162306a36Sopenharmony_ci */
47262306a36Sopenharmony_ci#define ATCS_FUNCTION_SET_PCIE_BUS_WIDTH                           0x4
47362306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_SET_PCIE_BUS_WIDTH
47462306a36Sopenharmony_ci * ARG1:
47562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
47662306a36Sopenharmony_ci * WORD  - client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
47762306a36Sopenharmony_ci * BYTE  - number of active lanes
47862306a36Sopenharmony_ci * OUTPUT:
47962306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
48062306a36Sopenharmony_ci * BYTE  - number of active lanes
48162306a36Sopenharmony_ci */
48262306a36Sopenharmony_ci
48362306a36Sopenharmony_ci#define ATCS_FUNCTION_POWER_SHIFT_CONTROL                          0x8
48462306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_POWER_SHIFT_CONTROL
48562306a36Sopenharmony_ci * ARG1:
48662306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
48762306a36Sopenharmony_ci * WORD  - dGPU id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
48862306a36Sopenharmony_ci * BYTE  - Device ACPI state
48962306a36Sopenharmony_ci * BYTE  - Driver state
49062306a36Sopenharmony_ci * OUTPUT: none
49162306a36Sopenharmony_ci */
49262306a36Sopenharmony_ci
49362306a36Sopenharmony_ci#endif
494