linux/drivers/gpu/drm/amd/powerplay/eventmgr/eventinit.c
<<
>>
Prefs
   1/*
   2 * Copyright 2015 Advanced Micro Devices, Inc.
   3 *
   4 * Permission is hereby granted, free of charge, to any person obtaining a
   5 * copy of this software and associated documentation files (the "Software"),
   6 * to deal in the Software without restriction, including without limitation
   7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   8 * and/or sell copies of the Software, and to permit persons to whom the
   9 * Software is furnished to do so, subject to the following conditions:
  10 *
  11 * The above copyright notice and this permission notice shall be included in
  12 * all copies or substantial portions of the Software.
  13 *
  14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18 * 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 OR
  20 * OTHER DEALINGS IN THE SOFTWARE.
  21 *
  22 */
  23#include "eventmgr.h"
  24#include "eventinit.h"
  25#include "ppinterrupt.h"
  26#include "hardwaremanager.h"
  27
  28void pem_init_feature_info(struct pp_eventmgr *eventmgr)
  29{
  30
  31        /* PowerPlay info */
  32        eventmgr->ui_state_info[PP_PowerSource_AC].default_ui_lable =
  33                                            PP_StateUILabel_Performance;
  34
  35        eventmgr->ui_state_info[PP_PowerSource_AC].current_ui_label =
  36                                            PP_StateUILabel_Performance;
  37
  38        eventmgr->ui_state_info[PP_PowerSource_DC].default_ui_lable =
  39                                                  PP_StateUILabel_Battery;
  40
  41        eventmgr->ui_state_info[PP_PowerSource_DC].current_ui_label =
  42                                                  PP_StateUILabel_Battery;
  43
  44        if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_PowerPlaySupport)) {
  45                eventmgr->features[PP_Feature_PowerPlay].supported = true;
  46                eventmgr->features[PP_Feature_PowerPlay].version = PEM_CURRENT_POWERPLAY_FEATURE_VERSION;
  47                eventmgr->features[PP_Feature_PowerPlay].enabled_default = true;
  48                eventmgr->features[PP_Feature_PowerPlay].enabled = true;
  49        } else {
  50                eventmgr->features[PP_Feature_PowerPlay].supported = false;
  51                eventmgr->features[PP_Feature_PowerPlay].enabled = false;
  52                eventmgr->features[PP_Feature_PowerPlay].enabled_default = false;
  53        }
  54
  55        eventmgr->features[PP_Feature_Force3DClock].supported = true;
  56        eventmgr->features[PP_Feature_Force3DClock].enabled = false;
  57        eventmgr->features[PP_Feature_Force3DClock].enabled_default = false;
  58        eventmgr->features[PP_Feature_Force3DClock].version = 1;
  59
  60        /* over drive*/
  61        eventmgr->features[PP_Feature_User2DPerformance].version = 4;
  62        eventmgr->features[PP_Feature_User3DPerformance].version = 4;
  63        eventmgr->features[PP_Feature_OverdriveTest].version = 4;
  64
  65        eventmgr->features[PP_Feature_OverDrive].version = 4;
  66        eventmgr->features[PP_Feature_OverDrive].enabled = false;
  67        eventmgr->features[PP_Feature_OverDrive].enabled_default = false;
  68
  69        eventmgr->features[PP_Feature_User2DPerformance].supported = false;
  70        eventmgr->features[PP_Feature_User2DPerformance].enabled = false;
  71        eventmgr->features[PP_Feature_User2DPerformance].enabled_default = false;
  72
  73        eventmgr->features[PP_Feature_User3DPerformance].supported = false;
  74        eventmgr->features[PP_Feature_User3DPerformance].enabled = false;
  75        eventmgr->features[PP_Feature_User3DPerformance].enabled_default = false;
  76
  77        eventmgr->features[PP_Feature_OverdriveTest].supported = false;
  78        eventmgr->features[PP_Feature_OverdriveTest].enabled = false;
  79        eventmgr->features[PP_Feature_OverdriveTest].enabled_default = false;
  80
  81        eventmgr->features[PP_Feature_OverDrive].supported = false;
  82
  83        eventmgr->features[PP_Feature_PowerBudgetWaiver].enabled_default = false;
  84        eventmgr->features[PP_Feature_PowerBudgetWaiver].version = 1;
  85        eventmgr->features[PP_Feature_PowerBudgetWaiver].supported = false;
  86        eventmgr->features[PP_Feature_PowerBudgetWaiver].enabled = false;
  87
  88        /* Multi UVD States support */
  89        eventmgr->features[PP_Feature_MultiUVDState].supported = false;
  90        eventmgr->features[PP_Feature_MultiUVDState].enabled = false;
  91        eventmgr->features[PP_Feature_MultiUVDState].enabled_default = false;
  92
  93        /* Dynamic UVD States support */
  94        eventmgr->features[PP_Feature_DynamicUVDState].supported = false;
  95        eventmgr->features[PP_Feature_DynamicUVDState].enabled = false;
  96        eventmgr->features[PP_Feature_DynamicUVDState].enabled_default = false;
  97
  98        /* VCE DPM support */
  99        eventmgr->features[PP_Feature_VCEDPM].supported = false;
 100        eventmgr->features[PP_Feature_VCEDPM].enabled = false;
 101        eventmgr->features[PP_Feature_VCEDPM].enabled_default = false;
 102
 103        /* ACP PowerGating support */
 104        eventmgr->features[PP_Feature_ACP_POWERGATING].supported = false;
 105        eventmgr->features[PP_Feature_ACP_POWERGATING].enabled = false;
 106        eventmgr->features[PP_Feature_ACP_POWERGATING].enabled_default = false;
 107
 108        /* PPM support */
 109        eventmgr->features[PP_Feature_PPM].version = 1;
 110        eventmgr->features[PP_Feature_PPM].supported = false;
 111        eventmgr->features[PP_Feature_PPM].enabled = false;
 112
 113        /* FFC support (enables fan and temp settings, Gemini needs temp settings) */
 114        if (phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_ODFuzzyFanControlSupport) ||
 115            phm_cap_enabled(eventmgr->platform_descriptor->platformCaps, PHM_PlatformCaps_GeminiRegulatorFanControlSupport)) {
 116                eventmgr->features[PP_Feature_FFC].version = 1;
 117                eventmgr->features[PP_Feature_FFC].supported = true;
 118                eventmgr->features[PP_Feature_FFC].enabled = true;
 119                eventmgr->features[PP_Feature_FFC].enabled_default = true;
 120        } else {
 121                eventmgr->features[PP_Feature_FFC].supported = false;
 122                eventmgr->features[PP_Feature_FFC].enabled = false;
 123                eventmgr->features[PP_Feature_FFC].enabled_default = false;
 124        }
 125
 126        eventmgr->features[PP_Feature_VariBright].supported = false;
 127        eventmgr->features[PP_Feature_VariBright].enabled = false;
 128        eventmgr->features[PP_Feature_VariBright].enabled_default = false;
 129
 130        eventmgr->features[PP_Feature_BACO].supported = false;
 131        eventmgr->features[PP_Feature_BACO].supported = false;
 132        eventmgr->features[PP_Feature_BACO].enabled_default = false;
 133
 134        /* PowerDown feature support */
 135        eventmgr->features[PP_Feature_PowerDown].supported = false;
 136        eventmgr->features[PP_Feature_PowerDown].enabled = false;
 137        eventmgr->features[PP_Feature_PowerDown].enabled_default = false;
 138
 139        eventmgr->features[PP_Feature_FPS].version = 1;
 140        eventmgr->features[PP_Feature_FPS].supported = false;
 141        eventmgr->features[PP_Feature_FPS].enabled_default = false;
 142        eventmgr->features[PP_Feature_FPS].enabled = false;
 143
 144        eventmgr->features[PP_Feature_ViPG].version = 1;
 145        eventmgr->features[PP_Feature_ViPG].supported = false;
 146        eventmgr->features[PP_Feature_ViPG].enabled_default = false;
 147        eventmgr->features[PP_Feature_ViPG].enabled = false;
 148}
 149
 150static int thermal_interrupt_callback(void *private_data,
 151                                      unsigned src_id, const uint32_t *iv_entry)
 152{
 153        /* TO DO hanle PEM_Event_ThermalNotification (struct pp_eventmgr *)private_data*/
 154        pr_info("current thermal is out of range \n");
 155        return 0;
 156}
 157
 158int pem_register_interrupts(struct pp_eventmgr *eventmgr)
 159{
 160        int result = 0;
 161        struct pp_interrupt_registration_info info;
 162
 163        info.call_back = thermal_interrupt_callback;
 164        info.context = eventmgr;
 165
 166        result = phm_register_thermal_interrupt(eventmgr->hwmgr, &info);
 167
 168        /* TODO:
 169         * 2. Register CTF event interrupt
 170         * 3. Register for vbios events interrupt
 171         * 4. Register External Throttle Interrupt
 172         * 5. Register Smc To Host Interrupt
 173         * */
 174        return result;
 175}
 176
 177
 178int pem_unregister_interrupts(struct pp_eventmgr *eventmgr)
 179{
 180        return 0;
 181}
 182
 183
 184void pem_uninit_featureInfo(struct pp_eventmgr *eventmgr)
 185{
 186        eventmgr->features[PP_Feature_MultiUVDState].supported = false;
 187        eventmgr->features[PP_Feature_VariBright].supported = false;
 188        eventmgr->features[PP_Feature_PowerBudgetWaiver].supported = false;
 189        eventmgr->features[PP_Feature_OverDrive].supported = false;
 190        eventmgr->features[PP_Feature_OverdriveTest].supported = false;
 191        eventmgr->features[PP_Feature_User3DPerformance].supported = false;
 192        eventmgr->features[PP_Feature_User2DPerformance].supported = false;
 193        eventmgr->features[PP_Feature_PowerPlay].supported = false;
 194        eventmgr->features[PP_Feature_Force3DClock].supported = false;
 195}
 196