root/lm-sensors/trunk/src/sensors.h @ 73

Revision 73, 5.9 KB (checked in by phil, 15 years ago)

(Phil) Now functional serial eeprom interface! sysctl entries for eeprom
module.

  • 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#endif /* def __KERNEL__ */
77
78
79/* The maximum length of the prefix */
80#define SENSORS_PREFIX_MAX 20
81
82/* Driver IDs */
83#define I2C_DRIVERID_I2CPROC 1001
84#define I2C_DRIVERID_LM78 1002
85#define I2C_DRIVERID_LM75 1003
86#define I2C_DRIVERID_GL518 1004
87#define I2C_DRIVERID_EEPROM 1005
88
89/* Sysctl IDs */
90#ifdef DEV_HWMON
91#define DEV_SENSORS DEV_HWMON
92#else /* ndef DEV_HWMOM */
93#define DEV_SENSORS 2  /* The id of the lm_sensors directory within the
94                          dev table */
95#endif /* def DEV_HWMON */
96
97#define SENSORS_CHIPS 1
98struct sensors_chips_data {
99  int sysctl_id;
100  char name[SENSORS_PREFIX_MAX + 13];
101};
102
103#define LM78_SYSCTL_IN0 1000  /* Volts * 100 */
104#define LM78_SYSCTL_IN1 1001
105#define LM78_SYSCTL_IN2 1002
106#define LM78_SYSCTL_IN3 1003
107#define LM78_SYSCTL_IN4 1004
108#define LM78_SYSCTL_IN5 1005
109#define LM78_SYSCTL_IN6 1006
110#define LM78_SYSCTL_FAN1 1101 /* Rotations/min */
111#define LM78_SYSCTL_FAN2 1102
112#define LM78_SYSCTL_FAN3 1103
113#define LM78_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */
114#define LM78_SYSCTL_VID 1300 /* Volts * 100 */
115#define LM78_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */
116#define LM78_SYSCTL_ALARMS 2001 /* bitvector */
117
118#define LM78_ALARM_IN0 0x0001
119#define LM78_ALARM_IN1 0x0002
120#define LM78_ALARM_IN2 0x0004
121#define LM78_ALARM_IN3 0x0008
122#define LM78_ALARM_IN4 0x0100
123#define LM78_ALARM_IN5 0x0200
124#define LM78_ALARM_IN6 0x0400
125#define LM78_ALARM_FAN1 0x0040
126#define LM78_ALARM_FAN2 0x0080
127#define LM78_ALARM_FAN3 0x0800
128#define LM78_ALARM_TEMP 0x0010
129#define LM78_ALARM_BTI 0x0020
130#define LM78_ALARM_CHAS 0x1000
131#define LM78_ALARM_FIFO 0x2000
132#define LM78_ALARM_SMI_IN 0x4000
133
134#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */
135
136#define GL518_SYSCTL_VDD  1000     /* Volts * 100 */
137#define GL518_SYSCTL_VIN1 1001
138#define GL518_SYSCTL_VIN2 1002
139#define GL518_SYSCTL_VIN3 1003
140#define GL518_SYSCTL_FAN1 1101     /* RPM */
141#define GL518_SYSCTL_FAN2 1102
142#define GL518_SYSCTL_TEMP 1200     /* Degrees Celcius * 10 */
143#define GL518_SYSCTL_FAN_DIV 2000  /* 1, 2, 4 or 8 */
144#define GL518_SYSCTL_ALARMS 2001   /* bitvector */
145
146#define GL518_ALARM_VDD 0x01
147#define GL518_ALARM_VIN1 0x02
148#define GL518_ALARM_VIN2 0x04
149#define GL518_ALARM_VIN3 0x08
150#define GL518_ALARM_TEMP 0x10
151#define GL518_ALARM_FAN1 0x20
152#define GL518_ALARM_FAN2 0x40
153
154#define EEPROM_SYSCTL1 1000
155#define EEPROM_SYSCTL2 1001
156#define EEPROM_SYSCTL3 1002
157#define EEPROM_SYSCTL4 1003
158
159#endif /* def SENSORS_SENSORS_H */
Note: See TracBrowser for help on using the browser.