tz.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:6k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  *
  3.  * Module Name: tz.h
  4.  *   $Revision: 24 $
  5.  *
  6.  *****************************************************************************/
  7. /*
  8.  *  Copyright (C) 2000, 2001 Andrew Grover
  9.  *
  10.  *  This program is free software; you can redistribute it and/or modify
  11.  *  it under the terms of the GNU General Public License as published by
  12.  *  the Free Software Foundation; either version 2 of the License, or
  13.  *  (at your option) any later version.
  14.  *
  15.  *  This program is distributed in the hope that it will be useful,
  16.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  *  GNU General Public License for more details.
  19.  *
  20.  *  You should have received a copy of the GNU General Public License
  21.  *  along with this program; if not, write to the Free Software
  22.  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23.  */
  24. #ifndef __TZ_H__
  25. #define __TZ_H__
  26. /* TBD: Linux-specific */
  27. #include <linux/module.h>
  28. #include <linux/timer.h>
  29. #include <bm.h>
  30. #include <pr.h>
  31. /*****************************************************************************
  32.  *                             Types & Other Defines
  33.  *****************************************************************************/
  34. #define TZ_MAX_THRESHOLDS 12 /* _AC0 through _AC9 + _CRT + _PSV */
  35. #define TZ_MAX_ACTIVE_THRESHOLDS 10 /* _AC0 through _AC9 */
  36. #define TZ_MAX_COOLING_DEVICES 10 /* TBD: Make size dynamic */
  37. /*
  38.  * Notifications:
  39.  * --------------
  40.  */
  41. #define TZ_NOTIFY_TEMPERATURE_CHANGE ((BM_NOTIFY) 0x80)
  42. #define TZ_NOTIFY_THRESHOLD_CHANGE ((BM_NOTIFY) 0x81)
  43. #define TZ_NOTIFY_DEVICE_LISTS_CHANGE ((BM_NOTIFY) 0x82)
  44. /*
  45.  * TZ_THRESHOLD_TYPE:
  46.  * ------------------
  47.  */
  48. typedef u32 TZ_THRESHOLD_TYPE;
  49. #define TZ_THRESHOLD_UNKNOWN ((TZ_THRESHOLD_TYPE) 0x00)
  50. #define TZ_THRESHOLD_CRITICAL ((TZ_THRESHOLD_TYPE) 0x01)
  51. #define TZ_THRESHOLD_PASSIVE ((TZ_THRESHOLD_TYPE) 0x02)
  52. #define TZ_THRESHOLD_ACTIVE ((TZ_THRESHOLD_TYPE) 0x03)
  53. /*
  54.  * TZ_COOLING_STATE:
  55.  * -----------------
  56.  */
  57. typedef u32 TZ_COOLING_STATE;
  58. #define TZ_COOLING_UNKNOWN ((TZ_COOLING_STATE) 0x00)
  59. #define TZ_COOLING_ENABLED ((TZ_COOLING_STATE) 0x01)
  60. #define TZ_COOLING_DISABLED ((TZ_COOLING_STATE) 0x02)
  61. /*
  62.  * TZ_COOLING_MODE:
  63.  * ----------------
  64.  */
  65. typedef u32 TZ_COOLING_MODE;
  66. #define TZ_COOLING_MODE_ACTIVE ((TZ_COOLING_MODE) 0x00)
  67. #define TZ_COOLING_MODE_PASSIVE ((TZ_COOLING_MODE) 0x01)
  68. /*
  69.  * Thermal State:
  70.  * --------------
  71.  * The encoding of TZ_STATE is illustrated below.
  72.  * Note that a set bit (1) indicates the property is TRUE
  73.  * (e.g. if bit 0 is set then the device has dynamic status).
  74.  * No bits set indicates an OK cooling state.
  75.  * +--+--+--+-----------+----------+
  76.  * |31|30|29| Bits 27:4 | Bits 3:0 |
  77.  * +--+--+--+-----------+----------+
  78.  *  |  |  |       |          |
  79.  *  |  |  |       |          +------ Active Index
  80.  *  |  |  |       +----------------- <reserved>
  81.  *  |  |  +------------------------- Active
  82.  *  |  +---------------------------- Passive
  83.  *  +------------------------------- Critical
  84.  *
  85.  * Active Index:    Value representing the level of active cooling
  86.  *                  presently applied (e.g. 0=_AL0, 9=_AL9).  Only
  87.  *                  valid when 'Active' is set.
  88.  * Active:          If set, indicates that the system temperature
  89.  *                  has crossed at least one active threshold (_ALx).
  90.  * Passive:         If set, indicates that the system temperature
  91.  *                  has crossed the passive threshold (_PSL).
  92.  * Passive:         If set, indicates that the system temperature
  93.  *                  has crossed the critical threshold (_CRT).
  94.  */
  95. typedef u32 TZ_STATE;
  96. #define TZ_STATE_OK ((TZ_STATE) 0x00000000)
  97. #define TZ_STATE_HOT ((TZ_STATE) 0x10000000)
  98. #define TZ_STATE_ACTIVE ((TZ_STATE) 0x20000000)
  99. #define TZ_STATE_PASSIVE ((TZ_STATE) 0x40000000)
  100. #define TZ_STATE_CRITICAL ((TZ_STATE) 0x80000000)
  101. typedef struct {
  102. u32 temperature;
  103. } TZ_CRITICAL_THRESHOLD;
  104. typedef struct {
  105. u8 is_valid;
  106. u32 temperature;
  107. } TZ_HOT_THRESHOLD;
  108. typedef struct {
  109. u8 is_valid;
  110. u32 temperature;
  111. u32 tc1;
  112. u32 tc2;
  113. u32 tsp;
  114. BM_HANDLE_LIST devices;
  115. } TZ_PASSIVE_THRESHOLD;
  116. typedef struct {
  117. u8 is_valid;
  118. u32 temperature;
  119. TZ_COOLING_STATE cooling_state;
  120. BM_HANDLE_LIST devices;
  121. } TZ_ACTIVE_THRESHOLD;
  122. typedef struct {
  123. TZ_CRITICAL_THRESHOLD critical;
  124. TZ_HOT_THRESHOLD hot;
  125. TZ_PASSIVE_THRESHOLD passive;
  126. TZ_ACTIVE_THRESHOLD active[TZ_MAX_ACTIVE_THRESHOLDS];
  127. } TZ_THRESHOLDS;
  128. /*
  129.  * TZ_POLICY:
  130.  * ---------
  131.  */
  132. typedef struct {
  133. u32 temperature;
  134. TZ_STATE state;
  135. TZ_COOLING_MODE cooling_mode;
  136. u32 polling_freq;
  137. TZ_THRESHOLDS thresholds;
  138. struct timer_list timer;
  139. } TZ_POLICY;
  140. /*
  141.  * TZ_CONTEXT:
  142.  * -----------
  143.  */
  144. typedef struct {
  145. BM_HANDLE device_handle;
  146. acpi_handle acpi_handle;
  147. char uid[9];
  148. TZ_POLICY policy;
  149. } TZ_CONTEXT;
  150. /*****************************************************************************
  151.  *                             Function Prototypes
  152.  *****************************************************************************/
  153. /* tz.c */
  154. acpi_status
  155. tz_initialize (void);
  156. acpi_status
  157. tz_terminate (void);
  158. acpi_status
  159. tz_notify (
  160. BM_NOTIFY               notify_type,
  161. BM_HANDLE               device_handle,
  162. BM_DRIVER_CONTEXT *context);
  163. acpi_status
  164. tz_request (
  165. BM_REQUEST              *request,
  166. BM_DRIVER_CONTEXT context);
  167. acpi_status
  168. tz_get_temperature (
  169. TZ_CONTEXT *tz);
  170. acpi_status
  171. tz_get_thresholds (
  172. TZ_CONTEXT *tz);
  173. acpi_status
  174. tz_set_cooling_preference (
  175. TZ_CONTEXT              *tz,
  176. TZ_COOLING_MODE         cooling_mode);
  177. void
  178. tz_print (
  179. TZ_CONTEXT              *tz);
  180. /* tzpolicy.c */
  181. acpi_status
  182. tz_policy_add_device (
  183. TZ_CONTEXT              *tz);
  184. acpi_status
  185. tz_policy_remove_device (
  186. TZ_CONTEXT              *tz);
  187. void
  188. tz_policy_check (
  189. void                    *context);
  190. /* tz_osl.c */
  191. acpi_status
  192. tz_osl_add_device (
  193. TZ_CONTEXT *tz);
  194. acpi_status
  195. tz_osl_remove_device (
  196. TZ_CONTEXT *tz);
  197. acpi_status
  198. tz_osl_generate_event (
  199. u32 event,
  200. TZ_CONTEXT *tz);
  201. #endif  /* __TZ_H__ */