提交 d639b4f5 编写于 作者: B Ben Skeggs

drm/nouveau/therm: collect fan tach info in common fan constructor

This info will be used by two more implementations in upcoming commits.
Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
Signed-off-by: NMartin Peres <martin.peres@labri.fr>
上级 5f066c32
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <core/object.h> #include <core/object.h>
#include <core/device.h> #include <core/device.h>
#include <subdev/gpio.h> #include <subdev/gpio.h>
#include <subdev/timer.h> #include <subdev/timer.h>
...@@ -104,13 +105,13 @@ nouveau_therm_fan_set(struct nouveau_therm *therm, int percent) ...@@ -104,13 +105,13 @@ nouveau_therm_fan_set(struct nouveau_therm *therm, int percent)
int int
nouveau_therm_fan_sense(struct nouveau_therm *therm) nouveau_therm_fan_sense(struct nouveau_therm *therm)
{ {
struct nouveau_therm_priv *priv = (void *)therm;
struct nouveau_timer *ptimer = nouveau_timer(therm); struct nouveau_timer *ptimer = nouveau_timer(therm);
struct nouveau_gpio *gpio = nouveau_gpio(therm); struct nouveau_gpio *gpio = nouveau_gpio(therm);
struct dcb_gpio_func func;
u32 cycles, cur, prev; u32 cycles, cur, prev;
u64 start, end, tach; u64 start, end, tach;
if (gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &func)) if (priv->fan.tach.func == DCB_GPIO_UNUSED)
return -ENODEV; return -ENODEV;
/* Time a complete rotation and extrapolate to RPM: /* Time a complete rotation and extrapolate to RPM:
...@@ -118,12 +119,12 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm) ...@@ -118,12 +119,12 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm)
* We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation. * We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation.
*/ */
start = ptimer->read(ptimer); start = ptimer->read(ptimer);
prev = gpio->get(gpio, 0, func.func, func.line); prev = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line);
cycles = 0; cycles = 0;
do { do {
usleep_range(500, 1000); /* supports 0 < rpm < 7500 */ usleep_range(500, 1000); /* supports 0 < rpm < 7500 */
cur = gpio->get(gpio, 0, func.func, func.line); cur = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line);
if (prev != cur) { if (prev != cur) {
if (!start) if (!start)
start = ptimer->read(ptimer); start = ptimer->read(ptimer);
...@@ -220,7 +221,13 @@ int ...@@ -220,7 +221,13 @@ int
nouveau_therm_fan_ctor(struct nouveau_therm *therm) nouveau_therm_fan_ctor(struct nouveau_therm *therm)
{ {
struct nouveau_therm_priv *priv = (void *)therm; struct nouveau_therm_priv *priv = (void *)therm;
struct nouveau_gpio *gpio = nouveau_gpio(therm);
struct nouveau_bios *bios = nouveau_bios(therm); struct nouveau_bios *bios = nouveau_bios(therm);
int ret;
ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan.tach);
if (ret)
priv->fan.tach.func = DCB_GPIO_UNUSED;
nouveau_therm_fan_set_defaults(therm); nouveau_therm_fan_set_defaults(therm);
nvbios_perf_fan_parse(bios, &priv->bios_perf_fan); nvbios_perf_fan_parse(bios, &priv->bios_perf_fan);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <subdev/therm.h> #include <subdev/therm.h>
#include <subdev/bios/extdev.h> #include <subdev/bios/extdev.h>
#include <subdev/bios/gpio.h>
#include <subdev/bios/perf.h> #include <subdev/bios/perf.h>
#include <subdev/bios/therm.h> #include <subdev/bios/therm.h>
...@@ -44,6 +45,8 @@ struct nouveau_therm_priv { ...@@ -44,6 +45,8 @@ struct nouveau_therm_priv {
enum nouveau_therm_fan_mode mode; enum nouveau_therm_fan_mode mode;
int percent; int percent;
struct dcb_gpio_func tach;
int (*pwm_get)(struct nouveau_therm *, int line, u32*, u32*); int (*pwm_get)(struct nouveau_therm *, int line, u32*, u32*);
int (*pwm_set)(struct nouveau_therm *, int line, u32, u32); int (*pwm_set)(struct nouveau_therm *, int line, u32, u32);
int (*pwm_clock)(struct nouveau_therm *); int (*pwm_clock)(struct nouveau_therm *);
...@@ -70,9 +73,11 @@ int nouveau_therm_fan_user_set(struct nouveau_therm *therm, int percent); ...@@ -70,9 +73,11 @@ int nouveau_therm_fan_user_set(struct nouveau_therm *therm, int percent);
int nouveau_therm_fan_set_mode(struct nouveau_therm *therm, int nouveau_therm_fan_set_mode(struct nouveau_therm *therm,
enum nouveau_therm_fan_mode mode); enum nouveau_therm_fan_mode mode);
int nouveau_therm_fan_sense(struct nouveau_therm *therm); int nouveau_therm_fan_sense(struct nouveau_therm *therm);
int nv50_fan_pwm_get(struct nouveau_therm *, int, u32 *, u32 *);
int nv50_fan_pwm_set(struct nouveau_therm *, int, u32, u32);
int nv50_fan_pwm_clock(struct nouveau_therm *);
int nv50_temp_get(struct nouveau_therm *therm); int nv50_temp_get(struct nouveau_therm *therm);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册