From 6c22378720d92c759c90ff60ddf3185a394d8180 Mon Sep 17 00:00:00 2001 From: Martin Peres Date: Sun, 2 Sep 2012 04:01:43 +0200 Subject: [PATCH] --- yaml --- r: 329683 b: refs/heads/master c: cfc732bbc59d8905634fef7d7b02bdac84ea9221 h: refs/heads/master i: 329681: dc9f0713549fbafd772dee5190c6fd299b5e9d1e 329679: 2a971e1d8654bf4ba6abe4295b5e0a44a3c940a5 v: v3 --- [refs] | 2 +- .../gpu/drm/nouveau/core/subdev/therm/fan.c | 13 ++++++--- .../gpu/drm/nouveau/core/subdev/therm/nv50.c | 27 +++++++++++++++++++ .../gpu/drm/nouveau/core/subdev/therm/priv.h | 1 + 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index e0c3c46b74d4..2071d67d9011 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bf6546b4219d2b188529f3242efda4048f5b1b41 +refs/heads/master: cfc732bbc59d8905634fef7d7b02bdac84ea9221 diff --git a/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c b/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c index b7339b52559e..409b95d5b679 100644 --- a/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c +++ b/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c @@ -81,10 +81,10 @@ nouveau_therm_fan_set(struct nouveau_therm *therm, int percent) if (ret == 0) { divs = priv->bios_perf_fan.pwm_divisor; if (priv->bios_fan.pwm_freq) { - /*XXX: PNVIO clock more than likely... */ - divs = 135000 /priv->bios_fan.pwm_freq; - if (nv_device(therm)->chipset < 0xa3) - divs /= 4; + divs = 1; + if (priv->fan.pwm_clock) + divs = priv->fan.pwm_clock(therm); + divs /= priv->bios_fan.pwm_freq; } duty = ((divs * percent) + 99) / 100; @@ -163,6 +163,11 @@ nouveau_therm_fan_safety_checks(struct nouveau_therm *therm) priv->bios_fan.min_duty = priv->bios_fan.max_duty; } +int nouveau_fan_pwm_clock_dummy(struct nouveau_therm *therm) +{ + return 1; +} + int nouveau_therm_fan_ctor(struct nouveau_therm *therm) { diff --git a/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/nv50.c b/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/nv50.c index f7f51f35d18b..de7dc20ed436 100644 --- a/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/nv50.c +++ b/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/nv50.c @@ -79,6 +79,32 @@ nv50_fan_pwm_set(struct nouveau_therm *therm, int line, u32 divs, u32 duty) return 0; } +int +nv50_fan_pwm_clock(struct nouveau_therm *therm) +{ + int chipset = nv_device(therm)->chipset; + int crystal = nv_device(therm)->crystal; + int pwm_clock; + + /* determine the PWM source clock */ + if (chipset > 0x50 && chipset < 0x94) { + u8 pwm_div = nv_rd32(therm, 0x410c); + if (nv_rd32(therm, 0xc040) & 0x800000) { + /* Use the HOST clock (100 MHz) + * Where does this constant(2.4) comes from? */ + pwm_clock = (100000000 >> pwm_div) / 10 / 24; + } else { + /* Where does this constant(20) comes from? */ + pwm_clock = (crystal * 1000) >> pwm_div; + pwm_clock /= 20; + } + } else { + pwm_clock = (crystal * 1000) / 20; + } + + return pwm_clock; +} + int nv50_temp_get(struct nouveau_therm *therm) { @@ -107,6 +133,7 @@ nv50_therm_ctor(struct nouveau_object *parent, priv->fan.pwm_get = nv50_fan_pwm_get; priv->fan.pwm_set = nv50_fan_pwm_set; + priv->fan.pwm_clock = nv50_fan_pwm_clock; therm->temp_get = nv50_temp_get; therm->fan_get = nouveau_therm_fan_get; diff --git a/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h b/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h index b7207b4524f6..c53eb5396972 100644 --- a/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h +++ b/trunk/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h @@ -42,6 +42,7 @@ struct nouveau_therm_priv { int (*pwm_get)(struct nouveau_therm *, int line, u32*, u32*); int (*pwm_set)(struct nouveau_therm *, int line, u32, u32); + int (*pwm_clock)(struct nouveau_therm *); } fan; /* ic */