| .. | .. |
|---|
| 20 | 20 | * Authors: Rafał Miłecki <zajec5@gmail.com> |
|---|
| 21 | 21 | * Alex Deucher <alexdeucher@gmail.com> |
|---|
| 22 | 22 | */ |
|---|
| 23 | | -#include <drm/drmP.h> |
|---|
| 24 | | -#include "radeon.h" |
|---|
| 25 | | -#include "avivod.h" |
|---|
| 26 | | -#include "atom.h" |
|---|
| 27 | | -#include "r600_dpm.h" |
|---|
| 28 | | -#include <linux/power_supply.h> |
|---|
| 29 | | -#include <linux/hwmon.h> |
|---|
| 23 | + |
|---|
| 30 | 24 | #include <linux/hwmon-sysfs.h> |
|---|
| 25 | +#include <linux/hwmon.h> |
|---|
| 26 | +#include <linux/pci.h> |
|---|
| 27 | +#include <linux/power_supply.h> |
|---|
| 28 | + |
|---|
| 29 | +#include <drm/drm_debugfs.h> |
|---|
| 30 | +#include <drm/drm_vblank.h> |
|---|
| 31 | + |
|---|
| 32 | +#include "atom.h" |
|---|
| 33 | +#include "avivod.h" |
|---|
| 34 | +#include "r600_dpm.h" |
|---|
| 35 | +#include "radeon.h" |
|---|
| 31 | 36 | |
|---|
| 32 | 37 | #define RADEON_IDLE_LOOP_MS 100 |
|---|
| 33 | 38 | #define RADEON_RECLOCK_DELAY_MS 200 |
|---|
| .. | .. |
|---|
| 707 | 712 | static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, radeon_hwmon_get_pwm1_min, NULL, 0); |
|---|
| 708 | 713 | static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, radeon_hwmon_get_pwm1_max, NULL, 0); |
|---|
| 709 | 714 | |
|---|
| 715 | +static ssize_t radeon_hwmon_show_sclk(struct device *dev, |
|---|
| 716 | + struct device_attribute *attr, char *buf) |
|---|
| 717 | +{ |
|---|
| 718 | + struct radeon_device *rdev = dev_get_drvdata(dev); |
|---|
| 719 | + struct drm_device *ddev = rdev->ddev; |
|---|
| 720 | + u32 sclk = 0; |
|---|
| 721 | + |
|---|
| 722 | + /* Can't get clock frequency when the card is off */ |
|---|
| 723 | + if ((rdev->flags & RADEON_IS_PX) && |
|---|
| 724 | + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) |
|---|
| 725 | + return -EINVAL; |
|---|
| 726 | + |
|---|
| 727 | + if (rdev->asic->dpm.get_current_sclk) |
|---|
| 728 | + sclk = radeon_dpm_get_current_sclk(rdev); |
|---|
| 729 | + |
|---|
| 730 | + /* Value returned by dpm is in 10 KHz units, need to convert it into Hz |
|---|
| 731 | + for hwmon */ |
|---|
| 732 | + sclk *= 10000; |
|---|
| 733 | + |
|---|
| 734 | + return snprintf(buf, PAGE_SIZE, "%u\n", sclk); |
|---|
| 735 | +} |
|---|
| 736 | + |
|---|
| 737 | +static SENSOR_DEVICE_ATTR(freq1_input, S_IRUGO, radeon_hwmon_show_sclk, NULL, |
|---|
| 738 | + 0); |
|---|
| 739 | + |
|---|
| 710 | 740 | |
|---|
| 711 | 741 | static struct attribute *hwmon_attributes[] = { |
|---|
| 712 | 742 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
|---|
| .. | .. |
|---|
| 716 | 746 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
|---|
| 717 | 747 | &sensor_dev_attr_pwm1_min.dev_attr.attr, |
|---|
| 718 | 748 | &sensor_dev_attr_pwm1_max.dev_attr.attr, |
|---|
| 749 | + &sensor_dev_attr_freq1_input.dev_attr.attr, |
|---|
| 719 | 750 | NULL |
|---|
| 720 | 751 | }; |
|---|
| 721 | 752 | |
|---|
| .. | .. |
|---|
| 733 | 764 | attr == &sensor_dev_attr_pwm1.dev_attr.attr || |
|---|
| 734 | 765 | attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || |
|---|
| 735 | 766 | attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || |
|---|
| 736 | | - attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) |
|---|
| 767 | + attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || |
|---|
| 768 | + attr == &sensor_dev_attr_freq1_input.dev_attr.attr)) |
|---|
| 737 | 769 | return 0; |
|---|
| 738 | 770 | |
|---|
| 739 | 771 | /* Skip fan attributes if fan is not present */ |
|---|
| .. | .. |
|---|
| 1792 | 1824 | u32 stat_crtc = 0; |
|---|
| 1793 | 1825 | bool in_vbl = radeon_pm_in_vbl(rdev); |
|---|
| 1794 | 1826 | |
|---|
| 1795 | | - if (in_vbl == false) |
|---|
| 1827 | + if (!in_vbl) |
|---|
| 1796 | 1828 | DRM_DEBUG_DRIVER("not in vbl for pm change %08x at %s\n", stat_crtc, |
|---|
| 1797 | 1829 | finish ? "exit" : "entry"); |
|---|
| 1798 | 1830 | return in_vbl; |
|---|