mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-20 19:41:47 +00:00
(Kyösti) some cleanups for 2.4+
Module refcounting using .owner, removing of inc/dec_use.
These require (yet unreleased) i2c 2.8.0+.
Named initializers everywhere. Unified namespace.
Cleanup for 2.5, remove EXPORT_NO_SYMBOLS, declare everything
static. Apply initcalls.
PCI device registration changes for busses started, replicating
from i2c-amd*. While everything does compile, nothing really
works. Well, maybe i2c-amd* ported back from 2.5 tree.
After updating your work directory, run
> cvs diff -u -r LAST-PRE-2-8-I2C > lm-2.8-patches-1
BEWARE: I have not even insmoded any of these yet.
To compile, you need i2c from cvs too.
For 2.4 kernel :
> cvs co -r lk2-4 i2c
For 2.5 kernel :
> cvs co i2c
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1698 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
2a462eaae3
commit
39391ba6ea
59 files changed
+1596
-5391
No files matched your search
@@ -229,21 +229,7 @@ void __init dmi_scan_mach(void)
|
||||
printk("dmi_scan.o: SM BIOS found\n");
|
||||
}
|
||||
|
||||
#ifdef MODULE
|
||||
MODULE_DESCRIPTION("SM BIOS DMI Scanner");
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
EXPORT_SYMBOL(dmi_ident);
|
||||
EXPORT_SYMBOL(dmi_scan_mach);
|
||||
int init_module(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
+49
-111
@@ -66,9 +66,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
#ifndef DECLARE_MUTEX
|
||||
#define DECLARE_MUTEX(name) struct semaphore name = MUTEX
|
||||
@@ -144,52 +142,9 @@ MODULE_LICENSE("GPL");
|
||||
/* -> Read = 1 */
|
||||
#define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_ali1535_init(void);
|
||||
static int __init ali1535_cleanup(void);
|
||||
static int ali1535_setup(void);
|
||||
static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size,
|
||||
union i2c_smbus_data *data);
|
||||
static void ali1535_do_pause(unsigned int amount);
|
||||
static int ali1535_transaction(void);
|
||||
static void ali1535_inc(struct i2c_adapter *adapter);
|
||||
static void ali1535_dec(struct i2c_adapter *adapter);
|
||||
static u32 ali1535_func(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
/* name */ "Non-i2c SMBus adapter",
|
||||
/* id */ I2C_ALGO_SMBUS,
|
||||
/* master_xfer */ NULL,
|
||||
/* smbus_access */ ali1535_access,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
/* functionality */ ali1535_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter ali1535_adapter = {
|
||||
"unset",
|
||||
I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI1535,
|
||||
&smbus_algorithm,
|
||||
NULL,
|
||||
ali1535_inc,
|
||||
ali1535_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int __initdata ali1535_initialized;
|
||||
static unsigned short ali1535_smba = 0;
|
||||
DECLARE_MUTEX(i2c_ali1535_sem);
|
||||
|
||||
@@ -591,16 +546,6 @@ EXIT:
|
||||
return result;
|
||||
}
|
||||
|
||||
void ali1535_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void ali1535_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 ali1535_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -609,82 +554,75 @@ u32 ali1535_func(struct i2c_adapter *adapter)
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA;
|
||||
}
|
||||
|
||||
int __init i2c_ali1535_init(void)
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-i2c SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = ali1535_access,
|
||||
.functionality = ali1535_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter ali1535_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI1535,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id ali1535_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-ali1535.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
#ifdef DEBUG
|
||||
/* PE- It might be good to make this a permanent part of the code! */
|
||||
if (ali1535_initialized) {
|
||||
printk
|
||||
("i2c-ali1535.o: Oops, ali1535_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
ali1535_initialized = 0;
|
||||
if ((res = ali1535_setup())) {
|
||||
if (ali1535_setup()) {
|
||||
printk
|
||||
("i2c-ali1535.o: ALI1535 not detected, module not inserted.\n");
|
||||
ali1535_cleanup();
|
||||
return res;
|
||||
return -ENODEV;
|
||||
}
|
||||
ali1535_initialized++;
|
||||
|
||||
sprintf(ali1535_adapter.name, "SMBus ALI1535 adapter at %04x",
|
||||
ali1535_smba);
|
||||
if ((res = i2c_add_adapter(&ali1535_adapter))) {
|
||||
printk
|
||||
("i2c-ali1535.o: Adapter registration failed, module not inserted.\n");
|
||||
ali1535_cleanup();
|
||||
return res;
|
||||
}
|
||||
ali1535_initialized++;
|
||||
printk
|
||||
("i2c-ali1535.o: ALI1535 SMBus Controller detected and initialized\n");
|
||||
return 0;
|
||||
i2c_add_adapter(&ali1535_adapter);
|
||||
}
|
||||
|
||||
int __init ali1535_cleanup(void)
|
||||
static void __devexit ali1535_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
if (ali1535_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&ali1535_adapter))) {
|
||||
printk
|
||||
("i2c-ali1535.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
} else
|
||||
ali1535_initialized--;
|
||||
}
|
||||
if (ali1535_initialized >= 1) {
|
||||
release_region(ali1535_smba, ALI1535_SMB_IOSIZE);
|
||||
ali1535_initialized--;
|
||||
}
|
||||
return 0;
|
||||
i2c_del_adapter(&ali1535_adapter);
|
||||
}
|
||||
|
||||
|
||||
static struct pci_driver ali1535_driver = {
|
||||
.name = "ali1535 smbus",
|
||||
.id_table = ali1535_ids,
|
||||
.probe = ali1535_probe,
|
||||
.remove = __devexit_p(ali1535_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_ali1535_init(void)
|
||||
{
|
||||
printk("i2c-ali1535.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&ali1535_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_ali1535_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&ali1535_driver);
|
||||
release_region(ali1535_smba, ALI1535_SMB_IOSIZE);
|
||||
}
|
||||
|
||||
#ifdef RLX
|
||||
EXPORT_SYMBOL(ali1535_smba);
|
||||
EXPORT_SYMBOL(ali1535_access);
|
||||
EXPORT_SYMBOL(i2c_ali1535_sem);
|
||||
#else
|
||||
EXPORT_NO_SYMBOLS;
|
||||
#endif
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, "
|
||||
"Mark D. Studebaker <mdsxyz123@yahoo.com> and Dan Eaton <dan.eaton@rocketlogix.com>");
|
||||
MODULE_DESCRIPTION("ALI1535 SMBus driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_ali1535_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return ali1535_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_ali1535_init);
|
||||
module_exit(i2c_ali1535_exit);
|
||||
|
||||
+51
-109
@@ -72,9 +72,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
/* ALI15X3 SMBus address offsets */
|
||||
#define SMBHSTSTS (0 + ali15x3_smba)
|
||||
@@ -135,52 +133,10 @@ MODULE_PARM(force_addr, "i");
|
||||
MODULE_PARM_DESC(force_addr,
|
||||
"Initialize the base address of the i2c controller");
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_ali15x3_init(void);
|
||||
static int __init ali15x3_cleanup(void);
|
||||
static int ali15x3_setup(void);
|
||||
static s32 ali15x3_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size,
|
||||
union i2c_smbus_data *data);
|
||||
|
||||
static void ali15x3_do_pause(unsigned int amount);
|
||||
static int ali15x3_transaction(void);
|
||||
static void ali15x3_inc(struct i2c_adapter *adapter);
|
||||
static void ali15x3_dec(struct i2c_adapter *adapter);
|
||||
static u32 ali15x3_func(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
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,
|
||||
/* functionality */ ali15x3_func,
|
||||
};
|
||||
|
||||
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 __initdata ali15x3_initialized;
|
||||
static unsigned short ali15x3_smba = 0;
|
||||
static int locked=0;
|
||||
|
||||
@@ -558,16 +514,6 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ali15x3_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void ali15x3_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 ali15x3_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -576,74 +522,70 @@ u32 ali15x3_func(struct i2c_adapter *adapter)
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA;
|
||||
}
|
||||
|
||||
int __init i2c_ali15x3_init(void)
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-I2C SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = ali15x3_access,
|
||||
.functionality = ali15x3_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter ali15x3_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static struct pci_device_id ali15x3_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-ali15x3.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
#ifdef DEBUG
|
||||
/* PE- It might be good to make this a permanent part of the code! */
|
||||
if (ali15x3_initialized) {
|
||||
printk
|
||||
("i2c-ali15x3.o: Oops, ali15x3_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
ali15x3_initialized = 0;
|
||||
if ((res = ali15x3_setup())) {
|
||||
if (ali15x3_setup()) {
|
||||
printk
|
||||
("i2c-ali15x3.o: ALI15X3 not detected, module not inserted.\n");
|
||||
ali15x3_cleanup();
|
||||
return res;
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
ali15x3_initialized++;
|
||||
|
||||
sprintf(ali15x3_adapter.name, "SMBus ALI15X3 adapter at %04x",
|
||||
ali15x3_smba);
|
||||
if ((res = i2c_add_adapter(&ali15x3_adapter))) {
|
||||
printk
|
||||
("i2c-ali15x3.o: Adapter registration failed, module not inserted.\n");
|
||||
ali15x3_cleanup();
|
||||
return res;
|
||||
}
|
||||
ali15x3_initialized++;
|
||||
printk
|
||||
("i2c-ali15x3.o: ALI15X3 SMBus Controller detected and initialized\n");
|
||||
return 0;
|
||||
i2c_add_adapter(&ali15x3_adapter);
|
||||
}
|
||||
|
||||
int __init ali15x3_cleanup(void)
|
||||
static void __devexit ali15x3_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
if (ali15x3_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&ali15x3_adapter))) {
|
||||
printk
|
||||
("i2c-ali15x3.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
} else
|
||||
ali15x3_initialized--;
|
||||
}
|
||||
if (ali15x3_initialized >= 1) {
|
||||
release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE);
|
||||
ali15x3_initialized--;
|
||||
}
|
||||
return 0;
|
||||
i2c_del_adapter(&ali15x3_adapter);
|
||||
}
|
||||
|
||||
static struct pci_driver ali15x3_driver = {
|
||||
.name = "ali15x3 smbus",
|
||||
.id_table = ali15x3_ids,
|
||||
.probe = ali15x3_probe,
|
||||
.remove = __devexit_p(ali15x3_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_ali15x3_init(void)
|
||||
{
|
||||
printk("i2c-ali15x3.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&ali15x3_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_ali15x3_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&ali15x3_driver);
|
||||
release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("ALI15X3 SMBus driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_ali15x3_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return ali15x3_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_ali15x3_init);
|
||||
module_exit(i2c_ali15x3_exit);
|
||||
@@ -203,6 +203,7 @@ static int amd756_transaction(void)
|
||||
}
|
||||
|
||||
/* Return -1 on error. */
|
||||
|
||||
static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size, union i2c_smbus_data * data)
|
||||
@@ -297,17 +298,6 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void amd756_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void amd756_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
static u32 amd756_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
|
||||
@@ -323,11 +313,10 @@ static struct i2c_algorithm smbus_algorithm = {
|
||||
};
|
||||
|
||||
static struct i2c_adapter amd756_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756,
|
||||
.algo = &smbus_algorithm,
|
||||
.inc_use = amd756_inc,
|
||||
.dec_use = amd756_dec,
|
||||
};
|
||||
|
||||
enum chiptype { AMD756, AMD766, AMD768, NFORCE };
|
||||
@@ -405,10 +394,10 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static void __devexit amd756_remove(struct pci_dev *dev)
|
||||
{
|
||||
i2c_del_adapter(&amd756_adapter);
|
||||
release_region(amd756_ioport, SMB_IOSIZE);
|
||||
}
|
||||
|
||||
static struct pci_driver amd756_driver = {
|
||||
@@ -418,20 +407,22 @@ static struct pci_driver amd756_driver = {
|
||||
.remove = __devexit_p(amd756_remove),
|
||||
};
|
||||
|
||||
static int __init amd756_init(void)
|
||||
static int __init i2c_amd756_init(void)
|
||||
{
|
||||
printk(KERN_INFO "i2c-amd756.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&amd756_driver);
|
||||
}
|
||||
|
||||
static void __exit amd756_exit(void)
|
||||
|
||||
static void __exit i2c_amd756_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&amd756_driver);
|
||||
release_region(amd756_ioport, SMB_IOSIZE);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Merlin Hughes <merlin@merlin.org>");
|
||||
MODULE_DESCRIPTION("AMD756/766/768/nVidia nForce SMBus driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(amd756_init)
|
||||
module_exit(amd756_exit)
|
||||
module_init(i2c_amd756_init)
|
||||
module_exit(i2c_amd756_exit)
|
||||
+21
-29
@@ -320,15 +320,6 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void amd8111_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void amd8111_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 amd8111_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -345,9 +336,16 @@ static struct i2c_algorithm smbus_algorithm = {
|
||||
.functionality = amd8111_func,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id amd8111_ids[] __devinitdata = {
|
||||
{ 0x1022, 0x746a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
struct amd_smbus *smbus;
|
||||
int error;
|
||||
|
||||
if (~pci_resource_flags(dev, 0) & IORESOURCE_IO)
|
||||
return -1;
|
||||
@@ -366,14 +364,14 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
|
||||
return -1;
|
||||
}
|
||||
|
||||
smbus->adapter.owner = THIS_MODULE;
|
||||
sprintf(smbus->adapter.name, "SMBus2 AMD8111 adapter at %04x", smbus->base);
|
||||
smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111;
|
||||
smbus->adapter.algo = &smbus_algorithm;
|
||||
smbus->adapter.algo_data = smbus;
|
||||
smbus->adapter.inc_use = amd8111_inc;
|
||||
smbus->adapter.dec_use = amd8111_dec;
|
||||
|
||||
if (i2c_add_adapter(&smbus->adapter)) {
|
||||
error = i2c_add_adapter(&smbus->adapter);
|
||||
if (error) {
|
||||
printk(KERN_WARNING "i2c-amd8111.c: Failed to register adapter.\n");
|
||||
release_region(smbus->base, smbus->size);
|
||||
kfree(smbus);
|
||||
@@ -386,39 +384,33 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void __devexit amd8111_remove(struct pci_dev *dev)
|
||||
{
|
||||
struct amd_smbus *smbus = (void*) pci_get_drvdata(dev);
|
||||
if (i2c_del_adapter(&smbus->adapter)) {
|
||||
printk(KERN_WARNING "i2c-amd8111.c: Failed to unregister adapter.\n");
|
||||
return;
|
||||
}
|
||||
i2c_del_adapter(&smbus->adapter);
|
||||
release_region(smbus->base, smbus->size);
|
||||
kfree(smbus);
|
||||
}
|
||||
|
||||
static struct pci_device_id amd8111_id_table[] __devinitdata =
|
||||
{{ 0x1022, 0x746a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
|
||||
{ 0 }};
|
||||
|
||||
|
||||
static struct pci_driver amd8111_driver = {
|
||||
.name = "amd8111 smbus 2.0",
|
||||
.id_table = amd8111_id_table,
|
||||
.probe = amd8111_probe,
|
||||
.remove = __devexit_p(amd8111_remove),
|
||||
.name = "amd8111 smbus 2.0",
|
||||
.id_table = amd8111_ids,
|
||||
.probe = amd8111_probe,
|
||||
.remove = __devexit_p(amd8111_remove),
|
||||
};
|
||||
|
||||
int __init amd8111_init(void)
|
||||
static int __init i2c_amd8111_init(void)
|
||||
{
|
||||
printk(KERN_INFO "i2c-amd8111.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&amd8111_driver);
|
||||
}
|
||||
|
||||
void __exit amd8111_exit(void)
|
||||
|
||||
static void __exit i2c_amd8111_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&amd8111_driver);
|
||||
}
|
||||
|
||||
module_init(amd8111_init);
|
||||
module_exit(amd8111_exit);
|
||||
module_init(i2c_amd8111_init);
|
||||
module_exit(i2c_amd8111_exit);
|
||||
+50
-84
@@ -35,13 +35,8 @@
|
||||
#include <linux/i2c-algo-bit.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
/* PCI device */
|
||||
#define VENDOR PCI_VENDOR_ID_APPLE
|
||||
#define DEVICE PCI_DEVICE_ID_APPLE_HYDRA
|
||||
|
||||
#define HYDRA_CACHE_PD 0x00000030
|
||||
|
||||
@@ -104,105 +99,76 @@ static int bit_hydra_getsda(void *data)
|
||||
return (pdregr() & HYDRA_SDAT) != 0;
|
||||
}
|
||||
|
||||
static void bit_hydra_inc(struct i2c_adapter *adap)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
static void bit_hydra_dec(struct i2c_adapter *adap)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static struct i2c_algo_bit_data bit_hydra_data = {
|
||||
NULL,
|
||||
bit_hydra_setsda,
|
||||
bit_hydra_setscl,
|
||||
bit_hydra_getsda,
|
||||
bit_hydra_getscl,
|
||||
5, 5, 100, /*waits, timeout */
|
||||
.setsda = bit_hydra_setsda,
|
||||
.setscl = bit_hydra_setscl,
|
||||
.getsda = bit_hydra_getsda,
|
||||
.getscl = bit_hydra_getscl,
|
||||
.udelay = 5,
|
||||
.mdelay = 5,
|
||||
.timeout = HZ
|
||||
};
|
||||
|
||||
static struct i2c_adapter bit_hydra_ops = {
|
||||
"Hydra i2c",
|
||||
I2C_HW_B_HYDRA,
|
||||
NULL,
|
||||
&bit_hydra_data,
|
||||
bit_hydra_inc,
|
||||
bit_hydra_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
.owner = THIS_MODULE,
|
||||
.name = "Hydra i2c",
|
||||
.id = I2C_HW_B_HYDRA,
|
||||
.algo_data = &bit_hydra_data,
|
||||
};
|
||||
|
||||
|
||||
static int find_hydra(void)
|
||||
/* PCI device */
|
||||
#define VENDOR PCI_VENDOR_ID_APPLE
|
||||
#define DEVICE PCI_DEVICE_ID_APPLE_HYDRA
|
||||
|
||||
static struct pci_device_id hydra_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit hydra_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
unsigned int base_addr;
|
||||
|
||||
if (!pci_present())
|
||||
return -ENODEV;
|
||||
|
||||
dev = pci_find_device(VENDOR, DEVICE, NULL);
|
||||
if (!dev) {
|
||||
printk("Hydra not found\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
|
||||
base_addr = dev->resource[0].start;
|
||||
#else
|
||||
base_addr = dev->base_address[0];
|
||||
#endif
|
||||
hydra_base = (unsigned long) ioremap(base_addr, 0x100);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_hydra_init(void)
|
||||
{
|
||||
if (find_hydra() < 0) {
|
||||
printk("Error while reading PCI configuration\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
pdregw(0); /* clear SCLK_OE and SDAT_OE */
|
||||
|
||||
if (i2c_bit_add_bus(&bit_hydra_ops) == 0) {
|
||||
printk("Hydra i2c: Module succesfully loaded\n");
|
||||
return 0;
|
||||
} else {
|
||||
iounmap((void *) hydra_base);
|
||||
printk
|
||||
("Hydra i2c: Algo-bit error, couldn't register bus\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
return i2c_bit_add_bus(&bit_hydra_ops);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
static void __devexit hydra_remove(struct pci_dev *dev)
|
||||
{
|
||||
pdregw(0); /* clear SCLK_OE and SDAT_OE */
|
||||
i2c_bit_del_bus(&bit_hydra_ops);
|
||||
}
|
||||
|
||||
|
||||
static struct pci_driver hydra_driver = {
|
||||
.name = "hydra smbus",
|
||||
.id_table = hydra_ids,
|
||||
.probe = hydra_probe,
|
||||
.remove = __devexit_p(hydra_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_hydra_init(void)
|
||||
{
|
||||
return pci_module_init(&hydra_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_hydra_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&hydra_driver);
|
||||
iounmap((void *) hydra_base);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MODULE
|
||||
MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>");
|
||||
MODULE_DESCRIPTION("i2c for Apple Hydra Mac I/O");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_hydra_init();
|
||||
}
|
||||
module_init(i2c_hydra_init);
|
||||
module_exit(i2c_hydra_exit);
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
i2c_bit_del_bus(&bit_hydra_ops);
|
||||
if (hydra_base) {
|
||||
pdregw(0); /* clear SCLK_OE and SDAT_OE */
|
||||
iounmap((void *) hydra_base);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+54
-103
@@ -51,9 +51,7 @@
|
||||
#include <linux/i2c.h>
|
||||
#include "version.h"
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
#ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC
|
||||
#define HAVE_PEC
|
||||
@@ -127,53 +125,18 @@ MODULE_PARM_DESC(force_addr,
|
||||
"Forcibly enable the I801 at the given address. "
|
||||
"EXTREMELY DANGEROUS!");
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_i801_init(void);
|
||||
static int __init i801_cleanup(void);
|
||||
static int i801_setup(void);
|
||||
static s32 i801_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size, union i2c_smbus_data *data);
|
||||
|
||||
|
||||
|
||||
|
||||
static void i801_do_pause(unsigned int amount);
|
||||
static int i801_transaction(void);
|
||||
static int i801_block_transaction(union i2c_smbus_data *data,
|
||||
char read_write, int command);
|
||||
static void i801_inc(struct i2c_adapter *adapter);
|
||||
static void i801_dec(struct i2c_adapter *adapter);
|
||||
static u32 i801_func(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
/* name */ "Non-I2C SMBus adapter",
|
||||
/* id */ I2C_ALGO_SMBUS,
|
||||
/* master_xfer */ NULL,
|
||||
/* smbus_xfer */ i801_access,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
/* functionality */ i801_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter i801_adapter = {
|
||||
"unset",
|
||||
I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801,
|
||||
&smbus_algorithm,
|
||||
NULL,
|
||||
i801_inc,
|
||||
i801_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int __initdata i801_initialized;
|
||||
static unsigned short i801_smba = 0;
|
||||
static struct pci_dev *I801_dev = NULL;
|
||||
static int isich4 = 0;
|
||||
@@ -670,15 +633,6 @@ s32 i801_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void i801_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void i801_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 i801_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -693,73 +647,70 @@ u32 i801_func(struct i2c_adapter *adapter)
|
||||
;
|
||||
}
|
||||
|
||||
int __init i2c_i801_init(void)
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-I2C SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = i801_access,
|
||||
.functionality = i801_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter i801_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static struct pci_device_id i801_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
int res;
|
||||
printk(KERN_INFO "i2c-i801.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
#ifdef DEBUG
|
||||
/* PE- It might be good to make this a permanent part of the code! */
|
||||
if (i801_initialized) {
|
||||
printk
|
||||
(KERN_DEBUG "i2c-i801.o: Oops, i801_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
i801_initialized = 0;
|
||||
if ((res = i801_setup())) {
|
||||
|
||||
if (i801_setup()) {
|
||||
printk
|
||||
(KERN_WARNING "i2c-i801.o: I801 not detected, module not inserted.\n");
|
||||
i801_cleanup();
|
||||
return res;
|
||||
return -ENODEV;
|
||||
}
|
||||
i801_initialized++;
|
||||
|
||||
sprintf(i801_adapter.name, "SMBus I801 adapter at %04x",
|
||||
i801_smba);
|
||||
if ((res = i2c_add_adapter(&i801_adapter))) {
|
||||
printk
|
||||
(KERN_ERR "i2c-i801.o: Adapter registration failed, module not inserted.\n");
|
||||
i801_cleanup();
|
||||
return res;
|
||||
}
|
||||
i801_initialized++;
|
||||
printk(KERN_INFO "i2c-i801.o: I801 bus detected and initialized\n");
|
||||
return 0;
|
||||
i2c_add_adapter(&i801_adapter);
|
||||
}
|
||||
|
||||
int __init i801_cleanup(void)
|
||||
static void __devexit i801_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
if (i801_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&i801_adapter))) {
|
||||
printk
|
||||
(KERN_ERR "i2c-i801.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
} else
|
||||
i801_initialized--;
|
||||
}
|
||||
if (i801_initialized >= 1) {
|
||||
release_region(i801_smba, (isich4 ? 16 : 8));
|
||||
i801_initialized--;
|
||||
}
|
||||
return 0;
|
||||
i2c_del_adapter(&i801_adapter);
|
||||
}
|
||||
|
||||
static struct pci_driver i801_driver = {
|
||||
.name = "i801 smbus",
|
||||
.id_table = i801_ids,
|
||||
.probe = i801_probe,
|
||||
.remove = __devexit_p(i801_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_i801_init(void)
|
||||
{
|
||||
printk(KERN_INFO "i2c-i801.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&i801_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_i801_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&i801_driver);
|
||||
release_region(i801_smba, (isich4 ? 16 : 8));
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("I801 SMBus driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_i801_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return i801_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_i801_init);
|
||||
module_exit(i2c_i801_exit);
|
||||
+64
-147
@@ -44,9 +44,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
/* PCI defines */
|
||||
#ifndef PCI_DEVICE_ID_INTEL_82810_IG1
|
||||
@@ -93,24 +91,10 @@ static int i810_supported[] = {PCI_DEVICE_ID_INTEL_82810_IG1,
|
||||
#define CYCLE_DELAY 10
|
||||
#define TIMEOUT (HZ / 2)
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_i810_init(void);
|
||||
static int __init i810i2c_cleanup(void);
|
||||
static int i810i2c_setup(void);
|
||||
|
||||
static void config_i810(struct pci_dev *dev);
|
||||
static void i810_inc(struct i2c_adapter *adapter);
|
||||
static void i810_dec(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
static int __initdata i810i2c_initialized;
|
||||
static unsigned char *mem;
|
||||
|
||||
static inline void outlong(unsigned int dat, int off)
|
||||
@@ -192,46 +176,6 @@ static int bit_i810ddc_getsda(void *data)
|
||||
return (0 != (readlong(I810_GPIOA) & SDA_VAL_IN));
|
||||
}
|
||||
|
||||
static struct i2c_algo_bit_data i810_i2c_bit_data = {
|
||||
NULL,
|
||||
bit_i810i2c_setsda,
|
||||
bit_i810i2c_setscl,
|
||||
bit_i810i2c_getsda,
|
||||
bit_i810i2c_getscl,
|
||||
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter i810_i2c_adapter = {
|
||||
"I810/I815 I2C Adapter",
|
||||
I2C_HW_B_I810,
|
||||
NULL,
|
||||
&i810_i2c_bit_data,
|
||||
i810_inc,
|
||||
i810_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct i2c_algo_bit_data i810_ddc_bit_data = {
|
||||
NULL,
|
||||
bit_i810ddc_setsda,
|
||||
bit_i810ddc_setscl,
|
||||
bit_i810ddc_getsda,
|
||||
bit_i810ddc_getscl,
|
||||
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter i810_ddc_adapter = {
|
||||
"I810/I815 DDC Adapter",
|
||||
I2C_HW_B_I810,
|
||||
NULL,
|
||||
&i810_ddc_bit_data,
|
||||
i810_inc,
|
||||
i810_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
/* Configures the chip */
|
||||
void config_i810(struct pci_dev *dev)
|
||||
@@ -239,11 +183,7 @@ void config_i810(struct pci_dev *dev)
|
||||
unsigned long cadr;
|
||||
|
||||
/* map I810 memory */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
|
||||
cadr = dev->resource[1].start;
|
||||
#else
|
||||
cadr = dev->base_address[1];
|
||||
#endif
|
||||
cadr += I810_IOCONTROL_OFFSET;
|
||||
cadr &= PCI_BASE_ADDRESS_MEM_MASK;
|
||||
mem = ioremap_nocache(cadr, 0x1000);
|
||||
@@ -255,110 +195,87 @@ void config_i810(struct pci_dev *dev)
|
||||
}
|
||||
}
|
||||
|
||||
/* Detect whether a supported device can be found,
|
||||
and initialize it */
|
||||
static int i810i2c_setup(void)
|
||||
|
||||
static struct i2c_algo_bit_data i810_i2c_bit_data = {
|
||||
.setsda = bit_i810i2c_setsda,
|
||||
.setscl = bit_i810i2c_setscl,
|
||||
.getsda = bit_i810i2c_getsda,
|
||||
.getscl = bit_i810i2c_getscl,
|
||||
.udelay = CYCLE_DELAY,
|
||||
.mdelay = CYCLE_DELAY,
|
||||
.timeout = TIMEOUT,
|
||||
};
|
||||
|
||||
static struct i2c_adapter i810_i2c_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "I810/I815 I2C Adapter",
|
||||
.id = I2C_HW_B_I810,
|
||||
.algo_data = &i810_i2c_bit_data,
|
||||
};
|
||||
|
||||
static struct i2c_algo_bit_data i810_ddc_bit_data = {
|
||||
.setsda = bit_i810ddc_setsda,
|
||||
.setscl = bit_i810ddc_setscl,
|
||||
.getsda = bit_i810ddc_getsda,
|
||||
.getscl = bit_i810ddc_getscl,
|
||||
.udelay = CYCLE_DELAY,
|
||||
.mdelay = CYCLE_DELAY,
|
||||
.timeout = TIMEOUT,
|
||||
};
|
||||
|
||||
static struct i2c_adapter i810_ddc_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "I810/I815 DDC Adapter",
|
||||
.id = I2C_HW_B_I810,
|
||||
.algo_data = &i810_ddc_bit_data,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id i810_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit i810_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
struct pci_dev *dev = NULL;
|
||||
int *num = i810_supported;
|
||||
config_i810(dev);
|
||||
printk("i2c-i810.o: i810/i815 found.\n");
|
||||
|
||||
do {
|
||||
if ((dev = pci_find_device(PCI_VENDOR_ID_INTEL,
|
||||
*num++, dev))) {
|
||||
config_i810(dev);
|
||||
if(!mem)
|
||||
return -ENOMEM;
|
||||
printk("i2c-i810.o: i810/i815 found.\n");
|
||||
return 0;
|
||||
}
|
||||
} while (*num != 0);
|
||||
i2c_bit_add_bus(&i810_i2c_adapter);
|
||||
i2c_bit_add_bus(&i810_ddc_adapter);
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
static void __devexit i810_remove(struct pci_dev *dev)
|
||||
{
|
||||
i2c_bit_del_bus(&i810_ddc_adapter);
|
||||
i2c_bit_del_bus(&i810_i2c_adapter);
|
||||
}
|
||||
|
||||
|
||||
void i810_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
static struct pci_driver i810_driver = {
|
||||
.name = "i810 smbus",
|
||||
.id_table = i810_ids,
|
||||
.probe = i810_probe,
|
||||
.remove = __devexit_p(i810_remove),
|
||||
};
|
||||
|
||||
void i810_dec(struct i2c_adapter *adapter)
|
||||
static int __init i2c_i810_init(void)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
int __init i2c_i810_init(void)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-i810.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
|
||||
i810i2c_initialized = 0;
|
||||
if ((res = i810i2c_setup())) {
|
||||
printk
|
||||
("i2c-i810.o: i810/i815 not detected, module not inserted.\n");
|
||||
i810i2c_cleanup();
|
||||
return res;
|
||||
}
|
||||
if ((res = i2c_bit_add_bus(&i810_i2c_adapter))) {
|
||||
printk("i2c-i810.o: I2C adapter registration failed\n");
|
||||
} else {
|
||||
printk("i2c-i810.o: I810/I815 I2C bus initialized\n");
|
||||
i810i2c_initialized |= INIT2;
|
||||
}
|
||||
if ((res = i2c_bit_add_bus(&i810_ddc_adapter))) {
|
||||
printk("i2c-i810.o: DDC adapter registration failed\n");
|
||||
} else {
|
||||
printk("i2c-i810.o: I810/I815 DDC bus initialized\n");
|
||||
i810i2c_initialized |= INIT3;
|
||||
}
|
||||
if(!(i810i2c_initialized & (INIT2 | INIT3))) {
|
||||
printk("i2c-i810.o: Both registrations failed, module not inserted\n");
|
||||
i810i2c_cleanup();
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
return pci_module_init(&i810_driver);
|
||||
}
|
||||
|
||||
int __init i810i2c_cleanup(void)
|
||||
|
||||
static void __exit i2c_i810_exit(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
pci_unregister_driver(&i810_driver);
|
||||
iounmap(mem);
|
||||
if (i810i2c_initialized & INIT3) {
|
||||
if ((res = i2c_bit_del_bus(&i810_ddc_adapter))) {
|
||||
printk
|
||||
("i2c-i810.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
if (i810i2c_initialized & INIT2) {
|
||||
if ((res = i2c_bit_del_bus(&i810_i2c_adapter))) {
|
||||
printk
|
||||
("i2c-i810.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
i810i2c_initialized = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, Ralph Metzler <rjkm@thp.uni-koeln.de>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("I810/I815 I2C/DDC driver");
|
||||
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_i810_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return i810i2c_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_i810_init);
|
||||
module_exit(i2c_i810_exit);
|
||||
@@ -30,51 +30,21 @@
|
||||
#include <linux/ipmi.h>
|
||||
#include "version.h"
|
||||
|
||||
static void i2c_ipmb_inc_use(struct i2c_adapter *adapter);
|
||||
static void i2c_ipmb_dec_use(struct i2c_adapter *adapter);
|
||||
static u32 i2c_ipmb_func(struct i2c_adapter *adapter);
|
||||
|
||||
int ipmb_access(struct i2c_adapter *adap,struct i2c_msg msgs[],
|
||||
int num);
|
||||
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_ipmb_init(void);
|
||||
static int __init i2c_ipmb_cleanup(void);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
/* I2C Data */
|
||||
static struct i2c_algorithm i2c_ipmb_algorithm = {
|
||||
.name = "IPMB algorithm",
|
||||
.id = I2C_ALGO_IPMB,
|
||||
.master_xfer = ipmb_access,
|
||||
.smbus_xfer = NULL,
|
||||
.slave_send = NULL,
|
||||
.slave_recv = NULL,
|
||||
.algo_control = NULL,
|
||||
.functionality = i2c_ipmb_func,
|
||||
};
|
||||
|
||||
#define MAX_IPMB_ADAPTERS 8
|
||||
static struct i2c_adapter i2c_ipmb_adapter[MAX_IPMB_ADAPTERS];
|
||||
/*
|
||||
static struct i2c_adapter i2c_ipmb_adapter = {
|
||||
.name = "IPMB adapter",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_IPMB,
|
||||
.algo = &i2c_ipmb_algorithm,
|
||||
.algo_data = NULL,
|
||||
.inc_use = &i2c_ipmb_inc_use,
|
||||
.dec_use = &i2c_ipmb_dec_use,
|
||||
.data = NULL,
|
||||
};
|
||||
*/
|
||||
|
||||
/* IPMI Data */
|
||||
#define IPMI_IPMB_CHANNEL 0
|
||||
@@ -240,7 +210,8 @@ static void ipmb_rcv_channel_info(struct ipmi_msg *msg)
|
||||
channel, type, protocol);
|
||||
}
|
||||
/*
|
||||
if ((rv = i2c_add_adapter(&i2c_ipmb_adapter))) {
|
||||
return i2c_add_adapter(&i2c_ipmb_adapter);
|
||||
if (error) {
|
||||
printk(KERN_ERR "i2c-ipmb.o: Adapter registration failed, "
|
||||
"module i2c-ipmb.o is not inserted\n.");
|
||||
return;
|
||||
@@ -311,20 +282,6 @@ int ipmb_access(struct i2c_adapter *adap,struct i2c_msg msgs[],
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void i2c_ipmb_inc_use(struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void i2c_ipmb_dec_use(struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
static u32 i2c_ipmb_func(struct i2c_adapter *adapter)
|
||||
@@ -385,7 +342,7 @@ static struct ipmi_smi_watcher smi_watcher =
|
||||
.smi_gone = ipmb_smi_gone
|
||||
};
|
||||
|
||||
int __init i2c_ipmb_init(void)
|
||||
static int __init i2c_ipmb_init(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
@@ -402,28 +359,16 @@ int __init i2c_ipmb_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init ipmi_cleanup(void)
|
||||
|
||||
static void __exit i2c_ipmi_exit(void)
|
||||
{
|
||||
ipmi_smi_watcher_unregister(&smi_watcher);
|
||||
ipmb_smi_gone(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef MODULE
|
||||
MODULE_AUTHOR("M. D. Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("IPMB-BMC access through i2c");
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_ipmb_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return ipmi_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_ipmb_init);
|
||||
module_exit(i2c_ipmi_exit);
|
||||
+15
-63
@@ -30,45 +30,22 @@
|
||||
#include <linux/ipmi.h>
|
||||
#include "version.h"
|
||||
|
||||
static void i2c_ipmi_inc_use(struct i2c_adapter *adapter);
|
||||
static void i2c_ipmi_dec_use(struct i2c_adapter *adapter);
|
||||
static u32 i2c_ipmi_func(struct i2c_adapter *adapter);
|
||||
|
||||
static int bmcclient_i2c_send_message(struct i2c_adapter *, char *, int);
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_ipmi_init(void);
|
||||
static int __init i2c_ipmi_cleanup(void);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
/* I2C Data */
|
||||
static struct i2c_algorithm i2c_ipmi_algorithm = {
|
||||
.name = "IPMI algorithm",
|
||||
.id = I2C_ALGO_IPMI,
|
||||
.master_xfer = NULL,
|
||||
.smbus_xfer = NULL,
|
||||
.slave_send = &bmcclient_i2c_send_message,
|
||||
.slave_recv = NULL,
|
||||
.algo_control = NULL,
|
||||
.functionality = &i2c_ipmi_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter i2c_ipmi_adapter = {
|
||||
.name = "IPMI adapter",
|
||||
.id = I2C_ALGO_IPMI | I2C_HW_IPMI,
|
||||
.algo = &i2c_ipmi_algorithm,
|
||||
.algo_data = NULL,
|
||||
.inc_use = &i2c_ipmi_inc_use,
|
||||
.dec_use = &i2c_ipmi_dec_use,
|
||||
.data = NULL,
|
||||
/* Other fields not initialized */
|
||||
.owner = THIS_MODULE,
|
||||
.name = "IPMI adapter",
|
||||
.id = I2C_ALGO_IPMI | I2C_HW_IPMI,
|
||||
.algo = &i2c_ipmi_algorithm,
|
||||
};
|
||||
|
||||
/* IPMI Data */
|
||||
@@ -87,19 +64,6 @@ static int interfaces; /* number of BMC's found */
|
||||
static int (*rcv_callback)(struct i2c_client *client, unsigned int cmd,
|
||||
void *arg);
|
||||
|
||||
void i2c_ipmi_inc_use(struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void i2c_ipmi_dec_use(struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Dummy adapter... */
|
||||
static u32 i2c_ipmi_func(struct i2c_adapter *adapter)
|
||||
@@ -189,8 +153,7 @@ static struct ipmi_user_hndl ipmi_hndlrs =
|
||||
/* callback for each BMC found */
|
||||
static void ipmi_register_bmc(int ipmi_intf)
|
||||
{
|
||||
unsigned long flags;
|
||||
int rv;
|
||||
int error;
|
||||
|
||||
if(interfaces > 0) { /* 1 max for now */
|
||||
printk(KERN_INFO
|
||||
@@ -199,13 +162,14 @@ static void ipmi_register_bmc(int ipmi_intf)
|
||||
return;
|
||||
}
|
||||
|
||||
rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &i2c_ipmi_user);
|
||||
if (rv < 0) {
|
||||
error = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &i2c_ipmi_user);
|
||||
if (error < 0) {
|
||||
printk(KERN_ERR "i2c-ipmi.o: Unable to register with ipmi\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((rv = i2c_add_adapter(&i2c_ipmi_adapter))) {
|
||||
return i2c_add_adapter(&i2c_ipmi_adapter);
|
||||
if (error) {
|
||||
printk(KERN_ERR "i2c-ipmi.o: Adapter registration failed, "
|
||||
"module i2c-ipmi.o is not inserted\n.");
|
||||
return;
|
||||
@@ -239,7 +203,7 @@ static struct ipmi_smi_watcher smi_watcher =
|
||||
.smi_gone = ipmi_smi_gone
|
||||
};
|
||||
|
||||
int __init i2c_ipmi_init(void)
|
||||
static int __init i2c_ipmi_init(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
@@ -256,28 +220,16 @@ int __init i2c_ipmi_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init ipmi_cleanup(void)
|
||||
|
||||
static void __exit i2c_ipmi_exit(void)
|
||||
{
|
||||
ipmi_smi_watcher_unregister(&smi_watcher);
|
||||
ipmi_smi_gone(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef MODULE
|
||||
MODULE_AUTHOR("M. D. Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("IPMI-BMC access through i2c");
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_ipmi_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return ipmi_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_ipmi_init);
|
||||
module_exit(i2c_ipmi_exit);
|
||||
+22
-102
@@ -31,67 +31,8 @@
|
||||
#include <linux/init.h>
|
||||
#include "version.h"
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
static void isa_inc_use(struct i2c_adapter *adapter);
|
||||
static void isa_dec_use(struct i2c_adapter *adapter);
|
||||
static u32 isa_func(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_isa_init(void);
|
||||
static int __init isa_cleanup(void);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
/* This is the actual algorithm we define */
|
||||
static struct i2c_algorithm isa_algorithm = {
|
||||
/* name */ "ISA bus algorithm",
|
||||
/* id */ I2C_ALGO_ISA,
|
||||
/* master_xfer */ NULL,
|
||||
/* smbus_access */ NULL,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
/* functionality */ &isa_func,
|
||||
};
|
||||
|
||||
/* There can only be one... */
|
||||
static struct i2c_adapter isa_adapter = {
|
||||
/* name */ "ISA main adapter",
|
||||
/* id */ I2C_ALGO_ISA | I2C_HW_ISA,
|
||||
/* algorithm */ &isa_algorithm,
|
||||
/* algo_data */ NULL,
|
||||
/* inc_use */ &isa_inc_use,
|
||||
/* dec_use */ &isa_dec_use,
|
||||
/* data */ NULL,
|
||||
/* Other fields not initialized */
|
||||
};
|
||||
|
||||
/* Used in isa_init/cleanup */
|
||||
static int __initdata isa_initialized;
|
||||
|
||||
void isa_inc_use(struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_INC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void isa_dec_use(struct i2c_adapter *adapter)
|
||||
{
|
||||
#ifdef MODULE
|
||||
MOD_DEC_USE_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We can't do a thing... */
|
||||
static u32 isa_func(struct i2c_adapter *adapter)
|
||||
@@ -99,58 +40,37 @@ static u32 isa_func(struct i2c_adapter *adapter)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init i2c_isa_init(void)
|
||||
/* This is the actual algorithm we define */
|
||||
static struct i2c_algorithm isa_algorithm = {
|
||||
.name = "ISA bus algorithm",
|
||||
.id = I2C_ALGO_ISA,
|
||||
.functionality = isa_func,
|
||||
};
|
||||
|
||||
/* There can only be one... */
|
||||
static struct i2c_adapter isa_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "ISA main adapter",
|
||||
.id = I2C_ALGO_ISA | I2C_HW_ISA,
|
||||
.algo = &isa_algorithm,
|
||||
};
|
||||
|
||||
static int __init i2c_isa_init(void)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-isa.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
#ifdef DEBUG
|
||||
if (isa_initialized) {
|
||||
printk
|
||||
("i2c-isa.o: Oops, isa_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
isa_initialized = 0;
|
||||
if ((res = i2c_add_adapter(&isa_adapter))) {
|
||||
printk("i2c-isa.o: Adapter registration failed, "
|
||||
"module i2c-isa.o is not inserted\n.");
|
||||
isa_cleanup();
|
||||
return res;
|
||||
}
|
||||
isa_initialized++;
|
||||
printk("i2c-isa.o: ISA bus access for i2c modules initialized.\n");
|
||||
return 0;
|
||||
return i2c_add_adapter(&isa_adapter);
|
||||
}
|
||||
|
||||
int __init isa_cleanup(void)
|
||||
|
||||
static void __exit i2c_isa_exit(void)
|
||||
{
|
||||
int res;
|
||||
if (isa_initialized >= 1) {
|
||||
if ((res = i2c_del_adapter(&isa_adapter))) {
|
||||
printk
|
||||
("i2c-isa.o: Adapter deregistration failed, module not removed.\n");
|
||||
return res;
|
||||
} else
|
||||
isa_initialized--;
|
||||
}
|
||||
return 0;
|
||||
i2c_del_adapter(&isa_adapter);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
|
||||
MODULE_DESCRIPTION("ISA bus access through i2c");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_isa_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return isa_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_isa_init);
|
||||
module_exit(i2c_isa_exit);
|
||||
+23
-38
@@ -76,7 +76,7 @@ MODULE_DESCRIPTION("I2C driver for Apple's Keywest");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_PARM(probe, "i");
|
||||
MODULE_PARM(debug, "i");
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
|
||||
int probe = 0;
|
||||
int debug = 0;
|
||||
@@ -415,35 +415,24 @@ keywest_func(struct i2c_adapter * adapter)
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA;
|
||||
}
|
||||
|
||||
static void
|
||||
keywest_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
static void
|
||||
keywest_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
/* For now, we only handle combined mode (smbus) */
|
||||
static struct i2c_algorithm keywest_algorithm = {
|
||||
name: "Keywest i2c",
|
||||
id: I2C_ALGO_SMBUS,
|
||||
smbus_xfer: keywest_smbus_xfer,
|
||||
master_xfer: keywest_xfer,
|
||||
functionality: keywest_func,
|
||||
.name = "Keywest i2c",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = keywest_smbus_xfer,
|
||||
.master_xfer = keywest_xfer,
|
||||
.functionality = keywest_func,
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
static int __init
|
||||
create_iface(struct device_node* np)
|
||||
{
|
||||
unsigned long steps, *psteps, *prate;
|
||||
unsigned bsteps, tsize, i, nchan, addroffset;
|
||||
struct keywest_iface* iface;
|
||||
int rc;
|
||||
int error;
|
||||
|
||||
psteps = (unsigned long *)get_property(np, "AAPL,address-step", NULL);
|
||||
steps = psteps ? (*psteps) : 0x10;
|
||||
@@ -518,8 +507,8 @@ create_iface(struct device_node* np)
|
||||
write_reg(reg_isr, KW_I2C_IRQ_MASK);
|
||||
|
||||
/* Request chip interrupt */
|
||||
rc = request_irq(iface->irq, keywest_irq, 0, "keywest i2c", iface);
|
||||
if (rc) {
|
||||
error = request_irq(iface->irq, keywest_irq, 0, "keywest i2c", iface);
|
||||
if (error) {
|
||||
printk(KERN_ERR "i2c-keywest: can't get IRQ %d !\n", iface->irq);
|
||||
iounmap((void *)iface->base);
|
||||
kfree(iface);
|
||||
@@ -536,14 +525,12 @@ create_iface(struct device_node* np)
|
||||
chan->adapter.id = I2C_ALGO_SMBUS;
|
||||
chan->adapter.algo = &keywest_algorithm;
|
||||
chan->adapter.algo_data = NULL;
|
||||
chan->adapter.inc_use = keywest_inc;
|
||||
chan->adapter.dec_use = keywest_dec;
|
||||
chan->adapter.client_register = NULL;
|
||||
chan->adapter.client_unregister = NULL;
|
||||
chan->adapter.data = chan;
|
||||
|
||||
rc = i2c_add_adapter(&chan->adapter);
|
||||
if (rc) {
|
||||
error = i2c_add_adapter(&chan->adapter);
|
||||
if (error) {
|
||||
printk("i2c-keywest.c: Adapter %s registration failed\n",
|
||||
chan->adapter.name);
|
||||
chan->adapter.data = NULL;
|
||||
@@ -567,10 +554,10 @@ create_iface(struct device_node* np)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static void __exit
|
||||
dispose_iface(struct keywest_iface *iface)
|
||||
{
|
||||
int i, rc;
|
||||
int i, error;
|
||||
|
||||
ifaces = iface->next;
|
||||
|
||||
@@ -593,39 +580,37 @@ dispose_iface(struct keywest_iface *iface)
|
||||
struct keywest_chan* chan = &iface->channels[i];
|
||||
if (!chan->adapter.data)
|
||||
continue;
|
||||
rc = i2c_del_adapter(&chan->adapter);
|
||||
i2c_del_adapter(&chan->adapter);
|
||||
chan->adapter.data = NULL;
|
||||
/* We aren't that prepared to deal with this... */
|
||||
if (rc)
|
||||
if (error)
|
||||
printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
|
||||
}
|
||||
iounmap((void *)iface->base);
|
||||
kfree(iface);
|
||||
}
|
||||
|
||||
static int __init
|
||||
i2c_keywest_init(void)
|
||||
static int __init i2c_keywest_init(void)
|
||||
{
|
||||
struct device_node *np;
|
||||
int rc = -ENODEV;
|
||||
int error = -ENODEV;
|
||||
|
||||
np = find_compatible_devices("i2c", "keywest");
|
||||
while (np != 0) {
|
||||
if (np->n_addrs >= 1 && np->n_intrs >= 1)
|
||||
rc = create_iface(np);
|
||||
error = create_iface(np);
|
||||
np = np->next;
|
||||
}
|
||||
if (ifaces)
|
||||
rc = 0;
|
||||
return rc;
|
||||
error = 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
static void __exit
|
||||
i2c_keywest_cleanup(void)
|
||||
static void __exit i2c_keywest_exit(void)
|
||||
{
|
||||
while(ifaces)
|
||||
dispose_iface(ifaces);
|
||||
}
|
||||
|
||||
module_init(i2c_keywest_init);
|
||||
module_exit(i2c_keywest_cleanup);
|
||||
module_exit(i2c_keywest_exit);
|
||||
+50
-105
@@ -135,51 +135,10 @@ MODULE_PARM_DESC(force_addr,
|
||||
"Forcibly enable the PIIX4 at the given address. "
|
||||
"EXTREMELY DANGEROUS!");
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_piix4_init(void);
|
||||
static int __init piix4_cleanup(void);
|
||||
static int piix4_setup(void);
|
||||
static s32 piix4_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size, union i2c_smbus_data *data);
|
||||
static void piix4_do_pause(unsigned int amount);
|
||||
static int piix4_transaction(void);
|
||||
static void piix4_inc(struct i2c_adapter *adapter);
|
||||
static void piix4_dec(struct i2c_adapter *adapter);
|
||||
static u32 piix4_func(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
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,
|
||||
/* functionality */ piix4_func,
|
||||
};
|
||||
|
||||
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 __initdata piix4_initialized;
|
||||
static unsigned short piix4_smba = 0;
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
@@ -189,6 +148,7 @@ static unsigned short piix4_smba = 0;
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,34)
|
||||
void dmi_scan_mach(void);
|
||||
#endif
|
||||
|
||||
static int __init ibm_dmi_probe(void)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34)
|
||||
@@ -520,16 +480,6 @@ s32 piix4_access(struct i2c_adapter * adap, u16 addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void piix4_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void piix4_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 piix4_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -538,72 +488,67 @@ u32 piix4_func(struct i2c_adapter *adapter)
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA;
|
||||
}
|
||||
|
||||
int __init i2c_piix4_init(void)
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-I2C SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = piix4_access,
|
||||
.functionality = piix4_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter piix4_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static struct pci_device_id piix4_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-piix4.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
if (piix4_initialized) {
|
||||
printk
|
||||
(KERN_ERR "i2c-piix4.o: Oops, piix4_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
piix4_initialized = 0;
|
||||
if ((res = piix4_setup())) {
|
||||
printk(KERN_ERR "i2c-piix4.o: Module insertion failed.\n");
|
||||
piix4_cleanup();
|
||||
return res;
|
||||
}
|
||||
piix4_initialized++;
|
||||
|
||||
sprintf(piix4_adapter.name, "SMBus PIIX4 adapter at %04x",
|
||||
piix4_smba);
|
||||
if ((res = i2c_add_adapter(&piix4_adapter))) {
|
||||
printk
|
||||
(KERN_ERR "i2c-piix4.o: Adapter registration failed, module not inserted.\n");
|
||||
piix4_cleanup();
|
||||
return res;
|
||||
}
|
||||
piix4_initialized++;
|
||||
printk(KERN_ERR "i2c-piix4.o: SMBus detected and initialized\n");
|
||||
return 0;
|
||||
|
||||
i2c_add_adapter(&piix4_adapter);
|
||||
}
|
||||
|
||||
int __init piix4_cleanup(void)
|
||||
static void __devexit piix4_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
if (piix4_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&piix4_adapter))) {
|
||||
printk
|
||||
(KERN_ERR "i2c-piix4.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
} else
|
||||
piix4_initialized--;
|
||||
}
|
||||
if (piix4_initialized >= 1) {
|
||||
release_region(piix4_smba, 8);
|
||||
piix4_initialized--;
|
||||
}
|
||||
return 0;
|
||||
i2c_del_adapter(&piix4_adapter);
|
||||
}
|
||||
|
||||
|
||||
static struct pci_driver piix4_driver = {
|
||||
.name = "piix4 smbus",
|
||||
.id_table = piix4_ids,
|
||||
.probe = piix4_probe,
|
||||
.remove = __devexit_p(piix4_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_piix4_init(void)
|
||||
{
|
||||
printk("i2c-piix4.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&piix4_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_piix4_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&piix4_driver);
|
||||
release_region(piix4_smba, 8);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("PIIX4 SMBus driver");
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_piix4_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return piix4_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_piix4_init);
|
||||
module_exit(i2c_piix4_exit);
|
||||
+50
-205
@@ -75,33 +75,19 @@
|
||||
#define CYCLE_DELAY 10
|
||||
#define TIMEOUT (HZ / 2)
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_savage4_init(void);
|
||||
static int __init savage4_cleanup(void);
|
||||
static int savage4_setup(void);
|
||||
|
||||
static void config_s4(struct pci_dev *dev);
|
||||
static void savage4_inc(struct i2c_adapter *adapter);
|
||||
static void savage4_dec(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
|
||||
static int __initdata savage4_initialized;
|
||||
|
||||
static unsigned char *mem;
|
||||
|
||||
extern inline void outlong(unsigned int dat)
|
||||
static inline void outlong(unsigned int dat)
|
||||
{
|
||||
*((unsigned int *) (mem + REG)) = dat;
|
||||
}
|
||||
|
||||
extern inline unsigned int readlong(void)
|
||||
static inline unsigned int readlong(void)
|
||||
{
|
||||
return *((unsigned int *) (mem + REG));
|
||||
}
|
||||
@@ -147,78 +133,6 @@ static int bit_savi2c_getsda(void *data)
|
||||
return (0 != (readlong() & I2C_SDA_IN));
|
||||
}
|
||||
|
||||
/*static void bit_savddc_setscl(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
if(val)
|
||||
r |= DDC_SCL_OUT;
|
||||
else
|
||||
r &= ~DDC_SCL_OUT;
|
||||
outlong(r);
|
||||
}
|
||||
|
||||
static void bit_savddc_setsda(void *data, int val)
|
||||
{
|
||||
unsigned int r;
|
||||
r = readlong();
|
||||
if(val)
|
||||
r |= DDC_SDA_OUT;
|
||||
else
|
||||
r &= ~DDC_SDA_OUT;
|
||||
outlong(r);
|
||||
}
|
||||
|
||||
static int bit_savddc_getscl(void *data)
|
||||
{
|
||||
return (0 != (readlong() & DDC_SCL_IN));
|
||||
}
|
||||
|
||||
static int bit_savddc_getsda(void *data)
|
||||
{
|
||||
return (0 != (readlong() & DDC_SDA_IN));
|
||||
}
|
||||
*/
|
||||
static struct i2c_algo_bit_data sav_i2c_bit_data = {
|
||||
NULL,
|
||||
bit_savi2c_setsda,
|
||||
bit_savi2c_setscl,
|
||||
bit_savi2c_getsda,
|
||||
bit_savi2c_getscl,
|
||||
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter savage4_i2c_adapter = {
|
||||
"I2C Savage4 adapter",
|
||||
I2C_HW_B_SAVG,
|
||||
NULL,
|
||||
&sav_i2c_bit_data,
|
||||
savage4_inc,
|
||||
savage4_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
/*
|
||||
static struct i2c_algo_bit_data sav_ddc_bit_data = {
|
||||
NULL,
|
||||
bit_savddc_setsda,
|
||||
bit_savddc_setscl,
|
||||
bit_savddc_getsda,
|
||||
bit_savddc_getscl,
|
||||
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter savage4_ddc_adapter = {
|
||||
"DDC Voodoo3/Banshee adapter",
|
||||
I2C_HW_B_VOO,
|
||||
NULL,
|
||||
&sav_ddc_bit_data,
|
||||
savage4_inc,
|
||||
savage4_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
*/
|
||||
/* Configures the chip */
|
||||
|
||||
void config_s4(struct pci_dev *dev)
|
||||
@@ -226,11 +140,7 @@ void config_s4(struct pci_dev *dev)
|
||||
unsigned int cadr;
|
||||
|
||||
/* map memory */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
|
||||
cadr = dev->resource[0].start;
|
||||
#else
|
||||
cadr = dev->base_address[0];
|
||||
#endif
|
||||
cadr &= PCI_BASE_ADDRESS_MEM_MASK;
|
||||
mem = ioremap_nocache(cadr, 0x0080000);
|
||||
if(mem) {
|
||||
@@ -240,136 +150,71 @@ void config_s4(struct pci_dev *dev)
|
||||
}
|
||||
}
|
||||
|
||||
/* Detect chip and initialize it. */
|
||||
static int savage4_setup(void)
|
||||
|
||||
static struct i2c_algo_bit_data sav_i2c_bit_data = {
|
||||
.setsda = bit_savi2c_setsda,
|
||||
.setscl = bit_savi2c_setscl,
|
||||
.getsda = bit_savi2c_getsda,
|
||||
.getscl = bit_savi2c_getscl,
|
||||
.udelay = CYCLE_DELAY,
|
||||
.mdelay = CYCLE_DELAY,
|
||||
.timeout = TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter savage4_i2c_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "I2C Savage4 adapter",
|
||||
.id = I2C_HW_B_SAVG,
|
||||
.algo_data = &sav_i2c_bit_data,
|
||||
};
|
||||
|
||||
#if 0
|
||||
PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE4,
|
||||
PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE2000,
|
||||
#endif
|
||||
|
||||
static struct pci_device_id savage4_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit savage4_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
int s4_num;
|
||||
|
||||
s4_num = 0;
|
||||
|
||||
dev = NULL;
|
||||
do {
|
||||
if ((dev = pci_find_device(PCI_VENDOR_ID_S3,
|
||||
PCI_CHIP_SAVAGE4,
|
||||
dev))) {
|
||||
if (!s4_num)
|
||||
config_s4(dev);
|
||||
s4_num++;
|
||||
}
|
||||
} while (dev);
|
||||
|
||||
dev = NULL;
|
||||
do {
|
||||
if ((dev = pci_find_device(PCI_VENDOR_ID_S3,
|
||||
PCI_CHIP_SAVAGE2000,
|
||||
dev))) {
|
||||
if (!s4_num)
|
||||
config_s4(dev);
|
||||
s4_num++;
|
||||
}
|
||||
} while (dev);
|
||||
|
||||
if (s4_num > 0) {
|
||||
if(!mem)
|
||||
return -ENOMEM;
|
||||
printk("i2c-savage4: %d Savage4 found.\n", s4_num);
|
||||
if (s4_num > 1)
|
||||
printk("i2c-savage4: warning: only 1 supported.\n");
|
||||
return 0;
|
||||
} else {
|
||||
printk("i2c-savage4: No Savage4 found.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
config_s4(dev);
|
||||
return i2c_bit_add_bus(&savage4_i2c_adapter);
|
||||
}
|
||||
|
||||
void savage4_inc(struct i2c_adapter *adapter)
|
||||
static void __devexit savage4_remove(struct pci_dev *dev)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
i2c_bit_del_bus(&savage4_i2c_adapter);
|
||||
}
|
||||
|
||||
void savage4_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
int __init i2c_savage4_init(void)
|
||||
static struct pci_driver savage4_driver = {
|
||||
.name = "savage4 smbus",
|
||||
.id_table = savage4_ids,
|
||||
.probe = savage4_probe,
|
||||
.remove = __devexit_p(savage4_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_savage4_init(void)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-savage4.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
savage4_initialized = 0;
|
||||
if ((res = savage4_setup())) {
|
||||
printk
|
||||
("i2c-savage4.o: Savage4 not detected, module not inserted.\n");
|
||||
savage4_cleanup();
|
||||
return res;
|
||||
}
|
||||
if ((res = i2c_bit_add_bus(&savage4_i2c_adapter))) {
|
||||
printk("i2c-savage4.o: I2C adapter registration failed\n");
|
||||
} else {
|
||||
printk("i2c-savage4.o: I2C bus initialized\n");
|
||||
savage4_initialized |= INIT2;
|
||||
}
|
||||
/*
|
||||
if ((res = i2c_bit_add_bus(&savage4_ddc_adapter))) {
|
||||
printk("i2c-savage4.o: DDC adapter registration failed\n");
|
||||
} else {
|
||||
printk("i2c-savage4.o: DDC bus initialized\n");
|
||||
savage4_initialized |= INIT3;
|
||||
}
|
||||
*/
|
||||
if(!(savage4_initialized & (INIT2 /* | INIT3 */ ))) {
|
||||
printk("i2c-savage4.o: Both registrations failed, module not inserted\n");
|
||||
savage4_cleanup();
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
return pci_module_init(&savage4_driver);
|
||||
}
|
||||
|
||||
int __init savage4_cleanup(void)
|
||||
|
||||
static void __exit i2c_savage4_exit(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
pci_unregister_driver(&savage4_driver);
|
||||
iounmap(mem);
|
||||
/*
|
||||
if (savage4_initialized & INIT3) {
|
||||
if ((res = i2c_bit_del_bus(&savage4_ddc_adapter))) {
|
||||
printk
|
||||
("i2c-savage4.o: i2c_bit_del_bus failed, module not removed\n");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (savage4_initialized & INIT2) {
|
||||
if ((res = i2c_bit_del_bus(&savage4_i2c_adapter))) {
|
||||
printk
|
||||
("i2c-savage4.o: i2c_bit_del_bus failed, module not removed\n");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, Ralph Metzler <rjkm@thp.uni-koeln.de>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("Savage4 I2C/SMBus driver");
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_savage4_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return savage4_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_savage4_init);
|
||||
module_exit(i2c_savage4_exit);
|
||||
+52
-108
@@ -61,9 +61,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_ID_SI_540
|
||||
#define PCI_DEVICE_ID_SI_540 0x0540
|
||||
@@ -138,52 +136,9 @@ MODULE_PARM(force_addr, "i");
|
||||
MODULE_PARM_DESC(force_addr,
|
||||
"Initialize the base address of the i2c controller");
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_sis5595_init(void);
|
||||
static int __init sis5595_cleanup(void);
|
||||
static int sis5595_setup(void);
|
||||
static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size,
|
||||
union i2c_smbus_data *data);
|
||||
static void sis5595_do_pause(unsigned int amount);
|
||||
static int sis5595_transaction(void);
|
||||
static void sis5595_inc(struct i2c_adapter *adapter);
|
||||
static void sis5595_dec(struct i2c_adapter *adapter);
|
||||
static u32 sis5595_func(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
/* name */ "Non-I2C SMBus adapter",
|
||||
/* id */ I2C_ALGO_SMBUS,
|
||||
/* master_xfer */ NULL,
|
||||
/* smbus_access */ sis5595_access,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
/* functionality */ sis5595_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter sis5595_adapter = {
|
||||
"unset",
|
||||
I2C_ALGO_SMBUS | I2C_HW_SMBUS_SIS5595,
|
||||
&smbus_algorithm,
|
||||
NULL,
|
||||
sis5595_inc,
|
||||
sis5595_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int __initdata sis5595_initialized;
|
||||
static unsigned short sis5595_base = 0;
|
||||
|
||||
static u8 sis5595_read(u8 reg)
|
||||
@@ -462,16 +417,6 @@ s32 sis5595_access(struct i2c_adapter * adap, u16 addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sis5595_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void sis5595_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 sis5595_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -480,72 +425,71 @@ u32 sis5595_func(struct i2c_adapter *adapter)
|
||||
I2C_FUNC_SMBUS_PROC_CALL;
|
||||
}
|
||||
|
||||
int __init i2c_sis5595_init(void)
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-I2C SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = sis5595_access,
|
||||
.functionality = sis5595_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter sis5595_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_SIS5595,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id sis5595_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit sis5595_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-sis5595.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
#ifdef DEBUG
|
||||
/* PE- It might be good to make this a permanent part of the code! */
|
||||
if (sis5595_initialized) {
|
||||
printk
|
||||
("i2c-sis5595.o: Oops, sis5595_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
sis5595_initialized = 0;
|
||||
if ((res = sis5595_setup())) {
|
||||
|
||||
if (sis5595_setup()) {
|
||||
printk
|
||||
("i2c-sis5595.o: SIS5595 not detected, module not inserted.\n");
|
||||
sis5595_cleanup();
|
||||
return res;
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
sis5595_initialized++;
|
||||
|
||||
sprintf(sis5595_adapter.name, "SMBus SIS5595 adapter at %04x",
|
||||
sis5595_base + SMB_INDEX);
|
||||
if ((res = i2c_add_adapter(&sis5595_adapter))) {
|
||||
printk
|
||||
("i2c-sis5595.o: Adapter registration failed, module not inserted.\n");
|
||||
sis5595_cleanup();
|
||||
return res;
|
||||
}
|
||||
sis5595_initialized++;
|
||||
printk("i2c-sis5595.o: SIS5595 bus detected and initialized\n");
|
||||
return 0;
|
||||
i2c_add_adapter(&sis5595_adapter);
|
||||
}
|
||||
|
||||
int __init sis5595_cleanup(void)
|
||||
static void __devexit sis5595_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
if (sis5595_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&sis5595_adapter))) {
|
||||
printk
|
||||
("i2c-sis5595.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
} else
|
||||
sis5595_initialized--;
|
||||
}
|
||||
if (sis5595_initialized >= 1) {
|
||||
release_region(sis5595_base + SMB_INDEX, 2);
|
||||
sis5595_initialized--;
|
||||
}
|
||||
return 0;
|
||||
i2c_del_adapter(&sis5595_adapter);
|
||||
}
|
||||
|
||||
|
||||
static struct pci_driver sis5595_driver = {
|
||||
.name = "sis5595 smbus",
|
||||
.id_table = sis5595_ids,
|
||||
.probe = sis5595_probe,
|
||||
.remove = __devexit_p(sis5595_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_sis5595_init(void)
|
||||
{
|
||||
printk("i2c-sis5595.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&sis5595_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_sis5595_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&sis5595_driver);
|
||||
release_region(sis5595_base + SMB_INDEX, 2);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
|
||||
MODULE_DESCRIPTION("SIS5595 SMBus driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_sis5595_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return sis5595_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_sis5595_init);
|
||||
module_exit(i2c_sis5595_exit);
|
||||
+62
-111
@@ -137,52 +137,15 @@ MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!");
|
||||
MODULE_PARM(high_clock, "i");
|
||||
MODULE_PARM_DESC(high_clock, "Set Host Master Clock to 56KHz (default 14KHz).");
|
||||
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_sis630_init(void);
|
||||
static int __init i2c_sis630_cleanup(void);
|
||||
static int sis630_setup(void);
|
||||
static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size,
|
||||
union i2c_smbus_data *data);
|
||||
static void sis630_do_pause(unsigned int amount);
|
||||
static int sis630_transaction(int size);
|
||||
static void sis630_inc(struct i2c_adapter *adapter);
|
||||
static void sis630_dec(struct i2c_adapter *adapter);
|
||||
static u32 sis630_func(struct i2c_adapter *adapter);
|
||||
|
||||
static u8 sis630_read(u8 reg);
|
||||
static void sis630_write(u8 reg, u8 data);
|
||||
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
/* name */ "Non-I2C SMBus adapter",
|
||||
/* id */ I2C_ALGO_SMBUS,
|
||||
/* master_xfer */ NULL,
|
||||
/* smbus_access */ sis630_access,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
/* functionality */ sis630_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter sis630_adapter = {
|
||||
"unset",
|
||||
I2C_ALGO_SMBUS | I2C_HW_SMBUS_SIS630,
|
||||
&smbus_algorithm,
|
||||
NULL,
|
||||
sis630_inc,
|
||||
sis630_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static unsigned short acpi_base = 0;
|
||||
static int __initdata sis630_initialized;
|
||||
|
||||
|
||||
u8 sis630_read(u8 reg) {
|
||||
return inb(acpi_base + reg);
|
||||
@@ -305,7 +268,8 @@ int sis630_transaction(int size) {
|
||||
/* Return -1 on error. */
|
||||
s32 sis630_access(struct i2c_adapter * adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size, union i2c_smbus_data * data) {
|
||||
u8 command, int size, union i2c_smbus_data * data)
|
||||
{
|
||||
|
||||
switch (size) {
|
||||
case I2C_SMBUS_QUICK:
|
||||
@@ -374,13 +338,6 @@ s32 sis630_access(struct i2c_adapter * adap, u16 addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sis630_inc(struct i2c_adapter *adapter) {
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void sis630_dec(struct i2c_adapter *adapter) {
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 sis630_func(struct i2c_adapter *adapter) {
|
||||
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
|
||||
@@ -452,88 +409,82 @@ int sis630_setup(void) {
|
||||
#endif
|
||||
|
||||
/* Everything is happy, let's grab the memory and set things up. */
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,14)
|
||||
if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, "sis630-smbus")){
|
||||
printk(KERN_ERR "i2c-sis630.o: SMBus registers 0x%04x-0x%04x "
|
||||
"already in use!\n",acpi_base + SMB_STS, acpi_base + SMB_SAA);
|
||||
return -ENODEV;
|
||||
}
|
||||
#else
|
||||
if (check_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION) < 0){
|
||||
printk(KERN_ERR "i2c-sis630.o: SMBus registers 0x%04x-0x%04x "
|
||||
"already in use!\n",acpi_base + SMB_STS, acpi_base + SMB_SAA);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-I2C SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = sis630_access,
|
||||
.functionality = sis630_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter sis630_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_SIS630,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id sis630_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit sis630_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
|
||||
if (sis630_setup()) {
|
||||
printk(KERN_ERR "i2c-sis630.o: SIS630 comp. bus not detected, module not inserted.\n");
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, "sis630-smbus");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __init i2c_sis630_init(void) {
|
||||
int res;
|
||||
printk("i2c-sis630.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
|
||||
if (sis630_initialized) {
|
||||
printk(KERN_ERR "i2c-sis630.o: Oops, sis630_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
sis630_initialized = 0;
|
||||
if ((res = sis630_setup())) {
|
||||
printk(KERN_ERR "i2c-sis630.o: SIS630 comp. bus not detected, module not inserted.\n");
|
||||
i2c_sis630_cleanup();
|
||||
return res;
|
||||
}
|
||||
sis630_initialized++;
|
||||
sprintf(sis630_adapter.name, "SMBus SIS630 adapter at %04x",
|
||||
acpi_base + SMB_STS);
|
||||
if ((res = i2c_add_adapter(&sis630_adapter))) {
|
||||
printk(KERN_ERR "i2c-sis630.o: Adapter registration failed, "
|
||||
"module not inserted.\n");
|
||||
i2c_sis630_cleanup();
|
||||
return res;
|
||||
}
|
||||
sis630_initialized++;
|
||||
printk(KERN_INFO "i2c-sis630.o: SIS630 comp. bus detected and initialized\n");
|
||||
|
||||
return 0;
|
||||
i2c_add_adapter(&sis630_adapter);
|
||||
}
|
||||
|
||||
int __init i2c_sis630_cleanup(void) {
|
||||
int res;
|
||||
if (sis630_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&sis630_adapter))) {
|
||||
printk(KERN_ERR "i2c-sis630.o: i2c_del_adapter failed, module not"
|
||||
"removed\n");
|
||||
return res;
|
||||
} else
|
||||
sis630_initialized--;
|
||||
}
|
||||
if (sis630_initialized >= 1) {
|
||||
release_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION);
|
||||
sis630_initialized--;
|
||||
}
|
||||
return 0;
|
||||
static void __devexit sis630_remove(struct pci_dev *dev)
|
||||
{
|
||||
i2c_del_adapter(&sis630_adapter);
|
||||
}
|
||||
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
static struct pci_driver sis630_driver = {
|
||||
.name = "sis630 smbus",
|
||||
.id_table = sis630_ids,
|
||||
.probe = sis630_probe,
|
||||
.remove = __devexit_p(sis630_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_sis630_init(void)
|
||||
{
|
||||
printk("i2c-sis630.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&sis630_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_sis630_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&sis630_driver);
|
||||
release_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
#ifdef MODULE
|
||||
MODULE_AUTHOR("Alexander Malysh <amalysh@web.de>");
|
||||
MODULE_DESCRIPTION("SIS630 SMBus driver");
|
||||
|
||||
int init_module(void) {
|
||||
return i2c_sis630_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void) {
|
||||
return i2c_sis630_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_sis630_init);
|
||||
module_exit(i2c_sis630_exit);
|
||||
+52
-101
@@ -46,9 +46,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
/* PCI identifiers */
|
||||
|
||||
@@ -111,47 +109,15 @@ MODULE_LICENSE("GPL");
|
||||
#define SIS645_PROC_CALL 0x04
|
||||
#define SIS645_BLOCK_DATA 0x05
|
||||
|
||||
|
||||
static int __init sis645_init(void);
|
||||
static void sis645_cleanup(void);
|
||||
|
||||
static int sis645_enable_smbus(struct pci_dev *dev);
|
||||
static int sis645_build_dev(struct pci_dev **smbus_dev,
|
||||
struct pci_dev *bridge_dev);
|
||||
static int sis645_setup(void);
|
||||
static s32 sis645_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size,
|
||||
union i2c_smbus_data *data);
|
||||
|
||||
static void sis645_do_pause(unsigned int amount);
|
||||
static int sis645_transaction(int size);
|
||||
static void sis645_inc(struct i2c_adapter *adapter);
|
||||
static void sis645_dec(struct i2c_adapter *adapter);
|
||||
static u32 sis645_func(struct i2c_adapter *adapter);
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
/* name */ "Non-I2C SMBus adapter",
|
||||
/* id */ I2C_ALGO_SMBUS,
|
||||
/* master_xfer */ NULL,
|
||||
/* smbus_access */ sis645_access,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
/* functionality */ sis645_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter sis645_adapter = {
|
||||
"unset",
|
||||
I2C_ALGO_SMBUS | I2C_HW_SMBUS_SIS645,
|
||||
&smbus_algorithm,
|
||||
NULL,
|
||||
sis645_inc,
|
||||
sis645_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int sis645_initialized;
|
||||
static unsigned short sis645_smbus_base = 0;
|
||||
|
||||
static u8 sis645_read(u8 reg)
|
||||
@@ -324,11 +290,7 @@ static int sis645_setup(void)
|
||||
}
|
||||
|
||||
/* get the IO base address */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
|
||||
sis645_smbus_base = SIS645_SMBUS_dev->resource[BASE_IO_REG].start;
|
||||
#else
|
||||
sis645_smbus_base = SIS645_SMBUS_dev->base_address[BASE_IO_REG];
|
||||
#endif
|
||||
if (!sis645_smbus_base) {
|
||||
printk("i2c-sis645.o: SiS645 SMBus base address not initialized!\n");
|
||||
return -EINVAL;
|
||||
@@ -336,22 +298,12 @@ static int sis645_setup(void)
|
||||
printk("i2c-sis645.o: SiS645 SMBus base address: 0x%04x\n", sis645_smbus_base);
|
||||
|
||||
/* Everything is happy, let's grab the memory and set things up. */
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,14)
|
||||
if (!request_region(sis645_smbus_base, SIS645_SMB_IOREGION, "sis645-smbus")) {
|
||||
printk
|
||||
("i2c-sis645.o: SMBus registers 0x%04x-0x%04x already in use!\n",
|
||||
sis645_smbus_base, sis645_smbus_base + SIS645_SMB_IOREGION - 1);
|
||||
return -EINVAL;
|
||||
}
|
||||
#else
|
||||
if (check_region(sis645_smbus_base, SIS645_SMB_IOREGION) < 0) {
|
||||
printk
|
||||
("i2c-sis645.o: SMBus registers 0x%04x-0x%04x already in use!\n",
|
||||
sis645_smbus_base, sis645_smbus_base + SIS645_SMB_IOREGION - 1);
|
||||
return -EINVAL;
|
||||
}
|
||||
request_region(sis645_smbus_base, SIS645_SMB_IOREGION, "sis645-smbus");
|
||||
#endif
|
||||
|
||||
return(0);
|
||||
}
|
||||
@@ -518,15 +470,6 @@ s32 sis645_access(struct i2c_adapter * adap, u16 addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sis645_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
static void sis645_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
static u32 sis645_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -535,62 +478,70 @@ static u32 sis645_func(struct i2c_adapter *adapter)
|
||||
I2C_FUNC_SMBUS_PROC_CALL;
|
||||
}
|
||||
|
||||
static int __init sis645_init(void)
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-I2C SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = sis645_access,
|
||||
.functionality = sis645_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter sis645_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_SIS645,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id sis645_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit sis645_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-sis645.o: version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
|
||||
if (sis645_initialized) {
|
||||
printk("i2c-sis645.o: Oops, sis645_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
sis645_initialized = 0;
|
||||
if ((res = sis645_setup())) {
|
||||
if (sis645_setup()) {
|
||||
printk ("i2c-sis645.o: SiS645 not detected, module not inserted.\n");
|
||||
sis645_cleanup();
|
||||
return res;
|
||||
}
|
||||
|
||||
sis645_initialized++;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
sprintf(sis645_adapter.name, "SMBus SiS645 adapter at 0x%04x", sis645_smbus_base);
|
||||
if ((res = i2c_add_adapter(&sis645_adapter))) {
|
||||
printk ("i2c-sis645.o: Adapter registration failed, module not inserted.\n");
|
||||
sis645_cleanup();
|
||||
return res;
|
||||
}
|
||||
|
||||
sis645_initialized++;
|
||||
printk("i2c-sis645.o: SiS645 bus detected and initialized.\n");
|
||||
return 0;
|
||||
i2c_add_adapter(&sis645_adapter);
|
||||
}
|
||||
|
||||
static void sis645_cleanup(void)
|
||||
static void __devexit sis645_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
if (sis645_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&sis645_adapter))) {
|
||||
printk("i2c-sis645.o: i2c_del_adapter failed, module not removed\n");
|
||||
return;
|
||||
} else
|
||||
sis645_initialized--;
|
||||
}
|
||||
if (sis645_initialized >= 1) {
|
||||
release_region(sis645_smbus_base, SIS645_SMB_IOREGION);
|
||||
sis645_initialized--;
|
||||
}
|
||||
return;
|
||||
i2c_del_adapter(&sis645_adapter);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
/* Register initialization functions using helper macros */
|
||||
module_init(sis645_init);
|
||||
module_exit(sis645_cleanup);
|
||||
static struct pci_driver sis645_driver = {
|
||||
.name = "sis645 smbus",
|
||||
.id_table = sis645_ids,
|
||||
.probe = sis645_probe,
|
||||
.remove = __devexit_p(sis645_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_sis645_init(void)
|
||||
{
|
||||
printk("i2c-sis645.o: version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&sis645_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_sis645_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&sis645_driver);
|
||||
release_region(sis645_smbus_base, SIS645_SMB_IOREGION);
|
||||
}
|
||||
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
|
||||
MODULE_DESCRIPTION("SiS645 SMBus driver");
|
||||
|
||||
#endif
|
||||
/* Register initialization functions using helper macros */
|
||||
module_init(i2c_sis645_init);
|
||||
module_exit(i2c_sis645_exit);
|
||||
+20
-68
@@ -39,9 +39,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
/* Memory Presence Detect Register (MPD-RW) bits
|
||||
with except of reserved RAZ bits */
|
||||
@@ -51,28 +49,13 @@ MODULE_LICENSE("GPL");
|
||||
#define MPD_DS 0x2 /* Data send - Must be a 1 to receive - WO */
|
||||
#define MPD_CKS 0x1 /* Clock send - WO */
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_tsunami_init(void);
|
||||
static int __init i2c_tsunami_cleanup(void);
|
||||
static void i2c_tsunami_inc(struct i2c_adapter *adapter);
|
||||
static void i2c_tsunami_dec(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
extern inline void writempd(unsigned long value)
|
||||
static inline void writempd(unsigned long value)
|
||||
{
|
||||
TSUNAMI_cchip->mpd.csr = value;
|
||||
mb();
|
||||
}
|
||||
|
||||
extern inline unsigned long readmpd(void)
|
||||
static inline unsigned long readmpd(void)
|
||||
{
|
||||
return TSUNAMI_cchip->mpd.csr;
|
||||
}
|
||||
@@ -118,7 +101,7 @@ static int bit_tsunami_getsda(void *data)
|
||||
}
|
||||
|
||||
static struct i2c_algo_bit_data tsunami_i2c_bit_data = {
|
||||
NULL,
|
||||
|
||||
bit_tsunami_setsda,
|
||||
bit_tsunami_setscl,
|
||||
bit_tsunami_getsda,
|
||||
@@ -127,29 +110,22 @@ static struct i2c_algo_bit_data tsunami_i2c_bit_data = {
|
||||
};
|
||||
|
||||
static struct i2c_adapter tsunami_i2c_adapter = {
|
||||
"I2C Tsunami/Typhoon adapter",
|
||||
I2C_HW_B_TSUNA,
|
||||
NULL,
|
||||
&tsunami_i2c_bit_data,
|
||||
i2c_tsunami_inc,
|
||||
i2c_tsunami_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
.owner = THIS_MODULE,
|
||||
.name = "I2C Tsunami/Typhoon adapter",
|
||||
.id = I2C_HW_B_TSUNA,
|
||||
.algo_data = &tsunami_i2c_bit_data,
|
||||
};
|
||||
|
||||
void i2c_tsunami_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void i2c_tsunami_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
static struct pci_driver tsunami_driver = {
|
||||
.name = "tsunami smbus",
|
||||
.id_table = tsunami_ids,
|
||||
.probe = tsunami_probe,
|
||||
.remove = __devexit_p(tsunami_remove),
|
||||
};
|
||||
|
||||
int __init i2c_tsunami_init(void)
|
||||
static int __init i2c_tsunami_init(void)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-tsunami.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
|
||||
if (hwrpb->sys_type != ST_DEC_TSUNAMI) {
|
||||
@@ -158,43 +134,19 @@ int __init i2c_tsunami_init(void)
|
||||
} else {
|
||||
printk("i2c-tsunami.o: using Cchip MPD at 0x%lx.\n", &TSUNAMI_cchip->mpd);
|
||||
}
|
||||
|
||||
if ((res = i2c_bit_add_bus(&tsunami_i2c_adapter))) {
|
||||
printk("i2c-tsunami.o: I2C adapter registration failed\n");
|
||||
} else {
|
||||
printk("i2c-tsunami.o: I2C bus initialized\n");
|
||||
}
|
||||
|
||||
return res;
|
||||
i2c_bit_add_bus(&tsunami_i2c_adapter);
|
||||
}
|
||||
|
||||
int __init i2c_tsunami_cleanup(void)
|
||||
|
||||
static void __exit i2c_tsunami_exit(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
if ((res = i2c_bit_del_bus(&tsunami_i2c_adapter))) {
|
||||
printk("i2c-tsunami.o: i2c_bit_del_bus failed, module not removed\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
return 0;
|
||||
i2c_bit_del_bus(&tsunami_i2c_adapter);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR("Oleg I. Vdovikin <vdovikin@jscc.ru>");
|
||||
MODULE_DESCRIPTION("Tsunami I2C/SMBus driver");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_tsunami_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return i2c_tsunami_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_tsunami_init);
|
||||
module_exit(i2c_tsunami_exit);
|
||||
+70
-88
@@ -33,9 +33,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
/* PCI device */
|
||||
#define VENDOR PCI_VENDOR_ID_VIA
|
||||
@@ -71,7 +69,7 @@ static u16 pm_io_base;
|
||||
open drain. So a we set a low value by setting the direction to
|
||||
output and a high value by setting the direction to input and
|
||||
relying on the required I2C pullup. The data value is initialized
|
||||
to 0 in i2c_via_init() and never changed.
|
||||
to 0 in via_init() and never changed.
|
||||
*/
|
||||
|
||||
static void bit_via_setscl(void *data, int state)
|
||||
@@ -96,45 +94,11 @@ static int bit_via_getsda(void *data)
|
||||
return (0 != (inb(I2C_IN) & I2C_SDA));
|
||||
}
|
||||
|
||||
static void bit_via_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
static void bit_via_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static struct i2c_algo_bit_data bit_data = {
|
||||
NULL,
|
||||
bit_via_setsda,
|
||||
bit_via_setscl,
|
||||
bit_via_getsda,
|
||||
bit_via_getscl,
|
||||
5, 5, HZ, /*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? */
|
||||
static int find_via(void)
|
||||
{
|
||||
struct pci_dev *s_bridge;
|
||||
u16 base;
|
||||
u8 rev;
|
||||
|
||||
if (!pci_present())
|
||||
return -ENODEV;
|
||||
@@ -146,9 +110,37 @@ static int find_via(void)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (PCIBIOS_SUCCESSFUL !=
|
||||
pci_read_config_byte(s_bridge, PM_CFG_REVID, &rev))
|
||||
return -ENODEV;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_algo_bit_data bit_data = {
|
||||
.setsda = bit_via_setsda,
|
||||
.setscl = bit_via_setscl,
|
||||
.getsda = bit_via_getsda,
|
||||
.getscl = bit_via_getscl,
|
||||
.udelay = 5,
|
||||
.mdelay = 5,
|
||||
.timeout = HZ
|
||||
};
|
||||
|
||||
static struct i2c_adapter bit_via_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "VIA i2c",
|
||||
.id = I2C_HW_B_VIA,
|
||||
.algo_data = &bit_data,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id vt586b_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
u16 base;
|
||||
u8 rev;
|
||||
|
||||
pci_read_config_byte(dev, PM_CFG_REVID, &rev);
|
||||
|
||||
switch (rev) {
|
||||
case 0x00:
|
||||
@@ -164,62 +156,52 @@ static int find_via(void)
|
||||
/* later revision */
|
||||
}
|
||||
|
||||
if (PCIBIOS_SUCCESSFUL !=
|
||||
pci_read_config_word(s_bridge, base, &pm_io_base))
|
||||
return -ENODEV;
|
||||
|
||||
pci_read_config_word(dev, base, &pm_io_base);
|
||||
pm_io_base &= (0xff << 8);
|
||||
return 0;
|
||||
|
||||
return -ENODEV;
|
||||
|
||||
if (! request_region(I2C_DIR, IOSPACE, IOTEXT)) {
|
||||
printk("i2c-via.o: IO 0x%x-0x%x already in use\n",
|
||||
I2C_DIR, I2C_DIR + IOSPACE);
|
||||
return -EBUSY;
|
||||
}
|
||||
outb(inb(I2C_DIR) & ~(I2C_SDA | I2C_SCL), I2C_DIR);
|
||||
outb(inb(I2C_OUT) & ~(I2C_SDA | I2C_SCL), I2C_OUT);
|
||||
|
||||
i2c_bit_add_bus(&bit_via_adapter);
|
||||
}
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_via_init(void)
|
||||
static void __devexit vt586b_remove(struct pci_dev *dev)
|
||||
{
|
||||
i2c_bit_del_bus(&bit_via_adapter);
|
||||
}
|
||||
|
||||
|
||||
static struct pci_driver vt586b_driver = {
|
||||
.name = "vt586b smbus",
|
||||
.id_table = vt586b_ids,
|
||||
.probe = vt586b_probe,
|
||||
.remove = __devexit_p(vt586b_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_vt586b_init(void)
|
||||
{
|
||||
printk("i2c-via.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
if (find_via() < 0) {
|
||||
printk("i2c-via.o: Error while reading PCI configuration\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (check_region(I2C_DIR, IOSPACE) < 0) {
|
||||
printk("i2c-via.o: IO 0x%x-0x%x already in use\n",
|
||||
I2C_DIR, I2C_DIR + IOSPACE);
|
||||
return -EBUSY;
|
||||
} else {
|
||||
request_region(I2C_DIR, IOSPACE, IOTEXT);
|
||||
outb(inb(I2C_DIR) & ~(I2C_SDA | I2C_SCL), I2C_DIR);
|
||||
outb(inb(I2C_OUT) & ~(I2C_SDA | I2C_SCL), I2C_OUT);
|
||||
}
|
||||
|
||||
if (i2c_bit_add_bus(&bit_via_ops) == 0) {
|
||||
printk("i2c-via.o: Module succesfully loaded\n");
|
||||
return 0;
|
||||
} else {
|
||||
release_region(I2C_DIR, IOSPACE);
|
||||
printk
|
||||
("i2c-via.o: Algo-bit error, couldn't register bus\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
return pci_module_init(&vt586b_driver);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
static void __exit i2c_vt586b_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&vt586b_driver);
|
||||
release_region(I2C_DIR, IOSPACE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>");
|
||||
MODULE_DESCRIPTION("i2c for Via vt82c586b southbridge");
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_via_init();
|
||||
}
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
i2c_bit_del_bus(&bit_via_ops);
|
||||
release_region(I2C_DIR, IOSPACE);
|
||||
}
|
||||
#endif
|
||||
module_init(i2c_vt586b_init);
|
||||
module_exit(i2c_vt586b_exit);
|
||||
+55
-105
@@ -135,51 +135,15 @@ MODULE_PARM_DESC(force_addr,
|
||||
"Forcibly enable the SMBus at the given address. "
|
||||
"EXTREMELY DANGEROUS!");
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_vt596_init(void);
|
||||
static int __init vt596_cleanup(void);
|
||||
static int vt596_setup(void);
|
||||
static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
|
||||
unsigned short flags, char read_write,
|
||||
u8 command, int size, union i2c_smbus_data *data);
|
||||
|
||||
|
||||
|
||||
|
||||
static void vt596_do_pause(unsigned int amount);
|
||||
static int vt596_transaction(void);
|
||||
static void vt596_inc(struct i2c_adapter *adapter);
|
||||
static void vt596_dec(struct i2c_adapter *adapter);
|
||||
static u32 vt596_func(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
/* name */ "Non-I2C SMBus adapter",
|
||||
/* id */ I2C_ALGO_SMBUS,
|
||||
/* master_xfer */ NULL,
|
||||
/* smbus_access */ vt596_access,
|
||||
/* slave_send */ NULL,
|
||||
/* slave_rcv */ NULL,
|
||||
/* algo_control */ NULL,
|
||||
/* functionality */ vt596_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter vt596_adapter = {
|
||||
"unset",
|
||||
I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2,
|
||||
&smbus_algorithm,
|
||||
NULL,
|
||||
vt596_inc,
|
||||
vt596_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int __initdata vt596_initialized;
|
||||
static unsigned short vt596_smba = 0;
|
||||
|
||||
|
||||
@@ -481,16 +445,6 @@ s32 vt596_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vt596_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void vt596_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
u32 vt596_func(struct i2c_adapter *adapter)
|
||||
{
|
||||
@@ -499,77 +453,73 @@ u32 vt596_func(struct i2c_adapter *adapter)
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA;
|
||||
}
|
||||
|
||||
int __init i2c_vt596_init(void)
|
||||
|
||||
static struct i2c_algorithm smbus_algorithm = {
|
||||
.name = "Non-I2C SMBus adapter",
|
||||
.id = I2C_ALGO_SMBUS,
|
||||
.smbus_xfer = vt596_access,
|
||||
.functionality = vt596_func,
|
||||
};
|
||||
|
||||
static struct i2c_adapter vt596_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "unset",
|
||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2,
|
||||
.algo = &smbus_algorithm,
|
||||
};
|
||||
|
||||
|
||||
static struct pci_device_id vt596_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit vt596_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-viapro.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
#ifdef DEBUG
|
||||
/* PE- It might be good to make this a permanent part of the code! */
|
||||
if (vt596_initialized) {
|
||||
printk
|
||||
("i2c-viapro.o: Oops, vt596_init called a second time!\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
vt596_initialized = 0;
|
||||
if ((res = vt596_setup())) {
|
||||
|
||||
if (vt596_setup()) {
|
||||
printk
|
||||
("i2c-viapro.o: Can't detect vt82c596 or compatible device, module not inserted.\n");
|
||||
vt596_cleanup();
|
||||
return res;
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
vt596_initialized++;
|
||||
|
||||
sprintf(vt596_adapter.name, "SMBus Via Pro adapter at %04x",
|
||||
vt596_smba);
|
||||
if ((res = i2c_add_adapter(&vt596_adapter))) {
|
||||
printk
|
||||
("i2c-viapro.o: Adapter registration failed, module not inserted.\n");
|
||||
vt596_cleanup();
|
||||
return res;
|
||||
}
|
||||
vt596_initialized++;
|
||||
printk("i2c-viapro.o: Via Pro SMBus detected and initialized\n");
|
||||
return 0;
|
||||
i2c_add_adapter(&vt596_adapter);
|
||||
}
|
||||
|
||||
int __init vt596_cleanup(void)
|
||||
static void __devexit vt596_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
if (vt596_initialized >= 2) {
|
||||
if ((res = i2c_del_adapter(&vt596_adapter))) {
|
||||
printk
|
||||
("i2c-viapro.o: i2c_del_adapter failed, module not removed\n");
|
||||
return res;
|
||||
} else
|
||||
vt596_initialized--;
|
||||
}
|
||||
if (vt596_initialized >= 1) {
|
||||
release_region(vt596_smba, 8);
|
||||
vt596_initialized--;
|
||||
}
|
||||
return 0;
|
||||
i2c_del_adapter(&vt596_adapter);
|
||||
}
|
||||
|
||||
static struct pci_driver vt596_driver = {
|
||||
.name = "vt596 smbus",
|
||||
.id_table = vt596_ids,
|
||||
.probe = vt596_probe,
|
||||
.remove = __devexit_p(vt596_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_vt596_init(void)
|
||||
{
|
||||
printk("i2c-viapro.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&vt596_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_vt596_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&vt596_driver);
|
||||
release_region(vt596_smba, 8);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
|
||||
MODULE_DESCRIPTION("vt82c596 SMBus driver");
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_vt596_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return vt596_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_vt596_init);
|
||||
module_exit(i2c_vt596_exit);
|
||||
+78
-174
@@ -36,9 +36,7 @@
|
||||
#include "version.h"
|
||||
#include <linux/init.h>
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
/* 3DFX defines */
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO3
|
||||
@@ -72,33 +70,18 @@ MODULE_LICENSE("GPL");
|
||||
#define CYCLE_DELAY 10
|
||||
#define TIMEOUT (HZ / 2)
|
||||
|
||||
#ifdef MODULE
|
||||
static
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
int __init i2c_voodoo3_init(void);
|
||||
static int __init voodoo3_cleanup(void);
|
||||
static int voodoo3_setup(void);
|
||||
|
||||
static void config_v3(struct pci_dev *dev);
|
||||
static void voodoo3_inc(struct i2c_adapter *adapter);
|
||||
static void voodoo3_dec(struct i2c_adapter *adapter);
|
||||
|
||||
#ifdef MODULE
|
||||
extern int init_module(void);
|
||||
extern int cleanup_module(void);
|
||||
#endif /* MODULE */
|
||||
|
||||
|
||||
static int __initdata voodoo3_initialized;
|
||||
static unsigned char *mem;
|
||||
|
||||
extern inline void outlong(unsigned int dat)
|
||||
static inline void outlong(unsigned int dat)
|
||||
{
|
||||
*((unsigned int *) (mem + REG)) = dat;
|
||||
}
|
||||
|
||||
extern inline unsigned int readlong(void)
|
||||
static inline unsigned int readlong(void)
|
||||
{
|
||||
return *((unsigned int *) (mem + REG));
|
||||
}
|
||||
@@ -178,45 +161,6 @@ static int bit_vooddc_getsda(void *data)
|
||||
return (0 != (readlong() & DDC_SDA_IN));
|
||||
}
|
||||
|
||||
static struct i2c_algo_bit_data voo_i2c_bit_data = {
|
||||
NULL,
|
||||
bit_vooi2c_setsda,
|
||||
bit_vooi2c_setscl,
|
||||
bit_vooi2c_getsda,
|
||||
bit_vooi2c_getscl,
|
||||
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter voodoo3_i2c_adapter = {
|
||||
"I2C Voodoo3/Banshee adapter",
|
||||
I2C_HW_B_VOO,
|
||||
NULL,
|
||||
&voo_i2c_bit_data,
|
||||
voodoo3_inc,
|
||||
voodoo3_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct i2c_algo_bit_data voo_ddc_bit_data = {
|
||||
NULL,
|
||||
bit_vooddc_setsda,
|
||||
bit_vooddc_setscl,
|
||||
bit_vooddc_getsda,
|
||||
bit_vooddc_getscl,
|
||||
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter voodoo3_ddc_adapter = {
|
||||
"DDC Voodoo3/Banshee adapter",
|
||||
I2C_HW_B_VOO,
|
||||
NULL,
|
||||
&voo_ddc_bit_data,
|
||||
voodoo3_inc,
|
||||
voodoo3_dec,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* Configures the chip */
|
||||
|
||||
@@ -225,11 +169,7 @@ void config_v3(struct pci_dev *dev)
|
||||
unsigned int cadr;
|
||||
|
||||
/* map Voodoo3 memory */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
|
||||
cadr = dev->resource[0].start;
|
||||
#else
|
||||
cadr = dev->base_address[0];
|
||||
#endif
|
||||
cadr &= PCI_BASE_ADDRESS_MEM_MASK;
|
||||
mem = ioremap_nocache(cadr, 0x1000);
|
||||
if(mem) {
|
||||
@@ -239,130 +179,94 @@ void config_v3(struct pci_dev *dev)
|
||||
}
|
||||
}
|
||||
|
||||
/* Detect whether a Voodoo3 or a Banshee can be found,
|
||||
and initialize it. */
|
||||
static int voodoo3_setup(void)
|
||||
static struct i2c_algo_bit_data voo_i2c_bit_data = {
|
||||
.setsda = bit_vooi2c_setsda,
|
||||
.setscl = bit_vooi2c_setscl,
|
||||
.getsda = bit_vooi2c_getsda,
|
||||
.getscl = bit_vooi2c_getscl,
|
||||
.udelay = CYCLE_DELAY,
|
||||
.mdelay = CYCLE_DELAY,
|
||||
.timeout = TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter voodoo3_i2c_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "I2C Voodoo3/Banshee adapter",
|
||||
.id = I2C_HW_B_VOO,
|
||||
.algo_data = &voo_i2c_bit_data,
|
||||
};
|
||||
|
||||
static struct i2c_algo_bit_data voo_ddc_bit_data = {
|
||||
.setsda = bit_vooddc_setsda,
|
||||
.setscl = bit_vooddc_setscl,
|
||||
.getsda = bit_vooddc_getsda,
|
||||
.getscl = bit_vooddc_getscl,
|
||||
.udelay = CYCLE_DELAY,
|
||||
.mdelay = CYCLE_DELAY,
|
||||
.timeout = TIMEOUT
|
||||
};
|
||||
|
||||
static struct i2c_adapter voodoo3_ddc_adapter = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "DDC Voodoo3/Banshee adapter",
|
||||
.id = I2C_HW_B_VOO,
|
||||
.algo_data = &voo_ddc_bit_data,
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3,
|
||||
PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE,
|
||||
#endif
|
||||
static struct pci_device_id voodoo3_ids[] __devinitdata = {
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static int __devinit voodoo3_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
int v3_num;
|
||||
|
||||
v3_num = 0;
|
||||
|
||||
dev = NULL;
|
||||
do {
|
||||
if ((dev = pci_find_device(PCI_VENDOR_ID_3DFX,
|
||||
PCI_DEVICE_ID_3DFX_VOODOO3,
|
||||
dev))) {
|
||||
if (!v3_num)
|
||||
config_v3(dev);
|
||||
v3_num++;
|
||||
}
|
||||
} while (dev);
|
||||
|
||||
dev = NULL;
|
||||
do {
|
||||
if ((dev = pci_find_device(PCI_VENDOR_ID_3DFX,
|
||||
PCI_DEVICE_ID_3DFX_BANSHEE,
|
||||
dev))) {
|
||||
if (!v3_num)
|
||||
config_v3(dev);
|
||||
v3_num++;
|
||||
}
|
||||
} while (dev);
|
||||
|
||||
if (v3_num > 0) {
|
||||
if(!mem)
|
||||
return -ENOMEM;
|
||||
printk("i2c-voodoo3: %d Banshee/Voodoo3 found.\n", v3_num);
|
||||
if (v3_num > 1)
|
||||
printk("i2c-voodoo3: warning: only 1 supported.\n");
|
||||
return 0;
|
||||
} else {
|
||||
printk("i2c-voodoo3: No Voodoo3 found.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
void voodoo3_inc(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_INC_USE_COUNT;
|
||||
}
|
||||
|
||||
void voodoo3_dec(struct i2c_adapter *adapter)
|
||||
{
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
int __init i2c_voodoo3_init(void)
|
||||
{
|
||||
int res;
|
||||
printk("i2c-voodoo3.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
voodoo3_initialized = 0;
|
||||
if ((res = voodoo3_setup())) {
|
||||
if (voodoo3_setup()) {
|
||||
printk
|
||||
("i2c-voodoo3.o: Voodoo3 not detected, module not inserted.\n");
|
||||
voodoo3_cleanup();
|
||||
return res;
|
||||
return -ENODEV;
|
||||
}
|
||||
if ((res = i2c_bit_add_bus(&voodoo3_i2c_adapter))) {
|
||||
printk("i2c-voodoo3.o: I2C adapter registration failed\n");
|
||||
} else {
|
||||
printk("i2c-voodoo3.o: I2C bus initialized\n");
|
||||
voodoo3_initialized |= INIT2;
|
||||
}
|
||||
if ((res = i2c_bit_add_bus(&voodoo3_ddc_adapter))) {
|
||||
printk("i2c-voodoo3.o: DDC adapter registration failed\n");
|
||||
} else {
|
||||
printk("i2c-voodoo3.o: DDC bus initialized\n");
|
||||
voodoo3_initialized |= INIT3;
|
||||
}
|
||||
if(!(voodoo3_initialized & (INIT2 | INIT3))) {
|
||||
printk("i2c-voodoo3.o: Both registrations failed, module not inserted\n");
|
||||
voodoo3_cleanup();
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
config_v3(dev);
|
||||
|
||||
i2c_bit_add_bus(&voodoo3_i2c_adapter);
|
||||
i2c_bit_add_bus(&voodoo3_ddc_adapter);
|
||||
}
|
||||
|
||||
int __init voodoo3_cleanup(void)
|
||||
static void __devexit voodoo3_remove(struct pci_dev *dev)
|
||||
{
|
||||
int res;
|
||||
|
||||
iounmap(mem);
|
||||
if (voodoo3_initialized & INIT3) {
|
||||
if ((res = i2c_bit_del_bus(&voodoo3_ddc_adapter))) {
|
||||
printk
|
||||
("i2c-voodoo3.o: i2c_bit_del_bus failed, module not removed\n");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
if (voodoo3_initialized & INIT2) {
|
||||
if ((res = i2c_bit_del_bus(&voodoo3_i2c_adapter))) {
|
||||
printk
|
||||
("i2c-voodoo3.o: i2c_bit_del_bus failed, module not removed\n");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
i2c_bit_del_bus(&voodoo3_i2c_adapter);
|
||||
i2c_bit_del_bus(&voodoo3_ddc_adapter);
|
||||
}
|
||||
|
||||
EXPORT_NO_SYMBOLS;
|
||||
|
||||
#ifdef MODULE
|
||||
static struct pci_driver voodoo3_driver = {
|
||||
.name = "voodoo3 smbus",
|
||||
.id_table = voodoo3_ids,
|
||||
.probe = voodoo3_probe,
|
||||
.remove = __devexit_p(voodoo3_remove),
|
||||
};
|
||||
|
||||
static int __init i2c_voodoo3_init(void)
|
||||
{
|
||||
printk("i2c-voodoo3.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||
return pci_module_init(&voodoo3_driver);
|
||||
}
|
||||
|
||||
|
||||
static void __exit i2c_voodoo3_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&voodoo3_driver);
|
||||
iounmap(mem);
|
||||
}
|
||||
|
||||
|
||||
MODULE_AUTHOR
|
||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, Ralph Metzler <rjkm@thp.uni-koeln.de>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
|
||||
MODULE_DESCRIPTION("Voodoo3 I2C/SMBus driver");
|
||||
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_voodoo3_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
return voodoo3_cleanup();
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
module_init(i2c_voodoo3_init);
|
||||
module_exit(i2c_voodoo3_exit);
|
||||
Reference in new issue
Block a user