[PATCH 2/2] drm/amdgpu: add sysfs for current gpu voltage.

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

 



Am 09.06.2017 um 10:19 schrieb Rex Zhu:
> Change-Id: I348f9307c8e03e193df481e6c9faf234039d97b5
> Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h |  4 +++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c  | 50 +++++++++++++++++++++++++++++++++
>   2 files changed, 54 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
> index f187680..3b77966 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
> @@ -414,6 +414,10 @@ struct amdgpu_dpm_funcs {
>   	((adev)->powerplay.pp_funcs->switch_power_profile(\
>   			(adev)->powerplay.pp_handle, type))
>   
> +#define amdgpu_get_voltage(adev, type, vol) \
> +	((adev)->powerplay.pp_funcs->get_gpu_voltage(\
> +			(adev)->powerplay.pp_handle, type, vol))
> +

Could we keep the amdgpu_dpm_ prefix here?

Apart from that the change looks good to me, but Alex should probably 
take a look as well.

Regards,
Christian.

>   struct amdgpu_dpm {
>   	struct amdgpu_ps        *ps;
>   	/* number of valid power states */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> index f435275..20dcf06 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> @@ -958,6 +958,52 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
>   	return sprintf(buf, "%i\n", speed);
>   }
>   
> +
> +static ssize_t amdgpu_hwmon_show_vddc(struct device *dev,
> +					   struct device_attribute *attr,
> +					   char *buf)
> +{
> +	struct amdgpu_device *adev = dev_get_drvdata(dev);
> +	u32 vol = 0;
> +
> +	if (adev->pp_enabled)
> +		amdgpu_get_voltage(adev, PP_VDDC, &vol);
> +
> +	return sprintf(buf, "%i\n", vol >> 15);  /* voltage in unit of mv */
> +
> +}
> +
> +
> +static ssize_t amdgpu_hwmon_set_vddc(struct device *dev,
> +				     struct device_attribute *attr,
> +				     const char *buf, size_t count)
> +{
> +	/* to do */
> +	return count;
> +}
> +
> +static ssize_t amdgpu_hwmon_show_vddci(struct device *dev,
> +					   struct device_attribute *attr,
> +					   char *buf)
> +{
> +	struct amdgpu_device *adev = dev_get_drvdata(dev);
> +	u32 vol = 0;
> +
> +	if (adev->pp_enabled)
> +		amdgpu_get_voltage(adev, PP_VDDCI, &vol);
> +
> +	return sprintf(buf, "%i\n", vol >> 15); /* voltage in unit of mv */
> +}
> +
> +
> +static ssize_t amdgpu_hwmon_set_vddci(struct device *dev,
> +				     struct device_attribute *attr,
> +				     const char *buf, size_t count)
> +{
> +	/* to do */
> +	return count;
> +}
> +
>   static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0);
>   static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0);
>   static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);
> @@ -966,6 +1012,8 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
>   static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0);
>   static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0);
>   static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0);
> +static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO | S_IWUSR, amdgpu_hwmon_show_vddc, amdgpu_hwmon_set_vddc, 0);
> +static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO | S_IWUSR, amdgpu_hwmon_show_vddci, amdgpu_hwmon_set_vddci, 0);
>   
>   static struct attribute *hwmon_attributes[] = {
>   	&sensor_dev_attr_temp1_input.dev_attr.attr,
> @@ -976,6 +1024,8 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
>   	&sensor_dev_attr_pwm1_min.dev_attr.attr,
>   	&sensor_dev_attr_pwm1_max.dev_attr.attr,
>   	&sensor_dev_attr_fan1_input.dev_attr.attr,
> +	&sensor_dev_attr_in0_input.dev_attr.attr,
> +	&sensor_dev_attr_in1_input.dev_attr.attr,
>   	NULL
>   };
>   




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

  Powered by Linux