Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329682
b: refs/heads/master
c: bf6546b
h: refs/heads/master
v: v3
  • Loading branch information
Martin Peres authored and Ben Skeggs committed Oct 3, 2012
1 parent dc9f071 commit f57609f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aa1b9b4836a8ab093ec06b0780553566a5430da7
refs/heads/master: bf6546b4219d2b188529f3242efda4048f5b1b41
25 changes: 16 additions & 9 deletions trunk/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,37 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm)
struct nouveau_gpio *gpio = nouveau_gpio(therm);
struct dcb_gpio_func func;
u32 cycles, cur, prev;
u64 start;
u64 start, end, tach;

if (gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &func))
return -ENODEV;

/* Monitor the GPIO input 0x3b for 250ms.
/* Time a complete rotation and extrapolate to RPM:
* When the fan spins, it changes the value of GPIO FAN_SENSE.
* 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);
prev = gpio->get(gpio, 0, func.func, func.line);
cycles = 0;
do {
usleep_range(500, 1000); /* supports 0 < rpm < 7500 */

cur = gpio->get(gpio, 0, func.func, func.line);
if (prev != cur) {
if (!start)
start = ptimer->read(ptimer);
cycles++;
prev = cur;
}

usleep_range(500, 1000); /* supports 0 < rpm < 7500 */
} while (ptimer->read(ptimer) - start < 250000000);

/* interpolate to get rpm */
return cycles / 4 * 4 * 60;
} while (cycles < 5 && ptimer->read(ptimer) - start < 250000000);
end = ptimer->read(ptimer);

if (cycles == 5) {
tach = (u64)60000000000;
do_div(tach, (end - start));
return tach;
} else
return 0;
}

static void
Expand Down

0 comments on commit f57609f

Please sign in to comment.