mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-03 07:45:30 +00:00
backport from kernel 2.5.69. tested OK.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1756 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -60,6 +60,8 @@
|
|||||||
|
|
||||||
/* Note: we assume there can only be one ALI15X3, with one SMBus interface */
|
/* Note: we assume there can only be one ALI15X3, with one SMBus interface */
|
||||||
|
|
||||||
|
/* #define DEBUG 1 */
|
||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
@@ -69,49 +71,49 @@
|
|||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include "version.h"
|
#include "sensors_compat.h"
|
||||||
|
|
||||||
/* ALI15X3 SMBus address offsets */
|
/* ALI15X3 SMBus address offsets */
|
||||||
#define SMBHSTSTS (0 + ali15x3_smba)
|
#define SMBHSTSTS (0 + ali15x3_smba)
|
||||||
#define SMBHSTCNT (1 + ali15x3_smba)
|
#define SMBHSTCNT (1 + ali15x3_smba)
|
||||||
#define SMBHSTSTART (2 + ali15x3_smba)
|
#define SMBHSTSTART (2 + ali15x3_smba)
|
||||||
#define SMBHSTCMD (7 + ali15x3_smba)
|
#define SMBHSTCMD (7 + ali15x3_smba)
|
||||||
#define SMBHSTADD (3 + ali15x3_smba)
|
#define SMBHSTADD (3 + ali15x3_smba)
|
||||||
#define SMBHSTDAT0 (4 + ali15x3_smba)
|
#define SMBHSTDAT0 (4 + ali15x3_smba)
|
||||||
#define SMBHSTDAT1 (5 + ali15x3_smba)
|
#define SMBHSTDAT1 (5 + ali15x3_smba)
|
||||||
#define SMBBLKDAT (6 + ali15x3_smba)
|
#define SMBBLKDAT (6 + ali15x3_smba)
|
||||||
|
|
||||||
/* PCI Address Constants */
|
/* PCI Address Constants */
|
||||||
#define SMBCOM 0x004
|
#define SMBCOM 0x004
|
||||||
#define SMBBA 0x014
|
#define SMBBA 0x014
|
||||||
#define SMBATPC 0x05B /* used to unlock xxxBA registers */
|
#define SMBATPC 0x05B /* used to unlock xxxBA registers */
|
||||||
#define SMBHSTCFG 0x0E0
|
#define SMBHSTCFG 0x0E0
|
||||||
#define SMBSLVC 0x0E1
|
#define SMBSLVC 0x0E1
|
||||||
#define SMBCLK 0x0E2
|
#define SMBCLK 0x0E2
|
||||||
#define SMBREV 0x008
|
#define SMBREV 0x008
|
||||||
|
|
||||||
/* Other settings */
|
/* Other settings */
|
||||||
#define MAX_TIMEOUT 200 /* times 1/100 sec */
|
#define MAX_TIMEOUT 200 /* times 1/100 sec */
|
||||||
#define ALI15X3_SMB_IOSIZE 32
|
#define ALI15X3_SMB_IOSIZE 32
|
||||||
|
|
||||||
/* this is what the Award 1004 BIOS sets them to on a ASUS P5A MB.
|
/* this is what the Award 1004 BIOS sets them to on a ASUS P5A MB.
|
||||||
We don't use these here. If the bases aren't set to some value we
|
We don't use these here. If the bases aren't set to some value we
|
||||||
tell user to upgrade BIOS and we fail.
|
tell user to upgrade BIOS and we fail.
|
||||||
*/
|
*/
|
||||||
#define ALI15X3_SMB_DEFAULTBASE 0xE800
|
#define ALI15X3_SMB_DEFAULTBASE 0xE800
|
||||||
|
|
||||||
/* ALI15X3 address lock bits */
|
/* ALI15X3 address lock bits */
|
||||||
#define ALI15X3_LOCK 0x06
|
#define ALI15X3_LOCK 0x06
|
||||||
|
|
||||||
/* ALI15X3 command constants */
|
/* ALI15X3 command constants */
|
||||||
#define ALI15X3_ABORT 0x02
|
#define ALI15X3_ABORT 0x02
|
||||||
#define ALI15X3_T_OUT 0x04
|
#define ALI15X3_T_OUT 0x04
|
||||||
#define ALI15X3_QUICK 0x00
|
#define ALI15X3_QUICK 0x00
|
||||||
#define ALI15X3_BYTE 0x10
|
#define ALI15X3_BYTE 0x10
|
||||||
#define ALI15X3_BYTE_DATA 0x20
|
#define ALI15X3_BYTE_DATA 0x20
|
||||||
#define ALI15X3_WORD_DATA 0x30
|
#define ALI15X3_WORD_DATA 0x30
|
||||||
#define ALI15X3_BLOCK_DATA 0x40
|
#define ALI15X3_BLOCK_DATA 0x40
|
||||||
#define ALI15X3_BLOCK_CLR 0x80
|
#define ALI15X3_BLOCK_CLR 0x80
|
||||||
|
|
||||||
/* ALI15X3 status register bits */
|
/* ALI15X3 status register bits */
|
||||||
#define ALI15X3_STS_IDLE 0x04
|
#define ALI15X3_STS_IDLE 0x04
|
||||||
@@ -130,77 +132,52 @@ MODULE_PARM(force_addr, "i");
|
|||||||
MODULE_PARM_DESC(force_addr,
|
MODULE_PARM_DESC(force_addr,
|
||||||
"Initialize the base address of the i2c controller");
|
"Initialize the base address of the i2c controller");
|
||||||
|
|
||||||
|
|
||||||
static void ali15x3_do_pause(unsigned int amount);
|
|
||||||
static int ali15x3_transaction(void);
|
|
||||||
|
|
||||||
static unsigned short ali15x3_smba = 0;
|
static unsigned short ali15x3_smba = 0;
|
||||||
static int locked=0;
|
|
||||||
|
|
||||||
/* Detect whether a ALI15X3 can be found, and initialize it, where necessary.
|
static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
|
||||||
Note the differences between kernels with the old PCI BIOS interface and
|
|
||||||
newer kernels with the real PCI interface. In compat.h some things are
|
|
||||||
defined to make the transition easier. */
|
|
||||||
int ali15x3_setup(void)
|
|
||||||
{
|
{
|
||||||
u16 a;
|
u16 a;
|
||||||
unsigned char temp;
|
unsigned char temp;
|
||||||
|
|
||||||
struct pci_dev *ALI15X3_dev;
|
/* Check the following things:
|
||||||
|
- SMB I/O address is initialized
|
||||||
|
- Device is enabled
|
||||||
|
- We can use the addresses
|
||||||
|
*/
|
||||||
|
|
||||||
/* First check whether we can access PCI at all */
|
/* Unlock the register.
|
||||||
if (pci_present() == 0) {
|
The data sheet says that the address registers are read-only
|
||||||
printk("i2c-ali15x3.o: Error: No PCI-bus found!\n");
|
if the lock bits are 1, but in fact the address registers
|
||||||
return -ENODEV;
|
are zero unless you clear the lock bits.
|
||||||
}
|
*/
|
||||||
|
|
||||||
/* Look for the ALI15X3, M7101 device */
|
|
||||||
ALI15X3_dev = NULL;
|
|
||||||
ALI15X3_dev = pci_find_device(PCI_VENDOR_ID_AL,
|
|
||||||
PCI_DEVICE_ID_AL_M7101, ALI15X3_dev);
|
|
||||||
if (ALI15X3_dev == NULL) {
|
|
||||||
printk("i2c-ali15x3.o: Error: Can't detect ali15x3!\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the following things:
|
|
||||||
- SMB I/O address is initialized
|
|
||||||
- Device is enabled
|
|
||||||
- We can use the addresses
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Unlock the register.
|
|
||||||
The data sheet says that the address registers are read-only
|
|
||||||
if the lock bits are 1, but in fact the address registers
|
|
||||||
are zero unless you clear the lock bits.
|
|
||||||
*/
|
|
||||||
pci_read_config_byte(ALI15X3_dev, SMBATPC, &temp);
|
pci_read_config_byte(ALI15X3_dev, SMBATPC, &temp);
|
||||||
if (temp & ALI15X3_LOCK) {
|
if (temp & ALI15X3_LOCK) {
|
||||||
temp &= ~ALI15X3_LOCK;
|
temp &= ~ALI15X3_LOCK;
|
||||||
pci_write_config_byte(ALI15X3_dev, SMBATPC, temp);
|
pci_write_config_byte(ALI15X3_dev, SMBATPC, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine the address of the SMBus area */
|
/* Determine the address of the SMBus area */
|
||||||
pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba);
|
pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba);
|
||||||
ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1));
|
ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1));
|
||||||
if (ali15x3_smba == 0 && force_addr == 0) {
|
if (ali15x3_smba == 0 && force_addr == 0) {
|
||||||
printk
|
dev_err(ALI15X3_dev, "ALI15X3_smb region uninitialized "
|
||||||
("i2c-ali15x3.o: ALI15X3_smb region uninitialized - upgrade BIOS or use force_addr=0xaddr\n");
|
"- upgrade BIOS or use force_addr=0xaddr\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(force_addr)
|
if(force_addr)
|
||||||
ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);
|
ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);
|
||||||
|
|
||||||
if (check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE)) {
|
if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb")) {
|
||||||
printk
|
dev_err(ALI15X3_dev,
|
||||||
("i2c-ali15x3.o: ALI15X3_smb region 0x%x already in use!\n",
|
"ALI15X3_smb region 0x%x already in use!\n",
|
||||||
ali15x3_smba);
|
ali15x3_smba);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(force_addr) {
|
if(force_addr) {
|
||||||
printk("i2c-ali15x3.o: forcing ISA address 0x%04X\n", ali15x3_smba);
|
dev_info(ALI15X3_dev, "forcing ISA address 0x%04X\n",
|
||||||
|
ali15x3_smba);
|
||||||
if (PCIBIOS_SUCCESSFUL !=
|
if (PCIBIOS_SUCCESSFUL !=
|
||||||
pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba))
|
pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
@@ -209,68 +186,60 @@ int ali15x3_setup(void)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
|
if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) {
|
||||||
/* make sure it works */
|
/* make sure it works */
|
||||||
printk("i2c-ali15x3.o: force address failed - not supported?\n");
|
dev_err(ALI15X3_dev,
|
||||||
|
"force address failed - not supported?\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* check if whole device is enabled */
|
/* check if whole device is enabled */
|
||||||
pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp);
|
pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp);
|
||||||
if ((temp & 1) == 0) {
|
if ((temp & 1) == 0) {
|
||||||
printk("i2c-ali15x3: enabling SMBus device\n");
|
dev_info(ALI15X3_dev, "enabling SMBus device\n");
|
||||||
pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01);
|
pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is SMB Host controller enabled? */
|
/* Is SMB Host controller enabled? */
|
||||||
pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp);
|
pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp);
|
||||||
if ((temp & 1) == 0) {
|
if ((temp & 1) == 0) {
|
||||||
printk("i2c-ali15x3: enabling SMBus controller\n");
|
dev_info(ALI15X3_dev, "enabling SMBus controller\n");
|
||||||
pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01);
|
pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set SMB clock to 74KHz as recommended in data sheet */
|
/* set SMB clock to 74KHz as recommended in data sheet */
|
||||||
pci_write_config_byte(ALI15X3_dev, SMBCLK, 0x20);
|
pci_write_config_byte(ALI15X3_dev, SMBCLK, 0x20);
|
||||||
|
|
||||||
/* Everything is happy, let's grab the memory and set things up. */
|
/*
|
||||||
request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb");
|
The interrupt routing for SMB is set up in register 0x77 in the
|
||||||
|
1533 ISA Bridge device, NOT in the 7101 device.
|
||||||
#ifdef DEBUG
|
Don't bother with finding the 1533 device and reading the register.
|
||||||
/*
|
if ((....... & 0x0F) == 1)
|
||||||
The interrupt routing for SMB is set up in register 0x77 in the
|
dev_dbg(&ALI15X3_dev, "ALI15X3 using Interrupt 9 for SMBus.\n");
|
||||||
1533 ISA Bridge device, NOT in the 7101 device.
|
*/
|
||||||
Don't bother with finding the 1533 device and reading the register.
|
|
||||||
if ((....... & 0x0F) == 1)
|
|
||||||
printk("i2c-ali15x3.o: ALI15X3 using Interrupt 9 for SMBus.\n");
|
|
||||||
*/
|
|
||||||
pci_read_config_byte(ALI15X3_dev, SMBREV, &temp);
|
pci_read_config_byte(ALI15X3_dev, SMBREV, &temp);
|
||||||
printk("i2c-ali15x3.o: SMBREV = 0x%X\n", temp);
|
dev_dbg(&ALI15X3_dev, "SMBREV = 0x%X\n", temp);
|
||||||
printk("i2c-ali15x3.o: ALI15X3_smba = 0x%X\n", ali15x3_smba);
|
dev_dbg(&ALI15X3_dev, "iALI15X3_smba = 0x%X\n", ali15x3_smba);
|
||||||
#endif /* DEBUG */
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Internally used pause function */
|
/* Internally used pause function */
|
||||||
void ali15x3_do_pause(unsigned int amount)
|
static void ali15x3_do_pause(unsigned int amount)
|
||||||
{
|
{
|
||||||
current->state = TASK_INTERRUPTIBLE;
|
current->state = TASK_INTERRUPTIBLE;
|
||||||
schedule_timeout(amount);
|
schedule_timeout(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Another internally used function */
|
/* Another internally used function */
|
||||||
int ali15x3_transaction(void)
|
static int ali15x3_transaction(struct i2c_adapter *adap)
|
||||||
{
|
{
|
||||||
int temp;
|
int temp;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
dev_dbg(&adap, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, "
|
||||||
printk
|
"ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS),
|
||||||
("i2c-ali15x3.o: Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, "
|
inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
|
||||||
"DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT),
|
inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
|
||||||
inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
|
|
||||||
inb_p(SMBHSTDAT1));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* get status */
|
/* get status */
|
||||||
temp = inb_p(SMBHSTSTS);
|
temp = inb_p(SMBHSTSTS);
|
||||||
@@ -278,43 +247,32 @@ int ali15x3_transaction(void)
|
|||||||
/* Make sure the SMBus host is ready to start transmitting */
|
/* Make sure the SMBus host is ready to start transmitting */
|
||||||
/* Check the busy bit first */
|
/* Check the busy bit first */
|
||||||
if (temp & ALI15X3_STS_BUSY) {
|
if (temp & ALI15X3_STS_BUSY) {
|
||||||
/*
|
/*
|
||||||
If the host controller is still busy, it may have timed out in the previous transaction,
|
If the host controller is still busy, it may have timed out in the
|
||||||
resulting in a "SMBus Timeout" printk.
|
previous transaction, resulting in a "SMBus Timeout" Dev.
|
||||||
I've tried the following to reset a stuck busy bit.
|
I've tried the following to reset a stuck busy bit.
|
||||||
1. Reset the controller with an ABORT command.
|
1. Reset the controller with an ABORT command.
|
||||||
(this doesn't seem to clear the controller if an external device is hung)
|
(this doesn't seem to clear the controller if an external
|
||||||
2. Reset the controller and the other SMBus devices with a T_OUT command.
|
device is hung)
|
||||||
(this clears the host busy bit if an external device is hung,
|
2. Reset the controller and the other SMBus devices with a
|
||||||
but it comes back upon a new access to a device)
|
T_OUT command. (this clears the host busy bit if an
|
||||||
3. Disable and reenable the controller in SMBHSTCFG
|
external device is hung, but it comes back upon a new access
|
||||||
Worst case, nothing seems to work except power reset.
|
to a device)
|
||||||
*/
|
3. Disable and reenable the controller in SMBHSTCFG
|
||||||
/* Abort - reset the host controller */
|
Worst case, nothing seems to work except power reset.
|
||||||
/*
|
*/
|
||||||
#ifdef DEBUG
|
/* Abort - reset the host controller */
|
||||||
printk("i2c-ali15x3.o: Resetting host controller to clear busy condition\n",temp);
|
/*
|
||||||
#endif
|
Try resetting entire SMB bus, including other devices -
|
||||||
outb_p(ALI15X3_ABORT, SMBHSTCNT);
|
This may not work either - it clears the BUSY bit but
|
||||||
temp = inb_p(SMBHSTSTS);
|
then the BUSY bit may come back on when you try and use the chip again.
|
||||||
if (temp & ALI15X3_STS_BUSY) {
|
If that's the case you are stuck.
|
||||||
*/
|
*/
|
||||||
|
dev_info(adap, "Resetting entire SMB Bus to "
|
||||||
/*
|
"clear busy condition (%02x)\n", temp);
|
||||||
Try resetting entire SMB bus, including other devices -
|
|
||||||
This may not work either - it clears the BUSY bit but
|
|
||||||
then the BUSY bit may come back on when you try and use the chip again.
|
|
||||||
If that's the case you are stuck.
|
|
||||||
*/
|
|
||||||
printk
|
|
||||||
("i2c-ali15x3.o: Resetting entire SMB Bus to clear busy condition (%02x)\n",
|
|
||||||
temp);
|
|
||||||
outb_p(ALI15X3_T_OUT, SMBHSTCNT);
|
outb_p(ALI15X3_T_OUT, SMBHSTCNT);
|
||||||
temp = inb_p(SMBHSTSTS);
|
temp = inb_p(SMBHSTSTS);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* now check the error bits and the busy bit */
|
/* now check the error bits and the busy bit */
|
||||||
if (temp & (ALI15X3_STS_ERR | ALI15X3_STS_BUSY)) {
|
if (temp & (ALI15X3_STS_ERR | ALI15X3_STS_BUSY)) {
|
||||||
@@ -325,9 +283,9 @@ int ali15x3_transaction(void)
|
|||||||
/* this is probably going to be correctable only by a power reset
|
/* this is probably going to be correctable only by a power reset
|
||||||
as one of the bits now appears to be stuck */
|
as one of the bits now appears to be stuck */
|
||||||
/* This may be a bus or device with electrical problems. */
|
/* This may be a bus or device with electrical problems. */
|
||||||
printk
|
dev_err(adap, "SMBus reset failed! (0x%02x) - "
|
||||||
("i2c-ali15x3.o: SMBus reset failed! (0x%02x) - controller or device on bus is probably hung\n",
|
"controller or device on bus is probably hung\n",
|
||||||
temp);
|
temp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -351,48 +309,41 @@ int ali15x3_transaction(void)
|
|||||||
/* If the SMBus is still busy, we give up */
|
/* If the SMBus is still busy, we give up */
|
||||||
if (timeout >= MAX_TIMEOUT) {
|
if (timeout >= MAX_TIMEOUT) {
|
||||||
result = -1;
|
result = -1;
|
||||||
printk("i2c-ali15x3.o: SMBus Timeout!\n");
|
dev_err(adap, "SMBus Timeout!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp & ALI15X3_STS_TERM) {
|
if (temp & ALI15X3_STS_TERM) {
|
||||||
result = -1;
|
result = -1;
|
||||||
#ifdef DEBUG
|
dev_dbg(&adap, "Error: Failed bus transaction\n");
|
||||||
printk("i2c-ali15x3.o: Error: Failed bus transaction\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Unfortunately the ALI SMB controller maps "no response" and "bus collision"
|
Unfortunately the ALI SMB controller maps "no response" and "bus
|
||||||
into a single bit. No reponse is the usual case so don't
|
collision" into a single bit. No reponse is the usual case so don't
|
||||||
do a printk.
|
do a printk.
|
||||||
This means that bus collisions go unreported.
|
This means that bus collisions go unreported.
|
||||||
*/
|
*/
|
||||||
if (temp & ALI15X3_STS_COLL) {
|
if (temp & ALI15X3_STS_COLL) {
|
||||||
result = -1;
|
result = -1;
|
||||||
#ifdef DEBUG
|
dev_dbg(&adap,
|
||||||
printk
|
"Error: no response or bus collision ADD=%02x\n",
|
||||||
("i2c-ali15x3.o: Error: no response or bus collision ADD=%02x\n",
|
inb_p(SMBHSTADD));
|
||||||
inb_p(SMBHSTADD));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* haven't ever seen this */
|
/* haven't ever seen this */
|
||||||
if (temp & ALI15X3_STS_DEV) {
|
if (temp & ALI15X3_STS_DEV) {
|
||||||
result = -1;
|
result = -1;
|
||||||
printk("i2c-ali15x3.o: Error: device error\n");
|
dev_err(adap, "Error: device error\n");
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
dev_dbg(&adap, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, "
|
||||||
printk
|
"ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS),
|
||||||
("i2c-ali15x3.o: Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, "
|
inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
|
||||||
"DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT),
|
inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
|
||||||
inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
|
|
||||||
inb_p(SMBHSTDAT1));
|
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return -1 on error. */
|
/* Return -1 on error. */
|
||||||
s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
||||||
unsigned short flags, char read_write, u8 command,
|
unsigned short flags, char read_write, u8 command,
|
||||||
int size, union i2c_smbus_data * data)
|
int size, union i2c_smbus_data * data)
|
||||||
{
|
{
|
||||||
@@ -400,9 +351,9 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
|||||||
int temp;
|
int temp;
|
||||||
int timeout;
|
int timeout;
|
||||||
|
|
||||||
/* clear all the bits (clear-on-write) */
|
/* clear all the bits (clear-on-write) */
|
||||||
outb_p(0xFF, SMBHSTSTS);
|
outb_p(0xFF, SMBHSTSTS);
|
||||||
/* make sure SMBus is idle */
|
/* make sure SMBus is idle */
|
||||||
temp = inb_p(SMBHSTSTS);
|
temp = inb_p(SMBHSTSTS);
|
||||||
for (timeout = 0;
|
for (timeout = 0;
|
||||||
(timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE);
|
(timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE);
|
||||||
@@ -411,14 +362,12 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
|||||||
temp = inb_p(SMBHSTSTS);
|
temp = inb_p(SMBHSTSTS);
|
||||||
}
|
}
|
||||||
if (timeout >= MAX_TIMEOUT) {
|
if (timeout >= MAX_TIMEOUT) {
|
||||||
printk("i2c-ali15x3.o: Idle wait Timeout! STS=0x%02x\n",
|
dev_err(adap, "Idle wait Timeout! STS=0x%02x\n", temp);
|
||||||
temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case I2C_SMBUS_PROC_CALL:
|
case I2C_SMBUS_PROC_CALL:
|
||||||
printk
|
dev_err(adap, "I2C_SMBUS_PROC_CALL not supported!\n");
|
||||||
("i2c-ali15x3.o: I2C_SMBUS_PROC_CALL not supported!\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
case I2C_SMBUS_QUICK:
|
case I2C_SMBUS_QUICK:
|
||||||
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
|
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
|
||||||
@@ -465,7 +414,8 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
|||||||
data->block[0] = len;
|
data->block[0] = len;
|
||||||
}
|
}
|
||||||
outb_p(len, SMBHSTDAT0);
|
outb_p(len, SMBHSTDAT0);
|
||||||
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */
|
/* Reset SMBBLKDAT */
|
||||||
|
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT);
|
||||||
for (i = 1; i <= len; i++)
|
for (i = 1; i <= len; i++)
|
||||||
outb_p(data->block[i], SMBBLKDAT);
|
outb_p(data->block[i], SMBBLKDAT);
|
||||||
}
|
}
|
||||||
@@ -475,7 +425,7 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
|||||||
|
|
||||||
outb_p(size, SMBHSTCNT); /* output command */
|
outb_p(size, SMBHSTCNT); /* output command */
|
||||||
|
|
||||||
if (ali15x3_transaction()) /* Error in transaction */
|
if (ali15x3_transaction(adap)) /* Error in transaction */
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK))
|
if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK))
|
||||||
@@ -497,22 +447,19 @@ s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
|
|||||||
if (len > 32)
|
if (len > 32)
|
||||||
len = 32;
|
len = 32;
|
||||||
data->block[0] = len;
|
data->block[0] = len;
|
||||||
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */
|
/* Reset SMBBLKDAT */
|
||||||
|
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT);
|
||||||
for (i = 1; i <= data->block[0]; i++) {
|
for (i = 1; i <= data->block[0]; i++) {
|
||||||
data->block[i] = inb_p(SMBBLKDAT);
|
data->block[i] = inb_p(SMBBLKDAT);
|
||||||
#ifdef DEBUG
|
dev_dbg(&adap, "Blk: len=%d, i=%d, data=%02x\n",
|
||||||
printk
|
len, i, data->block[i]);
|
||||||
("i2c-ali15x3.o: Blk: len=%d, i=%d, data=%02x\n",
|
|
||||||
len, i, data->block[i]);
|
|
||||||
#endif /* DEBUG */
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static u32 ali15x3_func(struct i2c_adapter *adapter)
|
||||||
u32 ali15x3_func(struct i2c_adapter *adapter)
|
|
||||||
{
|
{
|
||||||
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
|
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
|
||||||
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
|
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
|
||||||
@@ -528,29 +475,32 @@ static struct i2c_algorithm smbus_algorithm = {
|
|||||||
|
|
||||||
static struct i2c_adapter ali15x3_adapter = {
|
static struct i2c_adapter ali15x3_adapter = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.name = "unset",
|
|
||||||
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
|
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
|
||||||
.algo = &smbus_algorithm,
|
.algo = &smbus_algorithm,
|
||||||
|
.name = "unset",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct pci_device_id ali15x3_ids[] __devinitdata = {
|
static struct pci_device_id ali15x3_ids[] __devinitdata = {
|
||||||
|
{
|
||||||
|
.vendor = PCI_VENDOR_ID_AL,
|
||||||
|
.device = PCI_DEVICE_ID_AL_M7101,
|
||||||
|
.subvendor = PCI_ANY_ID,
|
||||||
|
.subdevice = PCI_ANY_ID,
|
||||||
|
},
|
||||||
{ 0, }
|
{ 0, }
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
if (ali15x3_setup()) {
|
if (ali15x3_setup(dev)) {
|
||||||
printk
|
dev_err(dev,
|
||||||
("i2c-ali15x3.o: ALI15X3 not detected, module not inserted.\n");
|
"ALI15X3 not detected, module not inserted.\n");
|
||||||
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(ali15x3_adapter.name, "SMBus ALI15X3 adapter at %04x",
|
snprintf(ali15x3_adapter.name, 32,
|
||||||
ali15x3_smba);
|
"SMBus ALI15X3 adapter at %04x", ali15x3_smba);
|
||||||
i2c_add_adapter(&ali15x3_adapter);
|
return i2c_add_adapter(&ali15x3_adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __devexit ali15x3_remove(struct pci_dev *dev)
|
static void __devexit ali15x3_remove(struct pci_dev *dev)
|
||||||
@@ -567,21 +517,19 @@ static struct pci_driver ali15x3_driver = {
|
|||||||
|
|
||||||
static int __init i2c_ali15x3_init(void)
|
static int __init i2c_ali15x3_init(void)
|
||||||
{
|
{
|
||||||
printk("i2c-ali15x3.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
printk("i2c-ali15x3.o version %s (%s)\n", I2C_VERSION, I2C_DATE);
|
||||||
return pci_module_init(&ali15x3_driver);
|
return pci_module_init(&ali15x3_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void __exit i2c_ali15x3_exit(void)
|
static void __exit i2c_ali15x3_exit(void)
|
||||||
{
|
{
|
||||||
pci_unregister_driver(&ali15x3_driver);
|
pci_unregister_driver(&ali15x3_driver);
|
||||||
release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE);
|
release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl>, "
|
||||||
|
"Philip Edelbrock <phil@netroedge.com>, "
|
||||||
MODULE_AUTHOR
|
"and Mark D. Studebaker <mdsxyz123@yahoo.com>");
|
||||||
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
|
|
||||||
MODULE_DESCRIPTION("ALI15X3 SMBus driver");
|
MODULE_DESCRIPTION("ALI15X3 SMBus driver");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user