2010-09-16 13:39:49 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors: Ben Skeggs
|
|
|
|
*/
|
|
|
|
|
2010-10-12 10:31:32 +08:00
|
|
|
#ifdef CONFIG_ACPI
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#endif
|
|
|
|
#include <linux/power_supply.h>
|
2010-09-23 02:54:22 +08:00
|
|
|
#include <linux/hwmon.h>
|
|
|
|
#include <linux/hwmon-sysfs.h>
|
|
|
|
|
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm merge (part 1) from Dave Airlie:
"So first of all my tree and uapi stuff has a conflict mess, its my
fault as the nouveau stuff didn't hit -next as were trying to rebase
regressions out of it before we merged.
Highlights:
- SH mobile modesetting driver and associated helpers
- some DRM core documentation
- i915 modesetting rework, haswell hdmi, haswell and vlv fixes, write
combined pte writing, ilk rc6 support,
- nouveau: major driver rework into a hw core driver, makes features
like SLI a lot saner to implement,
- psb: add eDP/DP support for Cedarview
- radeon: 2 layer page tables, async VM pte updates, better PLL
selection for > 2 screens, better ACPI interactions
The rest is general grab bag of fixes.
So why part 1? well I have the exynos pull req which came in a bit
late but was waiting for me to do something they shouldn't have and it
looks fairly safe, and David Howells has some more header cleanups
he'd like me to pull, that seem like a good idea, but I'd like to get
this merge out of the way so -next dosen't get blocked."
Tons of conflicts mostly due to silly include line changes, but mostly
mindless. A few other small semantic conflicts too, noted from Dave's
pre-merged branch.
* 'drm-next' of git://people.freedesktop.org/~airlied/linux: (447 commits)
drm/nv98/crypt: fix fuc build with latest envyas
drm/nouveau/devinit: fixup various issues with subdev ctor/init ordering
drm/nv41/vm: fix and enable use of "real" pciegart
drm/nv44/vm: fix and enable use of "real" pciegart
drm/nv04/dmaobj: fixup vm target handling in preparation for nv4x pcie
drm/nouveau: store supported dma mask in vmmgr
drm/nvc0/ibus: initial implementation of subdev
drm/nouveau/therm: add support for fan-control modes
drm/nouveau/hwmon: rename pwm0* to pmw1* to follow hwmon's rules
drm/nouveau/therm: calculate the pwm divisor on nv50+
drm/nouveau/fan: rewrite the fan tachometer driver to get more precision, faster
drm/nouveau/therm: move thermal-related functions to the therm subdev
drm/nouveau/bios: parse the pwm divisor from the perf table
drm/nouveau/therm: use the EXTDEV table to detect i2c monitoring devices
drm/nouveau/therm: rework thermal table parsing
drm/nouveau/gpio: expose the PWM/TOGGLE parameter found in the gpio vbios table
drm/nouveau: fix pm initialization order
drm/nouveau/bios: check that fixed tvdac gpio data is valid before using it
drm/nouveau: log channel debug/error messages from client object rather than drm client
drm/nouveau: have drm debugging macros build on top of core macros
...
2012-10-04 14:29:23 +08:00
|
|
|
#include <drm/drmP.h>
|
2011-09-16 23:42:12 +08:00
|
|
|
|
2016-05-20 07:22:55 +08:00
|
|
|
#include "nouveau_drv.h"
|
2013-10-15 07:44:02 +08:00
|
|
|
#include "nouveau_hwmon.h"
|
2011-09-16 23:42:12 +08:00
|
|
|
|
2016-02-19 03:10:19 +08:00
|
|
|
#include <nvkm/subdev/iccsense.h>
|
2015-09-20 20:40:27 +08:00
|
|
|
#include <nvkm/subdev/volt.h>
|
|
|
|
|
2011-07-04 02:54:28 +08:00
|
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
2010-09-23 02:54:22 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2015-08-20 12:54:21 +08:00
|
|
|
int temp = nvkm_therm_temp_get(therm);
|
2010-09-23 02:54:22 +08:00
|
|
|
|
2013-03-15 07:59:55 +08:00
|
|
|
if (temp < 0)
|
|
|
|
return temp;
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", temp * 1000);
|
2010-09-23 02:54:22 +08:00
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, nouveau_hwmon_show_temp,
|
|
|
|
NULL, 0);
|
|
|
|
|
2012-11-20 08:14:13 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_show_temp1_auto_point1_pwm(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", 100);
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO,
|
|
|
|
nouveau_hwmon_show_temp1_auto_point1_pwm, NULL, 0);
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_temp1_auto_point1_temp(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000);
|
2012-11-20 08:14:13 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d,
|
|
|
|
struct device_attribute *a,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST,
|
2012-11-20 08:14:13 +08:00
|
|
|
value / 1000);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_temp1_auto_point1_temp,
|
|
|
|
nouveau_hwmon_set_temp1_auto_point1_temp, 0);
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000);
|
2012-11-20 08:14:13 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d,
|
|
|
|
struct device_attribute *a,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST,
|
2012-11-20 08:14:13 +08:00
|
|
|
value / 1000);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp_hyst, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_temp1_auto_point1_temp_hyst,
|
|
|
|
nouveau_hwmon_set_temp1_auto_point1_temp_hyst, 0);
|
|
|
|
|
2010-09-23 02:54:22 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_max_temp(struct device *d, struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2010-09-23 02:54:22 +08:00
|
|
|
|
2012-09-02 08:55:58 +08:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK) * 1000);
|
2010-09-23 02:54:22 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_max_temp(struct device *d, struct device_attribute *a,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2010-09-23 02:54:22 +08:00
|
|
|
long value;
|
|
|
|
|
2011-12-17 19:24:59 +08:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2010-09-23 02:54:22 +08:00
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK, value / 1000);
|
2010-09-23 02:54:22 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, nouveau_hwmon_max_temp,
|
|
|
|
nouveau_hwmon_set_max_temp,
|
|
|
|
0);
|
|
|
|
|
2012-11-20 08:14:13 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_max_temp_hyst(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST) * 1000);
|
2012-11-20 08:14:13 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_max_temp_hyst(struct device *d, struct device_attribute *a,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST,
|
2012-11-20 08:14:13 +08:00
|
|
|
value / 1000);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_max_temp_hyst,
|
|
|
|
nouveau_hwmon_set_max_temp_hyst, 0);
|
|
|
|
|
2010-09-23 02:54:22 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_critical_temp(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2010-09-23 02:54:22 +08:00
|
|
|
|
2012-09-02 08:55:58 +08:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_CRITICAL) * 1000);
|
2010-09-23 02:54:22 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_critical_temp(struct device *d, struct device_attribute *a,
|
|
|
|
const char *buf,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2010-09-23 02:54:22 +08:00
|
|
|
long value;
|
|
|
|
|
2011-12-17 19:24:59 +08:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2010-09-23 02:54:22 +08:00
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_CRITICAL, value / 1000);
|
2010-09-23 02:54:22 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_critical_temp,
|
|
|
|
nouveau_hwmon_set_critical_temp,
|
|
|
|
0);
|
|
|
|
|
2012-11-20 08:14:13 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_critical_temp_hyst(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_CRITICAL_HYST) * 1000);
|
2012-11-20 08:14:13 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_critical_temp_hyst(struct device *d,
|
|
|
|
struct device_attribute *a,
|
|
|
|
const char *buf,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_CRITICAL_HYST,
|
2012-11-20 08:14:13 +08:00
|
|
|
value / 1000);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_critical_temp_hyst,
|
|
|
|
nouveau_hwmon_set_critical_temp_hyst, 0);
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_emergency_temp(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN) * 1000);
|
2012-11-20 08:14:13 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_emergency_temp(struct device *d, struct device_attribute *a,
|
|
|
|
const char *buf,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN, value / 1000);
|
2012-11-20 08:14:13 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_emergency, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_emergency_temp,
|
|
|
|
nouveau_hwmon_set_emergency_temp,
|
|
|
|
0);
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_emergency_temp_hyst(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST) * 1000);
|
2012-11-20 08:14:13 +08:00
|
|
|
}
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_emergency_temp_hyst(struct device *d,
|
|
|
|
struct device_attribute *a,
|
|
|
|
const char *buf,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-11-20 08:14:13 +08:00
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
therm->attr_set(therm, NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST,
|
2012-11-20 08:14:13 +08:00
|
|
|
value / 1000);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_emergency_hyst, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_emergency_temp_hyst,
|
|
|
|
nouveau_hwmon_set_emergency_temp_hyst,
|
|
|
|
0);
|
|
|
|
|
2010-09-23 02:54:22 +08:00
|
|
|
static ssize_t nouveau_hwmon_show_name(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
return sprintf(buf, "nouveau\n");
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(name, S_IRUGO, nouveau_hwmon_show_name, NULL, 0);
|
|
|
|
|
|
|
|
static ssize_t nouveau_hwmon_show_update_rate(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
return sprintf(buf, "1000\n");
|
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(update_rate, S_IRUGO,
|
|
|
|
nouveau_hwmon_show_update_rate,
|
|
|
|
NULL, 0);
|
|
|
|
|
2011-08-15 09:10:30 +08:00
|
|
|
static ssize_t
|
2012-12-06 13:13:06 +08:00
|
|
|
nouveau_hwmon_show_fan1_input(struct device *d, struct device_attribute *attr,
|
2011-08-15 09:10:30 +08:00
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-07-31 14:16:21 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2015-08-20 12:54:21 +08:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", nvkm_therm_fan_sense(therm));
|
2011-08-15 09:10:30 +08:00
|
|
|
}
|
2012-12-06 13:13:06 +08:00
|
|
|
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, nouveau_hwmon_show_fan1_input,
|
2011-08-15 09:10:30 +08:00
|
|
|
NULL, 0);
|
|
|
|
|
2012-09-04 19:52:00 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_pwm1_enable(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2011-11-21 14:41:48 +08:00
|
|
|
int ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE);
|
2012-09-04 19:52:00 +08:00
|
|
|
if (ret < 0)
|
2011-11-21 14:41:48 +08:00
|
|
|
return ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2012-09-04 19:52:00 +08:00
|
|
|
return sprintf(buf, "%i\n", ret);
|
|
|
|
}
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2012-09-04 19:52:00 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_set_pwm1_enable(struct device *d, struct device_attribute *a,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-09-04 19:52:00 +08:00
|
|
|
long value;
|
|
|
|
int ret;
|
|
|
|
|
2014-02-05 10:02:59 +08:00
|
|
|
ret = kstrtol(buf, 10, &value);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
ret = therm->attr_set(therm, NVKM_THERM_ATTR_FAN_MODE, value);
|
2012-09-04 19:52:00 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
else
|
|
|
|
return count;
|
2011-08-15 09:10:30 +08:00
|
|
|
}
|
2012-09-04 19:52:00 +08:00
|
|
|
static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_get_pwm1_enable,
|
|
|
|
nouveau_hwmon_set_pwm1_enable, 0);
|
2011-08-15 09:10:30 +08:00
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 19:39:40 +08:00
|
|
|
nouveau_hwmon_get_pwm1(struct device *d, struct device_attribute *a, char *buf)
|
2011-08-15 09:10:30 +08:00
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2011-09-16 23:42:12 +08:00
|
|
|
int ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2012-09-02 08:55:58 +08:00
|
|
|
ret = therm->fan_get(therm);
|
2011-08-15 09:10:30 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return sprintf(buf, "%i\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 19:39:40 +08:00
|
|
|
nouveau_hwmon_set_pwm1(struct device *d, struct device_attribute *a,
|
2011-08-15 09:10:30 +08:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2011-08-15 09:10:30 +08:00
|
|
|
int ret = -ENODEV;
|
|
|
|
long value;
|
|
|
|
|
2011-12-17 19:24:59 +08:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2011-08-15 09:10:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2012-09-02 08:55:58 +08:00
|
|
|
ret = therm->fan_set(therm, value);
|
2011-08-15 09:10:30 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-09-04 19:39:40 +08:00
|
|
|
static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_get_pwm1,
|
|
|
|
nouveau_hwmon_set_pwm1, 0);
|
2011-08-15 09:10:30 +08:00
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 19:39:40 +08:00
|
|
|
nouveau_hwmon_get_pwm1_min(struct device *d,
|
2011-08-15 09:10:30 +08:00
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-09-02 08:55:58 +08:00
|
|
|
int ret;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MIN_DUTY);
|
2012-09-02 08:55:58 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2012-09-02 08:55:58 +08:00
|
|
|
return sprintf(buf, "%i\n", ret);
|
2011-08-15 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 19:39:40 +08:00
|
|
|
nouveau_hwmon_set_pwm1_min(struct device *d, struct device_attribute *a,
|
2011-08-15 09:10:30 +08:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2011-08-15 09:10:30 +08:00
|
|
|
long value;
|
2012-09-02 08:55:58 +08:00
|
|
|
int ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2011-12-17 19:24:59 +08:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2011-08-15 09:10:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
ret = therm->attr_set(therm, NVKM_THERM_ATTR_FAN_MIN_DUTY, value);
|
2012-09-02 08:55:58 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-09-04 19:39:40 +08:00
|
|
|
static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_get_pwm1_min,
|
|
|
|
nouveau_hwmon_set_pwm1_min, 0);
|
2011-08-15 09:10:30 +08:00
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 19:39:40 +08:00
|
|
|
nouveau_hwmon_get_pwm1_max(struct device *d,
|
2011-08-15 09:10:30 +08:00
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2012-09-02 08:55:58 +08:00
|
|
|
int ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MAX_DUTY);
|
2012-09-02 08:55:58 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2012-09-02 08:55:58 +08:00
|
|
|
return sprintf(buf, "%i\n", ret);
|
2011-08-15 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 19:39:40 +08:00
|
|
|
nouveau_hwmon_set_pwm1_max(struct device *d, struct device_attribute *a,
|
2011-08-15 09:10:30 +08:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 08:55:58 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
2011-08-15 09:10:30 +08:00
|
|
|
long value;
|
2012-09-02 08:55:58 +08:00
|
|
|
int ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2011-12-17 19:24:59 +08:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2011-08-15 09:10:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2015-01-14 13:11:48 +08:00
|
|
|
ret = therm->attr_set(therm, NVKM_THERM_ATTR_FAN_MAX_DUTY, value);
|
2012-09-02 08:55:58 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-09-04 19:39:40 +08:00
|
|
|
static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_get_pwm1_max,
|
|
|
|
nouveau_hwmon_set_pwm1_max, 0);
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2015-09-20 20:40:27 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_in0_input(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
|
2015-09-20 20:40:27 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = nvkm_volt_get(volt);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return sprintf(buf, "%i\n", ret / 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO,
|
|
|
|
nouveau_hwmon_get_in0_input, NULL, 0);
|
|
|
|
|
2016-04-17 20:51:23 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_in0_min(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
|
2016-04-17 20:51:23 +08:00
|
|
|
|
|
|
|
if (!volt || !volt->min_uv)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return sprintf(buf, "%i\n", volt->min_uv / 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO,
|
|
|
|
nouveau_hwmon_get_in0_min, NULL, 0);
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_in0_max(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
|
2016-04-17 20:51:23 +08:00
|
|
|
|
|
|
|
if (!volt || !volt->max_uv)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return sprintf(buf, "%i\n", volt->max_uv / 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO,
|
|
|
|
nouveau_hwmon_get_in0_max, NULL, 0);
|
|
|
|
|
2015-09-20 20:40:27 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_in0_label(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
return sprintf(buf, "GPU core\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO,
|
|
|
|
nouveau_hwmon_get_in0_label, NULL, 0);
|
|
|
|
|
2016-02-19 03:10:19 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
|
2016-02-19 03:10:19 +08:00
|
|
|
int result = nvkm_iccsense_read_all(iccsense);
|
|
|
|
|
|
|
|
if (result < 0)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
return sprintf(buf, "%i\n", result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO,
|
|
|
|
nouveau_hwmon_get_power1_input, NULL, 0);
|
|
|
|
|
2017-01-24 06:10:13 +08:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_power1_max(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
|
|
|
|
return sprintf(buf, "%i\n", iccsense->power_w_max);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SENSOR_DEVICE_ATTR(power1_max, S_IRUGO,
|
|
|
|
nouveau_hwmon_get_power1_max, NULL, 0);
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_get_power1_crit(struct device *d, struct device_attribute *a,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
|
|
|
|
return sprintf(buf, "%i\n", iccsense->power_w_crit);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SENSOR_DEVICE_ATTR(power1_crit, S_IRUGO,
|
|
|
|
nouveau_hwmon_get_power1_crit, NULL, 0);
|
|
|
|
|
2013-03-15 07:59:55 +08:00
|
|
|
static struct attribute *hwmon_default_attributes[] = {
|
|
|
|
&sensor_dev_attr_name.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_update_rate.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
static struct attribute *hwmon_temp_attributes[] = {
|
2010-09-23 02:54:22 +08:00
|
|
|
&sensor_dev_attr_temp1_input.dev_attr.attr,
|
2012-11-20 08:14:13 +08:00
|
|
|
&sensor_dev_attr_temp1_auto_point1_pwm.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr,
|
2010-09-23 02:54:22 +08:00
|
|
|
&sensor_dev_attr_temp1_max.dev_attr.attr,
|
2012-11-20 08:14:13 +08:00
|
|
|
&sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
|
2010-09-23 02:54:22 +08:00
|
|
|
&sensor_dev_attr_temp1_crit.dev_attr.attr,
|
2012-11-20 08:14:13 +08:00
|
|
|
&sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_temp1_emergency.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_temp1_emergency_hyst.dev_attr.attr,
|
2010-09-23 02:54:22 +08:00
|
|
|
NULL
|
|
|
|
};
|
2011-08-15 09:10:30 +08:00
|
|
|
static struct attribute *hwmon_fan_rpm_attributes[] = {
|
2012-12-06 13:13:06 +08:00
|
|
|
&sensor_dev_attr_fan1_input.dev_attr.attr,
|
2011-08-15 09:10:30 +08:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
static struct attribute *hwmon_pwm_fan_attributes[] = {
|
2012-09-04 19:52:00 +08:00
|
|
|
&sensor_dev_attr_pwm1_enable.dev_attr.attr,
|
2012-09-04 19:39:40 +08:00
|
|
|
&sensor_dev_attr_pwm1.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_pwm1_min.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_pwm1_max.dev_attr.attr,
|
2011-08-15 09:10:30 +08:00
|
|
|
NULL
|
|
|
|
};
|
2010-09-23 02:54:22 +08:00
|
|
|
|
2015-09-20 20:40:27 +08:00
|
|
|
static struct attribute *hwmon_in0_attributes[] = {
|
|
|
|
&sensor_dev_attr_in0_input.dev_attr.attr,
|
2016-04-17 20:51:23 +08:00
|
|
|
&sensor_dev_attr_in0_min.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_in0_max.dev_attr.attr,
|
2015-09-20 20:40:27 +08:00
|
|
|
&sensor_dev_attr_in0_label.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2016-02-19 03:10:19 +08:00
|
|
|
static struct attribute *hwmon_power_attributes[] = {
|
|
|
|
&sensor_dev_attr_power1_input.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-01-24 06:10:13 +08:00
|
|
|
static struct attribute *hwmon_power_caps_attributes[] = {
|
|
|
|
&sensor_dev_attr_power1_max.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_power1_crit.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2013-03-15 07:59:55 +08:00
|
|
|
static const struct attribute_group hwmon_default_attrgroup = {
|
|
|
|
.attrs = hwmon_default_attributes,
|
|
|
|
};
|
|
|
|
static const struct attribute_group hwmon_temp_attrgroup = {
|
|
|
|
.attrs = hwmon_temp_attributes,
|
2010-09-23 02:54:22 +08:00
|
|
|
};
|
2011-08-15 09:10:30 +08:00
|
|
|
static const struct attribute_group hwmon_fan_rpm_attrgroup = {
|
|
|
|
.attrs = hwmon_fan_rpm_attributes,
|
|
|
|
};
|
|
|
|
static const struct attribute_group hwmon_pwm_fan_attrgroup = {
|
|
|
|
.attrs = hwmon_pwm_fan_attributes,
|
|
|
|
};
|
2015-09-20 20:40:27 +08:00
|
|
|
static const struct attribute_group hwmon_in0_attrgroup = {
|
|
|
|
.attrs = hwmon_in0_attributes,
|
|
|
|
};
|
2016-02-19 03:10:19 +08:00
|
|
|
static const struct attribute_group hwmon_power_attrgroup = {
|
|
|
|
.attrs = hwmon_power_attributes,
|
|
|
|
};
|
2017-01-24 06:10:13 +08:00
|
|
|
static const struct attribute_group hwmon_power_caps_attrgroup = {
|
|
|
|
.attrs = hwmon_power_caps_attributes,
|
|
|
|
};
|
2010-10-26 18:48:28 +08:00
|
|
|
#endif
|
2010-09-23 02:54:22 +08:00
|
|
|
|
2013-10-15 07:44:02 +08:00
|
|
|
int
|
2010-09-23 02:54:22 +08:00
|
|
|
nouveau_hwmon_init(struct drm_device *dev)
|
|
|
|
{
|
2012-01-10 18:13:16 +08:00
|
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
2013-01-01 19:28:00 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2016-05-18 11:57:42 +08:00
|
|
|
struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
|
|
|
|
struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
|
|
|
|
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
|
2013-10-15 07:44:02 +08:00
|
|
|
struct nouveau_hwmon *hwmon;
|
2010-09-23 02:54:22 +08:00
|
|
|
struct device *hwmon_dev;
|
2011-08-15 09:10:30 +08:00
|
|
|
int ret = 0;
|
2010-09-23 02:54:22 +08:00
|
|
|
|
2013-10-15 07:44:02 +08:00
|
|
|
hwmon = drm->hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL);
|
|
|
|
if (!hwmon)
|
|
|
|
return -ENOMEM;
|
|
|
|
hwmon->dev = dev;
|
|
|
|
|
2016-03-02 18:13:42 +08:00
|
|
|
hwmon_dev = hwmon_device_register(dev->dev);
|
2010-09-23 02:54:22 +08:00
|
|
|
if (IS_ERR(hwmon_dev)) {
|
|
|
|
ret = PTR_ERR(hwmon_dev);
|
2012-07-31 14:16:21 +08:00
|
|
|
NV_ERROR(drm, "Unable to register hwmon device: %d\n", ret);
|
2010-09-23 02:54:22 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
dev_set_drvdata(hwmon_dev, dev);
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2013-03-15 07:59:55 +08:00
|
|
|
/* set the default attributes */
|
|
|
|
ret = sysfs_create_group(&hwmon_dev->kobj, &hwmon_default_attrgroup);
|
2014-02-06 17:29:43 +08:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2016-02-21 00:10:12 +08:00
|
|
|
if (therm && therm->attr_get && therm->attr_set) {
|
|
|
|
/* if the card has a working thermal sensor */
|
|
|
|
if (nvkm_therm_temp_get(therm) >= 0) {
|
|
|
|
ret = sysfs_create_group(&hwmon_dev->kobj, &hwmon_temp_attrgroup);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the card has a pwm fan */
|
|
|
|
/*XXX: incorrect, need better detection for this, some boards have
|
|
|
|
* the gpio entries for pwm fan control even when there's no
|
|
|
|
* actual fan connected to it... therm table? */
|
|
|
|
if (therm->fan_get && therm->fan_get(therm) >= 0) {
|
|
|
|
ret = sysfs_create_group(&hwmon_dev->kobj,
|
|
|
|
&hwmon_pwm_fan_attrgroup);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2011-08-15 09:10:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if the card can read the fan rpm */
|
2016-02-21 00:10:12 +08:00
|
|
|
if (therm && nvkm_therm_fan_sense(therm) >= 0) {
|
2012-12-06 13:17:12 +08:00
|
|
|
ret = sysfs_create_group(&hwmon_dev->kobj,
|
2011-08-15 09:10:30 +08:00
|
|
|
&hwmon_fan_rpm_attrgroup);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
2010-09-23 02:54:22 +08:00
|
|
|
}
|
|
|
|
|
2015-09-20 20:40:27 +08:00
|
|
|
if (volt && nvkm_volt_get(volt) >= 0) {
|
|
|
|
ret = sysfs_create_group(&hwmon_dev->kobj,
|
|
|
|
&hwmon_in0_attrgroup);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2016-03-28 20:24:30 +08:00
|
|
|
if (iccsense && iccsense->data_valid && !list_empty(&iccsense->rails)) {
|
2016-02-19 03:10:19 +08:00
|
|
|
ret = sysfs_create_group(&hwmon_dev->kobj,
|
|
|
|
&hwmon_power_attrgroup);
|
2017-01-24 06:10:13 +08:00
|
|
|
|
2016-02-19 03:10:19 +08:00
|
|
|
if (ret)
|
|
|
|
goto error;
|
2017-01-24 06:10:13 +08:00
|
|
|
|
|
|
|
if (iccsense->power_w_max && iccsense->power_w_crit) {
|
|
|
|
ret = sysfs_create_group(&hwmon_dev->kobj,
|
|
|
|
&hwmon_power_caps_attrgroup);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
2016-02-19 03:10:19 +08:00
|
|
|
}
|
|
|
|
|
2013-10-15 07:44:02 +08:00
|
|
|
hwmon->hwmon = hwmon_dev;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2010-09-23 02:54:22 +08:00
|
|
|
return 0;
|
2011-08-15 09:10:30 +08:00
|
|
|
|
|
|
|
error:
|
2012-07-31 14:16:21 +08:00
|
|
|
NV_ERROR(drm, "Unable to create some hwmon sysfs files: %d\n", ret);
|
2011-08-15 09:10:30 +08:00
|
|
|
hwmon_device_unregister(hwmon_dev);
|
2013-10-15 07:44:02 +08:00
|
|
|
hwmon->hwmon = NULL;
|
2011-08-15 09:10:30 +08:00
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
2010-09-23 02:54:22 +08:00
|
|
|
}
|
|
|
|
|
2013-10-15 07:44:02 +08:00
|
|
|
void
|
2010-09-23 02:54:22 +08:00
|
|
|
nouveau_hwmon_fini(struct drm_device *dev)
|
|
|
|
{
|
2011-07-04 02:54:28 +08:00
|
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
2013-10-15 07:44:02 +08:00
|
|
|
struct nouveau_hwmon *hwmon = nouveau_hwmon(dev);
|
2010-09-23 02:54:22 +08:00
|
|
|
|
2013-10-15 07:44:02 +08:00
|
|
|
if (hwmon->hwmon) {
|
|
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_default_attrgroup);
|
|
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_temp_attrgroup);
|
|
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_pwm_fan_attrgroup);
|
|
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup);
|
2015-09-20 20:40:27 +08:00
|
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup);
|
2016-02-19 03:10:19 +08:00
|
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_attrgroup);
|
2017-01-24 06:10:13 +08:00
|
|
|
sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_caps_attrgroup);
|
2011-08-15 09:10:30 +08:00
|
|
|
|
2013-10-15 07:44:02 +08:00
|
|
|
hwmon_device_unregister(hwmon->hwmon);
|
2010-09-23 02:54:22 +08:00
|
|
|
}
|
2010-10-12 10:31:32 +08:00
|
|
|
|
2013-10-15 07:44:02 +08:00
|
|
|
nouveau_drm(dev)->hwmon = NULL;
|
|
|
|
kfree(hwmon);
|
2010-10-12 10:31:32 +08:00
|
|
|
#endif
|
2010-09-17 11:35:25 +08:00
|
|
|
}
|