aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0703-drm-amd-dal-Override-some-virtual-functions-for-Diag.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-kernel/linux/files/0703-drm-amd-dal-Override-some-virtual-functions-for-Diag.patch')
-rw-r--r--common/recipes-kernel/linux/files/0703-drm-amd-dal-Override-some-virtual-functions-for-Diag.patch1709
1 files changed, 1709 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/files/0703-drm-amd-dal-Override-some-virtual-functions-for-Diag.patch b/common/recipes-kernel/linux/files/0703-drm-amd-dal-Override-some-virtual-functions-for-Diag.patch
new file mode 100644
index 00000000..ab27d06e
--- /dev/null
+++ b/common/recipes-kernel/linux/files/0703-drm-amd-dal-Override-some-virtual-functions-for-Diag.patch
@@ -0,0 +1,1709 @@
+From 060a4205ae78b9cb3ffafcf0078c4011ca20d8ee Mon Sep 17 00:00:00 2001
+From: David Rokhvarg <David.Rokhvarg@amd.com>
+Date: Tue, 19 Jan 2016 13:43:50 -0500
+Subject: [PATCH 0703/1110] drm/amd/dal: Override some virtual functions for
+ Diagnostics use.
+
+This will prevent access to registers which are non-existent on
+FPGA emulation.
+
+Signed-off-by: David Rokhvarg <David.Rokhvarg@amd.com>
+Acked-by: Harry Wentland <harry.wentland@amd.com>
+---
+ drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c | 2 +
+ drivers/gpu/drm/amd/dal/dc/adapter/Makefile | 6 +
+ .../gpu/drm/amd/dal/dc/adapter/adapter_service.c | 180 +++++++++++++--------
+ .../gpu/drm/amd/dal/dc/adapter/adapter_service.h | 4 +-
+ .../diagnostics/hw_ctx_adapter_service_diag.c | 133 +++++++++++++++
+ .../diagnostics/hw_ctx_adapter_service_diag.h | 33 ++++
+ drivers/gpu/drm/amd/dal/dc/core/dc.c | 6 +
+ drivers/gpu/drm/amd/dal/dc/gpio/Makefile | 8 +
+ .../drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.c | 98 +++++++++++
+ .../drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.h | 34 ++++
+ .../amd/dal/dc/gpio/diagnostics/hw_factory_diag.c | 70 ++++++++
+ .../amd/dal/dc/gpio/diagnostics/hw_factory_diag.h | 32 ++++
+ .../drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.c | 102 ++++++++++++
+ .../drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.h | 35 ++++
+ .../dal/dc/gpio/diagnostics/hw_translate_diag.c | 42 +++++
+ .../dal/dc/gpio/diagnostics/hw_translate_diag.h | 34 ++++
+ drivers/gpu/drm/amd/dal/dc/gpio/gpio_service.c | 9 +-
+ drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.c | 14 +-
+ drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.h | 3 +-
+ drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.c | 13 +-
+ drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.h | 3 +-
+ drivers/gpu/drm/amd/dal/dc/i2caux/Makefile | 10 ++
+ .../amd/dal/dc/i2caux/diagnostics/i2caux_diag.c | 113 +++++++++++++
+ .../amd/dal/dc/i2caux/diagnostics/i2caux_diag.h | 33 ++++
+ drivers/gpu/drm/amd/dal/dc/i2caux/i2caux.c | 11 ++
+ drivers/gpu/drm/amd/dal/dc/inc/core_dc.h | 6 +
+ .../amd/dal/include/adapter_service_interface.h | 4 +
+ drivers/gpu/drm/amd/dal/include/dal_types.h | 7 +
+ .../drm/amd/dal/include/gpio_service_interface.h | 3 +-
+ 29 files changed, 973 insertions(+), 75 deletions(-)
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.c
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.h
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.c
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.h
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.c
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.h
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.c
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.h
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.c
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.h
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.c
+ create mode 100644 drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.h
+
+diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c
+index 9879512..7614ac8 100644
+--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c
++++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c
+@@ -527,6 +527,8 @@ int amdgpu_dm_init(struct amdgpu_device *adev)
+ init_data.display_param.bool_param_values |=
+ 1 << DAL_PARAM_ENABLE_GPU_SCALING;
+
++ init_data.dce_environment = DCE_ENV_PRODUCTION_DRV;
++
+ /* Display Core create. */
+ adev->dm.dc = dc_create(&init_data);
+
+diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/Makefile b/drivers/gpu/drm/amd/dal/dc/adapter/Makefile
+index 8ede504..2c6ca7a 100644
+--- a/drivers/gpu/drm/amd/dal/dc/adapter/Makefile
++++ b/drivers/gpu/drm/amd/dal/dc/adapter/Makefile
+@@ -16,3 +16,9 @@ AMD_DAL_FILES += $(AMD_DAL_ADAPTER)
+ ifdef CONFIG_DRM_AMD_DAL_DCE11_0
+ AMD_DAL_FILES += $(AMDDALPATH)/dc/adapter/dce110/hw_ctx_adapter_service_dce110.o
+ endif
++
++###############################################################################
++# FPGA Diagnositcs
++###############################################################################
++
++AMD_DAL_FILES += $(AMDDALPATH)/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.o
+diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
+index b3b3be7..b8d6033 100644
+--- a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
++++ b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
+@@ -45,6 +45,8 @@
+ #include "dce110/hw_ctx_adapter_service_dce110.h"
+ #endif
+
++#include "diagnostics/hw_ctx_adapter_service_diag.h"
++
+ /*
+ * Adapter service feature entry table.
+ *
+@@ -224,6 +226,7 @@ static void initialize_backlight_caps(
+ struct platform_info_params params;
+ bool custom_curve_present = false;
+ bool custom_min_max_present = false;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ if (!(PM_GET_EXTENDED_BRIGHNESS_CAPS & as->platform_methods_mask)) {
+ dal_logger_write(as->ctx->logger,
+@@ -233,8 +236,8 @@ static void initialize_backlight_caps(
+ return;
+ }
+
+- if (as->dcb->funcs->get_firmware_info(as->dcb, &fw_info) != BP_RESULT_OK ||
+- as->dcb->funcs->get_embedded_panel_info(as->dcb, &panel_info) != BP_RESULT_OK)
++ if (dcb->funcs->get_firmware_info(dcb, &fw_info) != BP_RESULT_OK ||
++ dcb->funcs->get_embedded_panel_info(dcb, &panel_info) != BP_RESULT_OK)
+ return;
+
+ params.data = &caps;
+@@ -550,8 +553,9 @@ static bool get_hpd_info(struct adapter_service *as,
+ struct graphics_object_id id,
+ struct graphics_object_hpd_info *info)
+ {
+- return BP_RESULT_OK ==
+- as->dcb->funcs->get_hpd_info(as->dcb, id, info);
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ return BP_RESULT_OK == dcb->funcs->get_hpd_info(dcb, id, info);
+ }
+
+ /*
+@@ -662,8 +666,16 @@ static bool generate_feature_set(
+ */
+ static struct hw_ctx_adapter_service *create_hw_ctx(
+ enum dce_version dce_version,
++ enum dce_environment dce_environment,
+ struct dc_context *ctx)
+ {
++ switch (dce_environment) {
++ case DCE_ENV_DIAG_FPGA_MAXIMUS:
++ return dal_adapter_service_create_hw_ctx_diag(ctx);
++ default:
++ break;
++ }
++
+ switch (dce_version) {
+ #if defined(CONFIG_DRM_AMD_DAL_DCE11_0)
+ case DCE_VERSION_11_0:
+@@ -683,12 +695,20 @@ static struct hw_ctx_adapter_service *create_hw_ctx(
+ static void adapter_service_destruct(
+ struct adapter_service *as)
+ {
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
+ dal_adapter_service_destroy_hw_ctx(&as->hw_ctx);
+ dal_i2caux_destroy(&as->i2caux);
+ dal_gpio_service_destroy(&as->gpio_service);
+ dal_asic_capability_destroy(&as->asic_cap);
+- as->dcb->funcs->destroy_integrated_info(as->dcb, &as->integrated_info);
+- dal_bios_parser_destroy(&as->dcb);
++
++ dcb->funcs->destroy_integrated_info(dcb, &as->integrated_info);
++
++ if (as->dcb_internal) {
++ /* We are responsible only for destruction of Internal BIOS.
++ * The External one will be destroyed by its creator. */
++ dal_bios_parser_destroy(&as->dcb_internal);
++ }
+ }
+
+ /*
+@@ -700,6 +720,9 @@ static bool adapter_service_construct(
+ struct adapter_service *as,
+ struct as_init_data *init_data)
+ {
++ struct dc_bios *dcb;
++ enum dce_version dce_version;
++
+ if (!init_data)
+ return false;
+
+@@ -734,25 +757,32 @@ static bool adapter_service_construct(
+ goto failed_to_generate_features;
+ }
+
++ as->dce_environment = init_data->dce_environment;
++
+ if (init_data->vbios_override)
+- as->dcb = init_data->vbios_override;
++ as->dcb_override = init_data->vbios_override;
+ else {
+ /* Create BIOS parser */
+ init_data->bp_init_data.ctx = init_data->ctx;
+
+- as->dcb = dal_bios_parser_create(&init_data->bp_init_data, as);
+- }
++ as->dcb_internal = dal_bios_parser_create(
++ &init_data->bp_init_data, as);
+
+- if (!as->dcb) {
+- ASSERT_CRITICAL(false);
+- goto failed_to_create_bios_parser;
++ if (!as->dcb_internal) {
++ ASSERT_CRITICAL(false);
++ goto failed_to_create_bios_parser;
++ }
+ }
+
++ dcb = dal_adapter_service_get_bios_parser(as);
++
++ dce_version = dal_adapter_service_get_dce_version(as);
++
+ /* Create GPIO service */
+- as->gpio_service =
+- dal_gpio_service_create(
+- dal_adapter_service_get_dce_version(as),
+- as->ctx);
++ as->gpio_service = dal_gpio_service_create(
++ dce_version,
++ as->dce_environment,
++ as->ctx);
+
+ if (!as->gpio_service) {
+ ASSERT_CRITICAL(false);
+@@ -769,8 +799,9 @@ static bool adapter_service_construct(
+
+ /* Create Adapter Service HW Context*/
+ as->hw_ctx = create_hw_ctx(
+- dal_adapter_service_get_dce_version(as),
+- as->ctx);
++ dce_version,
++ as->dce_environment,
++ as->ctx);
+
+ if (!as->hw_ctx) {
+ ASSERT_CRITICAL(false);
+@@ -780,10 +811,9 @@ static bool adapter_service_construct(
+ /* Avoid wireless encoder creation in upstream branch. */
+
+ /* Integrated info is not provided on discrete ASIC. NULL is allowed */
+- as->integrated_info = as->dcb->funcs->create_integrated_info(
+- as->dcb);
++ as->integrated_info = dcb->funcs->create_integrated_info(dcb);
+
+- as->dcb->funcs->post_init(as->dcb);
++ dcb->funcs->post_init(dcb);
+
+ /* Generate backlight translation table and initializes
+ other brightness properties */
+@@ -805,7 +835,8 @@ failed_to_create_i2caux:
+ dal_gpio_service_destroy(&as->gpio_service);
+
+ failed_to_create_gpio_service:
+- dal_bios_parser_destroy(&as->dcb);
++ if (as->dcb_internal)
++ dal_bios_parser_destroy(&as->dcb_internal);
+
+ failed_to_create_bios_parser:
+ dal_asic_capability_destroy(&as->asic_cap);
+@@ -890,6 +921,13 @@ enum dce_version dal_adapter_service_get_dce_version(
+ }
+ }
+
++enum dce_environment dal_adapter_service_get_dce_environment(
++ const struct adapter_service *as)
++{
++ return as->dce_environment;
++}
++
++
+ /*
+ * dal_adapter_service_get_controllers_num
+ *
+@@ -956,10 +994,12 @@ static bool is_wireless_object(struct graphics_object_id id)
+ uint32_t dal_adapter_service_get_src_num(
+ struct adapter_service *as, struct graphics_object_id id)
+ {
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
+ if (is_wireless_object(id))
+ return wireless_get_srcs_num(as, id);
+ else
+- return as->dcb->funcs->get_src_number(as->dcb, id);
++ return dcb->funcs->get_src_number(dcb, id);
+ }
+
+ /**
+@@ -979,18 +1019,19 @@ struct graphics_object_id dal_adapter_service_get_src_obj(
+ uint32_t index)
+ {
+ struct graphics_object_id src_object_id;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ if (is_wireless_object(id))
+ src_object_id = wireless_get_src_obj_id(as, id, index);
+ else {
+- if (BP_RESULT_OK !=
+- as->dcb->funcs->get_src_obj(
+- as->dcb, id, index, &src_object_id))
++ if (BP_RESULT_OK != dcb->funcs->get_src_obj(dcb, id, index,
++ &src_object_id)) {
+ src_object_id =
+ dal_graphics_object_id_init(
+ 0,
+ ENUM_ID_UNKNOWN,
+ OBJECT_TYPE_UNKNOWN);
++ }
+ }
+
+ return src_object_id;
+@@ -1017,13 +1058,9 @@ struct graphics_object_id dal_adapter_service_get_connector_obj_id(
+ bios_connectors_num = dcb->funcs->get_connectors_number(dcb);
+
+ if (connector_index >= bios_connectors_num)
+- return wireless_get_connector_id(
+- as,
+- connector_index);
++ return wireless_get_connector_id(as, connector_index);
+ else
+- return as->dcb->funcs->get_connector_id(
+- as->dcb,
+- connector_index);
++ return dcb->funcs->get_connector_id(dcb, connector_index);
+ }
+
+ bool dal_adapter_service_get_device_tag(
+@@ -1032,7 +1069,9 @@ bool dal_adapter_service_get_device_tag(
+ uint32_t device_tag_index,
+ struct connector_device_tag_info *info)
+ {
+- if (BP_RESULT_OK == as->dcb->funcs->get_device_tag(as->dcb,
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ if (BP_RESULT_OK == dcb->funcs->get_device_tag(dcb,
+ connector_object_id, device_tag_index, info))
+ return true;
+ else
+@@ -1043,7 +1082,9 @@ bool dal_adapter_service_get_device_tag(
+ bool dal_adapter_service_is_device_id_supported(struct adapter_service *as,
+ struct device_id id)
+ {
+- return as->dcb->funcs->is_device_id_supported(as->dcb, id);
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ return dcb->funcs->is_device_id_supported(dcb, id);
+ }
+
+ bool dal_adapter_service_is_meet_underscan_req(struct adapter_service *as)
+@@ -1080,14 +1121,13 @@ uint8_t dal_adapter_service_get_clock_sources_num(
+ struct firmware_info fw_info;
+ uint32_t max_clk_src = 0;
+ uint32_t num = as->asic_cap->data[ASIC_DATA_CLOCKSOURCES_NUM];
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ /*
+ * Check is system supports the use of the External clock source
+ * as a clock source for DP
+ */
+- enum bp_result bp_result =
+- as->dcb->funcs->get_firmware_info(as->dcb,
+- &fw_info);
++ enum bp_result bp_result = dcb->funcs->get_firmware_info(dcb, &fw_info);
+
+ if (BP_RESULT_OK == bp_result &&
+ fw_info.external_clock_source_frequency_for_dp != 0)
+@@ -1199,13 +1239,14 @@ bool dal_adapter_service_get_i2c_info(
+ struct graphics_object_id id,
+ struct graphics_object_i2c_info *i2c_info)
+ {
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
+ if (!i2c_info) {
+ ASSERT_CRITICAL(false);
+ return false;
+ }
+
+- return BP_RESULT_OK ==
+- as->dcb->funcs->get_i2c_info(as->dcb, id, i2c_info);
++ return BP_RESULT_OK == dcb->funcs->get_i2c_info(dcb, id, i2c_info);
+ }
+
+ /*
+@@ -1256,14 +1297,14 @@ struct irq *dal_adapter_service_obtain_hpd_irq(
+ struct graphics_object_id id)
+ {
+ enum bp_result bp_result;
+-
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+ struct graphics_object_hpd_info hpd_info;
+ struct gpio_pin_info pin_info;
+
+ if (!get_hpd_info(as, id, &hpd_info))
+ return NULL;
+
+- bp_result = as->dcb->funcs->get_gpio_pin_info(as->dcb,
++ bp_result = dcb->funcs->get_gpio_pin_info(dcb,
+ hpd_info.hpd_int_gpio_uid, &pin_info);
+
+ if (bp_result != BP_RESULT_OK) {
+@@ -1298,7 +1339,9 @@ uint32_t dal_adapter_service_get_ss_info_num(
+ struct adapter_service *as,
+ enum as_signal_type signal)
+ {
+- return as->dcb->funcs->get_ss_entry_number(as->dcb, signal);
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ return dcb->funcs->get_ss_entry_number(dcb, signal);
+ }
+
+ /*
+@@ -1312,9 +1355,10 @@ bool dal_adapter_service_get_ss_info(
+ uint32_t idx,
+ struct spread_spectrum_info *info)
+ {
+- enum bp_result bp_result =
+- as->dcb->funcs->get_spread_spectrum_info(
+- as->dcb, signal, idx, info);
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ enum bp_result bp_result = dcb->funcs->get_spread_spectrum_info(dcb,
++ signal, idx, info);
+
+ return BP_RESULT_OK == bp_result;
+ }
+@@ -1521,17 +1565,18 @@ struct gpio *dal_adapter_service_obtain_stereo_gpio(
+
+ struct bp_gpio_cntl_info cntl_info;
+ struct gpio_pin_info pin_info;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ /* Get GPIO record for this object.
+ * Stereo GPIO record should have exactly one entry
+ * where active state defines stereosync polarity */
+- if (1 != as->dcb->funcs->get_gpio_record(
+- as->dcb, id, &cntl_info,
++ if (1 != dcb->funcs->get_gpio_record(
++ dcb, id, &cntl_info,
+ 1)) {
+ return NULL;
+ } else if (BP_RESULT_OK
+- != as->dcb->funcs->get_gpio_pin_info(
+- as->dcb, cntl_info.id,
++ != dcb->funcs->get_gpio_pin_info(
++ dcb, cntl_info.id,
+ &pin_info)) {
+ /*ASSERT_CRITICAL(false);*/
+ return NULL;
+@@ -1564,8 +1609,9 @@ bool dal_adapter_service_get_firmware_info(
+ struct adapter_service *as,
+ struct firmware_info *info)
+ {
+- return as->dcb->funcs->get_firmware_info(as->dcb, info) ==
+- BP_RESULT_OK;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ return dcb->funcs->get_firmware_info(dcb, info) == BP_RESULT_OK;
+ }
+
+ /*
+@@ -1664,7 +1710,7 @@ uint32_t dal_adapter_service_get_memory_type_multiplier(
+ struct dc_bios *dal_adapter_service_get_bios_parser(
+ struct adapter_service *as)
+ {
+- return as->dcb;
++ return as->dcb_override ? as->dcb_override : as->dcb_internal;
+ }
+
+ /*
+@@ -1751,12 +1797,13 @@ bool dal_adapter_service_get_embedded_panel_info(
+ struct embedded_panel_info *info)
+ {
+ enum bp_result result;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ if (info == NULL)
+ /*TODO: add DALASSERT_MSG here*/
+ return false;
+
+- result = as->dcb->funcs->get_embedded_panel_info(as->dcb, info);
++ result = dcb->funcs->get_embedded_panel_info(dcb, info);
+
+ return result == BP_RESULT_OK;
+ }
+@@ -1767,13 +1814,13 @@ bool dal_adapter_service_enum_embedded_panel_patch_mode(
+ struct embedded_panel_patch_mode *mode)
+ {
+ enum bp_result result;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ if (mode == NULL)
+ /*TODO: add DALASSERT_MSG here*/
+ return false;
+
+- result = as->dcb->funcs->enum_embedded_panel_patch_mode(
+- as->dcb, index, mode);
++ result = dcb->funcs->enum_embedded_panel_patch_mode(dcb, index, mode);
+
+ return result == BP_RESULT_OK;
+ }
+@@ -1783,8 +1830,9 @@ bool dal_adapter_service_get_faked_edid_len(
+ uint32_t *len)
+ {
+ enum bp_result result;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+- result = as->dcb->funcs->get_faked_edid_len(as->dcb, len);
++ result = dcb->funcs->get_faked_edid_len(dcb, len);
+
+ return result == BP_RESULT_OK;
+ }
+@@ -1795,11 +1843,10 @@ bool dal_adapter_service_get_faked_edid_buf(
+ uint32_t len)
+ {
+ enum bp_result result;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ result = dcb->funcs->get_faked_edid_buf(dcb, buf, len);
+
+- result = as->dcb->funcs->get_faked_edid_buf(
+- as->dcb,
+- buf,
+- len);
+ return result == BP_RESULT_OK;
+
+ }
+@@ -1886,7 +1933,9 @@ bool dal_adapter_service_should_optimize(
+ */
+ bool dal_adapter_service_is_in_accelerated_mode(struct adapter_service *as)
+ {
+- return as->dcb->funcs->is_accelerated_mode(as->dcb);
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
++
++ return dcb->funcs->is_accelerated_mode(dcb);
+ }
+
+ struct ddc *dal_adapter_service_obtain_ddc_from_i2c_info(
+@@ -1927,6 +1976,7 @@ bool dal_adapter_service_is_lid_open(struct adapter_service *as)
+ {
+ bool is_lid_open = false;
+ struct platform_info_params params;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ params.data = &is_lid_open;
+ params.method = PM_GET_LID_STATE;
+@@ -1936,7 +1986,7 @@ bool dal_adapter_service_is_lid_open(struct adapter_service *as)
+ return is_lid_open;
+
+ #if defined(CONFIG_DRM_AMD_DAL_VBIOS_PRESENT)
+- return as->dcb->funcs->is_lid_open(as->dcb);
++ return dcb->funcs->is_lid_open(dcb);
+ #else
+ return false;
+ #endif
+@@ -2009,6 +2059,7 @@ bool dal_adapter_service_get_encoder_cap_info(
+ {
+ struct bp_encoder_cap_info bp_cap_info = {0};
+ enum bp_result result;
++ struct dc_bios *dcb = dal_adapter_service_get_bios_parser(as);
+
+ if (NULL == info) {
+ ASSERT_CRITICAL(false);
+@@ -2023,10 +2074,7 @@ bool dal_adapter_service_get_encoder_cap_info(
+ * - dpHbr2Cap: indicates supported/not supported by HW Encoder
+ * - dpHbr2En : indicates DP spec compliant/not compliant
+ */
+- result = as->dcb->funcs->get_encoder_cap_info(
+- as->dcb,
+- id,
+- &bp_cap_info);
++ result = dcb->funcs->get_encoder_cap_info(dcb, id, &bp_cap_info);
+
+ /* Set dp_hbr2_validated flag (it's equal to Enable) */
+ info->dp_hbr2_validated = bp_cap_info.DP_HBR2_EN;
+diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
+index 5bb4446..60464e8 100644
+--- a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
++++ b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
+@@ -42,7 +42,9 @@ struct asic_cap;
+ struct adapter_service {
+ struct dc_context *ctx;
+ struct asic_capability *asic_cap;
+- struct dc_bios *dcb;
++ struct dc_bios *dcb_internal;/* created by DC */
++ struct dc_bios *dcb_override;/* supplied by creator of DC */
++ enum dce_environment dce_environment;
+ struct gpio_service *gpio_service;
+ struct i2caux *i2caux;
+ struct wireless_data wireless_data;
+diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.c b/drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.c
+new file mode 100644
+index 0000000..de45ce3
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.c
+@@ -0,0 +1,133 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++/* FPGA Diagnostics version of AS HW CTX. */
++
++#include "dal_services.h"
++
++#include "../hw_ctx_adapter_service.h"
++
++#include "hw_ctx_adapter_service_diag.h"
++
++#include "include/logger_interface.h"
++#include "include/grph_object_id.h"
++
++static const struct graphics_object_id invalid_go = {
++ 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN
++};
++
++static void destroy(
++ struct hw_ctx_adapter_service *hw_ctx)
++{
++}
++
++static bool power_up(
++ struct hw_ctx_adapter_service *hw_ctx)
++{
++ return true;
++}
++
++static struct graphics_object_id enum_fake_path_resource(
++ const struct hw_ctx_adapter_service *hw_ctx,
++ uint32_t index)
++{
++ return invalid_go;
++}
++
++static struct graphics_object_id enum_stereo_sync_object(
++ const struct hw_ctx_adapter_service *hw_ctx,
++ uint32_t index)
++{
++ return invalid_go;
++}
++
++static struct graphics_object_id enum_sync_output_object(
++ const struct hw_ctx_adapter_service *hw_ctx,
++ uint32_t index)
++{
++ return invalid_go;
++}
++
++static struct graphics_object_id enum_audio_object(
++ const struct hw_ctx_adapter_service *hw_ctx,
++ uint32_t index)
++{
++ return invalid_go;
++}
++
++static void update_audio_connectivity(
++ struct hw_ctx_adapter_service *hw_ctx,
++ uint32_t number_of_audio_capable_display_path,
++ uint32_t number_of_controllers)
++{
++}
++
++static const struct hw_ctx_adapter_service_funcs funcs = {
++ destroy,
++ power_up,
++ enum_fake_path_resource,
++ enum_stereo_sync_object,
++ enum_sync_output_object,
++ enum_audio_object,
++ update_audio_connectivity
++};
++
++static bool construct(
++ struct hw_ctx_adapter_service *hw_ctx,
++ struct dc_context *ctx)
++
++{
++ if (!dal_adapter_service_construct_hw_ctx(hw_ctx, ctx)) {
++ ASSERT_CRITICAL(false);
++ return false;
++ }
++
++ hw_ctx->funcs = &funcs;
++
++ return true;
++}
++
++struct hw_ctx_adapter_service *dal_adapter_service_create_hw_ctx_diag(
++ struct dc_context *ctx)
++{
++ struct hw_ctx_adapter_service *hw_ctx = dc_service_alloc(ctx,
++ sizeof(*hw_ctx));
++
++ if (!hw_ctx) {
++ ASSERT_CRITICAL(false);
++ return NULL;
++ }
++
++ if (construct(hw_ctx, ctx))
++ return hw_ctx;
++
++ ASSERT_CRITICAL(false);
++
++ dc_service_free(ctx, hw_ctx);
++
++ return NULL;
++}
++
++/*****************************************************************************/
+diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.h b/drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.h
+new file mode 100644
+index 0000000..39ae752
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/adapter/diagnostics/hw_ctx_adapter_service_diag.h
+@@ -0,0 +1,33 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#ifndef __DAL_HW_CTX_ADAPTER_SERVICE_DIAG_H__
++#define __DAL_HW_CTX_ADAPTER_SERVICE_DIAG_H__
++
++
++struct hw_ctx_adapter_service *dal_adapter_service_create_hw_ctx_diag(
++ struct dc_context *ctx);
++
++#endif /* __DAL_HW_CTX_ADAPTER_SERVICE_DIAG_H__ */
+diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc.c b/drivers/gpu/drm/amd/dal/dc/core/dc.c
+index 4e87da5..14a1171 100644
+--- a/drivers/gpu/drm/amd/dal/dc/core/dc.c
++++ b/drivers/gpu/drm/amd/dal/dc/core/dc.c
+@@ -228,6 +228,7 @@ static struct adapter_service *create_as(
+
+ init_data.display_param = &init->display_param;
+ init_data.vbios_override = init->vbios_override;
++ init_data.dce_environment = init->dce_environment;
+
+ as = dal_adapter_service_create(&init_data);
+
+@@ -334,6 +335,11 @@ static bool construct(struct dc *dc, const struct dal_init_data *init_params)
+
+ dc->ctx = dc_init_data.ctx;
+
++ dc->dce_version = dal_adapter_service_get_dce_version(
++ dc_init_data.adapter_srv);
++ dc->dce_environment = dal_adapter_service_get_dce_environment(
++ dc_init_data.adapter_srv);
++
+ /* Create hardware sequencer */
+ if (!dc_construct_hw_sequencer(dc_init_data.adapter_srv, dc))
+ goto hwss_fail;
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/Makefile b/drivers/gpu/drm/amd/dal/dc/gpio/Makefile
+index 7380910..50a1d34 100644
+--- a/drivers/gpu/drm/amd/dal/dc/gpio/Makefile
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/Makefile
+@@ -22,3 +22,11 @@ AMD_DAL_GPIO_DCE110 = $(addprefix $(AMDDALPATH)/dc/gpio/dce110/,$(GPIO_DCE110))
+ AMD_DAL_FILES += $(AMD_DAL_GPIO_DCE110)
+ endif
+
++###############################################################################
++# Diagnostics on FPGA
++###############################################################################
++GPIO_DIAG_FPGA = hw_translate_diag.o hw_factory_diag.o hw_hpd_diag.o hw_ddc_diag.o
++
++AMD_DAL_GPIO_DIAG_FPGA = $(addprefix $(AMDDALPATH)/dc/gpio/diagnostics/,$(GPIO_DIAG_FPGA))
++
++AMD_DAL_FILES += $(AMD_DAL_GPIO_DIAG_FPGA)
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.c b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.c
+new file mode 100644
+index 0000000..f566241
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.c
+@@ -0,0 +1,98 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#include "dal_services.h"
++
++/*
++ * Pre-requisites: headers required by header of this unit
++ */
++
++#include "include/gpio_types.h"
++#include "../hw_gpio_pin.h"
++#include "../hw_gpio.h"
++#include "../hw_ddc.h"
++
++/*
++ * This unit
++ */
++static void destruct(
++ struct hw_ddc *pin)
++{
++ dal_hw_ddc_destruct(pin);
++}
++
++static void destroy(
++ struct hw_gpio_pin **ptr)
++{
++ struct hw_ddc *pin = HW_DDC_FROM_BASE(*ptr);
++
++ destruct(pin);
++
++ dc_service_free((*ptr)->ctx, pin);
++
++ *ptr = NULL;
++}
++
++static const struct hw_gpio_pin_funcs funcs = {
++ .destroy = destroy,
++ .open = NULL,
++ .get_value = NULL,
++ .set_value = NULL,
++ .set_config = NULL,
++ .change_mode = NULL,
++ .close = NULL,
++};
++
++static bool construct(
++ struct hw_ddc *pin,
++ enum gpio_id id,
++ uint32_t en,
++ struct dc_context *ctx)
++{
++ pin->base.base.funcs = &funcs;
++ return true;
++}
++
++struct hw_gpio_pin *dal_hw_ddc_diag_fpga_create(
++ struct dc_context *ctx,
++ enum gpio_id id,
++ uint32_t en)
++{
++ struct hw_ddc *pin = dc_service_alloc(ctx, sizeof(struct hw_ddc));
++
++ if (!pin) {
++ ASSERT_CRITICAL(false);
++ return NULL;
++ }
++
++ if (construct(pin, id, en, ctx))
++ return &pin->base.base;
++
++ ASSERT_CRITICAL(false);
++
++ dc_service_free(ctx, pin);
++
++ return NULL;
++}
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.h b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.h
+new file mode 100644
+index 0000000..7515aaf
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_ddc_diag.h
+@@ -0,0 +1,34 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#ifndef __DAL_HW_DDC_DIAG_FPGA_H__
++#define __DAL_HW_DDC_DIAG_FPGA_H__
++
++struct hw_gpio_pin *dal_hw_ddc_diag_fpga_create(
++ struct dc_context *ctx,
++ enum gpio_id id,
++ uint32_t en);
++
++#endif
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.c b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.c
+new file mode 100644
+index 0000000..13b69e2
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.c
+@@ -0,0 +1,70 @@
++/*
++ * Copyright 2013-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++/*
++ * Pre-requisites: headers required by header of this unit
++ */
++
++#include "dal_services.h"
++#include "include/gpio_types.h"
++#include "../hw_factory.h"
++
++/*
++ * Header of this unit
++ */
++
++#include "../hw_gpio_pin.h"
++#include "../hw_gpio.h"
++#include "../hw_ddc.h"
++#include "../hw_hpd.h"
++
++/* function table */
++static const struct hw_factory_funcs funcs = {
++ .create_dvo = NULL,
++ .create_ddc_data = NULL,
++ .create_ddc_clock = NULL,
++ .create_generic = NULL,
++ .create_hpd = NULL,
++ .create_gpio_pad = NULL,
++ .create_sync = NULL,
++ .create_gsl = NULL,
++};
++
++void dal_hw_factory_diag_fpga_init(struct hw_factory *factory)
++{
++ factory->number_of_pins[GPIO_ID_DVO1] = 24;
++ factory->number_of_pins[GPIO_ID_DVO12] = 2;
++ factory->number_of_pins[GPIO_ID_DVO24] = 1;
++ factory->number_of_pins[GPIO_ID_DDC_DATA] = 8;
++ factory->number_of_pins[GPIO_ID_DDC_CLOCK] = 8;
++ factory->number_of_pins[GPIO_ID_GENERIC] = 7;
++ factory->number_of_pins[GPIO_ID_HPD] = 6;
++ factory->number_of_pins[GPIO_ID_GPIO_PAD] = 31;
++ factory->number_of_pins[GPIO_ID_VIP_PAD] = 0;
++ factory->number_of_pins[GPIO_ID_SYNC] = 2;
++ factory->number_of_pins[GPIO_ID_GSL] = 4;
++
++ factory->funcs = &funcs;
++}
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.h b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.h
+new file mode 100644
+index 0000000..8a74f6a
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_factory_diag.h
+@@ -0,0 +1,32 @@
++/*
++ * Copyright 2013-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#ifndef __DAL_HW_FACTORY_DIAG_FPGA_H__
++#define __DAL_HW_FACTORY_DIAG_FPGA_H__
++
++/* Initialize HW factory function pointers and pin info */
++void dal_hw_factory_diag_fpga_init(struct hw_factory *factory);
++
++#endif /* __DAL_HW_FACTORY_DIAG_FPGA_H__ */
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.c b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.c
+new file mode 100644
+index 0000000..baf5caf
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.c
+@@ -0,0 +1,102 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#include "dal_services.h"
++
++/*
++ * Pre-requisites: headers required by header of this unit
++ */
++
++#include "include/gpio_types.h"
++#include "../hw_gpio_pin.h"
++#include "../hw_gpio.h"
++#include "../hw_hpd.h"
++
++
++static void destruct(
++ struct hw_hpd *pin)
++{
++ dal_hw_hpd_destruct(pin);
++}
++
++static void destroy(
++ struct hw_gpio_pin **ptr)
++{
++ struct hw_hpd *pin = HW_HPD_FROM_BASE(*ptr);
++
++ destruct(pin);
++
++ dc_service_free((*ptr)->ctx, pin);
++
++ *ptr = NULL;
++}
++
++static const struct hw_gpio_pin_funcs funcs = {
++ .destroy = destroy,
++ .open = NULL,
++ .get_value = NULL,
++ .set_value = NULL,
++ .set_config = NULL,
++ .change_mode = NULL,
++ .close = NULL,
++};
++
++static bool construct(
++ struct hw_hpd *pin,
++ enum gpio_id id,
++ uint32_t en,
++ struct dc_context *ctx)
++{
++ if (!dal_hw_hpd_construct(pin, id, en, ctx)) {
++ ASSERT_CRITICAL(false);
++ return false;
++ }
++
++ pin->base.base.funcs = &funcs;
++
++ return true;
++}
++
++struct hw_gpio_pin *dal_hw_hpd_diag_fpga_create(
++ struct dc_context *ctx,
++ enum gpio_id id,
++ uint32_t en)
++{
++ struct hw_hpd *pin = dc_service_alloc(ctx, sizeof(struct hw_hpd));
++
++ if (!pin) {
++ ASSERT_CRITICAL(false);
++ return NULL;
++ }
++
++ if (construct(pin, id, en, ctx))
++ return &pin->base.base;
++
++ ASSERT_CRITICAL(false);
++
++ dc_service_free(ctx, pin);
++
++ return NULL;
++}
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.h b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.h
+new file mode 100644
+index 0000000..bfa2c24
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_hpd_diag.h
+@@ -0,0 +1,35 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#ifndef __DAL_HW_HPD_DIAG_FPGA_H__
++#define __DAL_HW_HPD_DIAG_FPGA_H__
++
++
++struct hw_gpio_pin *dal_hw_hpd_diag_fpga_create(
++ struct dc_context *ctx,
++ enum gpio_id id,
++ uint32_t en);
++
++#endif /*__DAL_HW_HPD_DIAG_FPGA_H__*/
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.c b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.c
+new file mode 100644
+index 0000000..6d4da30
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.c
+@@ -0,0 +1,42 @@
++/*
++ * Copyright 2013-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++
++#include "dal_services.h"
++#include "include/gpio_types.h"
++
++#include "../hw_translate.h"
++
++
++/* function table */
++static const struct hw_translate_funcs funcs = {
++ .offset_to_id = NULL,
++ .id_to_offset = NULL,
++};
++
++void dal_hw_translate_diag_fpga_init(struct hw_translate *tr)
++{
++ tr->funcs = &funcs;
++}
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.h b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.h
+new file mode 100644
+index 0000000..4f05324
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/diagnostics/hw_translate_diag.h
+@@ -0,0 +1,34 @@
++/*
++ * Copyright 2013-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#ifndef __DAL_HW_TRANSLATE_DIAG_FPGA_H__
++#define __DAL_HW_TRANSLATE_DIAG_FPGA_H__
++
++struct hw_translate;
++
++/* Initialize Hw translate function pointers */
++void dal_hw_translate_diag_fpga_init(struct hw_translate *tr);
++
++#endif /* __DAL_HW_TRANSLATE_DIAG_FPGA_H__ */
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/gpio_service.c b/drivers/gpu/drm/amd/dal/dc/gpio/gpio_service.c
+index 660f80f..3a6b5f4 100644
+--- a/drivers/gpu/drm/amd/dal/dc/gpio/gpio_service.c
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/gpio_service.c
+@@ -63,7 +63,8 @@
+ */
+
+ struct gpio_service *dal_gpio_service_create(
+- enum dce_version dce_version,
++ enum dce_version dce_version_major,
++ enum dce_version dce_version_minor,
+ struct dc_context *ctx)
+ {
+ struct gpio_service *service;
+@@ -77,12 +78,14 @@ struct gpio_service *dal_gpio_service_create(
+ return NULL;
+ }
+
+- if (!dal_hw_translate_init(&service->translate, dce_version)) {
++ if (!dal_hw_translate_init(&service->translate, dce_version_major,
++ dce_version_minor)) {
+ BREAK_TO_DEBUGGER();
+ goto failure_1;
+ }
+
+- if (!dal_hw_factory_init(&service->factory, dce_version)) {
++ if (!dal_hw_factory_init(&service->factory, dce_version_major,
++ dce_version_minor)) {
+ BREAK_TO_DEBUGGER();
+ goto failure_1;
+ }
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.c b/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.c
+index d1b6b7e..a01024e 100644
+--- a/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.c
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.c
+@@ -44,14 +44,26 @@
+ #if defined(CONFIG_DRM_AMD_DAL_DCE11_0)
+ #include "dce110/hw_factory_dce110.h"
+ #endif
++
++#include "diagnostics/hw_factory_diag.h"
++
+ /*
+ * This unit
+ */
+
+ bool dal_hw_factory_init(
+ struct hw_factory *factory,
+- enum dce_version dce_version)
++ enum dce_version dce_version,
++ enum dce_environment dce_environment)
+ {
++ switch (dce_environment) {
++ case DCE_ENV_DIAG_FPGA_MAXIMUS:
++ dal_hw_factory_diag_fpga_init(factory);
++ return true;
++ default:
++ break;
++ }
++
+ switch (dce_version) {
+
+ #if defined(CONFIG_DRM_AMD_DAL_DCE11_0)
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.h b/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.h
+index f16678c..7fef3fa 100644
+--- a/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.h
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/hw_factory.h
+@@ -69,6 +69,7 @@ struct hw_factory {
+
+ bool dal_hw_factory_init(
+ struct hw_factory *factory,
+- enum dce_version dce_version);
++ enum dce_version dce_version,
++ enum dce_environment dce_environment);
+
+ #endif
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.c b/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.c
+index 96e135f..d49e952 100644
+--- a/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.c
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.c
+@@ -45,14 +45,25 @@
+ #include "dce110/hw_translate_dce110.h"
+ #endif
+
++#include "diagnostics/hw_translate_diag.h"
++
+ /*
+ * This unit
+ */
+
+ bool dal_hw_translate_init(
+ struct hw_translate *translate,
+- enum dce_version dce_version)
++ enum dce_version dce_version,
++ enum dce_environment dce_environment)
+ {
++ switch (dce_environment) {
++ case DCE_ENV_DIAG_FPGA_MAXIMUS:
++ dal_hw_translate_diag_fpga_init(translate);
++ return true;
++ default:
++ break;
++ }
++
+ switch (dce_version) {
+
+ #if defined(CONFIG_DRM_AMD_DAL_DCE11_0)
+diff --git a/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.h b/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.h
+index d5740ac..3a7d89c 100644
+--- a/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.h
++++ b/drivers/gpu/drm/amd/dal/dc/gpio/hw_translate.h
+@@ -44,6 +44,7 @@ struct hw_translate {
+
+ bool dal_hw_translate_init(
+ struct hw_translate *translate,
+- enum dce_version dce_version);
++ enum dce_version dce_version,
++ enum dce_environment dce_environment);
+
+ #endif
+diff --git a/drivers/gpu/drm/amd/dal/dc/i2caux/Makefile b/drivers/gpu/drm/amd/dal/dc/i2caux/Makefile
+index 15902a8..390d83d 100644
+--- a/drivers/gpu/drm/amd/dal/dc/i2caux/Makefile
++++ b/drivers/gpu/drm/amd/dal/dc/i2caux/Makefile
+@@ -21,3 +21,13 @@ AMD_DAL_I2CAUX_DCE110 = $(addprefix $(AMDDALPATH)/dc/i2caux/dce110/,$(I2CAUX_DCE
+
+ AMD_DAL_FILES += $(AMD_DAL_I2CAUX_DCE110)
+ endif
++
++###############################################################################
++# Diagnostics on FPGA
++###############################################################################
++I2CAUX_DIAG = i2caux_diag.o
++
++AMD_DAL_I2CAUX_DIAG = $(addprefix $(AMDDALPATH)/dc/i2caux/diagnostics/,$(I2CAUX_DIAG))
++
++AMD_DAL_FILES += $(AMD_DAL_I2CAUX_DIAG)
++
+diff --git a/drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.c b/drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.c
+new file mode 100644
+index 0000000..86b606d
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.c
+@@ -0,0 +1,113 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#include "dal_services.h"
++
++/*
++ * Pre-requisites: headers required by header of this unit
++ */
++
++#include "include/i2caux_interface.h"
++#include "../i2caux.h"
++#include "../engine.h"
++#include "../i2c_engine.h"
++#include "../i2c_sw_engine.h"
++#include "../i2c_hw_engine.h"
++
++/*
++ * Header of this unit
++ */
++#include "i2caux_diag.h"
++
++/*
++ * Post-requisites: headers required by this unit
++ */
++
++/*
++ * This unit
++ */
++
++static void destruct(
++ struct i2caux *i2caux)
++{
++ dal_i2caux_destruct(i2caux);
++}
++
++static void destroy(
++ struct i2caux **i2c_engine)
++{
++ destruct(*i2c_engine);
++
++ dc_service_free((*i2c_engine)->ctx, *i2c_engine);
++
++ *i2c_engine = NULL;
++}
++
++
++
++/* function table */
++static const struct i2caux_funcs i2caux_funcs = {
++ .destroy = destroy,
++ .acquire_i2c_hw_engine = NULL,
++ .release_engine = NULL,
++ .acquire_i2c_sw_engine = NULL,
++ .acquire_aux_engine = NULL,
++};
++
++static bool construct(
++ struct i2caux *i2caux,
++ struct adapter_service *as,
++ struct dc_context *ctx)
++{
++ if (!dal_i2caux_construct(i2caux, as, ctx)) {
++ ASSERT_CRITICAL(false);
++ return false;
++ }
++
++ i2caux->funcs = &i2caux_funcs;
++
++ return true;
++}
++
++struct i2caux *dal_i2caux_diag_fpga_create(
++ struct adapter_service *as,
++ struct dc_context *ctx)
++{
++ struct i2caux *i2caux = dc_service_alloc(ctx, sizeof(struct i2caux));
++
++ if (!i2caux) {
++ ASSERT_CRITICAL(false);
++ return NULL;
++ }
++
++ if (construct(i2caux, as, ctx))
++ return i2caux;
++
++ ASSERT_CRITICAL(false);
++
++ dc_service_free(ctx, i2caux);
++
++ return NULL;
++}
+diff --git a/drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.h b/drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.h
+new file mode 100644
+index 0000000..3de250b
+--- /dev/null
++++ b/drivers/gpu/drm/amd/dal/dc/i2caux/diagnostics/i2caux_diag.h
+@@ -0,0 +1,33 @@
++/*
++ * Copyright 2012-16 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.
++ *
++ * Authors: AMD
++ *
++ */
++
++#ifndef __DAL_I2C_AUX_DIAG_FPGA_H__
++#define __DAL_I2C_AUX_DIAG_FPGA_H__
++
++struct i2caux *dal_i2caux_diag_fpga_create(
++ struct adapter_service *as,
++ struct dc_context *ctx);
++
++#endif /* __DAL_I2C_AUX_DIAG_FPGA_H__ */
+diff --git a/drivers/gpu/drm/amd/dal/dc/i2caux/i2caux.c b/drivers/gpu/drm/amd/dal/dc/i2caux/i2caux.c
+index 50262a4..6de108c 100644
+--- a/drivers/gpu/drm/amd/dal/dc/i2caux/i2caux.c
++++ b/drivers/gpu/drm/amd/dal/dc/i2caux/i2caux.c
+@@ -53,6 +53,8 @@
+ #include "dce110/i2caux_dce110.h"
+ #endif
+
++#include "diagnostics/i2caux_diag.h"
++
+ /*
+ * @brief
+ * Plain API, available publicly
+@@ -63,6 +65,7 @@ struct i2caux *dal_i2caux_create(
+ struct dc_context *ctx)
+ {
+ enum dce_version dce_version;
++ enum dce_environment dce_environment;
+
+ if (!as) {
+ BREAK_TO_DEBUGGER();
+@@ -70,6 +73,14 @@ struct i2caux *dal_i2caux_create(
+ }
+
+ dce_version = dal_adapter_service_get_dce_version(as);
++ dce_environment = dal_adapter_service_get_dce_environment(as);
++
++ switch (dce_environment) {
++ case DCE_ENV_DIAG_FPGA_MAXIMUS:
++ return dal_i2caux_diag_fpga_create(as, ctx);
++ default:
++ break;
++ }
+
+ switch (dce_version) {
+ #if defined(CONFIG_DRM_AMD_DAL_DCE11_0)
+diff --git a/drivers/gpu/drm/amd/dal/dc/inc/core_dc.h b/drivers/gpu/drm/amd/dal/dc/inc/core_dc.h
+index 9d62a24..be46f97 100644
+--- a/drivers/gpu/drm/amd/dal/dc/inc/core_dc.h
++++ b/drivers/gpu/drm/amd/dal/dc/inc/core_dc.h
+@@ -34,6 +34,12 @@ struct dc {
+
+ /* HW functions */
+ struct hw_sequencer_funcs hwss;
++
++ /* Diagnostics */
++ enum dce_version dce_version;
++ enum dce_environment dce_environment;
+ };
+
++#define IS_DIAGNOSTICS_DC(dc) ((dc)->dce_environment == DCE_ENV_DIAG_FPGA_MAXIMUS)
++
+ #endif /* __CORE_DC_H__ */
+diff --git a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
+index 2851266..8ebbe65 100644
+--- a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
++++ b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
+@@ -322,6 +322,7 @@ struct as_init_data {
+ struct bdf_info bdf_info;
+ const struct dal_override_parameters *display_param;
+ struct dc_bios *vbios_override;
++ enum dce_environment dce_environment;
+ };
+
+ /* Create adapter service */
+@@ -336,6 +337,9 @@ void dal_adapter_service_destroy(
+ enum dce_version dal_adapter_service_get_dce_version(
+ const struct adapter_service *as);
+
++enum dce_environment dal_adapter_service_get_dce_environment(
++ const struct adapter_service *as);
++
+ /* Get firmware information from BIOS */
+ bool dal_adapter_service_get_firmware_info(
+ struct adapter_service *as,
+diff --git a/drivers/gpu/drm/amd/dal/include/dal_types.h b/drivers/gpu/drm/amd/dal/include/dal_types.h
+index caaacf6..f756d36 100644
+--- a/drivers/gpu/drm/amd/dal/include/dal_types.h
++++ b/drivers/gpu/drm/amd/dal/include/dal_types.h
+@@ -40,6 +40,12 @@ enum dce_version {
+ DCE_VERSION_MAX
+ };
+
++enum dce_environment {
++ DCE_ENV_PRODUCTION_DRV = 0,
++ DCE_ENV_DIAG_FPGA_MAXIMUS, /* Emulation on FPGA, in Maximus System. */
++ DCE_ENV_DIAG_SILICON, /* Emulation on real HW */
++};
++
+ /*
+ * ASIC Runtime Flags
+ */
+@@ -141,6 +147,7 @@ struct dal_init_data {
+ /* If 'vbios_override' not NULL, it will be called instead
+ * of the real VBIOS. Intended use is Diagnostics on FPGA. */
+ struct dc_bios *vbios_override;
++ enum dce_environment dce_environment;
+ };
+
+ struct dal_dc_init_data {
+diff --git a/drivers/gpu/drm/amd/dal/include/gpio_service_interface.h b/drivers/gpu/drm/amd/dal/include/gpio_service_interface.h
+index b22bb1b..b4f30dd 100644
+--- a/drivers/gpu/drm/amd/dal/include/gpio_service_interface.h
++++ b/drivers/gpu/drm/amd/dal/include/gpio_service_interface.h
+@@ -35,7 +35,8 @@
+ struct gpio_service;
+
+ struct gpio_service *dal_gpio_service_create(
+- enum dce_version dce_version,
++ enum dce_version dce_version_major,
++ enum dce_version dce_version_minor,
+ struct dc_context *ctx);
+
+ struct gpio *dal_gpio_service_create_gpio(
+--
+2.7.4
+