diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-12-03 22:25:26 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2013-02-20 01:00:16 -0500 |
commit | d639b4f5ba5f1bbdfbba920e1deb035a1bed83ae (patch) | |
tree | ddbb8d9db0e612f8628d58d657ce4b8f03a90cb4 | |
parent | 5f066c32a50eac584c0c8c19d8d5e38714f7c574 (diff) |
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: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Martin Peres <martin.peres@labri.fr>
-rw-r--r-- | drivers/gpu/drm/nouveau/core/subdev/therm/fan.c | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/core/subdev/therm/priv.h | 7 |
2 files changed, 17 insertions, 5 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c index 523178685180..4822733ca885 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include <core/object.h> | 28 | #include <core/object.h> |
29 | #include <core/device.h> | 29 | #include <core/device.h> |
30 | |||
30 | #include <subdev/gpio.h> | 31 | #include <subdev/gpio.h> |
31 | #include <subdev/timer.h> | 32 | #include <subdev/timer.h> |
32 | 33 | ||
@@ -104,13 +105,13 @@ nouveau_therm_fan_set(struct nouveau_therm *therm, int percent) | |||
104 | int | 105 | int |
105 | nouveau_therm_fan_sense(struct nouveau_therm *therm) | 106 | nouveau_therm_fan_sense(struct nouveau_therm *therm) |
106 | { | 107 | { |
108 | struct nouveau_therm_priv *priv = (void *)therm; | ||
107 | struct nouveau_timer *ptimer = nouveau_timer(therm); | 109 | struct nouveau_timer *ptimer = nouveau_timer(therm); |
108 | struct nouveau_gpio *gpio = nouveau_gpio(therm); | 110 | struct nouveau_gpio *gpio = nouveau_gpio(therm); |
109 | struct dcb_gpio_func func; | ||
110 | u32 cycles, cur, prev; | 111 | u32 cycles, cur, prev; |
111 | u64 start, end, tach; | 112 | u64 start, end, tach; |
112 | 113 | ||
113 | if (gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &func)) | 114 | if (priv->fan.tach.func == DCB_GPIO_UNUSED) |
114 | return -ENODEV; | 115 | return -ENODEV; |
115 | 116 | ||
116 | /* Time a complete rotation and extrapolate to RPM: | 117 | /* Time a complete rotation and extrapolate to RPM: |
@@ -118,12 +119,12 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm) | |||
118 | * We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation. | 119 | * We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation. |
119 | */ | 120 | */ |
120 | start = ptimer->read(ptimer); | 121 | start = ptimer->read(ptimer); |
121 | prev = gpio->get(gpio, 0, func.func, func.line); | 122 | prev = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line); |
122 | cycles = 0; | 123 | cycles = 0; |
123 | do { | 124 | do { |
124 | usleep_range(500, 1000); /* supports 0 < rpm < 7500 */ | 125 | usleep_range(500, 1000); /* supports 0 < rpm < 7500 */ |
125 | 126 | ||
126 | cur = gpio->get(gpio, 0, func.func, func.line); | 127 | cur = gpio->get(gpio, 0, priv->fan.tach.func, priv->fan.tach.line); |
127 | if (prev != cur) { | 128 | if (prev != cur) { |
128 | if (!start) | 129 | if (!start) |
129 | start = ptimer->read(ptimer); | 130 | start = ptimer->read(ptimer); |
@@ -220,7 +221,13 @@ int | |||
220 | nouveau_therm_fan_ctor(struct nouveau_therm *therm) | 221 | nouveau_therm_fan_ctor(struct nouveau_therm *therm) |
221 | { | 222 | { |
222 | struct nouveau_therm_priv *priv = (void *)therm; | 223 | struct nouveau_therm_priv *priv = (void *)therm; |
224 | struct nouveau_gpio *gpio = nouveau_gpio(therm); | ||
223 | struct nouveau_bios *bios = nouveau_bios(therm); | 225 | struct nouveau_bios *bios = nouveau_bios(therm); |
226 | int ret; | ||
227 | |||
228 | ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan.tach); | ||
229 | if (ret) | ||
230 | priv->fan.tach.func = DCB_GPIO_UNUSED; | ||
224 | 231 | ||
225 | nouveau_therm_fan_set_defaults(therm); | 232 | nouveau_therm_fan_set_defaults(therm); |
226 | nvbios_perf_fan_parse(bios, &priv->bios_perf_fan); | 233 | nvbios_perf_fan_parse(bios, &priv->bios_perf_fan); |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h b/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h index 64f4a4ab80ea..33fbc596ee4f 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/priv.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <subdev/therm.h> | 28 | #include <subdev/therm.h> |
29 | 29 | ||
30 | #include <subdev/bios/extdev.h> | 30 | #include <subdev/bios/extdev.h> |
31 | #include <subdev/bios/gpio.h> | ||
31 | #include <subdev/bios/perf.h> | 32 | #include <subdev/bios/perf.h> |
32 | #include <subdev/bios/therm.h> | 33 | #include <subdev/bios/therm.h> |
33 | 34 | ||
@@ -44,6 +45,8 @@ struct nouveau_therm_priv { | |||
44 | enum nouveau_therm_fan_mode mode; | 45 | enum nouveau_therm_fan_mode mode; |
45 | int percent; | 46 | int percent; |
46 | 47 | ||
48 | struct dcb_gpio_func tach; | ||
49 | |||
47 | int (*pwm_get)(struct nouveau_therm *, int line, u32*, u32*); | 50 | int (*pwm_get)(struct nouveau_therm *, int line, u32*, u32*); |
48 | int (*pwm_set)(struct nouveau_therm *, int line, u32, u32); | 51 | int (*pwm_set)(struct nouveau_therm *, int line, u32, u32); |
49 | int (*pwm_clock)(struct nouveau_therm *); | 52 | int (*pwm_clock)(struct nouveau_therm *); |
@@ -70,9 +73,11 @@ int nouveau_therm_fan_user_set(struct nouveau_therm *therm, int percent); | |||
70 | int nouveau_therm_fan_set_mode(struct nouveau_therm *therm, | 73 | int nouveau_therm_fan_set_mode(struct nouveau_therm *therm, |
71 | enum nouveau_therm_fan_mode mode); | 74 | enum nouveau_therm_fan_mode mode); |
72 | 75 | ||
73 | |||
74 | int nouveau_therm_fan_sense(struct nouveau_therm *therm); | 76 | int nouveau_therm_fan_sense(struct nouveau_therm *therm); |
75 | 77 | ||
78 | int nv50_fan_pwm_get(struct nouveau_therm *, int, u32 *, u32 *); | ||
79 | int nv50_fan_pwm_set(struct nouveau_therm *, int, u32, u32); | ||
80 | int nv50_fan_pwm_clock(struct nouveau_therm *); | ||
76 | int nv50_temp_get(struct nouveau_therm *therm); | 81 | int nv50_temp_get(struct nouveau_therm *therm); |
77 | 82 | ||
78 | #endif | 83 | #endif |