| 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 | #include <linux/sysctl.h> |
|---|
| 24 | |
|---|
| 25 | #ifdef __KERNEL__ |
|---|
| 26 | |
|---|
| 27 | /* The type of callback functions used in sensors_{proc,sysctl}_real */ |
|---|
| 28 | typedef void (*sensors_real_callback) (struct i2c_client *client, |
|---|
| 29 | int operation, int ctl_name, |
|---|
| 30 | int *nrels_mag, long *results); |
|---|
| 31 | |
|---|
| 32 | /* Values for the operation field in the above function type */ |
|---|
| 33 | #define SENSORS_PROC_REAL_INFO 1 |
|---|
| 34 | #define SENSORS_PROC_REAL_READ 2 |
|---|
| 35 | #define SENSORS_PROC_REAL_WRITE 3 |
|---|
| 36 | |
|---|
| 37 | /* These funcion reads or writes a 'real' value (encoded by the combination |
|---|
| 38 | of an integer and a magnitude, the last is the power of ten the value |
|---|
| 39 | should be divided with) to a /proc/sys directory. To use these functions, |
|---|
| 40 | you must (before registering the ctl_table) set the extra2 field to the |
|---|
| 41 | client, and the extra1 field to a function of the form: |
|---|
| 42 | void func(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 43 | int *nrels_mag, long *results) |
|---|
| 44 | This last function can be called for three values of operation. If |
|---|
| 45 | operation equals SENSORS_PROC_REAL_INFO, the magnitude should be returned |
|---|
| 46 | in nrels_mag. If operation equals SENSORS_PROC_REAL_READ, values should |
|---|
| 47 | be read into results. nrels_mag should return the number of elements |
|---|
| 48 | read; the maximum number is put in it on entry. Finally, if operation |
|---|
| 49 | equals SENSORS_PROC_REAL_WRITE, the values in results should be |
|---|
| 50 | written to the chip. nrels_mag contains on entry the number of elements |
|---|
| 51 | found. |
|---|
| 52 | In all cases, client points to the client we wish to interact with, |
|---|
| 53 | and ctl_name is the SYSCTL id of the file we are accessing. */ |
|---|
| 54 | extern int sensors_sysctl_real (ctl_table *table, int *name, int nlen, |
|---|
| 55 | void *oldval, size_t *oldlenp, void *newval, |
|---|
| 56 | size_t newlen, void **context); |
|---|
| 57 | extern int sensors_proc_real(ctl_table *ctl, int write, struct file * filp, |
|---|
| 58 | void *buffer, size_t *lenp); |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | /* These rather complex functions must be called when you want to add or |
|---|
| 63 | delete an entry in /proc/sys/dev/sensors/chips (not yet implemented). It |
|---|
| 64 | also creates a new directory within /proc/sys/dev/sensors/. |
|---|
| 65 | ctl_template should be a template of the newly created directory. It is |
|---|
| 66 | copied in memory. The extra2 field of each file is set to point to client. |
|---|
| 67 | If any driver wants subdirectories within the newly created directory, |
|---|
| 68 | these functions must be updated! */ |
|---|
| 69 | extern int sensors_register_entry(struct i2c_client *client, |
|---|
| 70 | const char *prefix, ctl_table *ctl_template); |
|---|
| 71 | extern void sensors_deregister_entry(int id); |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | #endif /* def __KERNEL__ */ |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | /* Driver IDs */ |
|---|
| 78 | #define I2C_DRIVERID_I2CPROC 1001 |
|---|
| 79 | #define I2C_DRIVERID_LM78 1002 |
|---|
| 80 | |
|---|
| 81 | /* Sysctl IDs */ |
|---|
| 82 | #ifdef DEV_HWMON |
|---|
| 83 | #define DEV_SENSORS DEV_HWMON |
|---|
| 84 | #else /* ndef DEV_HWMOM */ |
|---|
| 85 | #define DEV_SENSORS 2 /* The id of the lm_sensors directory within the |
|---|
| 86 | dev table */ |
|---|
| 87 | #endif /* def DEV_HWMON */ |
|---|
| 88 | |
|---|
| 89 | #define LM78_SYSCTL_IN0 1000 /* Volts * 100 */ |
|---|
| 90 | #define LM78_SYSCTL_IN1 1001 |
|---|
| 91 | #define LM78_SYSCTL_IN2 1002 |
|---|
| 92 | #define LM78_SYSCTL_IN3 1003 |
|---|
| 93 | #define LM78_SYSCTL_IN4 1004 |
|---|
| 94 | #define LM78_SYSCTL_IN5 1005 |
|---|
| 95 | #define LM78_SYSCTL_IN6 1006 |
|---|
| 96 | #define LM78_SYSCTL_FAN1 1101 /* Rotations/min */ |
|---|
| 97 | #define LM78_SYSCTL_FAN2 1102 |
|---|
| 98 | #define LM78_SYSCTL_FAN3 1103 |
|---|
| 99 | #define LM78_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ |
|---|
| 100 | #define LM78_SYSCTL_VID 1300 /* Volts * 100 */ |
|---|
| 101 | #define LM78_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ |
|---|
| 102 | #define LM78_SYSCTL_ALARMS 2001 /* bitvector */ |
|---|
| 103 | |
|---|
| 104 | #endif /* def SENSORS_SENSORS_H */ |
|---|