Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pscnv: Change gpio voltage to a range, and choose the lowest possible

  • Loading branch information...
commit a19114d1fb0b625cfbe874588b41e4b4130aab86 1 parent 2e61da5
@mlankhorst mlankhorst authored
View
2  pscnv/nouveau_drv.h
@@ -327,7 +327,7 @@ struct nouveau_pm_engine {
int (*clocks_set)(struct drm_device *, void *);
int (*voltage_get)(struct drm_device *);
- int (*voltage_set)(struct drm_device *, int voltage);
+ int (*voltage_set_range)(struct drm_device *, int vol_min, int volt_max);
int (*pwm_get)(struct drm_device *, int line, u32*, u32*);
int (*pwm_set)(struct drm_device *, int line, u32, u32);
int (*temp_get)(struct drm_device *);
View
2  pscnv/nouveau_perf.c
@@ -376,7 +376,7 @@ nouveau_perf_init(struct drm_device *dev)
/* make sure vid is valid */
nouveau_perf_voltage(dev, perflvl);
if (pm->voltage.supported && perflvl->volt_min) {
- vid = nouveau_volt_vid_lookup(dev, perflvl->volt_min);
+ vid = nouveau_volt_vid_lookup_range(dev, perflvl->volt_min, perflvl->volt_max);
if (vid < 0) {
NV_DEBUG(dev, "perflvl %d, bad vid\n", i);
continue;
View
4 pscnv/nouveau_pm.c
@@ -119,9 +119,9 @@ nouveau_pm_perflvl_aux(struct drm_device *dev, struct nouveau_pm_level *perflvl,
}
}
- if (pm->voltage.supported && pm->voltage_set) {
+ if (pm->voltage.supported && pm->voltage_set_range) {
if (perflvl->volt_min && b->volt_min > a->volt_min) {
- ret = pm->voltage_set(dev, perflvl->volt_min);
+ ret = pm->voltage_set_range(dev, perflvl->volt_min, perflvl->volt_max);
if (ret) {
NV_ERROR(dev, "voltage set failed: %d\n", ret);
return ret;
View
4 pscnv/nouveau_pm.h
@@ -54,10 +54,10 @@ void nouveau_pm_trigger(struct drm_device *dev);
/* nouveau_volt.c */
void nouveau_volt_init(struct drm_device *);
void nouveau_volt_fini(struct drm_device *);
-int nouveau_volt_vid_lookup(struct drm_device *, int voltage);
+int nouveau_volt_vid_lookup_range(struct drm_device *, int volt_min, int volt_max);
int nouveau_volt_lvl_lookup(struct drm_device *, int vid);
int nouveau_voltage_gpio_get(struct drm_device *);
-int nouveau_voltage_gpio_set(struct drm_device *, int voltage);
+int nouveau_voltage_gpio_set_range(struct drm_device *, int volt_min, int volt_max);
/* nouveau_perf.c */
void nouveau_perf_init(struct drm_device *);
View
2  pscnv/nouveau_state.c
@@ -116,7 +116,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
if (dev_priv->chipset >= 0x30 && dev_priv->chipset < 0xc0) {
engine->pm.voltage_get = nouveau_voltage_gpio_get;
- engine->pm.voltage_set = nouveau_voltage_gpio_set;
+ engine->pm.voltage_set_range = nouveau_voltage_gpio_set_range;
}
if (dev_priv->chipset < 0x50 || (dev_priv->chipset & 0xf0) == 0x60) {
View
24 pscnv/nouveau_volt.c
@@ -50,14 +50,14 @@ nouveau_voltage_gpio_get(struct drm_device *dev)
}
int
-nouveau_voltage_gpio_set(struct drm_device *dev, int voltage)
+nouveau_voltage_gpio_set_range(struct drm_device *dev, int volt_min, int volt_max)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
struct nouveau_pm_voltage *volt = &dev_priv->engine.pm.voltage;
struct nouveau_gpio_engine *gpio = &dev_priv->engine.gpio;
int vid, i;
- vid = nouveau_volt_vid_lookup(dev, voltage);
+ vid = nouveau_volt_vid_lookup_range(dev, volt_min, volt_max);
if (vid < 0)
return vid;
@@ -72,17 +72,25 @@ nouveau_voltage_gpio_set(struct drm_device *dev, int voltage)
}
int
-nouveau_volt_vid_lookup(struct drm_device *dev, int voltage)
+nouveau_volt_vid_lookup_range(struct drm_device *dev, int volt_min, int volt_max)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
struct nouveau_pm_voltage *volt = &dev_priv->engine.pm.voltage;
- int i;
-
+ int i, best = -1;
+ if (volt_max < volt_min) {
+ NV_WARN(dev, "volt_max %d < volt_min %d\n", volt_min, volt_max);
+ volt_max = volt_min;
+ }
for (i = 0; i < volt->nr_level; i++) {
- if (voltage + 500 >= volt->level[i].voltage && voltage <= volt->level[i].voltage)
- return volt->level[i].vid;
+ if (volt->level[i].voltage < volt_min ||
+ volt->level[i].voltage > volt_max)
+ continue;
+ if (best < 0 ||
+ volt->level[i].voltage < volt->level[best].voltage)
+ best = i;
}
-
+ if (best >= 0)
+ return volt->level[best].vid;
return -ENOENT;
}
Please sign in to comment.
Something went wrong with that request. Please try again.