Commit c89122b1 authored by Linus Torvalds's avatar Linus Torvalds

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

into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents e9b73ef9 a7b2f24a
...@@ -118,8 +118,14 @@ config I2C_I810 ...@@ -118,8 +118,14 @@ config I2C_I810
will be called i2c-i810. will be called i2c-i810.
config I2C_IBM_IIC config I2C_IBM_IIC
tristate "IBM IIC I2C" tristate "IBM PPC 4xx on-chip I2C interface"
depends on IBM_OCP && I2C depends on IBM_OCP && I2C
help
Say Y here if you want to use IIC peripheral found on
embedded IBM PPC 4xx based systems.
This driver can also be built as a module. If so, the module
will be called i2c-ibm_iic.
config I2C_IOP3XX config I2C_IOP3XX
tristate "Intel XScale IOP3xx on-chip I2C interface" tristate "Intel XScale IOP3xx on-chip I2C interface"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Support for the IIC peripheral on IBM PPC 4xx * Support for the IIC peripheral on IBM PPC 4xx
* *
* Copyright (c) 2003 Zultys Technologies. * Copyright (c) 2003, 2004 Zultys Technologies.
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
* *
* Based on original work by * Based on original work by
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include "i2c-ibm_iic.h" #include "i2c-ibm_iic.h"
#define DRIVER_VERSION "2.0" #define DRIVER_VERSION "2.01"
MODULE_DESCRIPTION("IBM IIC driver v" DRIVER_VERSION); MODULE_DESCRIPTION("IBM IIC driver v" DRIVER_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -69,14 +69,14 @@ MODULE_PARM_DESC(iic_fast_poll, "Force fast mode (400 kHz)"); ...@@ -69,14 +69,14 @@ MODULE_PARM_DESC(iic_fast_poll, "Force fast mode (400 kHz)");
#endif #endif
#if DBG_LEVEL > 0 #if DBG_LEVEL > 0
# define DBG(x...) printk(KERN_DEBUG "ibm-iic" ##x) # define DBG(f,x...) printk(KERN_DEBUG "ibm-iic" f, ##x)
#else #else
# define DBG(x...) ((void)0) # define DBG(f,x...) ((void)0)
#endif #endif
#if DBG_LEVEL > 1 #if DBG_LEVEL > 1
# define DBG2(x...) DBG( ##x ) # define DBG2(f,x...) DBG(f, ##x)
#else #else
# define DBG2(x...) ((void)0) # define DBG2(f,x...) ((void)0)
#endif #endif
#if DBG_LEVEL > 2 #if DBG_LEVEL > 2
static void dump_iic_regs(const char* header, struct ibm_iic_private* dev) static void dump_iic_regs(const char* header, struct ibm_iic_private* dev)
...@@ -455,6 +455,16 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) ...@@ -455,6 +455,16 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
} }
for (i = 0; i < num; ++i){ for (i = 0; i < num; ++i){
if (unlikely(msgs[i].len <= 0)){ if (unlikely(msgs[i].len <= 0)){
if (num == 1 && !msgs[0].len){
/* Special case for I2C_SMBUS_QUICK emulation.
* Although this logic is FAR FROM PERFECT, this
* is what previous driver version did.
* IBM IIC doesn't support 0-length transactions
* (except bit-banging through IICx_DIRECTCNTL).
*/
DBG("%d: zero-length msg kludge\n", dev->idx);
return 0;
}
DBG("%d: invalid len %d in msg[%d]\n", dev->idx, DBG("%d: invalid len %d in msg[%d]\n", dev->idx,
msgs[i].len, i); msgs[i].len, i);
return -EINVAL; return -EINVAL;
...@@ -549,19 +559,24 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -549,19 +559,24 @@ static int __devinit iic_probe(struct ocp_device *ocp){
struct ibm_iic_private* dev; struct ibm_iic_private* dev;
struct i2c_adapter* adap; struct i2c_adapter* adap;
struct ocp_func_iic_data* iic_data = ocp->def->additions;
int ret; int ret;
bd_t* bd = (bd_t*)&__res;
if (!iic_data)
printk(KERN_WARNING"ibm-iic%d: missing additional data!\n",
ocp->def->index);
if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){ if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){
printk(KERN_CRIT "ibm-iic: failed to allocate device data\n"); printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n",
ocp->def->index);
return -ENOMEM; return -ENOMEM;
} }
memset(dev, 0, sizeof(*dev)); memset(dev, 0, sizeof(*dev));
dev->idx = ocp->num; dev->idx = ocp->def->index;
ocp_set_drvdata(ocp, dev); ocp_set_drvdata(ocp, dev);
if (!(dev->vaddr = ioremap(ocp->paddr, sizeof(struct iic_regs)))){ if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){
printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n", printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n",
dev->idx); dev->idx);
ret = -ENXIO; ret = -ENXIO;
...@@ -570,7 +585,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -570,7 +585,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
init_waitqueue_head(&dev->wq); init_waitqueue_head(&dev->wq);
dev->irq = iic_force_poll ? -1 : ocp->irq; dev->irq = iic_force_poll ? -1 : ocp->def->irq;
if (dev->irq >= 0){ if (dev->irq >= 0){
/* Disable interrupts until we finish intialization, /* Disable interrupts until we finish intialization,
assumes level-sensitive IRQ setup... assumes level-sensitive IRQ setup...
...@@ -589,13 +604,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -589,13 +604,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){
dev->idx); dev->idx);
/* Board specific settings */ /* Board specific settings */
BUG_ON(dev->idx >= sizeof(bd->bi_iic_fast) / sizeof(bd->bi_iic_fast[0])); dev->fast_mode = iic_force_fast ? 1 : (iic_data ? iic_data->fast_mode : 0);
dev->fast_mode = iic_force_fast ? 1 : bd->bi_iic_fast[dev->idx];
/* clckdiv is the same for *all* IIC interfaces, /* clckdiv is the same for *all* IIC interfaces,
* but I'd rather make a copy than introduce another global. --ebs * but I'd rather make a copy than introduce another global. --ebs
*/ */
dev->clckdiv = iic_clckdiv(bd->bi_opb_busfreq); dev->clckdiv = iic_clckdiv(ocp_sys_info.opb_bus_freq);
DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv); DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv);
/* Initialize IIC interface */ /* Initialize IIC interface */
...@@ -664,7 +678,7 @@ static void __devexit iic_remove(struct ocp_device *ocp) ...@@ -664,7 +678,7 @@ static void __devexit iic_remove(struct ocp_device *ocp)
static struct ocp_device_id ibm_iic_ids[] __devinitdata = static struct ocp_device_id ibm_iic_ids[] __devinitdata =
{ {
{ .vendor = OCP_VENDOR_IBM, .device = OCP_FUNC_IIC }, { .vendor = OCP_VENDOR_IBM, .function = OCP_FUNC_IIC },
{ .vendor = OCP_VENDOR_INVALID } { .vendor = OCP_VENDOR_INVALID }
}; };
...@@ -672,7 +686,7 @@ MODULE_DEVICE_TABLE(ocp, ibm_iic_ids); ...@@ -672,7 +686,7 @@ MODULE_DEVICE_TABLE(ocp, ibm_iic_ids);
static struct ocp_driver ibm_iic_driver = static struct ocp_driver ibm_iic_driver =
{ {
.name = "ocp_iic", .name = "iic",
.id_table = ibm_iic_ids, .id_table = ibm_iic_ids,
.probe = iic_probe, .probe = iic_probe,
.remove = __devexit_p(iic_remove), .remove = __devexit_p(iic_remove),
...@@ -685,7 +699,7 @@ static struct ocp_driver ibm_iic_driver = ...@@ -685,7 +699,7 @@ static struct ocp_driver ibm_iic_driver =
static int __init iic_init(void) static int __init iic_init(void)
{ {
printk(KERN_INFO "IBM IIC driver v" DRIVER_VERSION "\n"); printk(KERN_INFO "IBM IIC driver v" DRIVER_VERSION "\n");
return ocp_module_init(&ibm_iic_driver); return ocp_register_driver(&ibm_iic_driver);
} }
static void __exit iic_exit(void) static void __exit iic_exit(void)
......
...@@ -67,13 +67,18 @@ static struct adapter_parm adapter_parm[] = { ...@@ -67,13 +67,18 @@ static struct adapter_parm adapter_parm[] = {
.getsda = { 0x40, STAT, 1 }, .getsda = { 0x40, STAT, 1 },
.getscl = { 0x08, STAT, 1 }, .getscl = { 0x08, STAT, 1 },
}, },
/* type 4: ADM1025 and ADM1032 evaluation boards */ /* type 4: ADM1032 evaluation board */
{
.setsda = { 0x02, DATA, 1 },
.setscl = { 0x01, DATA, 1 },
.getsda = { 0x10, STAT, 1 },
.init = { 0xf0, DATA, 0 },
},
/* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */
{ {
.setsda = { 0x02, DATA, 1 }, .setsda = { 0x02, DATA, 1 },
.setscl = { 0x01, DATA, 1 }, .setscl = { 0x01, DATA, 1 },
.getsda = { 0x10, STAT, 1 }, .getsda = { 0x10, STAT, 1 },
.init = { 0xf0, DATA, 0 }, /* ADM1025 doesn't need this,
but it doesn't hurt */
}, },
}; };
...@@ -85,4 +90,5 @@ MODULE_PARM_DESC(type, ...@@ -85,4 +90,5 @@ MODULE_PARM_DESC(type,
" 1 = home brew teletext adapter\n" " 1 = home brew teletext adapter\n"
" 2 = Velleman K8000 adapter\n" " 2 = Velleman K8000 adapter\n"
" 3 = ELV adapter\n" " 3 = ELV adapter\n"
" 4 = ADM1025 and ADM1032 evaluation boards\n"); " 4 = ADM1032 evaluation board\n"
" 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n");
...@@ -145,6 +145,16 @@ config SENSORS_LM90 ...@@ -145,6 +145,16 @@ config SENSORS_LM90
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called lm90. will be called lm90.
config SENSORS_MAX1619
tristate "Maxim MAX1619 sensor chip"
depends on I2C && EXPERIMENTAL
select I2C_SENSOR
help
If you say yes here you get support for MAX1619 sensor chip.
This driver can also be built as a module. If so, the module
will be called max1619.
config SENSORS_VIA686A config SENSORS_VIA686A
tristate "VIA686A" tristate "VIA686A"
depends on I2C && EXPERIMENTAL depends on I2C && EXPERIMENTAL
......
...@@ -19,6 +19,7 @@ obj-$(CONFIG_SENSORS_LM80) += lm80.o ...@@ -19,6 +19,7 @@ obj-$(CONFIG_SENSORS_LM80) += lm80.o
obj-$(CONFIG_SENSORS_LM83) += lm83.o obj-$(CONFIG_SENSORS_LM83) += lm83.o
obj-$(CONFIG_SENSORS_LM85) += lm85.o obj-$(CONFIG_SENSORS_LM85) += lm85.o
obj-$(CONFIG_SENSORS_LM90) += lm90.o obj-$(CONFIG_SENSORS_LM90) += lm90.o
obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
......
...@@ -203,11 +203,12 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -203,11 +203,12 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
new_client->driver = &eeprom_driver; new_client->driver = &eeprom_driver;
new_client->flags = 0; new_client->flags = 0;
/* prevent 24RF08 corruption */
i2c_smbus_write_quick(new_client, 0);
/* Now, we do the remaining detection. It is not there, unless you force /* Now, we do the remaining detection. It is not there, unless you force
the checksum to work out. */ the checksum to work out. */
if (checksum) { if (checksum) {
/* prevent 24RF08 corruption */
i2c_smbus_write_quick(new_client, 0);
cs = 0; cs = 0;
for (i = 0; i <= 0x3e; i++) for (i = 0; i <= 0x3e; i++)
cs += i2c_smbus_read_byte_data(new_client, i); cs += i2c_smbus_read_byte_data(new_client, i);
......
This diff is collapsed.
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/idr.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
static LIST_HEAD(adapters); static LIST_HEAD(adapters);
static LIST_HEAD(drivers); static LIST_HEAD(drivers);
static DECLARE_MUTEX(core_lists); static DECLARE_MUTEX(core_lists);
static DEFINE_IDR(i2c_adapter_idr);
int i2c_device_probe(struct device *dev) int i2c_device_probe(struct device *dev)
{ {
...@@ -113,13 +115,19 @@ static struct device_attribute dev_attr_client_name = { ...@@ -113,13 +115,19 @@ static struct device_attribute dev_attr_client_name = {
*/ */
int i2c_add_adapter(struct i2c_adapter *adap) int i2c_add_adapter(struct i2c_adapter *adap)
{ {
static int nr = 0; int id, res = 0;
struct list_head *item; struct list_head *item;
struct i2c_driver *driver; struct i2c_driver *driver;
down(&core_lists); down(&core_lists);
adap->nr = nr++; if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) {
res = -ENOMEM;
goto out_unlock;
}
id = idr_get_new(&i2c_adapter_idr, NULL);
adap->nr = id & MAX_ID_MASK;
init_MUTEX(&adap->bus_lock); init_MUTEX(&adap->bus_lock);
init_MUTEX(&adap->clist_lock); init_MUTEX(&adap->clist_lock);
list_add_tail(&adap->list,&adapters); list_add_tail(&adap->list,&adapters);
...@@ -151,10 +159,12 @@ int i2c_add_adapter(struct i2c_adapter *adap) ...@@ -151,10 +159,12 @@ int i2c_add_adapter(struct i2c_adapter *adap)
/* We ignore the return code; if it fails, too bad */ /* We ignore the return code; if it fails, too bad */
driver->attach_adapter(adap); driver->attach_adapter(adap);
} }
up(&core_lists);
dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr); dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr);
return 0;
out_unlock:
up(&core_lists);
return res;
} }
...@@ -208,6 +218,9 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -208,6 +218,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
wait_for_completion(&adap->dev_released); wait_for_completion(&adap->dev_released);
wait_for_completion(&adap->class_dev_released); wait_for_completion(&adap->class_dev_released);
/* free dynamically allocated bus id */
idr_remove(&i2c_adapter_idr, adap->nr);
dev_dbg(&adap->dev, "adapter unregistered\n"); dev_dbg(&adap->dev, "adapter unregistered\n");
out_unlock: out_unlock:
......
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