mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-30 13:00:30 +00:00
First round of lm_sensors changes for the new I2C tree
* The i2c package can no longer be compiled as part of the lm_sensors tree
* The archive of the i2c package is removed
* smbus, i2c-dev and i2c-proc modules and headers have been removed; they
are now completely integrated into the i2c package
* The fake i2c.h header has been removed; this also allowed us to remove
the ugly LM_SENSORS and TBD defines.
* A new variable I2C_HEADERS is introduced in the Makefile. This allows
us to install the i2c headers in, for example, /usr/local/include/linux.
* All files now include <linux/i2c.h> instead of "i2c.h" and "smbus.h"
Status: 'make dep' works, all the right include files are found. 'make all'
does not yet work.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@496 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
17bb1f4934
commit
24e547b88e
35 files changed
+38
-1924
No files matched your search
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
i2c-dev.h - Part of lm_sensors, Linux kernel modules for hardware
|
||||
monitoring
|
||||
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* Important note: */ /* TBD */
|
||||
/* Lines like these, with the 'TBD' remark (To Be Deleted) */ /* TBD */
|
||||
/* WILL BE DELETED when this file is installed. */ /* TBD */
|
||||
/* This allows us to get rid of the ugly LM_SENSORS define */ /* TBD */
|
||||
|
||||
#ifndef SENSORS_I2C_DEV_H
|
||||
#define SENSORS_I2C_DEV_H
|
||||
|
||||
#ifdef LM_SENSORS /* TBD */
|
||||
#include "i2c.h" /* TBD */
|
||||
#include "smbus.h" /* TBD */
|
||||
#else /* ndef LM_SENSORS */ /* TBD */
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/smbus.h>
|
||||
#endif /* def LM_SENSORS */ /* TBD */
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* Some IOCTL commands are defined in <linux/i2c.h> */
|
||||
/* Note: 10-bit addresses are NOT supported! */
|
||||
|
||||
#define I2C_SMBUS 0x0720
|
||||
|
||||
/* This is the structure as used in the I2C_SMBUS ioctl call */
|
||||
struct i2c_smbus_data {
|
||||
char read_write;
|
||||
__u8 command;
|
||||
int size;
|
||||
union smbus_data *data;
|
||||
};
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
extern inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
|
||||
int size, union smbus_data *data)
|
||||
{
|
||||
struct i2c_smbus_data args;
|
||||
|
||||
args.read_write = read_write;
|
||||
args.command = command;
|
||||
args.size = size;
|
||||
args.data = data;
|
||||
return ioctl(file,I2C_SMBUS,&args);
|
||||
}
|
||||
|
||||
|
||||
extern inline __s32 i2c_smbus_write_quick(int file, __u8 value)
|
||||
{
|
||||
return i2c_smbus_access(file,value,0,SMBUS_QUICK,NULL);
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_read_byte(int file)
|
||||
{
|
||||
union smbus_data data;
|
||||
if (i2c_smbus_access(file,SMBUS_READ,0,SMBUS_BYTE,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FF & data.byte;
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_write_byte(int file, __u8 value)
|
||||
{
|
||||
return i2c_smbus_access(file,SMBUS_WRITE,value, SMBUS_BYTE,NULL);
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
|
||||
{
|
||||
union smbus_data data;
|
||||
if (i2c_smbus_access(file,SMBUS_READ,command,SMBUS_BYTE_DATA,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FF & data.byte;
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
|
||||
__u8 value)
|
||||
{
|
||||
union smbus_data data;
|
||||
data.byte = value;
|
||||
return i2c_smbus_access(file,SMBUS_WRITE,command,SMBUS_BYTE_DATA,&data);
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
|
||||
{
|
||||
union smbus_data data;
|
||||
if (i2c_smbus_access(file,SMBUS_READ,command,SMBUS_WORD_DATA,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FFFF & data.word;
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
|
||||
__u16 value)
|
||||
{
|
||||
union smbus_data data;
|
||||
data.word = value;
|
||||
return i2c_smbus_access(file,SMBUS_WRITE,command,SMBUS_WORD_DATA, &data);
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
|
||||
{
|
||||
union smbus_data data;
|
||||
data.word = value;
|
||||
if (i2c_smbus_access(file,SMBUS_WRITE,command,SMBUS_PROC_CALL,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FFFF & data.word;
|
||||
}
|
||||
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
extern inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
|
||||
__u8 *values)
|
||||
{
|
||||
union smbus_data data;
|
||||
int i;
|
||||
if (i2c_smbus_access(file,SMBUS_READ,command,SMBUS_BLOCK_DATA,&data))
|
||||
return -1;
|
||||
else {
|
||||
for (i = 1; i <= data.block[0]; i++)
|
||||
values[i-1] = data.block[i];
|
||||
return data.block[0];
|
||||
}
|
||||
}
|
||||
|
||||
extern inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
|
||||
__u8 length, __u8 *values)
|
||||
{
|
||||
union smbus_data data;
|
||||
int i;
|
||||
if (length > 32)
|
||||
length = 32;
|
||||
for (i = 1; i <= length; i++)
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
return i2c_smbus_access(file,SMBUS_WRITE,command,SMBUS_BLOCK_DATA,&data);
|
||||
}
|
||||
|
||||
#endif /* ndef __KERNEL__ */
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user