Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
base.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 <core/object.h>
26 #include <core/device.h>
27 
28 #include <subdev/bios.h>
29 
30 #include "priv.h"
31 
32 int
35 {
36  struct nouveau_therm_priv *priv = (void *)therm;
37 
38  switch (type) {
40  return priv->bios_fan.min_duty;
42  return priv->bios_fan.max_duty;
44  return priv->fan.mode;
46  return priv->bios_sensor.thrs_fan_boost.temp;
48  return priv->bios_sensor.thrs_fan_boost.hysteresis;
50  return priv->bios_sensor.thrs_down_clock.temp;
52  return priv->bios_sensor.thrs_down_clock.hysteresis;
54  return priv->bios_sensor.thrs_critical.temp;
56  return priv->bios_sensor.thrs_critical.hysteresis;
58  return priv->bios_sensor.thrs_shutdown.temp;
60  return priv->bios_sensor.thrs_shutdown.hysteresis;
61  }
62 
63  return -EINVAL;
64 }
65 
66 int
69 {
70  struct nouveau_therm_priv *priv = (void *)therm;
71 
72  switch (type) {
74  if (value < 0)
75  value = 0;
76  if (value > priv->bios_fan.max_duty)
77  value = priv->bios_fan.max_duty;
78  priv->bios_fan.min_duty = value;
79  return 0;
81  if (value < 0)
82  value = 0;
83  if (value < priv->bios_fan.min_duty)
84  value = priv->bios_fan.min_duty;
85  priv->bios_fan.max_duty = value;
86  return 0;
88  return nouveau_therm_fan_set_mode(therm, value);
90  priv->bios_sensor.thrs_fan_boost.temp = value;
91  return 0;
93  priv->bios_sensor.thrs_fan_boost.hysteresis = value;
94  return 0;
96  priv->bios_sensor.thrs_down_clock.temp = value;
97  return 0;
99  priv->bios_sensor.thrs_down_clock.hysteresis = value;
100  return 0;
102  priv->bios_sensor.thrs_critical.temp = value;
103  return 0;
105  priv->bios_sensor.thrs_critical.hysteresis = value;
106  return 0;
108  priv->bios_sensor.thrs_shutdown.temp = value;
109  return 0;
111  priv->bios_sensor.thrs_shutdown.hysteresis = value;
112  return 0;
113  }
114 
115  return -EINVAL;
116 }
117 
118 int
120 {
121  struct nouveau_therm *therm = (void *)object;
122  struct nouveau_therm_priv *priv = (void *)therm;
123  int ret;
124 
125  ret = nouveau_subdev_init(&therm->base);
126  if (ret)
127  return ret;
128 
129  if (priv->fan.percent >= 0)
130  therm->fan_set(therm, priv->fan.percent);
131 
132  return 0;
133 }
134 
135 int
137 {
138  struct nouveau_therm *therm = (void *)object;
139  struct nouveau_therm_priv *priv = (void *)therm;
140 
141  priv->fan.percent = therm->fan_get(therm);
142 
143  return nouveau_subdev_fini(&therm->base, suspend);
144 }