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:
Frodo Looijaard committed 1999-07-19 11:45:27 +00:00
1 parent 17bb1f4934
commit 24e547b88e
35 files changed
+38 -1924

No files matched your search

+4 -9
View File
@@ -20,18 +20,13 @@
# verbatim in the rules, until it is redefined.
MODULE_DIR := kernel/include
KERNELINCLUDEFILES := $(MODULE_DIR)/sensors.h $(MODULE_DIR)/i2c-isa.h \
$(MODULE_DIR)/smbus.h $(MODULE_DIR)/i2c-dev.h
KERNELINCLUDEFILES := $(MODULE_DIR)/sensors.h $(MODULE_DIR)/i2c-isa.h
install-all-kernel-include:
$(MKDIR) $(SYSINCLUDEDIR)
for file in $(KERNELINCLUDEFILES) ; do \
$(RM) $$file.install; \
$(GREP) -v '/\* TBD \*/' $$file > $$file.install; \
$(INSTALL) -o root -g root -m 644 $$file.install \
$(SYSINCLUDEDIR)/`basename $$file`; \
$(RM) $$file.install; \
done
$(INSTALL) -o root -g root -m 644 $(KERNELINCLUDEFILES) $(SYSINCLUDEDIR)
install :: install-all-kernel-include
clean-all-kernel-include:
-163
View File
@@ -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
+1 -10
View File
@@ -18,11 +18,6 @@
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_SENSOR_H
#define SENSORS_SENSOR_H
@@ -46,11 +41,7 @@
#endif
#endif
#ifdef LM_SENSORS /* TBD */
#include "i2c.h" /* TBD */
#else /* ndef LM_SENSORS */ /* TBD */
#include <linux/i2c.h>
#endif /* def LM_SENSORS */ /* TBD */
#include <linux/i2c.h>
/* Note that this driver is *not* built upon smbus.c, but is parallel to it.
We do not need SMBus facilities if we are on the ISA bus, after all */
-29
View File
@@ -1,29 +0,0 @@
/*
i2c.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.
*/
/* This is a stub files, that either includes <linux/i2c.h> (the kernel
header) or "i2c/i2c.h" (the header in the i2c directory). */
#ifdef I2C
#include "i2c/i2c.h"
#else /* def I2C */
#include <linux/i2c.h>
#endif /* def I2C */
-6
View File
@@ -18,12 +18,6 @@
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_SENSORS_H
#define SENSORS_SENSORS_H
-310
View File
@@ -1,310 +0,0 @@
/*
smbus.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_SMBUS_H
#define SENSORS_SMBUS_H
/* This file must interface with Simon Vogl's i2c driver. Version 19981006 is
OK, earlier versions are not; later versions will probably give problems
too.
*/
#include <asm/types.h>
/* This union is used within smbus_access routines */
union smbus_data {
__u8 byte;
__u16 word;
__u8 block[33]; /* block[0] is used for length */
};
/* smbus_access read or write markers */
#define SMBUS_READ 1
#define SMBUS_WRITE 0
/* SMBus transaction types (size parameter in the above functions)
Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
#define SMBUS_QUICK 0
#define SMBUS_BYTE 1
#define SMBUS_BYTE_DATA 2
#define SMBUS_WORD_DATA 3
#define SMBUS_PROC_CALL 4
#define SMBUS_BLOCK_DATA 5
#ifdef __KERNEL__
/* I2C_SPINLOCK is defined in i2c.h. */
#ifdef I2C_SPINLOCK
#include <asm/spinlock.h>
#else
#if LINUX_VERSION_CODE < 0x020019
#include <linux/sched.h>
#else
#include <asm/semaphore.h>
#endif
#endif
#ifdef LM_SENSORS /* TBD */
#include "i2c.h" /* TBD */
#else /* TBD */
#include <linux/i2c.h>
#endif /* TBD */
/* Declarations, to keep the compiler happy */
struct smbus_driver;
struct smbus_client;
struct smbus_algorithm;
struct smbus_adapter;
union smbus_data;
/* A driver tells us how we should handle a specific kind of chip.
A specific instance of such a chip is called a client.
This structure is essentially the same as i2c_driver. */
struct smbus_driver {
char name[32];
int id;
unsigned int flags;
int (* attach_adapter) (struct smbus_adapter *);
int (* detach_client) (struct smbus_client *);
int (* command) (struct smbus_client *, unsigned int cmd, void *arg);
void (* inc_use) (struct smbus_client *);
void (* dec_use) (struct smbus_client *);
};
/* A client is a specifc instance of a chip: for each detected chip, there will
be a client. Its operation is controlled by a driver.
This structure is essentially the same as i2c_client. */
struct smbus_client {
char name[32];
int id;
unsigned int flags;
unsigned char addr;
struct smbus_adapter *adapter;
struct smbus_driver *driver;
void *data;
};
/* An algorithm describes how a certain class of busses can be accessed.
A specific instance of sucj a bus is called an adapter.
This structure is essentially the same as i2c_adapter. */
struct smbus_algorithm {
char name[32];
unsigned int id;
int (* master_xfer) (struct smbus_adapter *adap, struct i2c_msg msgs[],
int num);
int (* slave_send) (struct smbus_adapter *,char *, int);
int (* slave_recv) (struct smbus_adapter *,char *, int);
int (* algo_control) (struct smbus_adapter *, unsigned int, unsigned long);
int (* client_register) (struct smbus_client *);
int (* client_unregister) (struct smbus_client *);
};
/* An adapter is a specifc instance of a bus: for each detected bus, there will
be an adapter. Its operation is controlled by an algorithm.
I2C_SPINLOCK must be the same as declared in i2c.h.
This structure is an extension of i2c_algorithm. */
struct smbus_adapter {
char name[32];
unsigned int id;
struct smbus_algorithm *algo;
void *data;
#ifdef I2C_SPINLOCK
spinlock_t lock;
unsigned long lockflags;
#else
struct semaphore lock;
#endif
unsigned int flags;
struct smbus_client *clients[I2C_CLIENT_MAX];
int client_count;
int timeout;
int retries;
/* Here ended i2c_adapter */
s32 (* smbus_access) (u8 addr, char read_write,
u8 command, int size, union smbus_data * data);
};
/* We need to mark SMBus algorithms in the algorithm structure.
Note that any and all adapters using a non-i2c driver use in this
setup ALGO_SMBUS. Adapters define their own smbus access routine.
This also means that adapter->smbus_access is only available if
this flag is set! */
#define ALGO_SMBUS 0x40000
/* SMBus Adapter ids */
#define SMBUS_PIIX4 1
#define SMBUS_VOODOO3 2
/* Detect whether we are on an SMBus-only bus. Note that if this returns
false, you can still use the smbus access routines, as these emulate
the SMBus on I2C. Unless they are undefined on your algorithm, of
course. */
#define i2c_is_smbus_client(clientptr) \
((clientptr)->adapter->algo->id == ALGO_SMBUS)
#define i2c_is_smbus_adapter(adapptr) \
((adapptr)->algo->id == ALGO_SMBUS)
/* Declare an algorithm structure. All SMBus derived adapters should use this
algorithm! */
extern struct smbus_algorithm smbus_algorithm;
/* This is the very generalized SMBus access routine. You probably do not
want to use this, though; one of the functions below may be much easier,
and probably just as fast.
Note that we use i2c_adapter here, because you do not need a specific
smbus adapter to call this function. */
extern s32 smbus_access (struct i2c_adapter * adapter, u8 addr,
char read_write, u8 command, int size,
union smbus_data * data);
/* Now follow the 'nice' access routines. These also document the calling
conventions of smbus_access. */
extern inline s32 smbus_write_quick(struct i2c_adapter * adapter, u8 addr,
u8 value)
{
return smbus_access(adapter,addr,value,0,SMBUS_QUICK,NULL);
}
extern inline s32 smbus_read_byte(struct i2c_adapter * adapter,u8 addr)
{
union smbus_data data;
if (smbus_access(adapter,addr,SMBUS_READ,0,SMBUS_BYTE,&data))
return -1;
else
return 0x0FF & data.byte;
}
extern inline s32 smbus_write_byte(struct i2c_adapter * adapter, u8 addr,
u8 value)
{
return smbus_access(adapter,addr,SMBUS_WRITE,value, SMBUS_BYTE,NULL);
}
extern inline s32 smbus_read_byte_data(struct i2c_adapter * adapter,
u8 addr, u8 command)
{
union smbus_data data;
if (smbus_access(adapter,addr,SMBUS_READ,command,SMBUS_BYTE_DATA,&data))
return -1;
else
return 0x0FF & data.byte;
}
extern inline s32 smbus_write_byte_data(struct i2c_adapter * adapter,
u8 addr, u8 command, u8 value)
{
union smbus_data data;
data.byte = value;
return smbus_access(adapter,addr,SMBUS_WRITE,command,SMBUS_BYTE_DATA,&data);
}
extern inline s32 smbus_read_word_data(struct i2c_adapter * adapter,
u8 addr, u8 command)
{
union smbus_data data;
if (smbus_access(adapter,addr,SMBUS_READ,command,SMBUS_WORD_DATA,&data))
return -1;
else
return 0x0FFFF & data.word;
}
extern inline s32 smbus_write_word_data(struct i2c_adapter * adapter,
u8 addr, u8 command, u16 value)
{
union smbus_data data;
data.word = value;
return smbus_access(adapter,addr,SMBUS_WRITE,command,SMBUS_WORD_DATA,&data);
}
extern inline s32 smbus_process_call(struct i2c_adapter * adapter,
u8 addr, u8 command, u16 value)
{
union smbus_data data;
data.word = value;
if (smbus_access(adapter,addr,SMBUS_WRITE,command,SMBUS_PROC_CALL,&data))
return -1;
else
return 0x0FFFF & data.word;
}
/* Returns the number of read bytes */
extern inline s32 smbus_read_block_data(struct i2c_adapter * adapter,
u8 addr, u8 command, u8 *values)
{
union smbus_data data;
int i;
if (smbus_access(adapter,addr,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 smbus_write_block_data(struct i2c_adapter * adapter,
u8 addr, 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 smbus_access(adapter,addr,SMBUS_WRITE,command,SMBUS_BLOCK_DATA,&data);
}
/* Next: define SMBus variants of registering. */
#define smbus_add_algorithm(algoptr) \
i2c_add_algorithm((struct i2c_algorithm *) (algoptr))
#define smbus_del_algorithm(algoptr) \
i2c_del_algorithm((struct i2c_algorithm *) (algoptr))
#define smbus_add_adapter(adapptr) \
i2c_add_adapter((struct i2c_adapter *) (adapptr))
#define smbus_del_adapter(adapptr) \
i2c_del_adapter((struct i2c_adapter *) (adapptr))
#define smbus_add_driver(driverptr) \
i2c_add_driver((struct i2c_driver *) (driverptr))
#define smbus_del_driver(driverptr) \
i2c_add_driver((struct i2c_driver *) (driverptr))
#define smbus_attach_client(clientptr) \
i2c_attach_client((struct i2c_client *) (clientptr))
#define smbus_detach_client(clientptr) \
i2c_detach_client((struct i2c_client *) (clientptr))
#endif /* def __KERNEL__ */
#endif /* ndef SENSORS_SMBUS_H */