[PATCH 16/76] drm/amd/dal: refactor bios scratch register access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tony Cheng <tony.cheng@xxxxxxx>

- offset of scratch register stored in dc_bios and assigned by resource.
- common code to set various of bits to communicate with bios.

Signed-off-by: Tony Cheng <tony.cheng at amd.com>
Acked-by: Harry Wentland <harry.wentland at amd.com>
---
 drivers/gpu/drm/amd/dal/dc/bios/Makefile           |   6 --
 drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c      |  14 +--
 .../gpu/drm/amd/dal/dc/bios/bios_parser_helper.c   |  65 +++++++-----
 .../gpu/drm/amd/dal/dc/bios/bios_parser_helper.h   |  26 +----
 .../gpu/drm/amd/dal/dc/bios/dce110/bios_dce110.h   |   6 --
 .../dal/dc/bios/dce110/bios_parser_helper_dce110.c | 118 ---------------------
 .../dal/dc/bios/dce110/bios_parser_helper_dce110.h |  34 ------
 .../dal/dc/bios/dce112/bios_parser_helper_dce112.c |  81 --------------
 .../dal/dc/bios/dce112/bios_parser_helper_dce112.h |  34 ------
 .../dal/dc/bios/dce80/bios_parser_helper_dce80.c   |  67 ------------
 .../dal/dc/bios/dce80/bios_parser_helper_dce80.h   |  33 ------
 drivers/gpu/drm/amd/dal/dc/dc_bios_types.h         |   5 +
 .../gpu/drm/amd/dal/dc/dce100/dce100_resource.c    |   7 ++
 .../drm/amd/dal/dc/dce110/dce110_hw_sequencer.c    |   4 +-
 .../gpu/drm/amd/dal/dc/dce110/dce110_resource.c    |   6 ++
 .../gpu/drm/amd/dal/dc/dce112/dce112_resource.c    |   7 ++
 drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c  |   7 ++
 17 files changed, 80 insertions(+), 440 deletions(-)
 delete mode 100644 drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_dce110.h
 delete mode 100644 drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.c
 delete mode 100644 drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.h
 delete mode 100644 drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.c
 delete mode 100644 drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.h
 delete mode 100644 drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.c
 delete mode 100644 drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.h

diff --git a/drivers/gpu/drm/amd/dal/dc/bios/Makefile b/drivers/gpu/drm/amd/dal/dc/bios/Makefile
index 328215a1c00b..20480d6e2a02 100644
--- a/drivers/gpu/drm/amd/dal/dc/bios/Makefile
+++ b/drivers/gpu/drm/amd/dal/dc/bios/Makefile
@@ -13,18 +13,12 @@ AMD_DAL_FILES += $(AMD_DAL_BIOS)
 ###############################################################################
 # All DCE8.x are derived from DCE8.0, so 8.0 MUST be defined if ANY of
 # DCE8.x is compiled.
-AMD_DAL_FILES += $(AMDDALPATH)/dc/bios/dce80/bios_parser_helper_dce80.o
-
 AMD_DAL_FILES += $(AMDDALPATH)/dc/bios/dce80/command_table_helper_dce80.o
 
 ###############################################################################
 # DCE 11x
 ###############################################################################
-AMD_DAL_FILES += $(AMDDALPATH)/dc/bios/dce110/bios_parser_helper_dce110.o
-
 AMD_DAL_FILES += $(AMDDALPATH)/dc/bios/dce110/command_table_helper_dce110.o
 
 ccflags-y += -DLATEST_ATOM_BIOS_SUPPORT
-AMD_DAL_FILES += $(AMDDALPATH)/dc/bios/dce112/bios_parser_helper_dce112.o
-
 AMD_DAL_FILES += $(AMDDALPATH)/dc/bios/dce112/command_table_helper_dce112.o
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
index 1080c6c5527b..79669d9516cb 100644
--- a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
+++ b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
@@ -37,7 +37,6 @@
 
 #include "command_table.h"
 #include "bios_parser_helper.h"
