(Kyösti)

* Fixed adapter drivers to compile with the new i2c structs.
   They might, or they might not work..


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@497 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Kyosti Malkki committed 1999-07-20 21:38:11 +00:00
1 parent 24e547b88e
commit 7ac5a6005f
6 files changed
+188 -90

No files matched your search

+2 -1
View File
@@ -24,7 +24,8 @@ MODULE_DIR := kernel/busses
# defined value verbatim into the command-list of rules... # defined value verbatim into the command-list of rules...
KERNELBUSSESTARGETS := $(MODULE_DIR)/i2c-piix4.o $(MODULE_DIR)/i2c-isa.o \ KERNELBUSSESTARGETS := $(MODULE_DIR)/i2c-piix4.o $(MODULE_DIR)/i2c-isa.o \
$(MODULE_DIR)/i2c-via.o $(MODULE_DIR)/i2c-ali15x3.o \ $(MODULE_DIR)/i2c-via.o $(MODULE_DIR)/i2c-ali15x3.o \
$(MODULE_DIR)/i2c-hydra.o $(MODULE_DIR)/i2c-voodoo3.o $(MODULE_DIR)/i2c-hydra.o $(MODULE_DIR)/i2c-voodoo3.o \
$(MODULE_DIR)/i2c-via2.o
KERNELBUSSESOLD := bit-via.o bit-mb.o isa.o piix4.o KERNELBUSSESOLD := bit-via.o bit-mb.o isa.o piix4.o
+52 -23
View File
@@ -146,17 +146,39 @@
static int ali15x3_init(void); static int ali15x3_init(void);
static int ali15x3_cleanup(void); static int ali15x3_cleanup(void);
static int ali15x3_setup(void); static int ali15x3_setup(void);
static s32 ali15x3_access(u8 addr, char read_write, static s32 ali15x3_access(struct i2c_adapter *adap, u8 addr, char read_write,
u8 command, int size, union smbus_data * data); u8 command, int size, union i2c_smbus_data * data);
static void ali15x3_do_pause( unsigned int amount ); static void ali15x3_do_pause( unsigned int amount );
static int ali15x3_transaction(void); static int ali15x3_transaction(void);
static void ali15x3_inc(struct i2c_adapter *adapter);
static void ali15x3_dec(struct i2c_adapter *adapter);
#ifdef MODULE #ifdef MODULE
extern int init_module(void); extern int init_module(void);
extern int cleanup_module(void); extern int cleanup_module(void);
#endif /* MODULE */ #endif /* MODULE */
static struct smbus_adapter ali15x3_adapter; static struct i2c_algorithm smbus_algorithm = {
/* name */ "Non-I2C SMBus adapter",
/* id */ I2C_ALGO_SMBUS,
/* master_xfer */ NULL,
/* smbus_access */ ali15x3_access,
/* slave_send */ NULL,
/* slave_rcv */ NULL,
/* algo_control */ NULL,
};
static struct i2c_adapter ali15x3_adapter = {
"unset",
I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
&smbus_algorithm,
NULL,
ali15x3_inc,
ali15x3_dec,
NULL,
NULL,
};
static int ali15x3_initialized; static int ali15x3_initialized;
#ifdef MAP_ACPI #ifdef MAP_ACPI
static unsigned short ali15x3_acpia = 0; static unsigned short ali15x3_acpia = 0;
@@ -457,8 +479,8 @@ int ali15x3_transaction(void)
} }
/* Return -1 on error. See smbus.h for more information */ /* Return -1 on error. See smbus.h for more information */
s32 ali15x3_access(u8 addr, char read_write, s32 ali15x3_access(struct i2c_adapter *adap, u8 addr, char read_write,
u8 command, int size, union smbus_data * data) u8 command, int size, union i2c_smbus_data * data)
{ {
int i,len; int i,len;
int temp; int temp;
@@ -478,39 +500,39 @@ s32 ali15x3_access(u8 addr, char read_write,
} }
switch(size) { switch(size) {
case SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
printk("i2c-ali15x3.o: SMBUS_PROC_CALL not supported!\n"); printk("i2c-ali15x3.o: I2C_SMBUS_PROC_CALL not supported!\n");
return -1; return -1;
case SMBUS_QUICK: case I2C_SMBUS_QUICK:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
size = ALI15X3_QUICK; size = ALI15X3_QUICK;
break; break;
case SMBUS_BYTE: case I2C_SMBUS_BYTE:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
if (read_write == SMBUS_WRITE) if (read_write == I2C_SMBUS_WRITE)
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
size = ALI15X3_BYTE; size = ALI15X3_BYTE;
break; break;
case SMBUS_BYTE_DATA: case I2C_SMBUS_BYTE_DATA:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
if (read_write == SMBUS_WRITE) if (read_write == I2C_SMBUS_WRITE)
outb_p(data->byte,SMBHSTDAT0); outb_p(data->byte,SMBHSTDAT0);
size = ALI15X3_BYTE_DATA; size = ALI15X3_BYTE_DATA;
break; break;
case SMBUS_WORD_DATA: case I2C_SMBUS_WORD_DATA:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
if (read_write == SMBUS_WRITE) { if (read_write == I2C_SMBUS_WRITE) {
outb_p(data->word & 0xff,SMBHSTDAT0); outb_p(data->word & 0xff,SMBHSTDAT0);
outb_p((data->word & 0xff00) >> 8,SMBHSTDAT1); outb_p((data->word & 0xff00) >> 8,SMBHSTDAT1);
} }
size = ALI15X3_WORD_DATA; size = ALI15X3_WORD_DATA;
break; break;
case SMBUS_BLOCK_DATA: case I2C_SMBUS_BLOCK_DATA:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
if (read_write == SMBUS_WRITE) { if (read_write == I2C_SMBUS_WRITE) {
len = data->block[0]; len = data->block[0];
if (len < 0) { if (len < 0) {
len = 0; len = 0;
@@ -534,7 +556,7 @@ s32 ali15x3_access(u8 addr, char read_write,
if (ali15x3_transaction()) /* Error in transaction */ if (ali15x3_transaction()) /* Error in transaction */
return -1; return -1;
if ((read_write == SMBUS_WRITE) || (size == ALI15X3_QUICK)) if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK))
return 0; return 0;
@@ -565,6 +587,16 @@ s32 ali15x3_access(u8 addr, char read_write,
return 0; return 0;
} }
void ali15x3_inc(struct i2c_adapter *adapter)
{
MOD_INC_USE_COUNT;
}
void ali15x3_dec(struct i2c_adapter *adapter)
{
MOD_DEC_USE_COUNT;
}
int ali15x3_init(void) int ali15x3_init(void)
{ {
@@ -588,10 +620,7 @@ int ali15x3_init(void)
sprintf(ali15x3_adapter.name,"ACPI ALI15X3 at %04x",ali15x3_acpia); sprintf(ali15x3_adapter.name,"ACPI ALI15X3 at %04x",ali15x3_acpia);
#endif #endif
sprintf(ali15x3_adapter.name,"SMBus ALI15X3 adapter at %04x",ali15x3_smba); sprintf(ali15x3_adapter.name,"SMBus ALI15X3 adapter at %04x",ali15x3_smba);
ali15x3_adapter.id = ALGO_SMBUS | SMBUS_PIIX4; if ((res = i2c_add_adapter(&ali15x3_adapter))) {
ali15x3_adapter.algo = &smbus_algorithm;
ali15x3_adapter.smbus_access = &ali15x3_access;
if ((res = smbus_add_adapter(&ali15x3_adapter))) {
printk("i2c-ali15x3.o: Adapter registration failed, module not inserted.\n"); printk("i2c-ali15x3.o: Adapter registration failed, module not inserted.\n");
ali15x3_cleanup(); ali15x3_cleanup();
return res; return res;
@@ -606,8 +635,8 @@ int ali15x3_cleanup(void)
int res; int res;
if (ali15x3_initialized >= 2) if (ali15x3_initialized >= 2)
{ {
if ((res = smbus_del_adapter(&ali15x3_adapter))) { if ((res = i2c_del_adapter(&ali15x3_adapter))) {
printk("i2c-ali15x3.o: smbus_del_adapter failed, module not removed\n"); printk("i2c-ali15x3.o: i2c_del_adapter failed, module not removed\n");
return res; return res;
} else } else
ali15x3_initialized--; ali15x3_initialized--;
+14 -10
View File
@@ -103,34 +103,38 @@ static int bit_hydra_getsda(void *data)
return (pdregr() & HYDRA_SDAT) != 0; return (pdregr() & HYDRA_SDAT) != 0;
} }
static int bit_hydra_reg(struct i2c_client *client) static void bit_hydra_inc(struct i2c_adapter *adap)
{ {
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
return 0;
} }
static int bit_hydra_unreg(struct i2c_client *client) static void bit_hydra_dec(struct i2c_adapter *adap)
{ {
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0;
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
struct bit_adapter bit_hydra_ops = { struct i2c_algo_bit_data bit_hydra_data = {
"Hydra i2c",
HW_B_HYDRA,
NULL, NULL,
bit_hydra_setsda, bit_hydra_setsda,
bit_hydra_setscl, bit_hydra_setscl,
bit_hydra_getsda, bit_hydra_getsda,
bit_hydra_getscl, bit_hydra_getscl,
bit_hydra_reg,
bit_hydra_unreg,
5, 5, 100, /*waits, timeout */ 5, 5, 100, /*waits, timeout */
}; };
struct i2c_adapter bit_hydra_ops = {
"Hydra i2c",
I2C_HW_B_HYDRA,
NULL,
&bit_hydra_data,
bit_hydra_inc,
bit_hydra_dec,
NULL,
NULL,
};
static int find_hydra(void) static int find_hydra(void)
{ {
+52 -23
View File
@@ -88,17 +88,39 @@ MODULE_PARM_DESC(force_addr,"Forcibly enable the PIIX4 at the given address. "
static int piix4_init(void); static int piix4_init(void);
static int piix4_cleanup(void); static int piix4_cleanup(void);
static int piix4_setup(void); static int piix4_setup(void);
static s32 piix4_access(u8 addr, char read_write, static s32 piix4_access(struct i2c_adapter *adap, u8 addr, char read_write,
u8 command, int size, union smbus_data * data); u8 command, int size, union i2c_smbus_data * data);
static void piix4_do_pause( unsigned int amount ); static void piix4_do_pause( unsigned int amount );
static int piix4_transaction(void); static int piix4_transaction(void);
static void piix4_inc(struct i2c_adapter *adapter);
static void piix4_dec(struct i2c_adapter *adapter);
#ifdef MODULE #ifdef MODULE
extern int init_module(void); extern int init_module(void);
extern int cleanup_module(void); extern int cleanup_module(void);
#endif /* MODULE */ #endif /* MODULE */
static struct smbus_adapter piix4_adapter; static struct i2c_algorithm smbus_algorithm = {
/* name */ "Non-I2C SMBus adapter",
/* id */ I2C_ALGO_SMBUS,
/* master_xfer */ NULL,
/* smbus_access */ piix4_access,
/* slave_send */ NULL,
/* slave_rcv */ NULL,
/* algo_control */ NULL,
};
static struct i2c_adapter piix4_adapter = {
"unset",
I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4,
&smbus_algorithm,
NULL,
piix4_inc,
piix4_dec,
NULL,
NULL,
};
static int piix4_initialized; static int piix4_initialized;
static unsigned short piix4_smba = 0; static unsigned short piix4_smba = 0;
@@ -317,45 +339,45 @@ int piix4_transaction(void)
} }
/* Return -1 on error. See smbus.h for more information */ /* Return -1 on error. See smbus.h for more information */
s32 piix4_access(u8 addr, char read_write, s32 piix4_access(struct i2c_adapter *adap, u8 addr, char read_write,
u8 command, int size, union smbus_data * data) u8 command, int size, union i2c_smbus_data * data)
{ {
int i,len; int i,len;
switch(size) { switch(size) {
case SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
printk("i2c-piix4.o: SMBUS_PROC_CALL not supported!\n"); printk("i2c-piix4.o: I2C_SMBUS_PROC_CALL not supported!\n");
return -1; return -1;
case SMBUS_QUICK: case I2C_SMBUS_QUICK:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
size = PIIX4_QUICK; size = PIIX4_QUICK;
break; break;
case SMBUS_BYTE: case I2C_SMBUS_BYTE:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
if (read_write == SMBUS_WRITE) if (read_write == I2C_SMBUS_WRITE)
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
size = PIIX4_BYTE; size = PIIX4_BYTE;
break; break;
case SMBUS_BYTE_DATA: case I2C_SMBUS_BYTE_DATA:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
if (read_write == SMBUS_WRITE) if (read_write == I2C_SMBUS_WRITE)
outb_p(data->byte,SMBHSTDAT0); outb_p(data->byte,SMBHSTDAT0);
size = PIIX4_BYTE_DATA; size = PIIX4_BYTE_DATA;
break; break;
case SMBUS_WORD_DATA: case I2C_SMBUS_WORD_DATA:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
if (read_write == SMBUS_WRITE) { if (read_write == I2C_SMBUS_WRITE) {
outb_p(data->word & 0xff,SMBHSTDAT0); outb_p(data->word & 0xff,SMBHSTDAT0);
outb_p((data->word & 0xff00) >> 8,SMBHSTDAT1); outb_p((data->word & 0xff00) >> 8,SMBHSTDAT1);
} }
size = PIIX4_WORD_DATA; size = PIIX4_WORD_DATA;
break; break;
case SMBUS_BLOCK_DATA: case I2C_SMBUS_BLOCK_DATA:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD);
outb_p(command, SMBHSTCMD); outb_p(command, SMBHSTCMD);
if (read_write == SMBUS_WRITE) { if (read_write == I2C_SMBUS_WRITE) {
len = data->block[0]; len = data->block[0];
if (len < 0) if (len < 0)
len = 0; len = 0;
@@ -375,7 +397,7 @@ s32 piix4_access(u8 addr, char read_write,
if (piix4_transaction()) /* Error in transaction */ if (piix4_transaction()) /* Error in transaction */
return -1; return -1;
if ((read_write == SMBUS_WRITE) || (size == PIIX4_QUICK)) if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK))
return 0; return 0;
@@ -402,6 +424,16 @@ s32 piix4_access(u8 addr, char read_write,
return 0; return 0;
} }
void piix4_inc(struct i2c_adapter *adapter)
{
MOD_INC_USE_COUNT;
}
void piix4_dec(struct i2c_adapter *adapter)
{
MOD_DEC_USE_COUNT;
}
int piix4_init(void) int piix4_init(void)
{ {
@@ -422,10 +454,7 @@ int piix4_init(void)
} }
piix4_initialized ++; piix4_initialized ++;
sprintf(piix4_adapter.name,"SMBus PIIX4 adapter at %04x",piix4_smba); sprintf(piix4_adapter.name,"SMBus PIIX4 adapter at %04x",piix4_smba);
piix4_adapter.id = ALGO_SMBUS | SMBUS_PIIX4; if ((res = i2c_add_adapter(&piix4_adapter))) {
piix4_adapter.algo = &smbus_algorithm;
piix4_adapter.smbus_access = &piix4_access;
if ((res = smbus_add_adapter(&piix4_adapter))) {
printk("i2c-piix4.o: Adapter registration failed, module not inserted.\n"); printk("i2c-piix4.o: Adapter registration failed, module not inserted.\n");
piix4_cleanup(); piix4_cleanup();
return res; return res;
@@ -440,8 +469,8 @@ int piix4_cleanup(void)
int res; int res;
if (piix4_initialized >= 2) if (piix4_initialized >= 2)
{ {
if ((res = smbus_del_adapter(&piix4_adapter))) { if ((res = i2c_del_adapter(&piix4_adapter))) {
printk("i2c-piix4.o: smbus_del_adapter failed, module not removed\n"); printk("i2c-piix4.o: i2c_del_adapter failed, module not removed\n");
return res; return res;
} else } else
piix4_initialized--; piix4_initialized--;
+18 -12
View File
@@ -86,32 +86,38 @@ static int bit_via_getsda(void *data)
return (0 != (inb(I2C_IN) & I2C_SDA) ); return (0 != (inb(I2C_IN) & I2C_SDA) );
} }
static int bit_via_reg(struct i2c_client *client) static void bit_via_inc(struct i2c_adapter *adapter)
{ {
return 0; MOD_INC_USE_COUNT;
} }
static int bit_via_unreg(struct i2c_client *client) static void bit_via_dec(struct i2c_adapter *adapter)
{ {
return 0; MOD_DEC_USE_COUNT;
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static struct bit_adapter bit_via_ops = { static struct i2c_algo_bit_data bit_data = {
"VIA i2c",
HW_B_VIA,
NULL, NULL,
bit_via_setsda, bit_via_setsda,
bit_via_setscl, bit_via_setscl,
bit_via_getsda, bit_via_getsda,
bit_via_getscl, bit_via_getscl,
bit_via_reg,
bit_via_unreg,
5, 5, 100, /*waits, timeout */ 5, 5, 100, /*waits, timeout */
}; };
static struct i2c_adapter bit_via_ops = {
"VIA i2c",
I2C_HW_B_VIA,
NULL,
&bit_data,
bit_via_inc,
bit_via_dec,
NULL,
NULL,
};
/* When exactly was the new pci interface introduced? */ /* When exactly was the new pci interface introduced? */
#if LINUX_VERSION_CODE >= 0x020136 /* 2.1.54 */ #if LINUX_VERSION_CODE >= 0x020136 /* 2.1.54 */
@@ -216,12 +222,12 @@ static int init_i2c_via(void)
} }
if (i2c_bit_add_bus(&bit_via_ops) == 0) { if (i2c_bit_add_bus(&bit_via_ops) == 0) {
printk("Via i2c: Module succesfully loaded\n"); printk("i2c-via.o: Module succesfully loaded\n");
return 0; return 0;
} else { } else {
outb(inb(I2C_DIR)&~(I2C_SDA|I2C_SCL), I2C_DIR); outb(inb(I2C_DIR)&~(I2C_SDA|I2C_SCL), I2C_DIR);
release_region(I2C_DIR, IOSPACE); release_region(I2C_DIR, IOSPACE);
printk("Via i2c: Algo-bit error, couldn't register bus\n"); printk("i2c-via.o: Algo-bit error, couldn't register bus\n");
return -ENODEV; return -ENODEV;
} }
} }
+50 -21
View File
@@ -55,8 +55,8 @@
static int voodoo3_init(void); static int voodoo3_init(void);
static int voodoo3_cleanup(void); static int voodoo3_cleanup(void);
static int voodoo3_setup(void); static int voodoo3_setup(void);
static s32 voodoo3_access(u8 addr, char read_write, static s32 voodoo3_access(struct i2c_adapter *adap, u8 addr, char read_write,
u8 command, int size, union smbus_data * data); u8 command, int size, union i2c_smbus_data * data);
static void Voodoo3_I2CStart(void); static void Voodoo3_I2CStart(void);
static void Voodoo3_I2CStop(void); static void Voodoo3_I2CStop(void);
static int Voodoo3_I2CAck(void); static int Voodoo3_I2CAck(void);
@@ -70,6 +70,8 @@ static int Voodoo3_I2CWrite_byte(int addr,int command);
static int Voodoo3_I2CWrite_byte_data(int addr,int command,int data); static int Voodoo3_I2CWrite_byte_data(int addr,int command,int data);
static int Voodoo3_I2CWrite_word(int addr,int command,long data); static int Voodoo3_I2CWrite_word(int addr,int command,long data);
static void config_v3(struct pci_dev *dev, int num); static void config_v3(struct pci_dev *dev, int num);
static void voodoo3_inc(struct i2c_adapter *adapter);
static void voodoo3_dec(struct i2c_adapter *adapter);
@@ -90,7 +92,27 @@ extern int init_module(void);
extern int cleanup_module(void); extern int cleanup_module(void);
#endif /* MODULE */ #endif /* MODULE */
static struct smbus_adapter voodoo3_adapter; static struct i2c_algorithm smbus_algorithm = {
/* name */ "Non-I2C SMBus adapter",
/* id */ I2C_ALGO_SMBUS,
/* master_xfer */ NULL,
/* smbus_access */ &voodoo3_access,
/* slave_send */ NULL,
/* slave_rcv */ NULL,
/* algo_control */ NULL,
};
static struct i2c_adapter voodoo3_adapter = {
"unset",
I2C_ALGO_SMBUS | I2C_HW_SMBUS_VOODOO3,
&smbus_algorithm,
NULL,
voodoo3_inc,
voodoo3_dec,
NULL,
NULL,
};
static int voodoo3_initialized; static int voodoo3_initialized;
static unsigned short voodoo3_smba = 0; static unsigned short voodoo3_smba = 0;
static unsigned int state=0xcf980020; static unsigned int state=0xcf980020;
@@ -451,42 +473,42 @@ static int voodoo3_setup(void)
/* Return -1 on error. See smbus.h for more information */ /* Return -1 on error. See smbus.h for more information */
s32 voodoo3_access(u8 addr, char read_write, s32 voodoo3_access(struct i2c_adapter *adap, u8 addr, char read_write,
u8 command, int size, union smbus_data * data) u8 command, int size, union i2c_smbus_data * data)
{ {
int temp=0; int temp=0;
if (Voodoo3_BusCheck()) return -1; if (Voodoo3_BusCheck()) return -1;
if ((read_write != SMBUS_READ) && (read_write != SMBUS_WRITE)) { if ((read_write != I2C_SMBUS_READ) && (read_write != I2C_SMBUS_WRITE)) {
printk("i2c-voodoo3: Unknown read_write command! (0x%X)\n",read_write); printk("i2c-voodoo3: Unknown read_write command! (0x%X)\n",read_write);
return -1; return -1;
} }
addr=((addr & 0x7f) << 1) | (read_write & 0x01); addr=((addr & 0x7f) << 1) | (read_write & 0x01);
switch(size) { switch(size) {
case SMBUS_QUICK: case I2C_SMBUS_QUICK:
Voodoo3_I2CStart(); Voodoo3_I2CStart();
if (Voodoo3_I2CSendByte(addr)) { if (Voodoo3_I2CSendByte(addr)) {
#ifdef DEBUG #ifdef DEBUG
printk("i2c-voodoo3: No Ack on addr WriteByte to addr 0x%X\n",addr); printk("i2c-voodoo3: No Ack on addr WriteByte to addr 0x%X\n",addr);
#endif #endif
return -1; } return -1; }
case SMBUS_BYTE: case I2C_SMBUS_BYTE:
if (read_write == SMBUS_READ) { temp=Voodoo3_I2CRead_byte(addr); data->byte=temp; if (read_write == I2C_SMBUS_READ) { temp=Voodoo3_I2CRead_byte(addr); data->byte=temp;
} else { temp=Voodoo3_I2CWrite_byte(addr,command); } } else { temp=Voodoo3_I2CWrite_byte(addr,command); }
goto TESTACK; goto TESTACK;
case SMBUS_BYTE_DATA: case I2C_SMBUS_BYTE_DATA:
if (read_write == SMBUS_READ) { temp=Voodoo3_I2CRead_byte_data(addr,command); data->byte=temp; if (read_write == I2C_SMBUS_READ) { temp=Voodoo3_I2CRead_byte_data(addr,command); data->byte=temp;
} else { temp=Voodoo3_I2CWrite_byte_data(addr,command,data->byte); } } else { temp=Voodoo3_I2CWrite_byte_data(addr,command,data->byte); }
goto TESTACK; goto TESTACK;
case SMBUS_WORD_DATA: case I2C_SMBUS_WORD_DATA:
if (read_write == SMBUS_READ) { temp=Voodoo3_I2CRead_word(addr,command); data->word=temp; if (read_write == I2C_SMBUS_READ) { temp=Voodoo3_I2CRead_word(addr,command); data->word=temp;
} else { temp=Voodoo3_I2CWrite_word(addr,command,data->word); } } else { temp=Voodoo3_I2CWrite_word(addr,command,data->word); }
goto TESTACK; goto TESTACK;
case SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
printk("i2c-voodoo3: Proc call not supported.\n"); printk("i2c-voodoo3: Proc call not supported.\n");
return -1; return -1;
case SMBUS_BLOCK_DATA: case I2C_SMBUS_BLOCK_DATA:
printk("i2c-voodoo3: Block transfers not supported yet.\n"); printk("i2c-voodoo3: Block transfers not supported yet.\n");
return -1; return -1;
} }
@@ -500,6 +522,16 @@ TESTACK: if (temp < 0) {
return 0; return 0;
} }
void voodoo3_inc(struct i2c_adapter *adapter)
{
MOD_INC_USE_COUNT;
}
void voodoo3_dec(struct i2c_adapter *adapter)
{
MOD_DEC_USE_COUNT;
}
int voodoo3_init(void) int voodoo3_init(void)
{ {
@@ -520,10 +552,7 @@ int voodoo3_init(void)
} }
voodoo3_initialized ++; voodoo3_initialized ++;
sprintf(voodoo3_adapter.name,"SMBus Voodoo3 adapter at %04x",voodoo3_smba); sprintf(voodoo3_adapter.name,"SMBus Voodoo3 adapter at %04x",voodoo3_smba);
voodoo3_adapter.id = ALGO_SMBUS | SMBUS_VOODOO3; if ((res = i2c_add_adapter(&voodoo3_adapter))) {
voodoo3_adapter.algo = &smbus_algorithm;
voodoo3_adapter.smbus_access = &voodoo3_access;
if ((res = smbus_add_adapter(&voodoo3_adapter))) {
printk("i2c-voodoo3.o: Adapter registration failed, module not inserted.\n"); printk("i2c-voodoo3.o: Adapter registration failed, module not inserted.\n");
voodoo3_cleanup(); voodoo3_cleanup();
return res; return res;
@@ -540,8 +569,8 @@ int voodoo3_cleanup(void)
iounmap(mem); iounmap(mem);
if (voodoo3_initialized >= 2) if (voodoo3_initialized >= 2)
{ {
if ((res = smbus_del_adapter(&voodoo3_adapter))) { if ((res = i2c_del_adapter(&voodoo3_adapter))) {
printk("i2c-voodoo3.o: smbus_del_adapter failed, module not removed\n"); printk("i2c-voodoo3.o: i2c_del_adapter failed, module not removed\n");
return res; return res;
} else } else
voodoo3_initialized--; voodoo3_initialized--;