2010-09-16 12:39:49 +07: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 09:31:32 +07:00
|
|
|
#ifdef CONFIG_ACPI
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#endif
|
|
|
|
#include <linux/power_supply.h>
|
2010-09-23 01:54:22 +07: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 13:29:23 +07:00
|
|
|
#include <drm/drmP.h>
|
2011-09-16 22:42:12 +07:00
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
#include "nouveau_drm.h"
|
|
|
|
#include "nouveau_pm.h"
|
2011-09-16 22:42:12 +07:00
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
#include <subdev/gpio.h>
|
|
|
|
#include <subdev/timer.h>
|
2012-09-02 07:55:58 +07:00
|
|
|
#include <subdev/therm.h>
|
2011-09-16 22:42:12 +07:00
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
MODULE_PARM_DESC(perflvl, "Performance level (default: boot)");
|
|
|
|
static char *nouveau_perflvl;
|
|
|
|
module_param_named(perflvl, nouveau_perflvl, charp, 0400);
|
2011-09-16 22:42:12 +07:00
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
MODULE_PARM_DESC(perflvl_wr, "Allow perflvl changes (warning: dangerous!)");
|
|
|
|
static int nouveau_perflvl_wr;
|
|
|
|
module_param_named(perflvl_wr, nouveau_perflvl_wr, int, 0400);
|
2011-09-16 22:42:12 +07:00
|
|
|
|
2010-09-17 10:35:25 +07:00
|
|
|
static int
|
2011-10-27 09:02:12 +07:00
|
|
|
nouveau_pm_perflvl_aux(struct drm_device *dev, struct nouveau_pm_level *perflvl,
|
|
|
|
struct nouveau_pm_level *a, struct nouveau_pm_level *b)
|
2010-09-17 10:35:25 +07:00
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2012-10-04 05:44:19 +07:00
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-17 10:35:25 +07:00
|
|
|
int ret;
|
|
|
|
|
2011-08-15 08:10:30 +07:00
|
|
|
/*XXX: not on all boards, we should control based on temperature
|
|
|
|
* on recent boards.. or maybe on some other factor we don't
|
|
|
|
* know about?
|
|
|
|
*/
|
2012-09-02 07:55:58 +07:00
|
|
|
if (therm && therm->fan_set &&
|
|
|
|
a->fanspeed && b->fanspeed && b->fanspeed > a->fanspeed) {
|
|
|
|
ret = therm->fan_set(therm, perflvl->fanspeed);
|
2011-10-27 09:02:12 +07:00
|
|
|
if (ret && ret != -ENODEV) {
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_ERROR(drm, "fanspeed set failed: %d\n", ret);
|
2011-10-27 09:02:12 +07:00
|
|
|
}
|
2011-07-28 08:01:21 +07:00
|
|
|
}
|
|
|
|
|
2011-10-27 09:02:12 +07:00
|
|
|
if (pm->voltage.supported && pm->voltage_set) {
|
2011-11-10 10:20:14 +07:00
|
|
|
if (perflvl->volt_min && b->volt_min > a->volt_min) {
|
2011-10-27 09:02:12 +07:00
|
|
|
ret = pm->voltage_set(dev, perflvl->volt_min);
|
|
|
|
if (ret) {
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_ERROR(drm, "voltage set failed: %d\n", ret);
|
2011-10-27 09:02:12 +07:00
|
|
|
return ret;
|
|
|
|
}
|
2010-09-17 10:35:25 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-27 09:02:12 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
nouveau_pm_perflvl_set(struct drm_device *dev, struct nouveau_pm_level *perflvl)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2011-10-27 09:02:12 +07:00
|
|
|
void *state;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (perflvl == pm->cur)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = nouveau_pm_perflvl_aux(dev, perflvl, pm->cur, perflvl);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2011-10-27 07:28:17 +07:00
|
|
|
state = pm->clocks_pre(dev, perflvl);
|
2011-11-03 06:03:06 +07:00
|
|
|
if (IS_ERR(state)) {
|
|
|
|
ret = PTR_ERR(state);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
ret = pm->clocks_set(dev, state);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
2010-09-17 10:35:25 +07:00
|
|
|
|
2011-10-27 09:02:12 +07:00
|
|
|
ret = nouveau_pm_perflvl_aux(dev, perflvl, perflvl, pm->cur);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2010-09-17 10:35:25 +07:00
|
|
|
pm->cur = perflvl;
|
|
|
|
return 0;
|
2011-11-03 06:03:06 +07:00
|
|
|
|
|
|
|
error:
|
|
|
|
/* restore the fan speed and voltage before leaving */
|
|
|
|
nouveau_pm_perflvl_aux(dev, perflvl, perflvl, pm->cur);
|
|
|
|
return ret;
|
2010-09-17 10:35:25 +07:00
|
|
|
}
|
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
void
|
|
|
|
nouveau_pm_trigger(struct drm_device *dev)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_timer *ptimer = nouveau_timer(drm->device);
|
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2012-01-24 12:59:07 +07:00
|
|
|
struct nouveau_pm_profile *profile = NULL;
|
|
|
|
struct nouveau_pm_level *perflvl = NULL;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* select power profile based on current power source */
|
|
|
|
if (power_supply_is_system_supplied())
|
|
|
|
profile = pm->profile_ac;
|
|
|
|
else
|
|
|
|
profile = pm->profile_dc;
|
|
|
|
|
2012-01-24 15:03:25 +07:00
|
|
|
if (profile != pm->profile) {
|
|
|
|
pm->profile->func->fini(pm->profile);
|
|
|
|
pm->profile = profile;
|
|
|
|
pm->profile->func->init(pm->profile);
|
|
|
|
}
|
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
/* select performance level based on profile */
|
|
|
|
perflvl = profile->func->select(profile);
|
|
|
|
|
|
|
|
/* change perflvl, if necessary */
|
|
|
|
if (perflvl != pm->cur) {
|
2012-07-31 13:16:21 +07:00
|
|
|
u64 time0 = ptimer->read(ptimer);
|
2012-01-24 12:59:07 +07:00
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_INFO(drm, "setting performance level: %d", perflvl->id);
|
2012-01-24 12:59:07 +07:00
|
|
|
ret = nouveau_pm_perflvl_set(dev, perflvl);
|
|
|
|
if (ret)
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_INFO(drm, "> reclocking failed: %d\n\n", ret);
|
2012-01-24 12:59:07 +07:00
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_INFO(drm, "> reclocking took %lluns\n\n",
|
|
|
|
ptimer->read(ptimer) - time0);
|
2012-01-24 12:59:07 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct nouveau_pm_profile *
|
|
|
|
profile_find(struct drm_device *dev, const char *string)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2012-01-24 12:59:07 +07:00
|
|
|
struct nouveau_pm_profile *profile;
|
|
|
|
|
|
|
|
list_for_each_entry(profile, &pm->profiles, head) {
|
|
|
|
if (!strncmp(profile->name, string, sizeof(profile->name)))
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-16 13:47:14 +07:00
|
|
|
static int
|
|
|
|
nouveau_pm_profile_set(struct drm_device *dev, const char *profile)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2012-01-24 12:59:07 +07:00
|
|
|
struct nouveau_pm_profile *ac = NULL, *dc = NULL;
|
|
|
|
char string[16], *cur = string, *ptr;
|
2010-09-16 13:47:14 +07:00
|
|
|
|
|
|
|
/* safety precaution, for now */
|
|
|
|
if (nouveau_perflvl_wr != 7777)
|
|
|
|
return -EPERM;
|
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
strncpy(string, profile, sizeof(string));
|
2012-04-18 02:27:54 +07:00
|
|
|
string[sizeof(string) - 1] = 0;
|
2012-01-24 12:59:07 +07:00
|
|
|
if ((ptr = strchr(string, '\n')))
|
|
|
|
*ptr = '\0';
|
2010-09-16 13:47:14 +07:00
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
ptr = strsep(&cur, ",");
|
|
|
|
if (ptr)
|
|
|
|
ac = profile_find(dev, ptr);
|
2010-09-16 13:47:14 +07:00
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
ptr = strsep(&cur, ",");
|
|
|
|
if (ptr)
|
|
|
|
dc = profile_find(dev, ptr);
|
|
|
|
else
|
|
|
|
dc = ac;
|
2011-11-03 06:03:06 +07:00
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
if (ac == NULL || dc == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pm->profile_ac = ac;
|
|
|
|
pm->profile_dc = dc;
|
|
|
|
nouveau_pm_trigger(dev);
|
|
|
|
return 0;
|
2010-09-16 13:47:14 +07:00
|
|
|
}
|
|
|
|
|
2012-01-24 15:03:25 +07:00
|
|
|
static void
|
|
|
|
nouveau_pm_static_dummy(struct nouveau_pm_profile *profile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
static struct nouveau_pm_level *
|
|
|
|
nouveau_pm_static_select(struct nouveau_pm_profile *profile)
|
|
|
|
{
|
|
|
|
return container_of(profile, struct nouveau_pm_level, profile);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct nouveau_pm_profile_func nouveau_pm_static_profile_func = {
|
2012-01-24 15:03:25 +07:00
|
|
|
.destroy = nouveau_pm_static_dummy,
|
|
|
|
.init = nouveau_pm_static_dummy,
|
|
|
|
.fini = nouveau_pm_static_dummy,
|
2012-01-24 12:59:07 +07:00
|
|
|
.select = nouveau_pm_static_select,
|
|
|
|
};
|
|
|
|
|
2010-09-16 12:39:49 +07:00
|
|
|
static int
|
|
|
|
nouveau_pm_perflvl_get(struct drm_device *dev, struct nouveau_pm_level *perflvl)
|
|
|
|
{
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-16 12:39:49 +07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(perflvl, 0, sizeof(*perflvl));
|
|
|
|
|
2012-03-07 11:18:49 +07:00
|
|
|
if (pm->clocks_get) {
|
|
|
|
ret = pm->clocks_get(dev, perflvl);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
2010-09-16 12:39:49 +07:00
|
|
|
|
|
|
|
if (pm->voltage.supported && pm->voltage_get) {
|
|
|
|
ret = pm->voltage_get(dev);
|
2011-06-09 13:57:07 +07:00
|
|
|
if (ret > 0) {
|
|
|
|
perflvl->volt_min = ret;
|
|
|
|
perflvl->volt_max = ret;
|
|
|
|
}
|
2010-09-16 12:39:49 +07:00
|
|
|
}
|
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
if (therm && therm->fan_get) {
|
|
|
|
ret = therm->fan_get(therm);
|
|
|
|
if (ret >= 0)
|
|
|
|
perflvl->fanspeed = ret;
|
|
|
|
}
|
2011-07-28 08:01:21 +07:00
|
|
|
|
2012-01-17 18:10:58 +07:00
|
|
|
nouveau_mem_timing_read(dev, &perflvl->timing);
|
2010-09-16 12:39:49 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nouveau_pm_perflvl_info(struct nouveau_pm_level *perflvl, char *ptr, int len)
|
|
|
|
{
|
2012-01-18 06:02:28 +07:00
|
|
|
char c[16], s[16], v[32], f[16], m[16];
|
2010-09-20 21:18:28 +07:00
|
|
|
|
|
|
|
c[0] = '\0';
|
|
|
|
if (perflvl->core)
|
|
|
|
snprintf(c, sizeof(c), " core %dMHz", perflvl->core / 1000);
|
2010-09-16 12:39:49 +07:00
|
|
|
|
|
|
|
s[0] = '\0';
|
|
|
|
if (perflvl->shader)
|
|
|
|
snprintf(s, sizeof(s), " shader %dMHz", perflvl->shader / 1000);
|
|
|
|
|
2011-06-09 14:27:47 +07:00
|
|
|
m[0] = '\0';
|
|
|
|
if (perflvl->memory)
|
|
|
|
snprintf(m, sizeof(m), " memory %dMHz", perflvl->memory / 1000);
|
|
|
|
|
2010-09-16 12:39:49 +07:00
|
|
|
v[0] = '\0';
|
2011-06-09 13:57:07 +07:00
|
|
|
if (perflvl->volt_min && perflvl->volt_min != perflvl->volt_max) {
|
|
|
|
snprintf(v, sizeof(v), " voltage %dmV-%dmV",
|
|
|
|
perflvl->volt_min / 1000, perflvl->volt_max / 1000);
|
|
|
|
} else
|
|
|
|
if (perflvl->volt_min) {
|
|
|
|
snprintf(v, sizeof(v), " voltage %dmV",
|
|
|
|
perflvl->volt_min / 1000);
|
|
|
|
}
|
2010-09-16 12:39:49 +07:00
|
|
|
|
|
|
|
f[0] = '\0';
|
|
|
|
if (perflvl->fanspeed)
|
|
|
|
snprintf(f, sizeof(f), " fanspeed %d%%", perflvl->fanspeed);
|
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
snprintf(ptr, len, "%s%s%s%s%s\n", c, s, m, v, f);
|
2010-09-16 12:39:49 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_pm_get_perflvl_info(struct device *d,
|
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
2012-01-24 12:59:07 +07:00
|
|
|
struct nouveau_pm_level *perflvl =
|
|
|
|
container_of(a, struct nouveau_pm_level, dev_attr);
|
2010-09-16 12:39:49 +07:00
|
|
|
char *ptr = buf;
|
|
|
|
int len = PAGE_SIZE;
|
|
|
|
|
2011-06-09 14:27:47 +07:00
|
|
|
snprintf(ptr, len, "%d:", perflvl->id);
|
2010-09-16 12:39:49 +07:00
|
|
|
ptr += strlen(buf);
|
|
|
|
len -= strlen(buf);
|
|
|
|
|
|
|
|
nouveau_pm_perflvl_info(perflvl, ptr, len);
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_pm_get_perflvl(struct device *d, struct device_attribute *a, char *buf)
|
|
|
|
{
|
2010-09-23 01:54:22 +07:00
|
|
|
struct drm_device *dev = pci_get_drvdata(to_pci_dev(d));
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2010-09-16 12:39:49 +07:00
|
|
|
struct nouveau_pm_level cur;
|
|
|
|
int len = PAGE_SIZE, ret;
|
|
|
|
char *ptr = buf;
|
|
|
|
|
2012-01-24 12:59:07 +07:00
|
|
|
snprintf(ptr, len, "profile: %s, %s\nc:",
|
|
|
|
pm->profile_ac->name, pm->profile_dc->name);
|
2010-09-16 12:39:49 +07:00
|
|
|
ptr += strlen(buf);
|
|
|
|
len -= strlen(buf);
|
|
|
|
|
|
|
|
ret = nouveau_pm_perflvl_get(dev, &cur);
|
|
|
|
if (ret == 0)
|
|
|
|
nouveau_pm_perflvl_info(&cur, ptr, len);
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
nouveau_pm_set_perflvl(struct device *d, struct device_attribute *a,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2010-09-23 01:54:22 +07:00
|
|
|
struct drm_device *dev = pci_get_drvdata(to_pci_dev(d));
|
2010-09-16 13:47:14 +07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = nouveau_pm_profile_set(dev, buf);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return strlen(buf);
|
2010-09-16 12:39:49 +07:00
|
|
|
}
|
|
|
|
|
2010-09-24 01:36:42 +07:00
|
|
|
static DEVICE_ATTR(performance_level, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_pm_get_perflvl, nouveau_pm_set_perflvl);
|
2010-09-16 12:39:49 +07:00
|
|
|
|
2010-09-23 01:54:22 +07:00
|
|
|
static int
|
|
|
|
nouveau_sysfs_init(struct drm_device *dev)
|
2010-09-16 12:39:49 +07:00
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2010-09-16 12:39:49 +07:00
|
|
|
struct device *d = &dev->pdev->dev;
|
|
|
|
int ret, i;
|
|
|
|
|
|
|
|
ret = device_create_file(d, &dev_attr_performance_level);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
for (i = 0; i < pm->nr_perflvl; i++) {
|
|
|
|
struct nouveau_pm_level *perflvl = &pm->perflvl[i];
|
|
|
|
|
|
|
|
perflvl->dev_attr.attr.name = perflvl->name;
|
|
|
|
perflvl->dev_attr.attr.mode = S_IRUGO;
|
|
|
|
perflvl->dev_attr.show = nouveau_pm_get_perflvl_info;
|
|
|
|
perflvl->dev_attr.store = NULL;
|
|
|
|
sysfs_attr_init(&perflvl->dev_attr.attr);
|
|
|
|
|
|
|
|
ret = device_create_file(d, &perflvl->dev_attr);
|
|
|
|
if (ret) {
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_ERROR(drm, "failed pervlvl %d sysfs: %d\n",
|
2010-09-16 12:39:49 +07:00
|
|
|
perflvl->id, i);
|
|
|
|
perflvl->dev_attr.attr.name = NULL;
|
|
|
|
nouveau_pm_fini(dev);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-23 01:54:22 +07:00
|
|
|
static void
|
|
|
|
nouveau_sysfs_fini(struct drm_device *dev)
|
2010-09-16 12:39:49 +07:00
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2010-09-16 12:39:49 +07:00
|
|
|
struct device *d = &dev->pdev->dev;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
device_remove_file(d, &dev_attr_performance_level);
|
|
|
|
for (i = 0; i < pm->nr_perflvl; i++) {
|
|
|
|
struct nouveau_pm_level *pl = &pm->perflvl[i];
|
|
|
|
|
|
|
|
if (!pl->dev_attr.attr.name)
|
|
|
|
break;
|
|
|
|
|
|
|
|
device_remove_file(d, &pl->dev_attr);
|
|
|
|
}
|
2010-09-23 01:54:22 +07:00
|
|
|
}
|
|
|
|
|
2011-07-04 01:54:28 +07:00
|
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
2010-09-23 01:54:22 +07: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 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", therm->temp_get(therm) * 1000);
|
2010-09-23 01:54:22 +07:00
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, nouveau_hwmon_show_temp,
|
|
|
|
NULL, 0);
|
|
|
|
|
2012-11-20 07:14:13 +07: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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST) * 1000);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST,
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST,
|
|
|
|
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 01:54:22 +07: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 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK) * 1000);
|
2010-09-23 01:54:22 +07: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 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-23 01:54:22 +07:00
|
|
|
long value;
|
|
|
|
|
2011-12-17 18:24:59 +07:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2010-09-23 01:54:22 +07:00
|
|
|
return count;
|
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK, value / 1000);
|
2010-09-23 01:54:22 +07: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 07:14:13 +07: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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST) * 1000);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST,
|
|
|
|
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 01:54:22 +07: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 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL) * 1000);
|
2010-09-23 01:54:22 +07: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 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-23 01:54:22 +07:00
|
|
|
long value;
|
|
|
|
|
2011-12-17 18:24:59 +07:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2010-09-23 01:54:22 +07:00
|
|
|
return count;
|
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL, value / 1000);
|
2010-09-23 01:54:22 +07: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 07:14:13 +07: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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST) * 1000);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST,
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN) * 1000);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN, value / 1000);
|
|
|
|
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST) * 1000);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
long value;
|
|
|
|
|
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return count;
|
|
|
|
|
|
|
|
therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST,
|
|
|
|
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 01:54:22 +07: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 08:10:30 +07:00
|
|
|
static ssize_t
|
|
|
|
nouveau_hwmon_show_fan0_input(struct device *d, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", therm->fan_sense(therm));
|
2011-08-15 08:10:30 +07:00
|
|
|
}
|
|
|
|
static SENSOR_DEVICE_ATTR(fan0_input, S_IRUGO, nouveau_hwmon_show_fan0_input,
|
|
|
|
NULL, 0);
|
|
|
|
|
2012-09-04 18:52:00 +07: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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2011-11-21 13:41:48 +07:00
|
|
|
int ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-04 18:52:00 +07:00
|
|
|
ret = therm->attr_get(therm, NOUVEAU_THERM_ATTR_FAN_MODE);
|
|
|
|
if (ret < 0)
|
2011-11-21 13:41:48 +07:00
|
|
|
return ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-04 18:52:00 +07:00
|
|
|
return sprintf(buf, "%i\n", ret);
|
|
|
|
}
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-04 18:52:00 +07: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);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
long value;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (strict_strtol(buf, 10, &value) == -EINVAL)
|
|
|
|
return -EINVAL;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-04 18:52:00 +07:00
|
|
|
ret = therm->attr_set(therm, NOUVEAU_THERM_ATTR_FAN_MODE, value);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
else
|
|
|
|
return count;
|
2011-08-15 08:10:30 +07:00
|
|
|
}
|
2012-09-04 18:52:00 +07: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 08:10:30 +07:00
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 18:39:40 +07:00
|
|
|
nouveau_hwmon_get_pwm1(struct device *d, struct device_attribute *a, char *buf)
|
2011-08-15 08:10:30 +07:00
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2011-09-16 22:42:12 +07:00
|
|
|
int ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
ret = therm->fan_get(therm);
|
2011-08-15 08:10:30 +07:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return sprintf(buf, "%i\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 18:39:40 +07:00
|
|
|
nouveau_hwmon_set_pwm1(struct device *d, struct device_attribute *a,
|
2011-08-15 08:10:30 +07:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2011-08-15 08:10:30 +07:00
|
|
|
int ret = -ENODEV;
|
|
|
|
long value;
|
|
|
|
|
|
|
|
if (nouveau_perflvl_wr != 7777)
|
|
|
|
return -EPERM;
|
|
|
|
|
2011-12-17 18:24:59 +07:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2011-08-15 08:10:30 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
ret = therm->fan_set(therm, value);
|
2011-08-15 08:10:30 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-09-04 18:39:40 +07:00
|
|
|
static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR,
|
|
|
|
nouveau_hwmon_get_pwm1,
|
|
|
|
nouveau_hwmon_set_pwm1, 0);
|
2011-08-15 08:10:30 +07:00
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 18:39:40 +07:00
|
|
|
nouveau_hwmon_get_pwm1_min(struct device *d,
|
2011-08-15 08:10:30 +07:00
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = therm->attr_get(therm, NOUVEAU_THERM_ATTR_FAN_MIN_DUTY);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
return sprintf(buf, "%i\n", ret);
|
2011-08-15 08:10:30 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 18:39:40 +07:00
|
|
|
nouveau_hwmon_set_pwm1_min(struct device *d, struct device_attribute *a,
|
2011-08-15 08:10:30 +07:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2011-08-15 08:10:30 +07:00
|
|
|
long value;
|
2012-09-02 07:55:58 +07:00
|
|
|
int ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2011-12-17 18:24:59 +07:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2011-08-15 08:10:30 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
ret = therm->attr_set(therm, NOUVEAU_THERM_ATTR_FAN_MIN_DUTY, value);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-09-04 18:39:40 +07: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 08:10:30 +07:00
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 18:39:40 +07:00
|
|
|
nouveau_hwmon_get_pwm1_max(struct device *d,
|
2011-08-15 08:10:30 +07:00
|
|
|
struct device_attribute *a, char *buf)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
|
|
|
int ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
ret = therm->attr_get(therm, NOUVEAU_THERM_ATTR_FAN_MAX_DUTY);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
return sprintf(buf, "%i\n", ret);
|
2011-08-15 08:10:30 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-04 18:39:40 +07:00
|
|
|
nouveau_hwmon_set_pwm1_max(struct device *d, struct device_attribute *a,
|
2011-08-15 08:10:30 +07:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = dev_get_drvdata(d);
|
2012-09-02 07:55:58 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2011-08-15 08:10:30 +07:00
|
|
|
long value;
|
2012-09-02 07:55:58 +07:00
|
|
|
int ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2011-12-17 18:24:59 +07:00
|
|
|
if (kstrtol(buf, 10, &value) == -EINVAL)
|
2011-08-15 08:10:30 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2012-09-02 07:55:58 +07:00
|
|
|
ret = therm->attr_set(therm, NOUVEAU_THERM_ATTR_FAN_MAX_DUTY, value);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-09-04 18:39:40 +07: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 08:10:30 +07:00
|
|
|
|
2010-09-23 01:54:22 +07:00
|
|
|
static struct attribute *hwmon_attributes[] = {
|
|
|
|
&sensor_dev_attr_temp1_input.dev_attr.attr,
|
2012-11-20 07:14:13 +07: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 01:54:22 +07:00
|
|
|
&sensor_dev_attr_temp1_max.dev_attr.attr,
|
2012-11-20 07:14:13 +07:00
|
|
|
&sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
|
2010-09-23 01:54:22 +07:00
|
|
|
&sensor_dev_attr_temp1_crit.dev_attr.attr,
|
2012-11-20 07:14:13 +07: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 01:54:22 +07:00
|
|
|
&sensor_dev_attr_name.dev_attr.attr,
|
|
|
|
&sensor_dev_attr_update_rate.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
2011-08-15 08:10:30 +07:00
|
|
|
static struct attribute *hwmon_fan_rpm_attributes[] = {
|
|
|
|
&sensor_dev_attr_fan0_input.dev_attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
static struct attribute *hwmon_pwm_fan_attributes[] = {
|
2012-09-04 18:52:00 +07:00
|
|
|
&sensor_dev_attr_pwm1_enable.dev_attr.attr,
|
2012-09-04 18:39:40 +07: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 08:10:30 +07:00
|
|
|
NULL
|
|
|
|
};
|
2010-09-23 01:54:22 +07:00
|
|
|
|
|
|
|
static const struct attribute_group hwmon_attrgroup = {
|
|
|
|
.attrs = hwmon_attributes,
|
|
|
|
};
|
2011-08-15 08:10:30 +07: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,
|
|
|
|
};
|
2010-10-26 17:48:28 +07:00
|
|
|
#endif
|
2010-09-23 01:54:22 +07:00
|
|
|
|
|
|
|
static int
|
|
|
|
nouveau_hwmon_init(struct drm_device *dev)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
|
|
|
|
2012-01-10 17:13:16 +07:00
|
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
2013-01-01 18:28:00 +07:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_therm *therm = nouveau_therm(drm->device);
|
2010-09-23 01:54:22 +07:00
|
|
|
struct device *hwmon_dev;
|
2011-08-15 08:10:30 +07:00
|
|
|
int ret = 0;
|
2010-09-23 01:54:22 +07:00
|
|
|
|
2012-10-04 05:28:21 +07:00
|
|
|
if (!therm || !therm->temp_get || !therm->attr_get || !therm->attr_set)
|
2010-09-24 01:58:38 +07:00
|
|
|
return -ENODEV;
|
2010-09-23 01:54:22 +07:00
|
|
|
|
|
|
|
hwmon_dev = hwmon_device_register(&dev->pdev->dev);
|
|
|
|
if (IS_ERR(hwmon_dev)) {
|
|
|
|
ret = PTR_ERR(hwmon_dev);
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_ERROR(drm, "Unable to register hwmon device: %d\n", ret);
|
2010-09-23 01:54:22 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
dev_set_drvdata(hwmon_dev, dev);
|
2011-08-15 08:10:30 +07:00
|
|
|
|
|
|
|
/* default sysfs entries */
|
2011-01-07 02:29:53 +07:00
|
|
|
ret = sysfs_create_group(&dev->pdev->dev.kobj, &hwmon_attrgroup);
|
2010-09-23 01:54:22 +07:00
|
|
|
if (ret) {
|
2011-08-15 08:10:30 +07:00
|
|
|
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? */
|
2012-09-02 07:55:58 +07:00
|
|
|
if (therm->fan_get && therm->fan_get(therm) >= 0) {
|
2011-08-15 08:10:30 +07:00
|
|
|
ret = sysfs_create_group(&dev->pdev->dev.kobj,
|
|
|
|
&hwmon_pwm_fan_attrgroup);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the card can read the fan rpm */
|
2012-09-02 07:55:58 +07:00
|
|
|
if (therm->fan_sense(therm) >= 0) {
|
2011-08-15 08:10:30 +07:00
|
|
|
ret = sysfs_create_group(&dev->pdev->dev.kobj,
|
|
|
|
&hwmon_fan_rpm_attrgroup);
|
|
|
|
if (ret)
|
|
|
|
goto error;
|
2010-09-23 01:54:22 +07:00
|
|
|
}
|
|
|
|
|
2010-09-24 01:58:38 +07:00
|
|
|
pm->hwmon = hwmon_dev;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2010-09-23 01:54:22 +07:00
|
|
|
return 0;
|
2011-08-15 08:10:30 +07:00
|
|
|
|
|
|
|
error:
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_ERROR(drm, "Unable to create some hwmon sysfs files: %d\n", ret);
|
2011-08-15 08:10:30 +07:00
|
|
|
hwmon_device_unregister(hwmon_dev);
|
|
|
|
pm->hwmon = NULL;
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
pm->hwmon = NULL;
|
|
|
|
return 0;
|
|
|
|
#endif
|
2010-09-23 01:54:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nouveau_hwmon_fini(struct drm_device *dev)
|
|
|
|
{
|
2011-07-04 01:54:28 +07:00
|
|
|
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
2010-09-24 01:58:38 +07:00
|
|
|
if (pm->hwmon) {
|
2011-01-30 16:54:11 +07:00
|
|
|
sysfs_remove_group(&dev->pdev->dev.kobj, &hwmon_attrgroup);
|
2011-12-17 18:24:59 +07:00
|
|
|
sysfs_remove_group(&dev->pdev->dev.kobj,
|
|
|
|
&hwmon_pwm_fan_attrgroup);
|
|
|
|
sysfs_remove_group(&dev->pdev->dev.kobj,
|
|
|
|
&hwmon_fan_rpm_attrgroup);
|
2011-08-15 08:10:30 +07:00
|
|
|
|
2010-09-24 01:58:38 +07:00
|
|
|
hwmon_device_unregister(pm->hwmon);
|
2010-09-23 01:54:22 +07:00
|
|
|
}
|
2010-10-26 17:48:28 +07:00
|
|
|
#endif
|
2010-09-23 01:54:22 +07:00
|
|
|
}
|
|
|
|
|
2011-04-12 05:55:44 +07:00
|
|
|
#if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
|
2010-10-12 09:31:32 +07:00
|
|
|
static int
|
|
|
|
nouveau_pm_acpi_event(struct notifier_block *nb, unsigned long val, void *data)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = container_of(nb, struct nouveau_pm, acpi_nb);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(pm->dev);
|
2010-10-12 09:31:32 +07:00
|
|
|
struct acpi_bus_event *entry = (struct acpi_bus_event *)data;
|
|
|
|
|
|
|
|
if (strcmp(entry->device_class, "ac_adapter") == 0) {
|
|
|
|
bool ac = power_supply_is_system_supplied();
|
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_DEBUG(drm, "power supply changed: %s\n", ac ? "AC" : "DC");
|
|
|
|
nouveau_pm_trigger(pm->dev);
|
2010-10-12 09:31:32 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-09-23 01:54:22 +07:00
|
|
|
int
|
|
|
|
nouveau_pm_init(struct drm_device *dev)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_device *device = nouveau_dev(dev);
|
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
|
|
|
struct nouveau_pm *pm;
|
2010-09-23 01:54:22 +07:00
|
|
|
char info[256];
|
|
|
|
int ret, i;
|
|
|
|
|
2012-07-31 13:16:21 +07:00
|
|
|
pm = drm->pm = kzalloc(sizeof(*pm), GFP_KERNEL);
|
|
|
|
if (!pm)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pm->dev = dev;
|
|
|
|
|
|
|
|
if (device->card_type < NV_40) {
|
|
|
|
pm->clocks_get = nv04_pm_clocks_get;
|
|
|
|
pm->clocks_pre = nv04_pm_clocks_pre;
|
|
|
|
pm->clocks_set = nv04_pm_clocks_set;
|
|
|
|
if (nouveau_gpio(drm->device)) {
|
|
|
|
pm->voltage_get = nouveau_voltage_gpio_get;
|
|
|
|
pm->voltage_set = nouveau_voltage_gpio_set;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (device->card_type < NV_50) {
|
|
|
|
pm->clocks_get = nv40_pm_clocks_get;
|
|
|
|
pm->clocks_pre = nv40_pm_clocks_pre;
|
|
|
|
pm->clocks_set = nv40_pm_clocks_set;
|
|
|
|
pm->voltage_get = nouveau_voltage_gpio_get;
|
|
|
|
pm->voltage_set = nouveau_voltage_gpio_set;
|
|
|
|
} else
|
|
|
|
if (device->card_type < NV_C0) {
|
|
|
|
if (device->chipset < 0xa3 ||
|
|
|
|
device->chipset == 0xaa ||
|
|
|
|
device->chipset == 0xac) {
|
|
|
|
pm->clocks_get = nv50_pm_clocks_get;
|
|
|
|
pm->clocks_pre = nv50_pm_clocks_pre;
|
|
|
|
pm->clocks_set = nv50_pm_clocks_set;
|
|
|
|
} else {
|
|
|
|
pm->clocks_get = nva3_pm_clocks_get;
|
|
|
|
pm->clocks_pre = nva3_pm_clocks_pre;
|
|
|
|
pm->clocks_set = nva3_pm_clocks_set;
|
|
|
|
}
|
|
|
|
pm->voltage_get = nouveau_voltage_gpio_get;
|
|
|
|
pm->voltage_set = nouveau_voltage_gpio_set;
|
|
|
|
} else
|
|
|
|
if (device->card_type < NV_E0) {
|
|
|
|
pm->clocks_get = nvc0_pm_clocks_get;
|
|
|
|
pm->clocks_pre = nvc0_pm_clocks_pre;
|
|
|
|
pm->clocks_set = nvc0_pm_clocks_set;
|
|
|
|
pm->voltage_get = nouveau_voltage_gpio_get;
|
|
|
|
pm->voltage_set = nouveau_voltage_gpio_set;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-23 10:47:02 +07:00
|
|
|
/* parse aux tables from vbios */
|
2010-09-23 01:54:22 +07:00
|
|
|
nouveau_volt_init(dev);
|
|
|
|
|
2012-09-25 13:31:40 +07:00
|
|
|
INIT_LIST_HEAD(&pm->profiles);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
2012-01-23 10:47:02 +07:00
|
|
|
/* determine current ("boot") performance level */
|
|
|
|
ret = nouveau_pm_perflvl_get(dev, &pm->boot);
|
|
|
|
if (ret) {
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_ERROR(drm, "failed to determine boot perflvl\n");
|
2012-01-23 10:47:02 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
strncpy(pm->boot.name, "boot", 4);
|
2012-01-24 12:59:07 +07:00
|
|
|
strncpy(pm->boot.profile.name, "boot", 4);
|
|
|
|
pm->boot.profile.func = &nouveau_pm_static_profile_func;
|
|
|
|
|
|
|
|
list_add(&pm->boot.profile.head, &pm->profiles);
|
|
|
|
|
|
|
|
pm->profile_ac = &pm->boot.profile;
|
|
|
|
pm->profile_dc = &pm->boot.profile;
|
2012-01-24 15:03:25 +07:00
|
|
|
pm->profile = &pm->boot.profile;
|
2012-01-23 10:47:02 +07:00
|
|
|
pm->cur = &pm->boot;
|
|
|
|
|
|
|
|
/* add performance levels from vbios */
|
|
|
|
nouveau_perf_init(dev);
|
|
|
|
|
|
|
|
/* display available performance levels */
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_INFO(drm, "%d available performance level(s)\n", pm->nr_perflvl);
|
2010-09-23 01:54:22 +07:00
|
|
|
for (i = 0; i < pm->nr_perflvl; i++) {
|
|
|
|
nouveau_pm_perflvl_info(&pm->perflvl[i], info, sizeof(info));
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_INFO(drm, "%d:%s", pm->perflvl[i].id, info);
|
2010-09-23 01:54:22 +07:00
|
|
|
}
|
|
|
|
|
2012-01-23 10:47:02 +07:00
|
|
|
nouveau_pm_perflvl_info(&pm->boot, info, sizeof(info));
|
2012-07-31 13:16:21 +07:00
|
|
|
NV_INFO(drm, "c:%s", info);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
|
|
|
/* switch performance levels now if requested */
|
2012-01-24 12:59:07 +07:00
|
|
|
if (nouveau_perflvl != NULL)
|
|
|
|
nouveau_pm_profile_set(dev, nouveau_perflvl);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
|
|
|
nouveau_sysfs_init(dev);
|
|
|
|
nouveau_hwmon_init(dev);
|
2011-04-12 05:55:44 +07:00
|
|
|
#if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
|
2010-10-12 09:31:32 +07:00
|
|
|
pm->acpi_nb.notifier_call = nouveau_pm_acpi_event;
|
|
|
|
register_acpi_notifier(&pm->acpi_nb);
|
|
|
|
#endif
|
2010-09-23 01:54:22 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nouveau_pm_fini(struct drm_device *dev)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2012-01-24 15:03:25 +07:00
|
|
|
struct nouveau_pm_profile *profile, *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(profile, tmp, &pm->profiles, head) {
|
|
|
|
list_del(&profile->head);
|
|
|
|
profile->func->destroy(profile);
|
|
|
|
}
|
2010-09-23 01:54:22 +07:00
|
|
|
|
|
|
|
if (pm->cur != &pm->boot)
|
|
|
|
nouveau_pm_perflvl_set(dev, &pm->boot);
|
2010-09-16 12:39:49 +07:00
|
|
|
|
|
|
|
nouveau_perf_fini(dev);
|
|
|
|
nouveau_volt_fini(dev);
|
2010-09-23 01:54:22 +07:00
|
|
|
|
2011-04-12 05:55:44 +07:00
|
|
|
#if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
|
2010-10-12 09:31:32 +07:00
|
|
|
unregister_acpi_notifier(&pm->acpi_nb);
|
|
|
|
#endif
|
2010-09-23 01:54:22 +07:00
|
|
|
nouveau_hwmon_fini(dev);
|
|
|
|
nouveau_sysfs_fini(dev);
|
2012-07-31 13:16:21 +07:00
|
|
|
|
|
|
|
nouveau_drm(dev)->pm = NULL;
|
|
|
|
kfree(pm);
|
2010-09-16 12:39:49 +07:00
|
|
|
}
|
|
|
|
|
2010-09-17 10:35:25 +07:00
|
|
|
void
|
|
|
|
nouveau_pm_resume(struct drm_device *dev)
|
|
|
|
{
|
2012-07-31 13:16:21 +07:00
|
|
|
struct nouveau_pm *pm = nouveau_pm(dev);
|
2010-09-17 10:35:25 +07:00
|
|
|
struct nouveau_pm_level *perflvl;
|
|
|
|
|
2011-02-17 08:11:28 +07:00
|
|
|
if (!pm->cur || pm->cur == &pm->boot)
|
2010-09-17 10:35:25 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
perflvl = pm->cur;
|
|
|
|
pm->cur = &pm->boot;
|
|
|
|
nouveau_pm_perflvl_set(dev, perflvl);
|
|
|
|
}
|