Commit f289aa67 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://kernel.bkbits.net/gregkh/linux/i2c-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents 76c25284 0b4a5d51
...@@ -76,6 +76,24 @@ config I2C_I801 ...@@ -76,6 +76,24 @@ config I2C_I801
in the lm_sensors package, which you can download at in the lm_sensors package, which you can download at
http://www.lm-sensors.nu http://www.lm-sensors.nu
config I2C_ISA
tristate " ISA Bus support"
depends on I2C && I2C_PROC && ISA && EXPERIMENTAL
help
If you say yes to this option, support will be included for i2c
interfaces that are on the ISA bus.
This can also be built as a module which can be inserted and removed
while the kernel is running. If you want to compile it as a module,
say M here and read <file:Documentation/modules.txt>.
The module will be called i2c-isa.
You will also need the latest user-space utilties: you can find them
in the lm_sensors package, which you can download at
http://www.lm-sensors.nu
config I2C_PIIX4 config I2C_PIIX4
tristate " Intel PIIX4" tristate " Intel PIIX4"
depends on I2C && I2C_PROC && PCI && EXPERIMENTAL depends on I2C && I2C_PROC && PCI && EXPERIMENTAL
......
...@@ -6,4 +6,5 @@ obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o ...@@ -6,4 +6,5 @@ obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o
obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o
obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o
obj-$(CONFIG_I2C_I801) += i2c-i801.o obj-$(CONFIG_I2C_I801) += i2c-i801.o
obj-$(CONFIG_I2C_ISA) += i2c-isa.o
obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o
This diff is collapsed.
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
Note: we assume there can only be one device, with one SMBus interface. Note: we assume there can only be one device, with one SMBus interface.
*/ */
/* #define DEBUG 1 */
#include <linux/version.h> #include <linux/version.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -46,8 +48,6 @@ ...@@ -46,8 +48,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <asm/io.h> #include <asm/io.h>
#define DRV_NAME "i2c-amd756"
/* AMD756 SMBus address offsets */ /* AMD756 SMBus address offsets */
#define SMB_ADDR_OFFSET 0xE0 #define SMB_ADDR_OFFSET 0xE0
#define SMB_IOSIZE 16 #define SMB_IOSIZE 16
...@@ -117,20 +117,20 @@ static void amd756_do_pause(unsigned int amount) ...@@ -117,20 +117,20 @@ static void amd756_do_pause(unsigned int amount)
#define GE_ABORT (1 << 5) #define GE_ABORT (1 << 5)
static int amd756_transaction(void) static int amd756_transaction(struct i2c_adapter *adap)
{ {
int temp; int temp;
int result = 0; int result = 0;
int timeout = 0; int timeout = 0;
pr_debug(DRV_NAME dev_dbg(&adap->dev, ": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", "DAT=%04x\n", inw_p(SMB_GLOBAL_STATUS),
inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_HOST_ADDRESS),
inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); inb_p(SMB_HOST_DATA));
/* Make sure the SMBus host is ready to start transmitting */ /* Make sure the SMBus host is ready to start transmitting */
if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) { if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
pr_debug(DRV_NAME ": SMBus busy (%04x). Waiting... \n", temp); dev_dbg(&adap->dev, ": SMBus busy (%04x). Waiting... \n", temp);
do { do {
amd756_do_pause(1); amd756_do_pause(1);
temp = inw_p(SMB_GLOBAL_STATUS); temp = inw_p(SMB_GLOBAL_STATUS);
...@@ -138,7 +138,7 @@ static int amd756_transaction(void) ...@@ -138,7 +138,7 @@ static int amd756_transaction(void)
(timeout++ < MAX_TIMEOUT)); (timeout++ < MAX_TIMEOUT));
/* 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) {
pr_debug(DRV_NAME ": Busy wait timeout (%04x)\n", temp); dev_dbg(&adap->dev, ": Busy wait timeout (%04x)\n", temp);
goto abort; goto abort;
} }
timeout = 0; timeout = 0;
...@@ -155,46 +155,46 @@ static int amd756_transaction(void) ...@@ -155,46 +155,46 @@ static int amd756_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) {
pr_debug(DRV_NAME ": Completion timeout!\n"); dev_dbg(&adap->dev, ": Completion timeout!\n");
goto abort; goto abort;
} }
if (temp & GS_PRERR_STS) { if (temp & GS_PRERR_STS) {
result = -1; result = -1;
pr_debug(DRV_NAME ": SMBus Protocol error (no response)!\n"); dev_dbg(&adap->dev, ": SMBus Protocol error (no response)!\n");
} }
if (temp & GS_COL_STS) { if (temp & GS_COL_STS) {
result = -1; result = -1;
printk(KERN_WARNING DRV_NAME " SMBus collision!\n"); dev_warn(&adap->dev, " SMBus collision!\n");
} }
if (temp & GS_TO_STS) { if (temp & GS_TO_STS) {
result = -1; result = -1;
pr_debug(DRV_NAME ": SMBus protocol timeout!\n"); dev_dbg(&adap->dev, ": SMBus protocol timeout!\n");
} }
if (temp & GS_HCYC_STS) if (temp & GS_HCYC_STS)
pr_debug(DRV_NAME " SMBus protocol success!\n"); dev_dbg(&adap->dev, " SMBus protocol success!\n");
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
#ifdef DEBUG #ifdef DEBUG
if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) { if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) {
pr_debug(DRV_NAME dev_dbg(&adap->dev,
": Failed reset at end of transaction (%04x)\n", temp); ": Failed reset at end of transaction (%04x)\n", temp);
} }
#endif
pr_debug(DRV_NAME dev_dbg(&adap->dev,
": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", ": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
#endif
return result; return result;
abort: abort:
printk(KERN_WARNING DRV_NAME ": Sending abort.\n"); dev_warn(&adap->dev, ": Sending abort.\n");
outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
amd756_do_pause(100); amd756_do_pause(100);
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
...@@ -211,7 +211,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, ...@@ -211,7 +211,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
/** TODO: Should I supporte the 10-bit transfers? */ /** TODO: Should I supporte the 10-bit transfers? */
switch (size) { switch (size) {
case I2C_SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
pr_debug(DRV_NAME ": I2C_SMBUS_PROC_CALL not supported!\n"); dev_dbg(&adap->dev, ": I2C_SMBUS_PROC_CALL not supported!\n");
/* TODO: Well... It is supported, I'm just not sure what to do here... */ /* TODO: Well... It is supported, I'm just not sure what to do here... */
return -1; return -1;
case I2C_SMBUS_QUICK: case I2C_SMBUS_QUICK:
...@@ -266,7 +266,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, ...@@ -266,7 +266,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
/* How about enabling interrupts... */ /* How about enabling interrupts... */
outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE); outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE);
if (amd756_transaction()) /* Error in transaction */ if (amd756_transaction(adap)) /* Error in transaction */
return -1; return -1;
if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK)) if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK))
...@@ -334,7 +334,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -334,7 +334,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
u8 temp; u8 temp;
if (amd756_ioport) { if (amd756_ioport) {
printk(KERN_ERR DRV_NAME ": Only one device supported. " dev_err(&pdev->dev, ": Only one device supported. "
"(you have a strange motherboard, btw..)\n"); "(you have a strange motherboard, btw..)\n");
return -ENODEV; return -ENODEV;
} }
...@@ -351,7 +351,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -351,7 +351,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
pci_read_config_byte(pdev, SMBGCFG, &temp); pci_read_config_byte(pdev, SMBGCFG, &temp);
if ((temp & 128) == 0) { if ((temp & 128) == 0) {
printk(KERN_ERR DRV_NAME dev_err(&pdev->dev,
": Error: SMBus controller I/O not enabled!\n"); ": Error: SMBus controller I/O not enabled!\n");
return -ENODEV; return -ENODEV;
} }
...@@ -364,16 +364,14 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -364,16 +364,14 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
} }
if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) {
printk(KERN_ERR DRV_NAME dev_err(&pdev->dev, ": SMB region 0x%x already in use!\n",
": SMB region 0x%x already in use!\n", amd756_ioport); amd756_ioport);
return -ENODEV; return -ENODEV;
} }
#ifdef DEBUG
pci_read_config_byte(pdev, SMBREV, &temp); pci_read_config_byte(pdev, SMBREV, &temp);
printk(KERN_DEBUG DRV_NAME ": SMBREV = 0x%X\n", temp); dev_dbg(&pdev->dev, ": SMBREV = 0x%X\n", temp);
printk(KERN_DEBUG DRV_NAME ": AMD756_smba = 0x%X\n", amd756_ioport); dev_dbg(&pdev->dev, ": AMD756_smba = 0x%X\n", amd756_ioport);
#endif
/* set up the driverfs linkage to our parent device */ /* set up the driverfs linkage to our parent device */
amd756_adapter.dev.parent = &pdev->dev; amd756_adapter.dev.parent = &pdev->dev;
...@@ -383,7 +381,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -383,7 +381,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
error = i2c_add_adapter(&amd756_adapter); error = i2c_add_adapter(&amd756_adapter);
if (error) { if (error) {
printk(KERN_ERR DRV_NAME dev_err(&pdev->dev,
": Adapter registration failed, module not inserted.\n"); ": Adapter registration failed, module not inserted.\n");
goto out_err; goto out_err;
} }
......
...@@ -74,7 +74,7 @@ unsigned int amd_ec_wait_write(struct amd_smbus *smbus) ...@@ -74,7 +74,7 @@ unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
udelay(1); udelay(1);
if (!timeout) { if (!timeout) {
printk(KERN_WARNING "i2c-amd8111.c: Timeout while waiting for IBF to clear\n"); dev_warn(&smbus->dev->dev, "Timeout while waiting for IBF to clear\n");
return -1; return -1;
} }
...@@ -89,7 +89,7 @@ unsigned int amd_ec_wait_read(struct amd_smbus *smbus) ...@@ -89,7 +89,7 @@ unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
udelay(1); udelay(1);
if (!timeout) { if (!timeout) {
printk(KERN_WARNING "i2c-amd8111.c: Timeout while waiting for OBF to set\n"); dev_warn(&smbus->dev->dev, "Timeout while waiting for OBF to set\n");
return -1; return -1;
} }
...@@ -256,11 +256,11 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, ...@@ -256,11 +256,11 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
case I2C_SMBUS_BLOCK_DATA_PEC: case I2C_SMBUS_BLOCK_DATA_PEC:
case I2C_SMBUS_PROC_CALL_PEC: case I2C_SMBUS_PROC_CALL_PEC:
case I2C_SMBUS_BLOCK_PROC_CALL_PEC: case I2C_SMBUS_BLOCK_PROC_CALL_PEC:
printk(KERN_WARNING "i2c-amd8111.c: Unexpected software PEC transaction %d\n.", size); dev_warn(&adap->dev, "Unexpected software PEC transaction %d\n.", size);
return -1; return -1;
default: default:
printk(KERN_WARNING "i2c-amd8111.c: Unsupported transaction %d\n", size); dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
return -1; return -1;
} }
...@@ -392,7 +392,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev) ...@@ -392,7 +392,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev)
} }
static struct pci_driver amd8111_driver = { static struct pci_driver amd8111_driver = {
.name = "amd8111 smbus", .name = "amd8111 smbus 2",
.id_table = amd8111_ids, .id_table = amd8111_ids,
.probe = amd8111_probe, .probe = amd8111_probe,
.remove = __devexit_p(amd8111_remove), .remove = __devexit_p(amd8111_remove),
......
This diff is collapsed.
/*
i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This implements an i2c algorithm/adapter for ISA bus. Not that this is
on first sight very useful; almost no functionality is preserved.
Except that it makes writing drivers for chips which can be on both
the SMBus and the ISA bus very much easier. See lm78.c for an example
of this. */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/i2c.h>
/* This is the actual algorithm we define */
static struct i2c_algorithm isa_algorithm = {
.name = "ISA bus algorithm",
.id = I2C_ALGO_ISA,
};
/* 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)
{
return i2c_add_adapter(&isa_adapter);
}
static void __exit i2c_isa_exit(void)
{
i2c_del_adapter(&isa_adapter);
}
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
MODULE_DESCRIPTION("ISA bus access through i2c");
MODULE_LICENSE("GPL");
module_init(i2c_isa_init);
module_exit(i2c_isa_exit);
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
Note: we assume there can only be one device, with one SMBus interface. Note: we assume there can only be one device, with one SMBus interface.
*/ */
/* #define DEBUG 1 */
#include <linux/module.h> #include <linux/module.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -102,6 +104,7 @@ static int piix4_transaction(void); ...@@ -102,6 +104,7 @@ static int piix4_transaction(void);
static unsigned short piix4_smba = 0; static unsigned short piix4_smba = 0;
static struct i2c_adapter piix4_adapter;
/* /*
* Get DMI information. * Get DMI information.
...@@ -125,18 +128,17 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id ...@@ -125,18 +128,17 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
if (PCI_FUNC(PIIX4_dev->devfn) != id->driver_data) if (PCI_FUNC(PIIX4_dev->devfn) != id->driver_data)
return -ENODEV; return -ENODEV;
printk(KERN_INFO "i2c-piix4.o: Found %s device\n", PIIX4_dev->dev.name); dev_info(&PIIX4_dev->dev, "Found %s device\n", PIIX4_dev->dev.name);
if(ibm_dmi_probe()) { if(ibm_dmi_probe()) {
printk dev_err(&PIIX4_dev->dev, "IBM Laptop detected; this module "
(KERN_ERR "i2c-piix4.o: IBM Laptop detected; this module may corrupt\n"); "may corrupt your serial eeprom! Refusing to load "
printk "module!\n");
(KERN_ERR " your serial eeprom! Refusing to load module!\n");
error_return = -EPERM; error_return = -EPERM;
goto END; goto END;
} }
/* Determine the address of the SMBus areas */ /* Determine the address of the SMBus areas */
if (force_addr) { if (force_addr) {
piix4_smba = force_addr & 0xfff0; piix4_smba = force_addr & 0xfff0;
force = 0; force = 0;
...@@ -144,75 +146,68 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id ...@@ -144,75 +146,68 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba); pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba);
piix4_smba &= 0xfff0; piix4_smba &= 0xfff0;
if(piix4_smba == 0) { if(piix4_smba == 0) {
printk(KERN_ERR "i2c-piix4.o: SMB base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); dev_err(&PIIX4_dev->dev, "SMB base address "
"uninitialized - upgrade BIOS or use "
"force_addr=0xaddr\n");
return -ENODEV; return -ENODEV;
} }
} }
if (check_region(piix4_smba, 8)) { if (!request_region(piix4_smba, 8, "piix4-smbus")) {
printk dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n",
(KERN_ERR "i2c-piix4.o: SMB region 0x%x already in use!\n",
piix4_smba); piix4_smba);
error_return = -ENODEV; error_return = -ENODEV;
goto END; goto END;
} }
pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp); pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp);
/* If force_addr is set, we program the new address here. Just to make /* If force_addr is set, we program the new address here. Just to make
sure, we disable the PIIX4 first. */ sure, we disable the PIIX4 first. */
if (force_addr) { if (force_addr) {
pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe); pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe);
pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba); pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba);
pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01); pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01);
printk dev_info(&PIIX4_dev->dev, "WARNING: SMBus interface set to "
(KERN_INFO "i2c-piix4.o: WARNING: SMBus interface set to new " "new address %04x!\n", piix4_smba);
"address %04x!\n", piix4_smba);
} else if ((temp & 1) == 0) { } else if ((temp & 1) == 0) {
if (force) { if (force) {
/* This should never need to be done, but has been noted that /* This should never need to be done, but has been
many Dell machines have the SMBus interface on the PIIX4 * noted that many Dell machines have the SMBus
disabled!? NOTE: This assumes I/O space and other allocations WERE * interface on the PIIX4 disabled!? NOTE: This assumes
done by the Bios! Don't complain if your hardware does weird * I/O space and other allocations WERE done by the
things after enabling this. :') Check for Bios updates before * Bios! Don't complain if your hardware does weird
resorting to this. */ * things after enabling this. :') Check for Bios
* updates before resorting to this.
*/
pci_write_config_byte(PIIX4_dev, SMBHSTCFG, pci_write_config_byte(PIIX4_dev, SMBHSTCFG,
temp | 1); temp | 1);
printk dev_printk(KERN_NOTICE, &PIIX4_dev->dev,
(KERN_NOTICE "i2c-piix4.o: WARNING: SMBus interface has been FORCEFULLY " "WARNING: SMBus interface has been "
"ENABLED!\n"); "FORCEFULLY ENABLED!\n");
} else { } else {
printk dev_err(&PIIX4_dev->dev,
(KERN_ERR "i2c-piix4.o: Host SMBus controller not enabled!\n"); "Host SMBus controller not enabled!\n");
error_return = -ENODEV; error_return = -ENODEV;
goto END; goto END;
} }
} }
/* Everything is happy, let's grab the memory and set things up. */
request_region(piix4_smba, 8, "piix4-smbus");
#ifdef DEBUG
if ((temp & 0x0E) == 8) if ((temp & 0x0E) == 8)
printk dev_dbg(&PIIX4_dev->dev, "Using Interrupt 9 for SMBus.\n");
(KERN_DEBUG "i2c-piix4.o: Using Interrupt 9 for SMBus.\n");
else if ((temp & 0x0E) == 0) else if ((temp & 0x0E) == 0)
printk dev_dbg(&PIIX4_dev->dev, "Using Interrupt SMI# for SMBus.\n");
(KERN_DEBUG "i2c-piix4.o: Using Interrupt SMI# for SMBus.\n");
else else
printk dev_err(&PIIX4_dev->dev, "Illegal Interrupt configuration "
(KERN_ERR "i2c-piix4.o: Illegal Interrupt configuration (or code out " "(or code out of date)!\n");
"of date)!\n");
pci_read_config_byte(PIIX4_dev, SMBREV, &temp); pci_read_config_byte(PIIX4_dev, SMBREV, &temp);
printk(KERN_DEBUG "i2c-piix4.o: SMBREV = 0x%X\n", temp); dev_dbg(&PIIX4_dev->dev, "SMBREV = 0x%X\n", temp);
printk(KERN_DEBUG "i2c-piix4.o: SMBA = 0x%X\n", piix4_smba); dev_dbg(&PIIX4_dev->dev, "SMBA = 0x%X\n", piix4_smba);
#endif /* DEBUG */
END: END:
return error_return; return error_return;
} }
/* Internally used pause function */ /* Internally used pause function */
static void piix4_do_pause(unsigned int amount) static void piix4_do_pause(unsigned int amount)
{ {
...@@ -227,29 +222,21 @@ static int piix4_transaction(void) ...@@ -227,29 +222,21 @@ static int piix4_transaction(void)
int result = 0; int result = 0;
int timeout = 0; int timeout = 0;
#ifdef DEBUG dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
printk "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
(KERN_DEBUG "i2c-piix4.o: Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
"DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTDAT1));
inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
#endif
/* Make sure the SMBus host is ready to start transmitting */ /* Make sure the SMBus host is ready to start transmitting */
if ((temp = inb_p(SMBHSTSTS)) != 0x00) { if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
#ifdef DEBUG dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). "
printk(KERN_DEBUG "i2c-piix4.o: SMBus busy (%02x). Resetting... \n", "Resetting... \n", temp);
temp);
#endif
outb_p(temp, SMBHSTSTS); outb_p(temp, SMBHSTSTS);
if ((temp = inb_p(SMBHSTSTS)) != 0x00) { if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
#ifdef DEBUG dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
printk(KERN_ERR "i2c-piix4.o: Failed! (%02x)\n", temp);
#endif
return -1; return -1;
} else { } else {
#ifdef DEBUG dev_dbg(&piix4_adapter.dev, "Successfull!\n");
printk(KERN_DEBUG "i2c-piix4.o: Successfull!\n");
#endif
} }
} }
...@@ -262,50 +249,40 @@ static int piix4_transaction(void) ...@@ -262,50 +249,40 @@ static int piix4_transaction(void)
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
#ifdef DEBUG
/* 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) {
printk(KERN_ERR "i2c-piix4.o: SMBus Timeout!\n"); dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
result = -1; result = -1;
} }
#endif
if (temp & 0x10) { if (temp & 0x10) {
result = -1; result = -1;
#ifdef DEBUG dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n");
printk(KERN_ERR "i2c-piix4.o: Error: Failed bus transaction\n");
#endif
} }
if (temp & 0x08) { if (temp & 0x08) {
result = -1; result = -1;
printk dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be "
(KERN_ERR "i2c-piix4.o: Bus collision! SMBus may be locked until next hard\n" "locked until next hard reset. (sorry!)\n");
"reset. (sorry!)\n");
/* Clock stops and slave is stuck in mid-transmission */ /* Clock stops and slave is stuck in mid-transmission */
} }
if (temp & 0x04) { if (temp & 0x04) {
result = -1; result = -1;
#ifdef DEBUG dev_err(&piix4_adapter.dev, "Error: no response!\n");
printk(KERN_ERR "i2c-piix4.o: Error: no response!\n");
#endif
} }
if (inb_p(SMBHSTSTS) != 0x00) if (inb_p(SMBHSTSTS) != 0x00)
outb_p(inb(SMBHSTSTS), SMBHSTSTS); outb_p(inb(SMBHSTSTS), SMBHSTSTS);
#ifdef DEBUG
if ((temp = inb_p(SMBHSTSTS)) != 0x00) { if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
printk dev_err(&piix4_adapter.dev, "Failed reset at end of "
(KERN_ERR "i2c-piix4.o: Failed reset at end of transaction (%02x)\n", "transaction (%02x)\n", temp);
temp);
} }
printk dev_dbg(&piix4_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
(KERN_DEBUG "i2c-piix4.o: Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, " "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
"DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); inb_p(SMBHSTDAT1));
#endif
return result; return result;
} }
...@@ -318,8 +295,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, ...@@ -318,8 +295,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
switch (size) { switch (size) {
case I2C_SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
printk dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
(KERN_ERR "i2c-piix4.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),
...@@ -402,7 +378,6 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, ...@@ -402,7 +378,6 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
return 0; return 0;
} }
static u32 piix4_func(struct i2c_adapter *adapter) static u32 piix4_func(struct i2c_adapter *adapter)
{ {
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
...@@ -424,8 +399,6 @@ static struct i2c_adapter piix4_adapter = { ...@@ -424,8 +399,6 @@ static struct i2c_adapter piix4_adapter = {
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
}; };
static struct pci_device_id piix4_ids[] __devinitdata = { static struct pci_device_id piix4_ids[] __devinitdata = {
{ {
.vendor = PCI_VENDOR_ID_INTEL, .vendor = PCI_VENDOR_ID_INTEL,
...@@ -499,7 +472,7 @@ static struct pci_driver piix4_driver = { ...@@ -499,7 +472,7 @@ static struct pci_driver piix4_driver = {
static int __init i2c_piix4_init(void) static int __init i2c_piix4_init(void)
{ {
printk("i2c-piix4.o version %s (%s)\n", I2C_VERSION, I2C_DATE); printk(KERN_INFO "i2c-piix4 version %s (%s)\n", I2C_VERSION, I2C_DATE);
return pci_module_init(&piix4_driver); return pci_module_init(&piix4_driver);
} }
...@@ -510,8 +483,6 @@ static void __exit i2c_piix4_exit(void) ...@@ -510,8 +483,6 @@ static void __exit i2c_piix4_exit(void)
release_region(piix4_smba, 8); release_region(piix4_smba, 8);
} }
MODULE_AUTHOR MODULE_AUTHOR
("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>"); ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
MODULE_DESCRIPTION("PIIX4 SMBus driver"); MODULE_DESCRIPTION("PIIX4 SMBus driver");
......
...@@ -93,9 +93,9 @@ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1 ...@@ -93,9 +93,9 @@ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1
/* Initial values */ /* Initial values */
/* Note: Eventhough I left the low and high limits named os and hyst, /* Note: Even though I left the low and high limits named os and hyst,
they don't quite work like a thermostat the way the LM75 does. I.e., they don't quite work like a thermostat the way the LM75 does. I.e.,
a lower temp than THYST actuall triggers an alarm instead of a lower temp than THYST actually triggers an alarm instead of
clearing it. Weird, ey? --Phil */ clearing it. Weird, ey? --Phil */
#define adm1021_INIT_TOS 60 #define adm1021_INIT_TOS 60
#define adm1021_INIT_THYST 20 #define adm1021_INIT_THYST 20
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/i2c-proc.h> #include <linux/i2c-proc.h>
#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ #define LM75_SYSCTL_TEMP 1200 /* Degrees Celsius * 10 */
/* Addresses to scan */ /* Addresses to scan */
static unsigned short normal_i2c[] = { SENSORS_I2C_END }; static unsigned short normal_i2c[] = { SENSORS_I2C_END };
......
...@@ -152,7 +152,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap) ...@@ -152,7 +152,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
/* load own address in S0, effective address is (own << 1) */ /* load own address in S0, effective address is (own << 1) */
i2c_outb(adap, get_own(adap)); i2c_outb(adap, get_own(adap));
/* check it's realy writen */ /* check it's really written */
if ((temp = i2c_inb(adap)) != get_own(adap)) { if ((temp = i2c_inb(adap)) != get_own(adap)) {
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp)); DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
return -ENXIO; return -ENXIO;
...@@ -168,7 +168,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap) ...@@ -168,7 +168,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
/* load clock register S2 */ /* load clock register S2 */
i2c_outb(adap, get_clock(adap)); i2c_outb(adap, get_clock(adap));
/* check it's realy writen, the only 5 lowest bits does matter */ /* check it's really written, the only 5 lowest bits does matter */
if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) { if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp)); DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
return -ENXIO; return -ENXIO;
...@@ -177,7 +177,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap) ...@@ -177,7 +177,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
/* Enable serial interface, idle, S0 selected */ /* Enable serial interface, idle, S0 selected */
set_pcf(adap, 1, I2C_PCF_IDLE); set_pcf(adap, 1, I2C_PCF_IDLE);
/* check to see PCF is realy idled and we can access status register */ /* check to see PCF is really idled and we can access status register */
if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) { if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp)); DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
return -ENXIO; return -ENXIO;
......
...@@ -53,6 +53,16 @@ static void i2cproc_remove(int bus); ...@@ -53,6 +53,16 @@ static void i2cproc_remove(int bus);
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
int i2c_device_probe(struct device *dev)
{
return -ENODEV;
}
int i2c_device_remove(struct device *dev)
{
return 0;
}
/* --------------------------------------------------- /* ---------------------------------------------------
* registering functions * registering functions
* --------------------------------------------------- * ---------------------------------------------------
...@@ -205,6 +215,16 @@ int i2c_add_driver(struct i2c_driver *driver) ...@@ -205,6 +215,16 @@ int i2c_add_driver(struct i2c_driver *driver)
DEB(printk(KERN_DEBUG "i2c-core.o: driver %s registered.\n",driver->name)); DEB(printk(KERN_DEBUG "i2c-core.o: driver %s registered.\n",driver->name));
/* add the driver to the list of i2c drivers in the driver core */
driver->driver.name = driver->name;
driver->driver.bus = &i2c_bus_type;
driver->driver.probe = i2c_device_probe;
driver->driver.remove = i2c_device_remove;
res = driver_register(&driver->driver);
if (res)
goto out_unlock;
/* now look for instances of driver on our adapters /* now look for instances of driver on our adapters
*/ */
if (driver->flags& (I2C_DF_NOTIFY|I2C_DF_DUMMY)) { if (driver->flags& (I2C_DF_NOTIFY|I2C_DF_DUMMY)) {
...@@ -236,6 +256,8 @@ int i2c_del_driver(struct i2c_driver *driver) ...@@ -236,6 +256,8 @@ int i2c_del_driver(struct i2c_driver *driver)
goto out_unlock; goto out_unlock;
} }
driver_unregister(&driver->driver);
/* Have a look at each adapter, if clients of this driver are still /* Have a look at each adapter, if clients of this driver are still
* attached. If so, detach them to be able to kill the driver * attached. If so, detach them to be able to kill the driver
* afterwards. * afterwards.
......
...@@ -270,7 +270,7 @@ static int i2c_sysctl_chips(ctl_table * table, int *name, int nlen, ...@@ -270,7 +270,7 @@ static int i2c_sysctl_chips(ctl_table * table, int *name, int nlen,
} }
/* This funcion reads or writes a 'real' value (encoded by the combination /* This function reads or writes a 'real' value (encoded by the combination
of an integer and a magnitude, the last is the power of ten the value of an integer and a magnitude, the last is the power of ten the value
should be divided with) to a /proc/sys directory. To use this function, should be divided with) to a /proc/sys directory. To use this function,
you must (before registering the ctl_table) set the extra2 field to the you must (before registering the ctl_table) set the extra2 field to the
......
...@@ -143,7 +143,10 @@ struct i2c_driver { ...@@ -143,7 +143,10 @@ struct i2c_driver {
* with the device. * with the device.
*/ */
int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
struct device_driver driver;
}; };
#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
extern struct bus_type i2c_bus_type; extern struct bus_type i2c_bus_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment