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 RADEON_ACPI_H
2562306a36Sopenharmony_ci#define RADEON_ACPI_H
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_cistruct radeon_device;
2862306a36Sopenharmony_cistruct acpi_bus_event;
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/* AMD hw uses four ACPI control methods:
3162306a36Sopenharmony_ci * 1. ATIF
3262306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) function code
3362306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
3462306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
3562306a36Sopenharmony_ci * ATIF provides an entry point for the gfx driver to interact with the sbios.
3662306a36Sopenharmony_ci * The AMD ACPI notification mechanism uses Notify (VGA, 0x81) or a custom
3762306a36Sopenharmony_ci * notification. Which notification is used as indicated by the ATIF Control
3862306a36Sopenharmony_ci * Method GET_SYSTEM_PARAMETERS. When the driver receives Notify (VGA, 0x81) or
3962306a36Sopenharmony_ci * a custom notification it invokes ATIF Control Method GET_SYSTEM_BIOS_REQUESTS
4062306a36Sopenharmony_ci * to identify pending System BIOS requests and associated parameters. For
4162306a36Sopenharmony_ci * example, if one of the pending requests is DISPLAY_SWITCH_REQUEST, the driver
4262306a36Sopenharmony_ci * will perform display device detection and invoke ATIF Control Method
4362306a36Sopenharmony_ci * SELECT_ACTIVE_DISPLAYS.
4462306a36Sopenharmony_ci *
4562306a36Sopenharmony_ci * 2. ATPX
4662306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) function code
4762306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
4862306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
4962306a36Sopenharmony_ci * ATPX methods are used on PowerXpress systems to handle mux switching and
5062306a36Sopenharmony_ci * discrete GPU power control.
5162306a36Sopenharmony_ci *
5262306a36Sopenharmony_ci * 3. ATRM
5362306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) offset of vbios rom data
5462306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) size of the buffer to fill (up to 4K).
5562306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer
5662306a36Sopenharmony_ci * ATRM provides an interfacess to access the discrete GPU vbios image on
5762306a36Sopenharmony_ci * PowerXpress systems with multiple GPUs.
5862306a36Sopenharmony_ci *
5962306a36Sopenharmony_ci * 4. ATCS
6062306a36Sopenharmony_ci * ARG0: (ACPI_INTEGER) function code
6162306a36Sopenharmony_ci * ARG1: (ACPI_BUFFER) parameter buffer, 256 bytes
6262306a36Sopenharmony_ci * OUTPUT: (ACPI_BUFFER) output buffer, 256 bytes
6362306a36Sopenharmony_ci * ATCS provides an interface to AMD chipset specific functionality.
6462306a36Sopenharmony_ci *
6562306a36Sopenharmony_ci */
6662306a36Sopenharmony_ci/* ATIF */
6762306a36Sopenharmony_ci#define ATIF_FUNCTION_VERIFY_INTERFACE                             0x0
6862306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_VERIFY_INTERFACE
6962306a36Sopenharmony_ci * ARG1: none
7062306a36Sopenharmony_ci * OUTPUT:
7162306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
7262306a36Sopenharmony_ci * WORD  - version
7362306a36Sopenharmony_ci * DWORD - supported notifications mask
7462306a36Sopenharmony_ci * DWORD - supported functions bit vector
7562306a36Sopenharmony_ci */
7662306a36Sopenharmony_ci/* Notifications mask */
7762306a36Sopenharmony_ci#       define ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED               (1 << 0)
7862306a36Sopenharmony_ci#       define ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED        (1 << 1)
7962306a36Sopenharmony_ci#       define ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED         (1 << 2)
8062306a36Sopenharmony_ci#       define ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED    (1 << 3)
8162306a36Sopenharmony_ci#       define ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED   (1 << 4)
8262306a36Sopenharmony_ci#       define ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED          (1 << 5)
8362306a36Sopenharmony_ci#       define ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED                (1 << 6)
8462306a36Sopenharmony_ci#       define ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED      (1 << 7)
8562306a36Sopenharmony_ci#       define ATIF_DGPU_DISPLAY_EVENT_SUPPORTED                   (1 << 8)
8662306a36Sopenharmony_ci/* supported functions vector */
8762306a36Sopenharmony_ci#       define ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED               (1 << 0)
8862306a36Sopenharmony_ci#       define ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED            (1 << 1)
8962306a36Sopenharmony_ci#       define ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED              (1 << 2)
9062306a36Sopenharmony_ci#       define ATIF_GET_LID_STATE_SUPPORTED                       (1 << 3)
9162306a36Sopenharmony_ci#       define ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED           (1 << 4)
9262306a36Sopenharmony_ci#       define ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED             (1 << 5)
9362306a36Sopenharmony_ci#       define ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED  (1 << 6)
9462306a36Sopenharmony_ci#       define ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED    (1 << 7)
9562306a36Sopenharmony_ci#       define ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED     (1 << 12)
9662306a36Sopenharmony_ci#       define ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED           (1 << 14)
9762306a36Sopenharmony_ci#       define ATIF_GET_EXTERNAL_GPU_INFORMATION_SUPPORTED        (1 << 20)
9862306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_SYSTEM_PARAMETERS                        0x1
9962306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
10062306a36Sopenharmony_ci * ARG1: none
10162306a36Sopenharmony_ci * OUTPUT:
10262306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
10362306a36Sopenharmony_ci * DWORD - valid flags mask
10462306a36Sopenharmony_ci * DWORD - flags
10562306a36Sopenharmony_ci *
10662306a36Sopenharmony_ci * OR
10762306a36Sopenharmony_ci *
10862306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
10962306a36Sopenharmony_ci * DWORD - valid flags mask
11062306a36Sopenharmony_ci * DWORD - flags
11162306a36Sopenharmony_ci * BYTE  - notify command code
11262306a36Sopenharmony_ci *
11362306a36Sopenharmony_ci * flags
11462306a36Sopenharmony_ci * bits 1:0:
11562306a36Sopenharmony_ci * 0 - Notify(VGA, 0x81) is not used for notification
11662306a36Sopenharmony_ci * 1 - Notify(VGA, 0x81) is used for notification
11762306a36Sopenharmony_ci * 2 - Notify(VGA, n) is used for notification where
11862306a36Sopenharmony_ci * n (0xd0-0xd9) is specified in notify command code.
11962306a36Sopenharmony_ci * bit 2:
12062306a36Sopenharmony_ci * 1 - lid changes not reported though int10
12162306a36Sopenharmony_ci */
12262306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS                     0x2
12362306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
12462306a36Sopenharmony_ci * ARG1: none
12562306a36Sopenharmony_ci * OUTPUT:
12662306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
12762306a36Sopenharmony_ci * DWORD - pending sbios requests
12862306a36Sopenharmony_ci * BYTE  - panel expansion mode
12962306a36Sopenharmony_ci * BYTE  - thermal state: target gfx controller
13062306a36Sopenharmony_ci * BYTE  - thermal state: state id (0: exit state, non-0: state)
13162306a36Sopenharmony_ci * BYTE  - forced power state: target gfx controller
13262306a36Sopenharmony_ci * BYTE  - forced power state: state id
13362306a36Sopenharmony_ci * BYTE  - system power source
13462306a36Sopenharmony_ci * BYTE  - panel backlight level (0-255)
13562306a36Sopenharmony_ci */
13662306a36Sopenharmony_ci/* pending sbios requests */
13762306a36Sopenharmony_ci#       define ATIF_DISPLAY_SWITCH_REQUEST                         (1 << 0)
13862306a36Sopenharmony_ci#       define ATIF_EXPANSION_MODE_CHANGE_REQUEST                  (1 << 1)
13962306a36Sopenharmony_ci#       define ATIF_THERMAL_STATE_CHANGE_REQUEST                   (1 << 2)
14062306a36Sopenharmony_ci#       define ATIF_FORCED_POWER_STATE_CHANGE_REQUEST              (1 << 3)
14162306a36Sopenharmony_ci#       define ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST             (1 << 4)
14262306a36Sopenharmony_ci#       define ATIF_DISPLAY_CONF_CHANGE_REQUEST                    (1 << 5)
14362306a36Sopenharmony_ci#       define ATIF_PX_GFX_SWITCH_REQUEST                          (1 << 6)
14462306a36Sopenharmony_ci#       define ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST                (1 << 7)
14562306a36Sopenharmony_ci#       define ATIF_DGPU_DISPLAY_EVENT                             (1 << 8)
14662306a36Sopenharmony_ci/* panel expansion mode */
14762306a36Sopenharmony_ci#       define ATIF_PANEL_EXPANSION_DISABLE                        0
14862306a36Sopenharmony_ci#       define ATIF_PANEL_EXPANSION_FULL                           1
14962306a36Sopenharmony_ci#       define ATIF_PANEL_EXPANSION_ASPECT                         2
15062306a36Sopenharmony_ci/* target gfx controller */
15162306a36Sopenharmony_ci#       define ATIF_TARGET_GFX_SINGLE                              0
15262306a36Sopenharmony_ci#       define ATIF_TARGET_GFX_PX_IGPU                             1
15362306a36Sopenharmony_ci#       define ATIF_TARGET_GFX_PX_DGPU                             2
15462306a36Sopenharmony_ci/* system power source */
15562306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_AC                                1
15662306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_DC                                2
15762306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_RESTRICTED_AC_1                   3
15862306a36Sopenharmony_ci#       define ATIF_POWER_SOURCE_RESTRICTED_AC_2                   4
15962306a36Sopenharmony_ci#define ATIF_FUNCTION_SELECT_ACTIVE_DISPLAYS                       0x3
16062306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_SELECT_ACTIVE_DISPLAYS
16162306a36Sopenharmony_ci * ARG1:
16262306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
16362306a36Sopenharmony_ci * WORD  - selected displays
16462306a36Sopenharmony_ci * WORD  - connected displays
16562306a36Sopenharmony_ci * OUTPUT:
16662306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
16762306a36Sopenharmony_ci * WORD  - selected displays
16862306a36Sopenharmony_ci */
16962306a36Sopenharmony_ci#       define ATIF_LCD1                                           (1 << 0)
17062306a36Sopenharmony_ci#       define ATIF_CRT1                                           (1 << 1)
17162306a36Sopenharmony_ci#       define ATIF_TV                                             (1 << 2)
17262306a36Sopenharmony_ci#       define ATIF_DFP1                                           (1 << 3)
17362306a36Sopenharmony_ci#       define ATIF_CRT2                                           (1 << 4)
17462306a36Sopenharmony_ci#       define ATIF_LCD2                                           (1 << 5)
17562306a36Sopenharmony_ci#       define ATIF_DFP2                                           (1 << 7)
17662306a36Sopenharmony_ci#       define ATIF_CV                                             (1 << 8)
17762306a36Sopenharmony_ci#       define ATIF_DFP3                                           (1 << 9)
17862306a36Sopenharmony_ci#       define ATIF_DFP4                                           (1 << 10)
17962306a36Sopenharmony_ci#       define ATIF_DFP5                                           (1 << 11)
18062306a36Sopenharmony_ci#       define ATIF_DFP6                                           (1 << 12)
18162306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_LID_STATE                                0x4
18262306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_LID_STATE
18362306a36Sopenharmony_ci * ARG1: none
18462306a36Sopenharmony_ci * OUTPUT:
18562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
18662306a36Sopenharmony_ci * BYTE  - lid state (0: open, 1: closed)
18762306a36Sopenharmony_ci *
18862306a36Sopenharmony_ci * GET_LID_STATE only works at boot and resume, for general lid
18962306a36Sopenharmony_ci * status, use the kernel provided status
19062306a36Sopenharmony_ci */
19162306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_TV_STANDARD_FROM_CMOS                    0x5
19262306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_TV_STANDARD_FROM_CMOS
19362306a36Sopenharmony_ci * ARG1: none
19462306a36Sopenharmony_ci * OUTPUT:
19562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
19662306a36Sopenharmony_ci * BYTE  - 0
19762306a36Sopenharmony_ci * BYTE  - TV standard
19862306a36Sopenharmony_ci */
19962306a36Sopenharmony_ci#       define ATIF_TV_STD_NTSC                                    0
20062306a36Sopenharmony_ci#       define ATIF_TV_STD_PAL                                     1
20162306a36Sopenharmony_ci#       define ATIF_TV_STD_PALM                                    2
20262306a36Sopenharmony_ci#       define ATIF_TV_STD_PAL60                                   3
20362306a36Sopenharmony_ci#       define ATIF_TV_STD_NTSCJ                                   4
20462306a36Sopenharmony_ci#       define ATIF_TV_STD_PALCN                                   5
20562306a36Sopenharmony_ci#       define ATIF_TV_STD_PALN                                    6
20662306a36Sopenharmony_ci#       define ATIF_TV_STD_SCART_RGB                               9
20762306a36Sopenharmony_ci#define ATIF_FUNCTION_SET_TV_STANDARD_IN_CMOS                      0x6
20862306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_SET_TV_STANDARD_IN_CMOS
20962306a36Sopenharmony_ci * ARG1:
21062306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
21162306a36Sopenharmony_ci * BYTE  - 0
21262306a36Sopenharmony_ci * BYTE  - TV standard
21362306a36Sopenharmony_ci * OUTPUT: none
21462306a36Sopenharmony_ci */
21562306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_PANEL_EXPANSION_MODE_FROM_CMOS           0x7
21662306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_PANEL_EXPANSION_MODE_FROM_CMOS
21762306a36Sopenharmony_ci * ARG1: none
21862306a36Sopenharmony_ci * OUTPUT:
21962306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
22062306a36Sopenharmony_ci * BYTE  - panel expansion mode
22162306a36Sopenharmony_ci */
22262306a36Sopenharmony_ci#define ATIF_FUNCTION_SET_PANEL_EXPANSION_MODE_IN_CMOS             0x8
22362306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_SET_PANEL_EXPANSION_MODE_IN_CMOS
22462306a36Sopenharmony_ci * ARG1:
22562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
22662306a36Sopenharmony_ci * BYTE  - panel expansion mode
22762306a36Sopenharmony_ci * OUTPUT: none
22862306a36Sopenharmony_ci */
22962306a36Sopenharmony_ci#define ATIF_FUNCTION_TEMPERATURE_CHANGE_NOTIFICATION              0xD
23062306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_TEMPERATURE_CHANGE_NOTIFICATION
23162306a36Sopenharmony_ci * ARG1:
23262306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
23362306a36Sopenharmony_ci * WORD  - gfx controller id
23462306a36Sopenharmony_ci * BYTE  - current temperature (degress Celsius)
23562306a36Sopenharmony_ci * OUTPUT: none
23662306a36Sopenharmony_ci */
23762306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_GRAPHICS_DEVICE_TYPES                    0xF
23862306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_GRAPHICS_DEVICE_TYPES
23962306a36Sopenharmony_ci * ARG1: none
24062306a36Sopenharmony_ci * OUTPUT:
24162306a36Sopenharmony_ci * WORD  - number of gfx devices
24262306a36Sopenharmony_ci * WORD  - device structure size in bytes (excludes device size field)
24362306a36Sopenharmony_ci * DWORD - flags         \
24462306a36Sopenharmony_ci * WORD  - bus number     } repeated structure
24562306a36Sopenharmony_ci * WORD  - device number /
24662306a36Sopenharmony_ci */
24762306a36Sopenharmony_ci/* flags */
24862306a36Sopenharmony_ci#       define ATIF_PX_REMOVABLE_GRAPHICS_DEVICE                   (1 << 0)
24962306a36Sopenharmony_ci#       define ATIF_XGP_PORT                                       (1 << 1)
25062306a36Sopenharmony_ci#       define ATIF_VGA_ENABLED_GRAPHICS_DEVICE                    (1 << 2)
25162306a36Sopenharmony_ci#       define ATIF_XGP_PORT_IN_DOCK                               (1 << 3)
25262306a36Sopenharmony_ci#define ATIF_FUNCTION_GET_EXTERNAL_GPU_INFORMATION                 0x15
25362306a36Sopenharmony_ci/* ARG0: ATIF_FUNCTION_GET_EXTERNAL_GPU_INFORMATION
25462306a36Sopenharmony_ci * ARG1: none
25562306a36Sopenharmony_ci * OUTPUT:
25662306a36Sopenharmony_ci * WORD  - number of reported external gfx devices
25762306a36Sopenharmony_ci * WORD  - device structure size in bytes (excludes device size field)
25862306a36Sopenharmony_ci * WORD  - flags         \
25962306a36Sopenharmony_ci * WORD  - bus number    / repeated structure
26062306a36Sopenharmony_ci */
26162306a36Sopenharmony_ci/* flags */
26262306a36Sopenharmony_ci#       define ATIF_EXTERNAL_GRAPHICS_PORT                         (1 << 0)
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ci/* ATPX */
26562306a36Sopenharmony_ci#define ATPX_FUNCTION_VERIFY_INTERFACE                             0x0
26662306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_VERIFY_INTERFACE
26762306a36Sopenharmony_ci * ARG1: none
26862306a36Sopenharmony_ci * OUTPUT:
26962306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
27062306a36Sopenharmony_ci * WORD  - version
27162306a36Sopenharmony_ci * DWORD - supported functions bit vector
27262306a36Sopenharmony_ci */
27362306a36Sopenharmony_ci/* supported functions vector */
27462306a36Sopenharmony_ci#       define ATPX_GET_PX_PARAMETERS_SUPPORTED                    (1 << 0)
27562306a36Sopenharmony_ci#       define ATPX_POWER_CONTROL_SUPPORTED                        (1 << 1)
27662306a36Sopenharmony_ci#       define ATPX_DISPLAY_MUX_CONTROL_SUPPORTED                  (1 << 2)
27762306a36Sopenharmony_ci#       define ATPX_I2C_MUX_CONTROL_SUPPORTED                      (1 << 3)
27862306a36Sopenharmony_ci#       define ATPX_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION_SUPPORTED (1 << 4)
27962306a36Sopenharmony_ci#       define ATPX_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION_SUPPORTED   (1 << 5)
28062306a36Sopenharmony_ci#       define ATPX_GET_DISPLAY_CONNECTORS_MAPPING_SUPPORTED       (1 << 7)
28162306a36Sopenharmony_ci#       define ATPX_GET_DISPLAY_DETECTION_PORTS_SUPPORTED          (1 << 8)
28262306a36Sopenharmony_ci#define ATPX_FUNCTION_GET_PX_PARAMETERS                            0x1
28362306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GET_PX_PARAMETERS
28462306a36Sopenharmony_ci * ARG1: none
28562306a36Sopenharmony_ci * OUTPUT:
28662306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
28762306a36Sopenharmony_ci * DWORD - valid flags mask
28862306a36Sopenharmony_ci * DWORD - flags
28962306a36Sopenharmony_ci */
29062306a36Sopenharmony_ci/* flags */
29162306a36Sopenharmony_ci#       define ATPX_LVDS_I2C_AVAILABLE_TO_BOTH_GPUS                (1 << 0)
29262306a36Sopenharmony_ci#       define ATPX_CRT1_I2C_AVAILABLE_TO_BOTH_GPUS                (1 << 1)
29362306a36Sopenharmony_ci#       define ATPX_DVI1_I2C_AVAILABLE_TO_BOTH_GPUS                (1 << 2)
29462306a36Sopenharmony_ci#       define ATPX_CRT1_RGB_SIGNAL_MUXED                          (1 << 3)
29562306a36Sopenharmony_ci#       define ATPX_TV_SIGNAL_MUXED                                (1 << 4)
29662306a36Sopenharmony_ci#       define ATPX_DFP_SIGNAL_MUXED                               (1 << 5)
29762306a36Sopenharmony_ci#       define ATPX_SEPARATE_MUX_FOR_I2C                           (1 << 6)
29862306a36Sopenharmony_ci#       define ATPX_DYNAMIC_PX_SUPPORTED                           (1 << 7)
29962306a36Sopenharmony_ci#       define ATPX_ACF_NOT_SUPPORTED                              (1 << 8)
30062306a36Sopenharmony_ci#       define ATPX_FIXED_NOT_SUPPORTED                            (1 << 9)
30162306a36Sopenharmony_ci#       define ATPX_DYNAMIC_DGPU_POWER_OFF_SUPPORTED               (1 << 10)
30262306a36Sopenharmony_ci#       define ATPX_DGPU_REQ_POWER_FOR_DISPLAYS                    (1 << 11)
30362306a36Sopenharmony_ci#       define ATPX_DGPU_CAN_DRIVE_DISPLAYS                        (1 << 12)
30462306a36Sopenharmony_ci#       define ATPX_MS_HYBRID_GFX_SUPPORTED                        (1 << 14)
30562306a36Sopenharmony_ci#define ATPX_FUNCTION_POWER_CONTROL                                0x2
30662306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_POWER_CONTROL
30762306a36Sopenharmony_ci * ARG1:
30862306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
30962306a36Sopenharmony_ci * BYTE  - dGPU power state (0: power off, 1: power on)
31062306a36Sopenharmony_ci * OUTPUT: none
31162306a36Sopenharmony_ci */
31262306a36Sopenharmony_ci#define ATPX_FUNCTION_DISPLAY_MUX_CONTROL                          0x3
31362306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_DISPLAY_MUX_CONTROL
31462306a36Sopenharmony_ci * ARG1:
31562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
31662306a36Sopenharmony_ci * WORD  - display mux control (0: iGPU, 1: dGPU)
31762306a36Sopenharmony_ci * OUTPUT: none
31862306a36Sopenharmony_ci */
31962306a36Sopenharmony_ci#       define ATPX_INTEGRATED_GPU                                 0
32062306a36Sopenharmony_ci#       define ATPX_DISCRETE_GPU                                   1
32162306a36Sopenharmony_ci#define ATPX_FUNCTION_I2C_MUX_CONTROL                              0x4
32262306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_I2C_MUX_CONTROL
32362306a36Sopenharmony_ci * ARG1:
32462306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
32562306a36Sopenharmony_ci * WORD  - i2c/aux/hpd mux control (0: iGPU, 1: dGPU)
32662306a36Sopenharmony_ci * OUTPUT: none
32762306a36Sopenharmony_ci */
32862306a36Sopenharmony_ci#define ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION    0x5
32962306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION
33062306a36Sopenharmony_ci * ARG1:
33162306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
33262306a36Sopenharmony_ci * WORD  - target gpu (0: iGPU, 1: dGPU)
33362306a36Sopenharmony_ci * OUTPUT: none
33462306a36Sopenharmony_ci */
33562306a36Sopenharmony_ci#define ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION      0x6
33662306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION
33762306a36Sopenharmony_ci * ARG1:
33862306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
33962306a36Sopenharmony_ci * WORD  - target gpu (0: iGPU, 1: dGPU)
34062306a36Sopenharmony_ci * OUTPUT: none
34162306a36Sopenharmony_ci */
34262306a36Sopenharmony_ci#define ATPX_FUNCTION_GET_DISPLAY_CONNECTORS_MAPPING               0x8
34362306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GET_DISPLAY_CONNECTORS_MAPPING
34462306a36Sopenharmony_ci * ARG1: none
34562306a36Sopenharmony_ci * OUTPUT:
34662306a36Sopenharmony_ci * WORD  - number of display connectors
34762306a36Sopenharmony_ci * WORD  - connector structure size in bytes (excludes connector size field)
34862306a36Sopenharmony_ci * BYTE  - flags                                                     \
34962306a36Sopenharmony_ci * BYTE  - ATIF display vector bit position                           } repeated
35062306a36Sopenharmony_ci * BYTE  - adapter id (0: iGPU, 1-n: dGPU ordered by pcie bus number) } structure
35162306a36Sopenharmony_ci * WORD  - connector ACPI id                                         /
35262306a36Sopenharmony_ci */
35362306a36Sopenharmony_ci/* flags */
35462306a36Sopenharmony_ci#       define ATPX_DISPLAY_OUTPUT_SUPPORTED_BY_ADAPTER_ID_DEVICE  (1 << 0)
35562306a36Sopenharmony_ci#       define ATPX_DISPLAY_HPD_SUPPORTED_BY_ADAPTER_ID_DEVICE     (1 << 1)
35662306a36Sopenharmony_ci#       define ATPX_DISPLAY_I2C_SUPPORTED_BY_ADAPTER_ID_DEVICE     (1 << 2)
35762306a36Sopenharmony_ci#define ATPX_FUNCTION_GET_DISPLAY_DETECTION_PORTS                  0x9
35862306a36Sopenharmony_ci/* ARG0: ATPX_FUNCTION_GET_DISPLAY_DETECTION_PORTS
35962306a36Sopenharmony_ci * ARG1: none
36062306a36Sopenharmony_ci * OUTPUT:
36162306a36Sopenharmony_ci * WORD  - number of HPD/DDC ports
36262306a36Sopenharmony_ci * WORD  - port structure size in bytes (excludes port size field)
36362306a36Sopenharmony_ci * BYTE  - ATIF display vector bit position \
36462306a36Sopenharmony_ci * BYTE  - hpd id                            } reapeated structure
36562306a36Sopenharmony_ci * BYTE  - ddc id                           /
36662306a36Sopenharmony_ci *
36762306a36Sopenharmony_ci * available on A+A systems only
36862306a36Sopenharmony_ci */
36962306a36Sopenharmony_ci/* hpd id */
37062306a36Sopenharmony_ci#       define ATPX_HPD_NONE                                       0
37162306a36Sopenharmony_ci#       define ATPX_HPD1                                           1
37262306a36Sopenharmony_ci#       define ATPX_HPD2                                           2
37362306a36Sopenharmony_ci#       define ATPX_HPD3                                           3
37462306a36Sopenharmony_ci#       define ATPX_HPD4                                           4
37562306a36Sopenharmony_ci#       define ATPX_HPD5                                           5
37662306a36Sopenharmony_ci#       define ATPX_HPD6                                           6
37762306a36Sopenharmony_ci/* ddc id */
37862306a36Sopenharmony_ci#       define ATPX_DDC_NONE                                       0
37962306a36Sopenharmony_ci#       define ATPX_DDC1                                           1
38062306a36Sopenharmony_ci#       define ATPX_DDC2                                           2
38162306a36Sopenharmony_ci#       define ATPX_DDC3                                           3
38262306a36Sopenharmony_ci#       define ATPX_DDC4                                           4
38362306a36Sopenharmony_ci#       define ATPX_DDC5                                           5
38462306a36Sopenharmony_ci#       define ATPX_DDC6                                           6
38562306a36Sopenharmony_ci#       define ATPX_DDC7                                           7
38662306a36Sopenharmony_ci#       define ATPX_DDC8                                           8
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci/* ATCS */
38962306a36Sopenharmony_ci#define ATCS_FUNCTION_VERIFY_INTERFACE                             0x0
39062306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_VERIFY_INTERFACE
39162306a36Sopenharmony_ci * ARG1: none
39262306a36Sopenharmony_ci * OUTPUT:
39362306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
39462306a36Sopenharmony_ci * WORD  - version
39562306a36Sopenharmony_ci * DWORD - supported functions bit vector
39662306a36Sopenharmony_ci */
39762306a36Sopenharmony_ci/* supported functions vector */
39862306a36Sopenharmony_ci#       define ATCS_GET_EXTERNAL_STATE_SUPPORTED                   (1 << 0)
39962306a36Sopenharmony_ci#       define ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED             (1 << 1)
40062306a36Sopenharmony_ci#       define ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED       (1 << 2)
40162306a36Sopenharmony_ci#       define ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED                   (1 << 3)
40262306a36Sopenharmony_ci#define ATCS_FUNCTION_GET_EXTERNAL_STATE                           0x1
40362306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_GET_EXTERNAL_STATE
40462306a36Sopenharmony_ci * ARG1: none
40562306a36Sopenharmony_ci * OUTPUT:
40662306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
40762306a36Sopenharmony_ci * DWORD - valid flags mask
40862306a36Sopenharmony_ci * DWORD - flags (0: undocked, 1: docked)
40962306a36Sopenharmony_ci */
41062306a36Sopenharmony_ci/* flags */
41162306a36Sopenharmony_ci#       define ATCS_DOCKED                                         (1 << 0)
41262306a36Sopenharmony_ci#define ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST                     0x2
41362306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST
41462306a36Sopenharmony_ci * ARG1:
41562306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
41662306a36Sopenharmony_ci * WORD  - client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
41762306a36Sopenharmony_ci * WORD  - valid flags mask
41862306a36Sopenharmony_ci * WORD  - flags
41962306a36Sopenharmony_ci * BYTE  - request type
42062306a36Sopenharmony_ci * BYTE  - performance request
42162306a36Sopenharmony_ci * OUTPUT:
42262306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
42362306a36Sopenharmony_ci * BYTE  - return value
42462306a36Sopenharmony_ci */
42562306a36Sopenharmony_ci/* flags */
42662306a36Sopenharmony_ci#       define ATCS_ADVERTISE_CAPS                                 (1 << 0)
42762306a36Sopenharmony_ci#       define ATCS_WAIT_FOR_COMPLETION                            (1 << 1)
42862306a36Sopenharmony_ci/* request type */
42962306a36Sopenharmony_ci#       define ATCS_PCIE_LINK_SPEED                                1
43062306a36Sopenharmony_ci/* performance request */
43162306a36Sopenharmony_ci#       define ATCS_REMOVE                                         0
43262306a36Sopenharmony_ci#       define ATCS_FORCE_LOW_POWER                                1
43362306a36Sopenharmony_ci#       define ATCS_PERF_LEVEL_1                                   2 /* PCIE Gen 1 */
43462306a36Sopenharmony_ci#       define ATCS_PERF_LEVEL_2                                   3 /* PCIE Gen 2 */
43562306a36Sopenharmony_ci#       define ATCS_PERF_LEVEL_3                                   4 /* PCIE Gen 3 */
43662306a36Sopenharmony_ci/* return value */
43762306a36Sopenharmony_ci#       define ATCS_REQUEST_REFUSED                                1
43862306a36Sopenharmony_ci#       define ATCS_REQUEST_COMPLETE                               2
43962306a36Sopenharmony_ci#       define ATCS_REQUEST_IN_PROGRESS                            3
44062306a36Sopenharmony_ci#define ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION               0x3
44162306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION
44262306a36Sopenharmony_ci * ARG1: none
44362306a36Sopenharmony_ci * OUTPUT: none
44462306a36Sopenharmony_ci */
44562306a36Sopenharmony_ci#define ATCS_FUNCTION_SET_PCIE_BUS_WIDTH                           0x4
44662306a36Sopenharmony_ci/* ARG0: ATCS_FUNCTION_SET_PCIE_BUS_WIDTH
44762306a36Sopenharmony_ci * ARG1:
44862306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
44962306a36Sopenharmony_ci * WORD  - client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num)
45062306a36Sopenharmony_ci * BYTE  - number of active lanes
45162306a36Sopenharmony_ci * OUTPUT:
45262306a36Sopenharmony_ci * WORD  - structure size in bytes (includes size field)
45362306a36Sopenharmony_ci * BYTE  - number of active lanes
45462306a36Sopenharmony_ci */
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ci#if defined(CONFIG_VGA_SWITCHEROO)
45762306a36Sopenharmony_civoid radeon_register_atpx_handler(void);
45862306a36Sopenharmony_civoid radeon_unregister_atpx_handler(void);
45962306a36Sopenharmony_cibool radeon_has_atpx_dgpu_power_cntl(void);
46062306a36Sopenharmony_cibool radeon_is_atpx_hybrid(void);
46162306a36Sopenharmony_cibool radeon_has_atpx(void);
46262306a36Sopenharmony_cibool radeon_atpx_dgpu_req_power_for_displays(void);
46362306a36Sopenharmony_ci#endif
46462306a36Sopenharmony_ci
46562306a36Sopenharmony_ci#endif
466