-#include "dce110/bios_dce110.h"
 #include "command_table_helper.h"
 #include "bios_parser.h"
 #include "bios_parser_types_internal.h"
@@ -3667,10 +3666,7 @@ static void bios_parser_post_init(struct dc_bios *dcb,
 static bool bios_parser_is_accelerated_mode(
 	struct dc_bios *dcb)
 {
-	struct bios_parser *bp = BP_FROM_DCB(dcb);
-
-	return bp->bios_helper->is_accelerated_mode(
-			bp->base.ctx);
+	bios_is_accelerated_mode(dcb);
 }
 
 /**
@@ -3686,10 +3682,7 @@ static void bios_parser_set_scratch_critical_state(
 	struct dc_bios *dcb,
 	bool state)
 {
-	struct bios_parser *bp = BP_FROM_DCB(dcb);
-
-	dce110_set_scratch_critical_state(
-			bp->base.ctx, state);
+	bios_set_scratch_critical_state(dcb, state);
 }
 
 /*
@@ -4127,7 +4120,7 @@ static const struct dc_vbios_funcs vbios_funcs = {
 	.get_encoder_cap_info = bios_parser_get_encoder_cap_info,
 
 	/* bios scratch register communication */
-	.is_accelerated_mode = bios_parser_is_accelerated_mode,
+	.is_accelerated_mode = bios_is_accelerated_mode,
 
 	.set_scratch_critical_state = bios_parser_set_scratch_critical_state,
 
@@ -4243,7 +4236,6 @@ static bool bios_parser_construct(
 	else
 		return false;
 
-	dal_bios_parser_init_bios_helper(bp, dce_version);
 	dal_bios_parser_init_cmd_tbl(bp);
 	dal_bios_parser_init_cmd_tbl_helper(&bp->cmd_helper, dce_version);
 
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.c b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.c
index 15d57badd716..8e56d2f25dea 100644
--- a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.c
+++ b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.c
@@ -33,33 +33,6 @@
 #include "command_table.h"
 #include "bios_parser_types_internal.h"
 
-bool dal_bios_parser_init_bios_helper(
-	struct bios_parser *bp,
-	enum dce_version version)
-{
-	switch (version) {
-	case DCE_VERSION_8_0:
-		bp->bios_helper = dal_bios_parser_helper_dce80_get_table();
-		return true;
-	case DCE_VERSION_10_0:
-		bp->bios_helper = dal_bios_parser_helper_dce110_get_table();
-		return true;
-
-	case DCE_VERSION_11_0:
-		bp->bios_helper = dal_bios_parser_helper_dce110_get_table();
-		return true;
-
-	case DCE_VERSION_11_2:
-		bp->bios_helper = dal_bios_parser_helper_dce112_get_table();
-		return true;
-
-	default:
-		BREAK_TO_DEBUGGER();
-		return false;
-	}
-}
-
-
 uint8_t *get_image(struct dc_bios *bp,
 	uint32_t offset,
 	uint32_t size)
@@ -69,3 +42,41 @@ uint8_t *get_image(struct dc_bios *bp,
 	else
 		return NULL;
 }
+
+#include "reg_helper.h"
+
+#define CTX \
+	bios->ctx
+#define REG(reg)\
+	(bios->regs->reg)
+
+#undef FN
+#define FN(reg_name, field_name) \
+		ATOM_ ## field_name ## _SHIFT, ATOM_ ## field_name
+
+bool bios_is_accelerated_mode(
+	struct dc_bios *bios)
+{
+	uint32_t acc_mode;
+	REG_GET(BIOS_SCRATCH_6, S6_ACC_MODE, &acc_mode);
+	return (acc_mode == 1);
+}
+
+
+void bios_set_scratch_acc_mode_change(
+	struct dc_bios *bios)
+{
+	REG_UPDATE(BIOS_SCRATCH_6, S6_ACC_MODE, 1);
+}
+
+
+void bios_set_scratch_critical_state(
+	struct dc_bios *bios,
+	bool state)
+{
+	uint32_t critial_state = state ? 1 : 0;
+	REG_UPDATE(BIOS_SCRATCH_6, S6_CRITICAL_STATE, critial_state);
+}
+
+
+
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.h b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.h
index 3b70a123f3f3..a8fbb82b8c8e 100644
--- a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.h
+++ b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser_helper.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012-15 Advanced Micro Devices, Inc.
+ * 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"),
@@ -26,31 +26,15 @@
 #ifndef __DAL_BIOS_PARSER_HELPER_H__
 #define __DAL_BIOS_PARSER_HELPER_H__
 
-#include "dce80/bios_parser_helper_dce80.h"
-
-#include "dce110/bios_parser_helper_dce110.h"
-
-#include "dce112/bios_parser_helper_dce112.h"
-
 struct bios_parser;
 
-struct bios_parser_helper {
-	bool (*is_accelerated_mode)(
-		struct dc_context *ctx);
-};
-
-bool dal_bios_parser_init_bios_helper(
-	struct bios_parser *bp,
-	enum dce_version ver);
-
-
 uint8_t *get_image(struct dc_bios *bp, uint32_t offset,
 	uint32_t size);
 
-#define GET_IMAGE(type, offset) ((type *) get_image(&bp->base, offset, sizeof(type)))
-
-
-
+bool bios_is_accelerated_mode(struct dc_bios *bios);
+void bios_set_scratch_acc_mode_change(struct dc_bios *bios);
+void bios_set_scratch_critical_state(struct dc_bios *bios, bool state);
 
+#define GET_IMAGE(type, offset) ((type *) get_image(&bp->base, offset, sizeof(type)))
 
 #endif
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_dce110.h b/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_dce110.h
deleted file mode 100644
index fd8629603aa6..000000000000
--- a/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_dce110.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef BIOS_DCE110_H
-#define BIOS_DCE110_H
-void dce110_set_scratch_critical_state(struct dc_context *ctx,
-				       bool state);
-void dce110_set_scratch_acc_mode_change(struct dc_context *ctx);
-#endif
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.c b/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.c
deleted file mode 100644
index 5b7c13f59b8c..000000000000
--- a/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2012-15 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, sub license,
- * 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 "dm_services.h"
-
-#include "atom.h"
-
-#include "include/bios_parser_types.h"
-#include "include/adapter_service_types.h"
-#include "include/logger_interface.h"
-
-#include "../bios_parser_helper.h"
-
-#include "dce/dce_11_0_d.h"
-#include "bif/bif_5_1_d.h"
-
-/**
- * set_scratch_acc_mode_change
- *
- * @brief
- *  set Accelerated Mode in VBIOS scratch register, VBIOS will clean it when
- *  VGA/non-Accelerated mode is set
- *
- * @param
- *  struct dc_context *ctx - [in] DAL context
- */
-void dce110_set_scratch_acc_mode_change(struct dc_context *ctx)
-{
-	uint32_t addr = mmBIOS_SCRATCH_6;
-	uint32_t value = 0;
-
-	value = dm_read_reg(ctx, addr);
-
-	value |= ATOM_S6_ACC_MODE;
-
-	dm_write_reg(ctx, addr, value);
-}
-
-/*
- * is_accelerated_mode
- *
- * @brief
- *  set Accelerated Mode in VBIOS scratch register, VBIOS will clean it when
- *  VGA/non-Accelerated mode is set
- *
- * @param
- * struct dc_context *ctx
- *
- * @return
- * true if in acceleration mode, false otherwise.
- */
-static bool is_accelerated_mode(
-	struct dc_context *ctx)
-{
-	uint32_t addr = mmBIOS_SCRATCH_6;
-	uint32_t value = dm_read_reg(ctx, addr);
-
-	return (value & ATOM_S6_ACC_MODE) ? true : false;
-}
-
-#define BIOS_SCRATCH0_DAC_B_SHIFT 8
-
-void dce110_set_scratch_critical_state(struct dc_context *ctx,
-				       bool state)
-{
-	uint32_t addr = mmBIOS_SCRATCH_6;
-	uint32_t value = dm_read_reg(ctx, addr);
-
-	if (state)
-		value |= ATOM_S6_CRITICAL_STATE;
-	else
-		value &= ~ATOM_S6_CRITICAL_STATE;
-
-	dm_write_reg(ctx, addr, value);
-}
-
-/* function table */
-static const struct bios_parser_helper bios_parser_helper_funcs = {
-	.is_accelerated_mode = is_accelerated_mode,
-};
-
-/*
- * dal_bios_parser_dce110_init_bios_helper
- *
- * @brief
- * Initialize BIOS helper functions
- *
- * @param
- * const struct command_table_helper **h - [out] struct of functions
- *
- */
-
-const struct bios_parser_helper *dal_bios_parser_helper_dce110_get_table()
-{
-	return &bios_parser_helper_funcs;
-}
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.h b/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.h
deleted file mode 100644
index 915f31ab9c1a..000000000000
--- a/drivers/gpu/drm/amd/dal/dc/bios/dce110/bios_parser_helper_dce110.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2012-15 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, sub license,
- * 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_BIOS_PARSER_HELPER_DCE110_H__
-#define __DAL_BIOS_PARSER_HELPER_DCE110_H__
-
-struct bios_parser_helper;
-
-/* Initialize BIOS helper functions */
-const struct bios_parser_helper *dal_bios_parser_helper_dce110_get_table(void);
-
-#endif /* __DAL_BIOS_PARSER_HELPER_DCE110_H__ */
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.c b/drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.c
deleted file mode 100644
index 0e3b1e6525bc..000000000000
--- a/drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2012-15 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, sub license,
- * 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 "dm_services.h"
-
-#include "atom.h"
-
-#include "include/bios_parser_types.h"
-#include "include/adapter_service_types.h"
-#include "include/logger_interface.h"
-
-#include "../bios_parser_helper.h"
-
-#include "dce/dce_11_0_d.h"
-#include "bif/bif_5_1_d.h"
-
-
-/*
- * is_accelerated_mode
- *
- * @brief
- *  set Accelerated Mode in VBIOS scratch register, VBIOS will clean it when
- *  VGA/non-Accelerated mode is set
- *
- * @param
- * struct dc_context *ctx
- *
- * @return
- * true if in acceleration mode, false otherwise.
- */
-static bool is_accelerated_mode(
-	struct dc_context *ctx)
-{
-	uint32_t addr = mmBIOS_SCRATCH_6;
-	uint32_t value = dm_read_reg(ctx, addr);
-
-	return (value & ATOM_S6_ACC_MODE) ? true : false;
-}
-
-/* function table */
-static const struct bios_parser_helper bios_parser_helper_funcs = {
-	.is_accelerated_mode = is_accelerated_mode,
-};
-
-/*
- * dal_bios_parser_dce112_init_bios_helper
- *
- * @brief
- * Initialize BIOS helper functions
- *
- * @param
- * const struct command_table_helper **h - [out] struct of functions
- *
- */
-
-const struct bios_parser_helper *dal_bios_parser_helper_dce112_get_table()
-{
-	return &bios_parser_helper_funcs;
-}
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.h b/drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.h
deleted file mode 100644
index 044327ea250b..000000000000
--- a/drivers/gpu/drm/amd/dal/dc/bios/dce112/bios_parser_helper_dce112.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2012-15 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, sub license,
- * 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_BIOS_PARSER_HELPER_DCE112_H__
-#define __DAL_BIOS_PARSER_HELPER_DCE112_H__
-
-struct bios_parser_helper;
-
-/* Initialize BIOS helper functions */
-const struct bios_parser_helper *dal_bios_parser_helper_dce112_get_table(void);
-
-#endif /* __DAL_BIOS_PARSER_HELPER_DCE110_H__ */
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.c b/drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.c
deleted file mode 100644
index a919e626d4ec..000000000000
--- a/drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2012-15 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, sub license,
- * 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 "dm_services.h"
-
-#include "atom.h"
-
-#include "dce/dce_8_0_d.h"
-#include "bif/bif_4_1_d.h"
-
-#include "include/grph_object_id.h"
-#include "include/grph_object_defs.h"
-#include "include/grph_object_ctrl_defs.h"
-#include "include/bios_parser_types.h"
-#include "include/adapter_service_types.h"
-
-#include "../bios_parser_helper.h"
-
-/**
- * is_accelerated_mode
- *
- * @brief
- *  set Accelerated Mode in VBIOS scratch register, VBIOS will clean it when
- *  VGA/non-Accelerated mode is set
- *
- * @param
- *  NONE
- */
-static bool is_accelerated_mode(
-	struct dc_context *ctx)
-{
-	uint32_t addr = mmBIOS_SCRATCH_6;
-	uint32_t value = dm_read_reg(ctx, addr);
-
-	return (value & ATOM_S6_ACC_MODE) ? true : false;
-}
-
-static const struct bios_parser_helper bios_parser_helper_funcs = {
-	.is_accelerated_mode = is_accelerated_mode,
-};
-
-const struct bios_parser_helper *dal_bios_parser_helper_dce80_get_table()
-{
-	return &bios_parser_helper_funcs;
-}
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.h b/drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.h
deleted file mode 100644
index db671be8025d..000000000000
--- a/drivers/gpu/drm/amd/dal/dc/bios/dce80/bios_parser_helper_dce80.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2012-15 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_BIOS_PARSER_HELPER_DCE80_H__
-#define __DAL_BIOS_PARSER_HELPER_DCE80_H__
-
-struct bios_parser_helper;
-
-const struct bios_parser_helper *dal_bios_parser_helper_dce80_get_table(void);
-
-#endif
diff --git a/drivers/gpu/drm/amd/dal/dc/dc_bios_types.h b/drivers/gpu/drm/amd/dal/dc/dc_bios_types.h
index 3d2efa8d2bde..2d598d004281 100644
--- a/drivers/gpu/drm/amd/dal/dc/dc_bios_types.h
+++ b/drivers/gpu/drm/amd/dal/dc/dc_bios_types.h
@@ -212,6 +212,10 @@ struct dc_vbios_funcs {
 	void (*bios_parser_destroy)(struct dc_bios **dcb);
 };
 
+struct bios_registers {
+	uint32_t BIOS_SCRATCH_6;
+};
+
 struct dc_bios {
 	const struct dc_vbios_funcs *funcs;
 
@@ -221,6 +225,7 @@ struct dc_bios {
 	uint8_t *bios_local_image;
 
 	struct dc_context *ctx;
+	const struct bios_registers *regs;
 };
 
 #endif /* DC_BIOS_TYPES_H */
diff --git a/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c
index ea7e12d8a1e4..c8c83e86eb53 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c
@@ -66,6 +66,7 @@
 
 #ifndef mmBIOS_SCRATCH_2
 	#define mmBIOS_SCRATCH_2 0x05CB
+	#define mmBIOS_SCRATCH_6 0x05CF
 #endif
 
 #ifndef mmDP_DPHY_BS_SR_SWAP_CNTL
@@ -358,6 +359,10 @@ static const struct dce110_opp_reg_offsets dce100_opp_reg_offsets[] = {
 }
 };
 
+static const struct bios_registers bios_regs = {
+	.BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6
+};
+
 static const struct resource_caps res_cap = {
 	.num_timing_generator = 6,
 	.num_audio = 6,
@@ -859,6 +864,8 @@ static bool construct(
 	struct dc_bios *bp;
 	struct dm_pp_static_clock_info static_clk_info = {0};
 
+	ctx->dc_bios->regs = &bios_regs;
+
 	pool->base.adapter_srv = as;
 	pool->base.res_cap = &res_cap;
 	pool->base.funcs = &dce100_res_pool_funcs;
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
index f010a785c4e2..4181a2207dc4 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
@@ -35,7 +35,7 @@
 
 #include "gpu/dce110/dc_clock_gating_dce110.h"
 
-#include "bios/dce110/bios_dce110.h"
+#include "bios/bios_parser_helper.h"
 #include "timing_generator.h"
 #include "mem_input.h"
 #include "opp.h"
@@ -975,7 +975,7 @@ void dce110_enable_accelerated_mode(struct core_dc *dc)
 	power_down_all_hw_blocks(dc);
 
 	disable_vga_and_power_gate_all_controllers(dc);
-	dce110_set_scratch_acc_mode_change(dc->ctx);
+	bios_set_scratch_acc_mode_change(dc->ctx->dc_bios);
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c
index 0404122cf31e..82cdcb5c2eb1 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c
@@ -69,6 +69,7 @@
 
 #ifndef mmBIOS_SCRATCH_2
 	#define mmBIOS_SCRATCH_2 0x05CB
+	#define mmBIOS_SCRATCH_6 0x05CF
 #endif
 
 #ifndef mmDP_DPHY_BS_SR_SWAP_CNTL
@@ -325,6 +326,9 @@ static const struct dce110_clk_src_reg_offsets dce110_clk_src_reg_offsets[] = {
 	}
 };
 
+static const struct bios_registers bios_regs = {
+	.BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6
+};
 
 static const struct resource_caps carrizo_resource_cap = {
 		.num_timing_generator = 3,
@@ -1179,6 +1183,8 @@ static bool construct(
 	struct dm_pp_static_clock_info static_clk_info = {0};
 	struct resource_straps straps = {0};
 
+	ctx->dc_bios->regs = &bios_regs;
+
 	pool->base.adapter_srv = as;
 	pool->base.res_cap = dce110_resource_cap(&dc->asic_id);
 	pool->base.funcs = &dce110_res_pool_funcs;
diff --git a/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c
index 8588a94e0fc5..5d53a0b9e8e1 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce112/dce112_resource.c
@@ -66,6 +66,7 @@
 
 #ifndef mmBIOS_SCRATCH_2
 	#define mmBIOS_SCRATCH_2 0x05CB
+	#define mmBIOS_SCRATCH_6 0x05CF
 #endif
 
 #ifndef mmDP_DPHY_BS_SR_SWAP_CNTL
@@ -375,6 +376,10 @@ static const struct dce112_clk_src_reg_offsets dce112_clk_src_reg_offsets[] = {
 	}
 };
 
+static const struct bios_registers bios_regs = {
+	.BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6
+};
+
 static const struct resource_caps polaris_10_resource_cap = {
 		.num_timing_generator = 6,
 		.num_audio = 6,
@@ -1187,6 +1192,8 @@ static bool construct(
 	struct dc_context *ctx = dc->ctx;
 	struct dm_pp_static_clock_info static_clk_info = {0};
 
+	ctx->dc_bios->regs = &bios_regs;
+
 	pool->base.adapter_srv = adapter_serv;
 	pool->base.res_cap = dce112_resource_cap(&dc->asic_id);
 	pool->base.funcs = &dce112_res_pool_funcs;
diff --git a/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c b/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c
index 0023ed344467..705c69a8a5c4 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce80/dce80_resource.c
@@ -69,6 +69,7 @@
 
 #ifndef mmBIOS_SCRATCH_2
 	#define mmBIOS_SCRATCH_2 0x05CB
+	#define mmBIOS_SCRATCH_6 0x05CF
 #endif
 
 #ifndef mmDP_DPHY_FAST_TRAINING
@@ -349,6 +350,10 @@ static const struct dce110_clk_src_reg_offsets dce80_clk_src_reg_offsets[] = {
 	}
 };
 
+static const struct bios_registers bios_regs = {
+	.BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6
+};
+
 static const struct resource_caps res_cap = {
 		.num_timing_generator = 6,
 		.num_audio = 6,
@@ -853,6 +858,8 @@ static bool construct(
 	struct dc_bios *bp;
 	struct dm_pp_static_clock_info static_clk_info = {0};
 
+	ctx->dc_bios->regs = &bios_regs;
+
 	pool->base.adapter_srv = as;
 	pool->base.res_cap = &res_cap;
 	pool->base.funcs = &dce80_res_pool_funcs;
-- 
2.10.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux