Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
temp.c
Go to the documentation of this file.
1 /*
2  * Copyright 2012 The Nouveau community
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: Martin Peres
23  */
24 
25 #include "priv.h"
26 
27 #include <core/object.h>
28 #include <core/device.h>
29 
30 #include <subdev/bios.h>
31 
32 static void
33 nouveau_therm_temp_set_defaults(struct nouveau_therm *therm)
34 {
35  struct nouveau_therm_priv *priv = (void *)therm;
36 
37  priv->bios_sensor.slope_mult = 1;
38  priv->bios_sensor.slope_div = 1;
39  priv->bios_sensor.offset_num = 0;
40  priv->bios_sensor.offset_den = 1;
41  priv->bios_sensor.offset_constant = 0;
42 
43  priv->bios_sensor.thrs_fan_boost.temp = 90;
44  priv->bios_sensor.thrs_fan_boost.hysteresis = 3;
45 
46  priv->bios_sensor.thrs_down_clock.temp = 95;
47  priv->bios_sensor.thrs_down_clock.hysteresis = 3;
48 
49  priv->bios_sensor.thrs_critical.temp = 105;
50  priv->bios_sensor.thrs_critical.hysteresis = 5;
51 
52  priv->bios_sensor.thrs_shutdown.temp = 135;
53  priv->bios_sensor.thrs_shutdown.hysteresis = 5; /*not that it matters */
54 }
55 
56 
57 static void
58 nouveau_therm_temp_safety_checks(struct nouveau_therm *therm)
59 {
60  struct nouveau_therm_priv *priv = (void *)therm;
61 
62  if (!priv->bios_sensor.slope_div)
63  priv->bios_sensor.slope_div = 1;
64  if (!priv->bios_sensor.offset_den)
65  priv->bios_sensor.offset_den = 1;
66 }
67 
68 int
70 {
71  struct nouveau_therm_priv *priv = (void *)therm;
72  struct nouveau_bios *bios = nouveau_bios(therm);
73 
74  nouveau_therm_temp_set_defaults(therm);
76  &priv->bios_sensor))
77  nv_error(therm, "nvbios_therm_sensor_parse failed\n");
78  nouveau_therm_temp_safety_checks(therm);
79 
80  return 0;
81 }