aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/Kconfig9
-rw-r--r--drivers/i2c/busses/i2c-acorn.c2
-rw-r--r--drivers/i2c/busses/i2c-davinci.c8
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c6
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c4
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c7
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c12
-rw-r--r--drivers/i2c/busses/i2c-omap.c47
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c39
-rw-r--r--drivers/i2c/busses/i2c-pca-platform.c48
-rw-r--r--drivers/i2c/busses/i2c-piix4.c77
-rw-r--r--drivers/i2c/busses/i2c-powermac.c3
-rw-r--r--drivers/i2c/busses/i2c-pxa.c9
-rw-r--r--drivers/i2c/busses/i2c-versatile.c10
15 files changed, 194 insertions, 89 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 7f95905bbb9d..da809ad0996a 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -132,6 +132,7 @@ config I2C_PIIX4
132 Serverworks CSB5 132 Serverworks CSB5
133 Serverworks CSB6 133 Serverworks CSB6
134 Serverworks HT-1000 134 Serverworks HT-1000
135 Serverworks HT-1100
135 SMSC Victory66 136 SMSC Victory66
136 137
137 This driver can also be built as a module. If so, the module 138 This driver can also be built as a module. If so, the module
@@ -617,12 +618,12 @@ config I2C_ELEKTOR
617 will be called i2c-elektor. 618 will be called i2c-elektor.
618 619
619config I2C_PCA_ISA 620config I2C_PCA_ISA
620 tristate "PCA9564 on an ISA bus" 621 tristate "PCA9564/PCA9665 on an ISA bus"
621 depends on ISA 622 depends on ISA
622 select I2C_ALGOPCA 623 select I2C_ALGOPCA
623 default n 624 default n
624 help 625 help
625 This driver supports ISA boards using the Philips PCA9564 626 This driver supports ISA boards using the Philips PCA9564/PCA9665
626 parallel bus to I2C bus controller. 627 parallel bus to I2C bus controller.
627 628
628 This driver can also be built as a module. If so, the module 629 This driver can also be built as a module. If so, the module
@@ -634,11 +635,11 @@ config I2C_PCA_ISA
634 time). If unsure, say N. 635 time). If unsure, say N.
635 636
636config I2C_PCA_PLATFORM 637config I2C_PCA_PLATFORM
637 tristate "PCA9564 as platform device" 638 tristate "PCA9564/PCA9665 as platform device"
638 select I2C_ALGOPCA 639 select I2C_ALGOPCA
639 default n 640 default n
640 help 641 help
641 This driver supports a memory mapped Philips PCA9564 642 This driver supports a memory mapped Philips PCA9564/PCA9665
642 parallel bus to I2C bus controller. 643 parallel bus to I2C bus controller.
643 644
644 This driver can also be built as a module. If so, the module 645 This driver can also be built as a module. If so, the module
diff --git a/drivers/i2c/busses/i2c-acorn.c b/drivers/i2c/busses/i2c-acorn.c
index 9aefb5e5864d..86796488ef4f 100644
--- a/drivers/i2c/busses/i2c-acorn.c
+++ b/drivers/i2c/busses/i2c-acorn.c
@@ -15,9 +15,9 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/i2c-algo-bit.h> 17#include <linux/i2c-algo-bit.h>
18#include <linux/io.h>
18 19
19#include <mach/hardware.h> 20#include <mach/hardware.h>
20#include <asm/io.h>
21#include <asm/hardware/ioc.h> 21#include <asm/hardware/ioc.h>
22#include <asm/system.h> 22#include <asm/system.h>
23 23
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 5d7789834b95..3fae3a91ce5b 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -216,7 +216,7 @@ static int i2c_davinci_wait_bus_not_busy(struct davinci_i2c_dev *dev,
216{ 216{
217 unsigned long timeout; 217 unsigned long timeout;
218 218
219 timeout = jiffies + DAVINCI_I2C_TIMEOUT; 219 timeout = jiffies + dev->adapter.timeout;
220 while (davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG) 220 while (davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG)
221 & DAVINCI_I2C_STR_BB) { 221 & DAVINCI_I2C_STR_BB) {
222 if (time_after(jiffies, timeout)) { 222 if (time_after(jiffies, timeout)) {
@@ -289,7 +289,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
289 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); 289 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
290 290
291 r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, 291 r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
292 DAVINCI_I2C_TIMEOUT); 292 dev->adapter.timeout);
293 if (r == 0) { 293 if (r == 0) {
294 dev_err(dev->dev, "controller timed out\n"); 294 dev_err(dev->dev, "controller timed out\n");
295 i2c_davinci_init(dev); 295 i2c_davinci_init(dev);
@@ -546,9 +546,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
546 strlcpy(adap->name, "DaVinci I2C adapter", sizeof(adap->name)); 546 strlcpy(adap->name, "DaVinci I2C adapter", sizeof(adap->name));
547 adap->algo = &i2c_davinci_algo; 547 adap->algo = &i2c_davinci_algo;
548 adap->dev.parent = &pdev->dev; 548 adap->dev.parent = &pdev->dev;
549 549 adap->timeout = DAVINCI_I2C_TIMEOUT;
550 /* FIXME */
551 adap->timeout = 1;
552 550
553 adap->nr = pdev->id; 551 adap->nr = pdev->id;
554 r = i2c_add_numbered_adapter(adap); 552 r = i2c_add_numbered_adapter(adap);
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 88f0db73b364..8b92a4666e02 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -415,7 +415,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
415 if (dev->irq >= 0){ 415 if (dev->irq >= 0){
416 /* Interrupt mode */ 416 /* Interrupt mode */
417 ret = wait_event_interruptible_timeout(dev->wq, 417 ret = wait_event_interruptible_timeout(dev->wq,
418 !(in_8(&iic->sts) & STS_PT), dev->adap.timeout * HZ); 418 !(in_8(&iic->sts) & STS_PT), dev->adap.timeout);
419 419
420 if (unlikely(ret < 0)) 420 if (unlikely(ret < 0))
421 DBG("%d: wait interrupted\n", dev->idx); 421 DBG("%d: wait interrupted\n", dev->idx);
@@ -426,7 +426,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
426 } 426 }
427 else { 427 else {
428 /* Polling mode */ 428 /* Polling mode */
429 unsigned long x = jiffies + dev->adap.timeout * HZ; 429 unsigned long x = jiffies + dev->adap.timeout;
430 430
431 while (in_8(&iic->sts) & STS_PT){ 431 while (in_8(&iic->sts) & STS_PT){
432 if (unlikely(time_after(jiffies, x))){ 432 if (unlikely(time_after(jiffies, x))){
@@ -748,7 +748,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
748 i2c_set_adapdata(adap, dev); 748 i2c_set_adapdata(adap, dev);
749 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 749 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
750 adap->algo = &iic_algo; 750 adap->algo = &iic_algo;
751 adap->timeout = 1; 751 adap->timeout = HZ;
752 752
753 ret = i2c_add_adapter(adap); 753 ret = i2c_add_adapter(adap);
754 if (ret < 0) { 754 if (ret < 0) {
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index 3190690c26ce..a75c75e77b92 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -488,7 +488,7 @@ iop3xx_i2c_probe(struct platform_device *pdev)
488 /* 488 /*
489 * Default values...should these come in from board code? 489 * Default values...should these come in from board code?
490 */ 490 */
491 new_adapter->timeout = 100; 491 new_adapter->timeout = HZ;
492 new_adapter->algo = &iop3xx_i2c_algo; 492 new_adapter->algo = &iop3xx_i2c_algo;
493 493
494 init_waitqueue_head(&adapter_data->waitq); 494 init_waitqueue_head(&adapter_data->waitq);
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 3163eab3f608..26bf37010586 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -116,7 +116,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
116 } else { 116 } else {
117 /* Interrupt mode */ 117 /* Interrupt mode */
118 result = wait_event_timeout(i2c->queue, 118 result = wait_event_timeout(i2c->queue,
119 (i2c->interrupt & CSR_MIF), timeout * HZ); 119 (i2c->interrupt & CSR_MIF), timeout);
120 120
121 if (unlikely(!(i2c->interrupt & CSR_MIF))) { 121 if (unlikely(!(i2c->interrupt & CSR_MIF))) {
122 pr_debug("I2C: wait timeout\n"); 122 pr_debug("I2C: wait timeout\n");
@@ -308,7 +308,7 @@ static struct i2c_adapter mpc_ops = {
308 .owner = THIS_MODULE, 308 .owner = THIS_MODULE,
309 .name = "MPC adapter", 309 .name = "MPC adapter",
310 .algo = &mpc_algo, 310 .algo = &mpc_algo,
311 .timeout = 1, 311 .timeout = HZ,
312}; 312};
313 313
314static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match) 314static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 7f186bbcb99d..5a4945d1dba4 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -358,7 +358,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
358 char abort = 0; 358 char abort = 0;
359 359
360 time_left = wait_event_interruptible_timeout(drv_data->waitq, 360 time_left = wait_event_interruptible_timeout(drv_data->waitq,
361 !drv_data->block, msecs_to_jiffies(drv_data->adapter.timeout)); 361 !drv_data->block, drv_data->adapter.timeout);
362 362
363 spin_lock_irqsave(&drv_data->lock, flags); 363 spin_lock_irqsave(&drv_data->lock, flags);
364 if (!time_left) { /* Timed out */ 364 if (!time_left) { /* Timed out */
@@ -374,8 +374,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
374 spin_unlock_irqrestore(&drv_data->lock, flags); 374 spin_unlock_irqrestore(&drv_data->lock, flags);
375 375
376 time_left = wait_event_timeout(drv_data->waitq, 376 time_left = wait_event_timeout(drv_data->waitq,
377 !drv_data->block, 377 !drv_data->block, drv_data->adapter.timeout);
378 msecs_to_jiffies(drv_data->adapter.timeout));
379 378
380 if ((time_left <= 0) && drv_data->block) { 379 if ((time_left <= 0) && drv_data->block) {
381 drv_data->state = MV64XXX_I2C_STATE_IDLE; 380 drv_data->state = MV64XXX_I2C_STATE_IDLE;
@@ -530,7 +529,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
530 drv_data->adapter.algo = &mv64xxx_i2c_algo; 529 drv_data->adapter.algo = &mv64xxx_i2c_algo;
531 drv_data->adapter.owner = THIS_MODULE; 530 drv_data->adapter.owner = THIS_MODULE;
532 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 531 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
533 drv_data->adapter.timeout = pdata->timeout; 532 drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout);
534 drv_data->adapter.nr = pd->id; 533 drv_data->adapter.nr = pd->id;
535 platform_set_drvdata(pd, drv_data); 534 platform_set_drvdata(pd, drv_data);
536 i2c_set_adapdata(&drv_data->adapter, drv_data); 535 i2c_set_adapdata(&drv_data->adapter, drv_data);
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 05af6cd7f270..2ff4683703a8 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -31,10 +31,14 @@
31 nForce3 250Gb MCP 00E4 31 nForce3 250Gb MCP 00E4
32 nForce4 MCP 0052 32 nForce4 MCP 0052
33 nForce4 MCP-04 0034 33 nForce4 MCP-04 0034
34 nForce4 MCP51 0264 34 nForce MCP51 0264
35 nForce4 MCP55 0368 35 nForce MCP55 0368
36 nForce MCP61 03EB 36 nForce MCP61 03EB
37 nForce MCP65 0446 37 nForce MCP65 0446
38 nForce MCP67 0542
39 nForce MCP73 07D8
40 nForce MCP78S 0752
41 nForce MCP79 0AA2
38 42
39 This driver supports the 2 SMBuses that are included in the MCP of the 43 This driver supports the 2 SMBuses that are included in the MCP of the
40 nForce2/3/4/5xx chipsets. 44 nForce2/3/4/5xx chipsets.
@@ -315,6 +319,10 @@ static struct pci_device_id nforce2_ids[] = {
315 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS) }, 319 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS) },
316 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SMBUS) }, 320 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SMBUS) },
317 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_SMBUS) }, 321 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_SMBUS) },
322 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_SMBUS) },
323 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_SMBUS) },
324 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP78S_SMBUS) },
325 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP79_SMBUS) },
318 { 0 } 326 { 0 }
319}; 327};
320 328
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index be8ee2cac8bb..ece0125a1ee5 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -193,22 +193,24 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
193 193
194static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) 194static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev)
195{ 195{
196 if (cpu_is_omap16xx() || cpu_class_is_omap2()) { 196 int ret;
197 dev->iclk = clk_get(dev->dev, "i2c_ick"); 197
198 if (IS_ERR(dev->iclk)) { 198 dev->iclk = clk_get(dev->dev, "ick");
199 dev->iclk = NULL; 199 if (IS_ERR(dev->iclk)) {
200 return -ENODEV; 200 ret = PTR_ERR(dev->iclk);
201 } 201 dev->iclk = NULL;
202 return ret;
202 } 203 }
203 204
204 dev->fclk = clk_get(dev->dev, "i2c_fck"); 205 dev->fclk = clk_get(dev->dev, "fck");
205 if (IS_ERR(dev->fclk)) { 206 if (IS_ERR(dev->fclk)) {
207 ret = PTR_ERR(dev->fclk);
206 if (dev->iclk != NULL) { 208 if (dev->iclk != NULL) {
207 clk_put(dev->iclk); 209 clk_put(dev->iclk);
208 dev->iclk = NULL; 210 dev->iclk = NULL;
209 } 211 }
210 dev->fclk = NULL; 212 dev->fclk = NULL;
211 return -ENODEV; 213 return ret;
212 } 214 }
213 215
214 return 0; 216 return 0;
@@ -218,18 +220,15 @@ static void omap_i2c_put_clocks(struct omap_i2c_dev *dev)
218{ 220{
219 clk_put(dev->fclk); 221 clk_put(dev->fclk);
220 dev->fclk = NULL; 222 dev->fclk = NULL;
221 if (dev->iclk != NULL) { 223 clk_put(dev->iclk);
222 clk_put(dev->iclk); 224 dev->iclk = NULL;
223 dev->iclk = NULL;
224 }
225} 225}
226 226
227static void omap_i2c_unidle(struct omap_i2c_dev *dev) 227static void omap_i2c_unidle(struct omap_i2c_dev *dev)
228{ 228{
229 WARN_ON(!dev->idle); 229 WARN_ON(!dev->idle);
230 230
231 if (dev->iclk != NULL) 231 clk_enable(dev->iclk);
232 clk_enable(dev->iclk);
233 clk_enable(dev->fclk); 232 clk_enable(dev->fclk);
234 dev->idle = 0; 233 dev->idle = 0;
235 if (dev->iestate) 234 if (dev->iestate)
@@ -254,8 +253,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
254 } 253 }
255 dev->idle = 1; 254 dev->idle = 1;
256 clk_disable(dev->fclk); 255 clk_disable(dev->fclk);
257 if (dev->iclk != NULL) 256 clk_disable(dev->iclk);
258 clk_disable(dev->iclk);
259} 257}
260 258
261static int omap_i2c_init(struct omap_i2c_dev *dev) 259static int omap_i2c_init(struct omap_i2c_dev *dev)
@@ -312,15 +310,14 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
312 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 310 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
313 311
314 if (cpu_class_is_omap1()) { 312 if (cpu_class_is_omap1()) {
315 struct clk *armxor_ck; 313 /*
316 314 * The I2C functional clock is the armxor_ck, so there's
317 armxor_ck = clk_get(NULL, "armxor_ck"); 315 * no need to get "armxor_ck" separately. Now, if OMAP2420
318 if (IS_ERR(armxor_ck)) 316 * always returns 12MHz for the functional clock, we can
319 dev_warn(dev->dev, "Could not get armxor_ck\n"); 317 * do this bit unconditionally.
320 else { 318 */
321 fclk_rate = clk_get_rate(armxor_ck); 319 fclk_rate = clk_get_rate(dev->fclk);
322 clk_put(armxor_ck); 320
323 }
324 /* TRM for 5912 says the I2C clock must be prescaled to be 321 /* TRM for 5912 says the I2C clock must be prescaled to be
325 * between 7 - 12 MHz. The XOR input clock is typically 322 * between 7 - 12 MHz. The XOR input clock is typically
326 * 12, 13 or 19.2 MHz. So we should have code that produces: 323 * 12, 13 or 19.2 MHz. So we should have code that produces:
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index 4aa8138cb0a9..0ed68e2ccd22 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/jiffies.h>
26#include <linux/init.h> 27#include <linux/init.h>
27#include <linux/interrupt.h> 28#include <linux/interrupt.h>
28#include <linux/wait.h> 29#include <linux/wait.h>
@@ -41,15 +42,17 @@ static int irq = -1;
41 42
42/* Data sheet recommends 59kHz for 100kHz operation due to variation 43/* Data sheet recommends 59kHz for 100kHz operation due to variation
43 * in the actual clock rate */ 44 * in the actual clock rate */
44static int clock = I2C_PCA_CON_59kHz; 45static int clock = 59000;
45 46
47static struct i2c_adapter pca_isa_ops;
46static wait_queue_head_t pca_wait; 48static wait_queue_head_t pca_wait;
47 49
48static void pca_isa_writebyte(void *pd, int reg, int val) 50static void pca_isa_writebyte(void *pd, int reg, int val)
49{ 51{
50#ifdef DEBUG_IO 52#ifdef DEBUG_IO
51 static char *names[] = { "T/O", "DAT", "ADR", "CON" }; 53 static char *names[] = { "T/O", "DAT", "ADR", "CON" };
52 printk("*** write %s at %#lx <= %#04x\n", names[reg], base+reg, val); 54 printk(KERN_DEBUG "*** write %s at %#lx <= %#04x\n", names[reg],
55 base+reg, val);
53#endif 56#endif
54 outb(val, base+reg); 57 outb(val, base+reg);
55} 58}
@@ -60,7 +63,7 @@ static int pca_isa_readbyte(void *pd, int reg)
60#ifdef DEBUG_IO 63#ifdef DEBUG_IO
61 { 64 {
62 static char *names[] = { "STA", "DAT", "ADR", "CON" }; 65 static char *names[] = { "STA", "DAT", "ADR", "CON" };
63 printk("*** read %s => %#04x\n", names[reg], res); 66 printk(KERN_DEBUG "*** read %s => %#04x\n", names[reg], res);
64 } 67 }
65#endif 68#endif
66 return res; 69 return res;
@@ -68,16 +71,22 @@ static int pca_isa_readbyte(void *pd, int reg)
68 71
69static int pca_isa_waitforcompletion(void *pd) 72static int pca_isa_waitforcompletion(void *pd)
70{ 73{
71 int ret = 0; 74 long ret = ~0;
75 unsigned long timeout;
72 76
73 if (irq > -1) { 77 if (irq > -1) {
74 ret = wait_event_interruptible(pca_wait, 78 ret = wait_event_interruptible_timeout(pca_wait,
75 pca_isa_readbyte(pd, I2C_PCA_CON) & I2C_PCA_CON_SI); 79 pca_isa_readbyte(pd, I2C_PCA_CON)
80 & I2C_PCA_CON_SI, pca_isa_ops.timeout);
76 } else { 81 } else {
77 while ((pca_isa_readbyte(pd, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0) 82 /* Do polling */
83 timeout = jiffies + pca_isa_ops.timeout;
84 while (((pca_isa_readbyte(pd, I2C_PCA_CON)
85 & I2C_PCA_CON_SI) == 0)
86 && (ret = time_before(jiffies, timeout)))
78 udelay(100); 87 udelay(100);
79 } 88 }
80 return ret; 89 return ret > 0;
81} 90}
82 91
83static void pca_isa_resetchip(void *pd) 92static void pca_isa_resetchip(void *pd)
@@ -102,8 +111,8 @@ static struct i2c_algo_pca_data pca_isa_data = {
102static struct i2c_adapter pca_isa_ops = { 111static struct i2c_adapter pca_isa_ops = {
103 .owner = THIS_MODULE, 112 .owner = THIS_MODULE,
104 .algo_data = &pca_isa_data, 113 .algo_data = &pca_isa_data,
105 .name = "PCA9564 ISA Adapter", 114 .name = "PCA9564/PCA9665 ISA Adapter",
106 .timeout = 100, 115 .timeout = HZ,
107}; 116};
108 117
109static int __devinit pca_isa_match(struct device *dev, unsigned int id) 118static int __devinit pca_isa_match(struct device *dev, unsigned int id)
@@ -195,7 +204,7 @@ static void __exit pca_isa_exit(void)
195} 204}
196 205
197MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>"); 206MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>");
198MODULE_DESCRIPTION("ISA base PCA9564 driver"); 207MODULE_DESCRIPTION("ISA base PCA9564/PCA9665 driver");
199MODULE_LICENSE("GPL"); 208MODULE_LICENSE("GPL");
200 209
201module_param(base, ulong, 0); 210module_param(base, ulong, 0);
@@ -204,7 +213,13 @@ MODULE_PARM_DESC(base, "I/O base address");
204module_param(irq, int, 0); 213module_param(irq, int, 0);
205MODULE_PARM_DESC(irq, "IRQ"); 214MODULE_PARM_DESC(irq, "IRQ");
206module_param(clock, int, 0); 215module_param(clock, int, 0);
207MODULE_PARM_DESC(clock, "Clock rate as described in table 1 of PCA9564 datasheet"); 216MODULE_PARM_DESC(clock, "Clock rate in hertz.\n\t\t"
217 "For PCA9564: 330000,288000,217000,146000,"
218 "88000,59000,44000,36000\n"
219 "\t\tFor PCA9665:\tStandard: 60300 - 100099\n"
220 "\t\t\t\tFast: 100100 - 400099\n"
221 "\t\t\t\tFast+: 400100 - 10000099\n"
222 "\t\t\t\tTurbo: Up to 1265800");
208 223
209module_init(pca_isa_init); 224module_init(pca_isa_init);
210module_exit(pca_isa_exit); 225module_exit(pca_isa_exit);
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 6bb15ad0a6b6..7b23891b7d59 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/jiffies.h>
18#include <linux/errno.h> 19#include <linux/errno.h>
19#include <linux/i2c.h> 20#include <linux/i2c.h>
20#include <linux/interrupt.h> 21#include <linux/interrupt.h>
@@ -81,24 +82,23 @@ static void i2c_pca_pf_writebyte32(void *pd, int reg, int val)
81static int i2c_pca_pf_waitforcompletion(void *pd) 82static int i2c_pca_pf_waitforcompletion(void *pd)
82{ 83{
83 struct i2c_pca_pf_data *i2c = pd; 84 struct i2c_pca_pf_data *i2c = pd;
84 int ret = 0; 85 long ret = ~0;
86 unsigned long timeout;
85 87
86 if (i2c->irq) { 88 if (i2c->irq) {
87 ret = wait_event_interruptible(i2c->wait, 89 ret = wait_event_interruptible_timeout(i2c->wait,
88 i2c->algo_data.read_byte(i2c, I2C_PCA_CON) 90 i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
89 & I2C_PCA_CON_SI); 91 & I2C_PCA_CON_SI, i2c->adap.timeout);
90 } else { 92 } else {
91 /* 93 /* Do polling */
92 * Do polling... 94 timeout = jiffies + i2c->adap.timeout;
93 * XXX: Could get stuck in extreme cases! 95 while (((i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
94 * Maybe add timeout, but using irqs is preferred anyhow.
95 */
96 while ((i2c->algo_data.read_byte(i2c, I2C_PCA_CON)
97 & I2C_PCA_CON_SI) == 0) 96 & I2C_PCA_CON_SI) == 0)
97 && (ret = time_before(jiffies, timeout)))
98 udelay(100); 98 udelay(100);
99 } 99 }
100 100
101 return ret; 101 return ret > 0;
102} 102}
103 103
104static void i2c_pca_pf_dummyreset(void *pd) 104static void i2c_pca_pf_dummyreset(void *pd)
@@ -172,14 +172,25 @@ static int __devinit i2c_pca_pf_probe(struct platform_device *pdev)
172 172
173 i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0; 173 i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0;
174 i2c->adap.owner = THIS_MODULE; 174 i2c->adap.owner = THIS_MODULE;
175 snprintf(i2c->adap.name, sizeof(i2c->adap.name), "PCA9564 at 0x%08lx", 175 snprintf(i2c->adap.name, sizeof(i2c->adap.name),
176 (unsigned long) res->start); 176 "PCA9564/PCA9665 at 0x%08lx",
177 (unsigned long) res->start);
177 i2c->adap.algo_data = &i2c->algo_data; 178 i2c->adap.algo_data = &i2c->algo_data;
178 i2c->adap.dev.parent = &pdev->dev; 179 i2c->adap.dev.parent = &pdev->dev;
179 i2c->adap.timeout = platform_data->timeout;
180 180
181 i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed; 181 if (platform_data) {
182 i2c->adap.timeout = platform_data->timeout;
183 i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed;
184 i2c->gpio = platform_data->gpio;
185 } else {
186 i2c->adap.timeout = HZ;
187 i2c->algo_data.i2c_clock = 59000;
188 i2c->gpio = -1;
189 }
190
182 i2c->algo_data.data = i2c; 191 i2c->algo_data.data = i2c;
192 i2c->algo_data.wait_for_completion = i2c_pca_pf_waitforcompletion;
193 i2c->algo_data.reset_chip = i2c_pca_pf_dummyreset;
183 194
184 switch (res->flags & IORESOURCE_MEM_TYPE_MASK) { 195 switch (res->flags & IORESOURCE_MEM_TYPE_MASK) {
185 case IORESOURCE_MEM_32BIT: 196 case IORESOURCE_MEM_32BIT:
@@ -197,11 +208,6 @@ static int __devinit i2c_pca_pf_probe(struct platform_device *pdev)
197 break; 208 break;
198 } 209 }
199 210
200 i2c->algo_data.wait_for_completion = i2c_pca_pf_waitforcompletion;
201
202 i2c->gpio = platform_data->gpio;
203 i2c->algo_data.reset_chip = i2c_pca_pf_dummyreset;
204
205 /* Use gpio_is_valid() when in mainline */ 211 /* Use gpio_is_valid() when in mainline */
206 if (i2c->gpio > -1) { 212 if (i2c->gpio > -1) {
207 ret = gpio_request(i2c->gpio, i2c->adap.name); 213 ret = gpio_request(i2c->gpio, i2c->adap.name);
@@ -246,7 +252,7 @@ e_remap:
246e_alloc: 252e_alloc:
247 release_mem_region(res->start, res_len(res)); 253 release_mem_region(res->start, res_len(res));
248e_print: 254e_print:
249 printk(KERN_ERR "Registering PCA9564 FAILED! (%d)\n", ret); 255 printk(KERN_ERR "Registering PCA9564/PCA9665 FAILED! (%d)\n", ret);
250 return ret; 256 return ret;
251} 257}
252 258
@@ -290,7 +296,7 @@ static void __exit i2c_pca_pf_exit(void)
290} 296}
291 297
292MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>"); 298MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>");
293MODULE_DESCRIPTION("I2C-PCA9564 platform driver"); 299MODULE_DESCRIPTION("I2C-PCA9564/PCA9665 platform driver");
294MODULE_LICENSE("GPL"); 300MODULE_LICENSE("GPL");
295 301
296module_init(i2c_pca_pf_init); 302module_init(i2c_pca_pf_init);
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 761f9dd53620..0249a7d762b9 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -20,7 +20,7 @@
20/* 20/*
21 Supports: 21 Supports:
22 Intel PIIX4, 440MX 22 Intel PIIX4, 440MX
23 Serverworks OSB4, CSB5, CSB6, HT-1000 23 Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100
24 ATI IXP200, IXP300, IXP400, SB600, SB700, SB800 24 ATI IXP200, IXP300, IXP400, SB600, SB700, SB800
25 SMSC Victory66 25 SMSC Victory66
26 26
@@ -226,6 +226,70 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
226 return 0; 226 return 0;
227} 227}
228 228
229static int __devinit piix4_setup_sb800(struct pci_dev *PIIX4_dev,
230 const struct pci_device_id *id)
231{
232 unsigned short smba_idx = 0xcd6;
233 u8 smba_en_lo, smba_en_hi, i2ccfg, i2ccfg_offset = 0x10, smb_en = 0x2c;
234
235 /* SB800 SMBus does not support forcing address */
236 if (force || force_addr) {
237 dev_err(&PIIX4_dev->dev, "SB800 SMBus does not support "
238 "forcing address!\n");
239 return -EINVAL;
240 }
241
242 /* Determine the address of the SMBus areas */
243 if (!request_region(smba_idx, 2, "smba_idx")) {
244 dev_err(&PIIX4_dev->dev, "SMBus base address index region "
245 "0x%x already in use!\n", smba_idx);
246 return -EBUSY;
247 }
248 outb_p(smb_en, smba_idx);
249 smba_en_lo = inb_p(smba_idx + 1);
250 outb_p(smb_en + 1, smba_idx);
251 smba_en_hi = inb_p(smba_idx + 1);
252 release_region(smba_idx, 2);
253
254 if ((smba_en_lo & 1) == 0) {
255 dev_err(&PIIX4_dev->dev,
256 "Host SMBus controller not enabled!\n");
257 return -ENODEV;
258 }
259
260 piix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0;
261 if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))
262 return -EBUSY;
263
264 if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
265 dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n",
266 piix4_smba);
267 return -EBUSY;
268 }
269
270 /* Request the SMBus I2C bus config region */
271 if (!request_region(piix4_smba + i2ccfg_offset, 1, "i2ccfg")) {
272 dev_err(&PIIX4_dev->dev, "SMBus I2C bus config region "
273 "0x%x already in use!\n", piix4_smba + i2ccfg_offset);
274 release_region(piix4_smba, SMBIOSIZE);
275 piix4_smba = 0;
276 return -EBUSY;
277 }
278 i2ccfg = inb_p(piix4_smba + i2ccfg_offset);
279 release_region(piix4_smba + i2ccfg_offset, 1);
280
281 if (i2ccfg & 1)
282 dev_dbg(&PIIX4_dev->dev, "Using IRQ for SMBus.\n");
283 else
284 dev_dbg(&PIIX4_dev->dev, "Using SMI# for SMBus.\n");
285
286 dev_info(&PIIX4_dev->dev,
287 "SMBus Host Controller at 0x%x, revision %d\n",
288 piix4_smba, i2ccfg >> 4);
289
290 return 0;
291}
292
229static int piix4_transaction(void) 293static int piix4_transaction(void)
230{ 294{
231 int temp; 295 int temp;
@@ -423,6 +487,8 @@ static struct pci_device_id piix4_ids[] = {
423 PCI_DEVICE_ID_SERVERWORKS_CSB6) }, 487 PCI_DEVICE_ID_SERVERWORKS_CSB6) },
424 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 488 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
425 PCI_DEVICE_ID_SERVERWORKS_HT1000SB) }, 489 PCI_DEVICE_ID_SERVERWORKS_HT1000SB) },
490 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
491 PCI_DEVICE_ID_SERVERWORKS_HT1100LD) },
426 { 0, } 492 { 0, }
427}; 493};
428 494
@@ -433,7 +499,14 @@ static int __devinit piix4_probe(struct pci_dev *dev,
433{ 499{
434 int retval; 500 int retval;
435 501
436 retval = piix4_setup(dev, id); 502 if ((dev->vendor == PCI_VENDOR_ID_ATI) &&
503 (dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS) &&
504 (dev->revision >= 0x40))
505 /* base address location etc changed in SB800 */
506 retval = piix4_setup_sb800(dev, id);
507 else
508 retval = piix4_setup(dev, id);
509
437 if (retval) 510 if (retval)
438 return retval; 511 return retval;
439 512
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 60ca91745e55..3c9d71f60187 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -191,7 +191,8 @@ static int __devexit i2c_powermac_remove(struct platform_device *dev)
191 i2c_set_adapdata(adapter, NULL); 191 i2c_set_adapdata(adapter, NULL);
192 /* We aren't that prepared to deal with this... */ 192 /* We aren't that prepared to deal with this... */
193 if (rc) 193 if (rc)
194 printk("i2c-powermac.c: Failed to remove bus %s !\n", 194 printk(KERN_WARNING
195 "i2c-powermac.c: Failed to remove bus %s !\n",
195 adapter->name); 196 adapter->name);
196 platform_set_drvdata(dev, NULL); 197 platform_set_drvdata(dev, NULL);
197 kfree(adapter); 198 kfree(adapter);
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index bdb1f7510e91..c1405c8f6ba5 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -210,11 +210,12 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id);
210static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) 210static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why)
211{ 211{
212 unsigned int i; 212 unsigned int i;
213 printk("i2c: error: %s\n", why); 213 printk(KERN_ERR "i2c: error: %s\n", why);
214 printk("i2c: msg_num: %d msg_idx: %d msg_ptr: %d\n", 214 printk(KERN_ERR "i2c: msg_num: %d msg_idx: %d msg_ptr: %d\n",
215 i2c->msg_num, i2c->msg_idx, i2c->msg_ptr); 215 i2c->msg_num, i2c->msg_idx, i2c->msg_ptr);
216 printk("i2c: ICR: %08x ISR: %08x\n" 216 printk(KERN_ERR "i2c: ICR: %08x ISR: %08x\n",
217 "i2c: log: ", readl(_ICR(i2c)), readl(_ISR(i2c))); 217 readl(_ICR(i2c)), readl(_ISR(i2c)));
218 printk(KERN_DEBUG "i2c: log: ");
218 for (i = 0; i < i2c->irqlogidx; i++) 219 for (i = 0; i < i2c->irqlogidx; i++)
219 printk("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]); 220 printk("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]);
220 printk("\n"); 221 printk("\n");
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
index 4678babd3ce6..fede619ba227 100644
--- a/drivers/i2c/busses/i2c-versatile.c
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -102,7 +102,13 @@ static int i2c_versatile_probe(struct platform_device *dev)
102 i2c->algo = i2c_versatile_algo; 102 i2c->algo = i2c_versatile_algo;
103 i2c->algo.data = i2c; 103 i2c->algo.data = i2c;
104 104
105 ret = i2c_bit_add_bus(&i2c->adap); 105 if (dev->id >= 0) {
106 /* static bus numbering */
107 i2c->adap.nr = dev->id;
108 ret = i2c_bit_add_numbered_bus(&i2c->adap);
109 } else
110 /* dynamic bus numbering */
111 ret = i2c_bit_add_bus(&i2c->adap);
106 if (ret >= 0) { 112 if (ret >= 0) {
107 platform_set_drvdata(dev, i2c); 113 platform_set_drvdata(dev, i2c);
108 return 0; 114 return 0;
@@ -146,7 +152,7 @@ static void __exit i2c_versatile_exit(void)
146 platform_driver_unregister(&i2c_versatile_driver); 152 platform_driver_unregister(&i2c_versatile_driver);
147} 153}
148 154
149module_init(i2c_versatile_init); 155subsys_initcall(i2c_versatile_init);
150module_exit(i2c_versatile_exit); 156module_exit(i2c_versatile_exit);
151 157
152MODULE_DESCRIPTION("ARM Versatile I2C bus driver"); 158MODULE_DESCRIPTION("ARM Versatile I2C bus driver");