Path: blob/master/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
26535 views
/*1* Copyright 2014 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21*/2223#ifndef __AMDGPU_PM_H__24#define __AMDGPU_PM_H__2526struct cg_flag_name {27u64 flag;28const char *name;29};3031enum amdgpu_device_attr_flags {32ATTR_FLAG_BASIC = (1 << 0),33ATTR_FLAG_ONEVF = (1 << 16),34};3536#define ATTR_FLAG_TYPE_MASK (0x0000ffff)37#define ATTR_FLAG_MODE_MASK (0xffff0000)38#define ATTR_FLAG_MASK_ALL (0xffffffff)3940enum amdgpu_device_attr_states {41ATTR_STATE_UNSUPPORTED = 0,42ATTR_STATE_SUPPORTED,43};4445enum amdgpu_device_attr_id {46device_attr_id__unknown = -1,47device_attr_id__power_dpm_state = 0,48device_attr_id__power_dpm_force_performance_level,49device_attr_id__pp_num_states,50device_attr_id__pp_cur_state,51device_attr_id__pp_force_state,52device_attr_id__pp_table,53device_attr_id__pp_dpm_sclk,54device_attr_id__pp_dpm_mclk,55device_attr_id__pp_dpm_socclk,56device_attr_id__pp_dpm_fclk,57device_attr_id__pp_dpm_vclk,58device_attr_id__pp_dpm_vclk1,59device_attr_id__pp_dpm_dclk,60device_attr_id__pp_dpm_dclk1,61device_attr_id__pp_dpm_dcefclk,62device_attr_id__pp_dpm_pcie,63device_attr_id__pp_sclk_od,64device_attr_id__pp_mclk_od,65device_attr_id__pp_power_profile_mode,66device_attr_id__pp_od_clk_voltage,67device_attr_id__gpu_busy_percent,68device_attr_id__mem_busy_percent,69device_attr_id__vcn_busy_percent,70device_attr_id__pcie_bw,71device_attr_id__pp_features,72device_attr_id__unique_id,73device_attr_id__thermal_throttling_logging,74device_attr_id__apu_thermal_cap,75device_attr_id__gpu_metrics,76device_attr_id__smartshift_apu_power,77device_attr_id__smartshift_dgpu_power,78device_attr_id__smartshift_bias,79device_attr_id__pm_metrics,80device_attr_id__count,81};8283struct amdgpu_device_attr {84struct device_attribute dev_attr;85enum amdgpu_device_attr_id attr_id;86enum amdgpu_device_attr_flags flags;87int (*attr_update)(struct amdgpu_device *adev, struct amdgpu_device_attr *attr,88uint32_t mask, enum amdgpu_device_attr_states *states);8990};9192struct amdgpu_device_attr_entry {93struct list_head entry;94struct amdgpu_device_attr *attr;95};9697#define to_amdgpu_device_attr(_dev_attr) \98container_of(_dev_attr, struct amdgpu_device_attr, dev_attr)99100#define __AMDGPU_DEVICE_ATTR(_name, _mode, _show, _store, _flags, ...) \101{ .dev_attr = __ATTR(_name, _mode, _show, _store), \102.attr_id = device_attr_id__##_name, \103.flags = _flags, \104##__VA_ARGS__, }105106#define AMDGPU_DEVICE_ATTR(_name, _mode, _flags, ...) \107__AMDGPU_DEVICE_ATTR(_name, _mode, \108amdgpu_get_##_name, amdgpu_set_##_name, \109_flags, ##__VA_ARGS__)110111#define AMDGPU_DEVICE_ATTR_RW(_name, _flags, ...) \112AMDGPU_DEVICE_ATTR(_name, S_IRUGO | S_IWUSR, \113_flags, ##__VA_ARGS__)114115#define AMDGPU_DEVICE_ATTR_RO(_name, _flags, ...) \116__AMDGPU_DEVICE_ATTR(_name, S_IRUGO, \117amdgpu_get_##_name, NULL, \118_flags, ##__VA_ARGS__)119120int amdgpu_pm_sysfs_init(struct amdgpu_device *adev);121int amdgpu_pm_virt_sysfs_init(struct amdgpu_device *adev);122void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev);123void amdgpu_pm_virt_sysfs_fini(struct amdgpu_device *adev);124125void amdgpu_debugfs_pm_init(struct amdgpu_device *adev);126127#endif128129130