Commit a712ff9f authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] update i2c algorithm drivers

This one is from lm_sensors CVS and mostly cosmetic changes.  I it up a
bit to compile properly under latest 2.5.
parent 28db79d6
This diff is collapsed.
...@@ -55,20 +55,12 @@ ...@@ -55,20 +55,12 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/version.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/uaccess.h>
#include <linux/ioport.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include "i2c-algo-ibm_ocp.h" #include <linux/i2c-algo-ibm_ocp.h>
//ACC#include <asm/ocp.h> #include <asm/ocp.h>
#ifdef MODULE_LICENSE
MODULE_LICENSE("GPL");
#endif
/* ----- global defines ----------------------------------------------- */ /* ----- global defines ----------------------------------------------- */
...@@ -79,26 +71,13 @@ MODULE_LICENSE("GPL"); ...@@ -79,26 +71,13 @@ MODULE_LICENSE("GPL");
/* debug the protocol by showing transferred bits */ /* debug the protocol by showing transferred bits */
#define DEF_TIMEOUT 5 #define DEF_TIMEOUT 5
/* debugging - slow down transfer to have a look at the data .. */
/* I use this with two leds&resistors, each one connected to sda,scl */
/* respectively. This makes sure that the algorithm works. Some chips */
/* might not like this, as they have an internal timeout of some mils */
/*
#define SLO_IO jif=jiffies;while(time_before_eq(jiffies,jif+i2c_table[minor].veryslow))\
if (need_resched) schedule();
*/
/* ----- global variables --------------------------------------------- */ /* ----- global variables --------------------------------------------- */
#ifdef SLO_IO
int jif;
#endif
/* module parameters: /* module parameters:
*/ */
static int i2c_debug=0; static int i2c_debug=0;
static int iic_scan=0; /* have a look at what's hanging 'round */
/* --- setting states on the bus with the right timing: --------------- */ /* --- setting states on the bus with the right timing: --------------- */
...@@ -758,7 +737,7 @@ static int iic_xfer(struct i2c_adapter *i2c_adap, ...@@ -758,7 +737,7 @@ static int iic_xfer(struct i2c_adapter *i2c_adap,
// Check to see if the bus is busy // Check to see if the bus is busy
// //
ret = iic_inb(adap, iic->extsts); ret = iic_inb(adap, iic->extsts);
// Mask off the irrelevant bits // Mask off the irrelevent bits
ret = ret & 0x70; ret = ret & 0x70;
// When the bus is free, the BCS bits in the EXTSTS register are 0b100 // When the bus is free, the BCS bits in the EXTSTS register are 0b100
if(ret != 0x40) return IIC_ERR_LOST_ARB; if(ret != 0x40) return IIC_ERR_LOST_ARB;
...@@ -858,17 +837,13 @@ static u32 iic_func(struct i2c_adapter *adap) ...@@ -858,17 +837,13 @@ static u32 iic_func(struct i2c_adapter *adap)
/* -----exported algorithm data: ------------------------------------- */ /* -----exported algorithm data: ------------------------------------- */
static struct i2c_algorithm iic_algo = { static struct i2c_algorithm iic_algo = {
"IBM on-chip IIC algorithm", .name = "IBM on-chip IIC algorithm",
I2C_ALGO_OCP, .id = I2C_ALGO_OCP,
iic_xfer, .master_xfer = iic_xfer,
NULL, .algo_control = algo_control,
NULL, /* slave_xmit */ .functionality = iic_func,
NULL, /* slave_recv */
algo_control, /* ioctl */
iic_func, /* functionality */
}; };
/* /*
* registering functions to load algorithms at runtime * registering functions to load algorithms at runtime
*/ */
...@@ -892,19 +867,8 @@ int i2c_ocp_add_bus(struct i2c_adapter *adap) ...@@ -892,19 +867,8 @@ int i2c_ocp_add_bus(struct i2c_adapter *adap)
adap->timeout = 100; /* default values, should */ adap->timeout = 100; /* default values, should */
adap->retries = 3; /* be replaced by defines */ adap->retries = 3; /* be replaced by defines */
#ifdef MODULE
MOD_INC_USE_COUNT;
#endif
iic_init(iic_adap); iic_init(iic_adap);
i2c_add_adapter(adap); i2c_add_adapter(adap);
/* scan bus */
/* By default scanning the bus is turned off. */
if (iic_scan) {
printk(KERN_INFO " i2c-algo-iic.o: scanning bus %s.\n",
adap->name);
}
return 0; return 0;
} }
...@@ -914,31 +878,7 @@ int i2c_ocp_add_bus(struct i2c_adapter *adap) ...@@ -914,31 +878,7 @@ int i2c_ocp_add_bus(struct i2c_adapter *adap)
// //
int i2c_ocp_del_bus(struct i2c_adapter *adap) int i2c_ocp_del_bus(struct i2c_adapter *adap)
{ {
int res; return i2c_del_adapter(adap);
if ((res = i2c_del_adapter(adap)) < 0)
return res;
DEB2(printk(KERN_DEBUG "i2c-algo-iic.o: adapter unregistered: %s\n",adap->name));
#ifdef MODULE
MOD_DEC_USE_COUNT;
#endif
return 0;
}
//
// Done
//
int __init i2c_algo_iic_init (void)
{
printk(KERN_INFO "IBM On-chip iic (i2c) algorithm module 2002.27.03\n");
return 0;
}
void i2c_algo_iic_exit(void)
{
return;
} }
...@@ -951,16 +891,10 @@ EXPORT_SYMBOL(i2c_ocp_del_bus); ...@@ -951,16 +891,10 @@ EXPORT_SYMBOL(i2c_ocp_del_bus);
// //
MODULE_AUTHOR("MontaVista Software <www.mvista.com>"); MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
MODULE_DESCRIPTION("PPC 405 iic algorithm"); MODULE_DESCRIPTION("PPC 405 iic algorithm");
MODULE_LICENSE("GPL");
MODULE_PARM(iic_test, "i");
MODULE_PARM(iic_scan, "i");
MODULE_PARM(i2c_debug,"i"); MODULE_PARM(i2c_debug,"i");
MODULE_PARM_DESC(iic_test, "Test if the I2C bus is available");
MODULE_PARM_DESC(iic_scan, "Scan for active chips on the bus");
MODULE_PARM_DESC(i2c_debug, MODULE_PARM_DESC(i2c_debug,
"debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol"); "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
module_init(i2c_algo_iic_init);
module_exit(i2c_algo_iic_exit);
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
/* module parameters: /* module parameters:
*/ */
static int i2c_debug=0; static int i2c_debug=0;
static int pcf_scan=0; /* have a look at what's hanging 'round */
/* --- setting states on the bus with the right timing: --------------- */ /* --- setting states on the bus with the right timing: --------------- */
...@@ -423,12 +422,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap, ...@@ -423,12 +422,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
return (i); return (i);
} }
static int algo_control(struct i2c_adapter *adapter,
unsigned int cmd, unsigned long arg)
{
return 0;
}
static u32 pcf_func(struct i2c_adapter *adap) static u32 pcf_func(struct i2c_adapter *adap)
{ {
return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |
...@@ -438,14 +431,10 @@ static u32 pcf_func(struct i2c_adapter *adap) ...@@ -438,14 +431,10 @@ static u32 pcf_func(struct i2c_adapter *adap)
/* -----exported algorithm data: ------------------------------------- */ /* -----exported algorithm data: ------------------------------------- */
static struct i2c_algorithm pcf_algo = { static struct i2c_algorithm pcf_algo = {
"PCF8584 algorithm", .name = "PCF8584 algorithm",
I2C_ALGO_PCF, .id = I2C_ALGO_PCF,
pcf_xfer, .master_xfer = pcf_xfer,
NULL, .functionality = pcf_func,
NULL, /* slave_xmit */
NULL, /* slave_recv */
algo_control, /* ioctl */
pcf_func, /* functionality */
}; };
/* /*
...@@ -453,8 +442,8 @@ static struct i2c_algorithm pcf_algo = { ...@@ -453,8 +442,8 @@ static struct i2c_algorithm pcf_algo = {
*/ */
int i2c_pcf_add_bus(struct i2c_adapter *adap) int i2c_pcf_add_bus(struct i2c_adapter *adap)
{ {
int i, status;
struct i2c_algo_pcf_data *pcf_adap = adap->algo_data; struct i2c_algo_pcf_data *pcf_adap = adap->algo_data;
int rval;
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: hw routines for %s registered.\n", DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: hw routines for %s registered.\n",
adap->name)); adap->name));
...@@ -467,36 +456,10 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) ...@@ -467,36 +456,10 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
adap->timeout = 100; /* default values, should */ adap->timeout = 100; /* default values, should */
adap->retries = 3; /* be replaced by defines */ adap->retries = 3; /* be replaced by defines */
if ((i = pcf_init_8584(pcf_adap))) { rval = pcf_init_8584(pcf_adap);
return i; if (!rval)
} i2c_add_adapter(adap);
return rval;
i2c_add_adapter(adap);
/* scan bus */
if (pcf_scan) {
printk(KERN_INFO " i2c-algo-pcf.o: scanning bus %s.\n",
adap->name);
for (i = 0x00; i < 0xff; i+=2) {
if (wait_for_bb(pcf_adap)) {
printk(KERN_INFO " i2c-algo-pcf.o: scanning bus %s - TIMEOUTed.\n",
adap->name);
break;
}
i2c_outb(pcf_adap, i);
i2c_start(pcf_adap);
if ((wait_for_pin(pcf_adap, &status) >= 0) &&
((status & I2C_PCF_LRB) == 0)) {
printk("(%02x)",i>>1);
} else {
printk(".");
}
i2c_stop(pcf_adap);
udelay(pcf_adap->udelay);
}
printk("\n");
}
return 0;
} }
...@@ -512,9 +475,6 @@ MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); ...@@ -512,9 +475,6 @@ MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_PARM(pcf_scan, "i");
MODULE_PARM(i2c_debug,"i"); MODULE_PARM(i2c_debug,"i");
MODULE_PARM_DESC(pcf_scan, "Scan for active chips on the bus");
MODULE_PARM_DESC(i2c_debug, MODULE_PARM_DESC(i2c_debug,
"debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol"); "debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment