root/lm-sensors/trunk/kernel/include/sensors.h @ 49

Revision 49, 5.0 KB (checked in by frodo, 14 years ago)

More documentation, and some small bug fixes

* LM75 temperature limits initializations were switched
* LM78 VID readings were off by a factor 100
* New bit-mask constants in sensors.h for LM78 alarm field

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2    sensors.h - A Linux module for reading sensor data.
3    Copyright (c) 1998  Frodo Looijaard <frodol@dds.nl>
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/
19
20#ifndef SENSORS_SENSORS_H
21#define SENSORS_SENSORS_H
22
23#ifdef __KERNEL__
24
25/* Next two must be included before sysctl.h can be included, in 2.0 kernels */
26#include <linux/types.h>
27#include <linux/fs.h>
28#include <linux/sysctl.h>
29
30/* The type of callback functions used in sensors_{proc,sysctl}_real */
31typedef void (*sensors_real_callback) (struct i2c_client *client,
32                                       int operation, int ctl_name,
33                                       int *nrels_mag, long *results);
34
35/* Values for the operation field in the above function type */
36#define SENSORS_PROC_REAL_INFO 1
37#define SENSORS_PROC_REAL_READ 2
38#define SENSORS_PROC_REAL_WRITE 3
39
40/* These funcion reads or writes a 'real' value (encoded by the combination
41   of an integer and a magnitude, the last is the power of ten the value
42   should be divided with) to a /proc/sys directory. To use these functions,
43   you must (before registering the ctl_table) set the extra2 field to the
44   client, and the extra1 field to a function of the form:
45      void func(struct i2c_client *client, int operation, int ctl_name,
46                int *nrels_mag, long *results)
47   This last function can be called for three values of operation. If
48   operation equals SENSORS_PROC_REAL_INFO, the magnitude should be returned
49   in nrels_mag. If operation equals SENSORS_PROC_REAL_READ, values should
50   be read into results. nrels_mag should return the number of elements
51   read; the maximum number is put in it on entry. Finally, if operation
52   equals SENSORS_PROC_REAL_WRITE, the values in results should be
53   written to the chip. nrels_mag contains on entry the number of elements
54   found.
55   In all cases, client points to the client we wish to interact with,
56   and ctl_name is the SYSCTL id of the file we are accessing. */
57extern int sensors_sysctl_real (ctl_table *table, int *name, int nlen,
58                                void *oldval, size_t *oldlenp, void *newval,
59                                size_t newlen, void **context);
60extern int sensors_proc_real(ctl_table *ctl, int write, struct file * filp,
61                             void *buffer, size_t *lenp);
62
63
64
65/* These rather complex functions must be called when you want to add or
66   delete an entry in /proc/sys/dev/sensors/chips (not yet implemented). It
67   also creates a new directory within /proc/sys/dev/sensors/.
68   ctl_template should be a template of the newly created directory. It is
69   copied in memory. The extra2 field of each file is set to point to client.
70   If any driver wants subdirectories within the newly created directory,
71   these functions must be updated! */
72extern int sensors_register_entry(struct i2c_client *client,
73                                  const char *prefix, ctl_table *ctl_template);
74extern void sensors_deregister_entry(int id);
75
76
77#endif /* def __KERNEL__ */
78
79
80/* Driver IDs */
81#define I2C_DRIVERID_I2CPROC 1001
82#define I2C_DRIVERID_LM78 1002
83#define I2C_DRIVERID_LM75 1003
84
85/* Sysctl IDs */
86#ifdef DEV_HWMON
87#define DEV_SENSORS DEV_HWMON
88#else /* ndef DEV_HWMOM */
89#define DEV_SENSORS 2  /* The id of the lm_sensors directory within the
90                          dev table */
91#endif /* def DEV_HWMON */
92
93#define LM78_SYSCTL_IN0 1000  /* Volts * 100 */
94#define LM78_SYSCTL_IN1 1001
95#define LM78_SYSCTL_IN2 1002
96#define LM78_SYSCTL_IN3 1003
97#define LM78_SYSCTL_IN4 1004
98#define LM78_SYSCTL_IN5 1005
99#define LM78_SYSCTL_IN6 1006
100#define LM78_SYSCTL_FAN1 1101 /* Rotations/min */
101#define LM78_SYSCTL_FAN2 1102
102#define LM78_SYSCTL_FAN3 1103
103#define LM78_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */
104#define LM78_SYSCTL_VID 1300 /* Volts * 100 */
105#define LM78_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */
106#define LM78_SYSCTL_ALARMS 2001 /* bitvector */
107
108#define LM78_ALARM_IN0 0x0001
109#define LM78_ALARM_IN1 0x0002
110#define LM78_ALARM_IN2 0x0004
111#define LM78_ALARM_IN3 0x0008
112#define LM78_ALARM_IN4 0x0100
113#define LM78_ALARM_IN5 0x0200
114#define LM78_ALARM_IN6 0x0400
115#define LM78_ALARM_FAN1 0x0040
116#define LM78_ALARM_FAN2 0x0080
117#define LM78_ALARM_FAN3 0x0800
118#define LM78_ALARM_TEMP 0x0010
119#define LM78_ALARM_BTI 0x0020
120#define LM78_ALARM_CHAS 0x1000
121#define LM78_ALARM_FIFO 0x2000
122#define LM78_ALARM_SMI_IN 0x4000
123
124#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */
125
126#endif /* def SENSORS_SENSORS_H */
Note: See TracBrowser for help on using the browser.