Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2019 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  *  and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 
0026 #include "dc_bios_types.h"
0027 #include "dcn30/dcn30_vpg.h"
0028 #include "dcn31_vpg.h"
0029 #include "reg_helper.h"
0030 #include "dc/dc.h"
0031 
0032 #define DC_LOGGER \
0033         vpg31->base.ctx->logger
0034 
0035 #define REG(reg)\
0036     (vpg31->regs->reg)
0037 
0038 #undef FN
0039 #define FN(reg_name, field_name) \
0040     vpg31->vpg_shift->field_name, vpg31->vpg_mask->field_name
0041 
0042 
0043 #define CTX \
0044     vpg31->base.ctx
0045 
0046 static struct vpg_funcs dcn31_vpg_funcs = {
0047     .update_generic_info_packet = vpg3_update_generic_info_packet,
0048     .vpg_poweron = vpg31_poweron,
0049     .vpg_powerdown = vpg31_powerdown,
0050 };
0051 
0052 void vpg31_powerdown(struct vpg *vpg)
0053 {
0054     struct dcn31_vpg *vpg31 = DCN31_VPG_FROM_VPG(vpg);
0055 
0056     if (vpg->ctx->dc->debug.enable_mem_low_power.bits.vpg == false)
0057         return;
0058 
0059     REG_UPDATE_2(VPG_MEM_PWR, VPG_GSP_MEM_LIGHT_SLEEP_DIS, 0, VPG_GSP_LIGHT_SLEEP_FORCE, 1);
0060 }
0061 
0062 void vpg31_poweron(struct vpg *vpg)
0063 {
0064     struct dcn31_vpg *vpg31 = DCN31_VPG_FROM_VPG(vpg);
0065 
0066     if (vpg->ctx->dc->debug.enable_mem_low_power.bits.vpg == false)
0067         return;
0068 
0069     REG_UPDATE_2(VPG_MEM_PWR, VPG_GSP_MEM_LIGHT_SLEEP_DIS, 1, VPG_GSP_LIGHT_SLEEP_FORCE, 0);
0070 }
0071 
0072 void vpg31_construct(struct dcn31_vpg *vpg31,
0073     struct dc_context *ctx,
0074     uint32_t inst,
0075     const struct dcn31_vpg_registers *vpg_regs,
0076     const struct dcn31_vpg_shift *vpg_shift,
0077     const struct dcn31_vpg_mask *vpg_mask)
0078 {
0079     vpg31->base.ctx = ctx;
0080 
0081     vpg31->base.inst = inst;
0082     vpg31->base.funcs = &dcn31_vpg_funcs;
0083 
0084     vpg31->regs = vpg_regs;
0085     vpg31->vpg_shift = vpg_shift;
0086     vpg31->vpg_mask = vpg_mask;
0087 }