brintos

brintos / linux-shallow public Read only

0
0
Text · 3.2 KiB · 05aac3e Raw
120 lines · c
1/*2 * Copyright 2019 Advanced Micro Devices, Inc.3 *4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"),6 * to deal in the Software without restriction, including without limitation7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,8 *  and/or sell copies of the Software, and to permit persons to whom the9 * Software is furnished to do so, subject to the following conditions:10 *11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 *14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR20 * OTHER DEALINGS IN THE SOFTWARE.21 *22 * Authors: AMD23 *24 */25 26 27#include "dc_bios_types.h"28#include "hw_shared.h"29#include "dcn31_apg.h"30#include "reg_helper.h"31 32#define DC_LOGGER \33		apg31->base.ctx->logger34 35#define REG(reg)\36	(apg31->regs->reg)37 38#undef FN39#define FN(reg_name, field_name) \40	apg31->apg_shift->field_name, apg31->apg_mask->field_name41 42 43#define CTX \44	apg31->base.ctx45 46 47static void apg31_enable(48	struct apg *apg)49{50	struct dcn31_apg *apg31 = DCN31_APG_FROM_APG(apg);51 52	/* Reset APG */53	REG_UPDATE(APG_CONTROL, APG_RESET, 1);54	REG_WAIT(APG_CONTROL,55			APG_RESET_DONE, 1,56			1, 10);57	REG_UPDATE(APG_CONTROL, APG_RESET, 0);58	REG_WAIT(APG_CONTROL,59			APG_RESET_DONE, 0,60			1, 10);61 62	/* Enable APG */63	REG_UPDATE(APG_CONTROL2, APG_ENABLE, 1);64}65 66static void apg31_disable(67	struct apg *apg)68{69	struct dcn31_apg *apg31 = DCN31_APG_FROM_APG(apg);70 71	/* Disable APG */72	REG_UPDATE(APG_CONTROL2, APG_ENABLE, 0);73}74 75static void apg31_se_audio_setup(76	struct apg *apg,77	unsigned int az_inst,78	struct audio_info *audio_info)79{80	struct dcn31_apg *apg31 = DCN31_APG_FROM_APG(apg);81 82	ASSERT(audio_info);83	/* This should not happen.it does so we don't get BSOD*/84	if (audio_info == NULL)85		return;86 87	/* DisplayPort only allows for one audio stream with stream ID 0 */88	REG_UPDATE(APG_CONTROL2, APG_DP_AUDIO_STREAM_ID, 0);89 90	/* When running in "pair mode", pairs of audio channels have their own enable91	 * this is for really old audio drivers */92	REG_UPDATE(APG_DBG_GEN_CONTROL, APG_DBG_AUDIO_CHANNEL_ENABLE, 0xFF);93 94	/* Disable forced mem power off */95	REG_UPDATE(APG_MEM_PWR, APG_MEM_PWR_FORCE, 0);96}97 98static struct apg_funcs dcn31_apg_funcs = {99	.se_audio_setup			= apg31_se_audio_setup,100	.enable_apg			= apg31_enable,101	.disable_apg			= apg31_disable,102};103 104void apg31_construct(struct dcn31_apg *apg31,105	struct dc_context *ctx,106	uint32_t inst,107	const struct dcn31_apg_registers *apg_regs,108	const struct dcn31_apg_shift *apg_shift,109	const struct dcn31_apg_mask *apg_mask)110{111	apg31->base.ctx = ctx;112 113	apg31->base.inst = inst;114	apg31->base.funcs = &dcn31_apg_funcs;115 116	apg31->regs = apg_regs;117	apg31->apg_shift = apg_shift;118	apg31->apg_mask = apg_mask;119}120