aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-davinci.c17
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c2
-rw-r--r--drivers/i2c/busses/i2c-omap.c36
-rw-r--r--drivers/i2c/busses/i2c-tiny-usb.c12
-rw-r--r--drivers/i2c/i2c-core.c4
6 files changed, 46 insertions, 27 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 476b0bb72d6c..5fa9c3c67e0c 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -100,7 +100,7 @@ config I2C_AU1550
100 100
101config I2C_BLACKFIN_TWI 101config I2C_BLACKFIN_TWI
102 tristate "Blackfin TWI I2C support" 102 tristate "Blackfin TWI I2C support"
103 depends on BF534 || BF536 || BF537 || BF54x 103 depends on BF534 || BF536 || BF537
104 help 104 help
105 This is the TWI I2C device driver for Blackfin 534/536/537/54x. 105 This is the TWI I2C device driver for Blackfin 534/536/537/54x.
106 This driver can also be built as a module. If so, the module 106 This driver can also be built as a module. If so, the module
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index cce5a614758d..fde26345a379 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -382,9 +382,8 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
382 break; 382 break;
383 383
384 case DAVINCI_I2C_IVR_ARDY: 384 case DAVINCI_I2C_IVR_ARDY:
385 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG); 385 davinci_i2c_write_reg(dev,
386 MOD_REG_BIT(w, DAVINCI_I2C_STR_ARDY, 1); 386 DAVINCI_I2C_STR_REG, DAVINCI_I2C_STR_ARDY);
387 davinci_i2c_write_reg(dev, DAVINCI_I2C_STR_REG, w);
388 complete(&dev->cmd_complete); 387 complete(&dev->cmd_complete);
389 break; 388 break;
390 389
@@ -397,12 +396,9 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
397 if (dev->buf_len) 396 if (dev->buf_len)
398 continue; 397 continue;
399 398
400 w = davinci_i2c_read_reg(dev,
401 DAVINCI_I2C_STR_REG);
402 MOD_REG_BIT(w, DAVINCI_I2C_IMR_RRDY, 0);
403 davinci_i2c_write_reg(dev, 399 davinci_i2c_write_reg(dev,
404 DAVINCI_I2C_STR_REG, 400 DAVINCI_I2C_STR_REG,
405 w); 401 DAVINCI_I2C_IMR_RRDY);
406 } else 402 } else
407 dev_err(dev->dev, "RDR IRQ while no " 403 dev_err(dev->dev, "RDR IRQ while no "
408 "data requested\n"); 404 "data requested\n");
@@ -428,9 +424,8 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
428 break; 424 break;
429 425
430 case DAVINCI_I2C_IVR_SCD: 426 case DAVINCI_I2C_IVR_SCD:
431 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG); 427 davinci_i2c_write_reg(dev,
432 MOD_REG_BIT(w, DAVINCI_I2C_STR_SCD, 1); 428 DAVINCI_I2C_STR_REG, DAVINCI_I2C_STR_SCD);
433 davinci_i2c_write_reg(dev, DAVINCI_I2C_STR_REG, w);
434 complete(&dev->cmd_complete); 429 complete(&dev->cmd_complete);
435 break; 430 break;
436 431
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 7c7eb0cfeceb..22bb247d0e60 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(iic_force_poll, "Force polling mode");
55 55
56static int iic_force_fast; 56static int iic_force_fast;
57module_param(iic_force_fast, bool, 0); 57module_param(iic_force_fast, bool, 0);
58MODULE_PARM_DESC(iic_fast_poll, "Force fast mode (400 kHz)"); 58MODULE_PARM_DESC(iic_force_fast, "Force fast mode (400 kHz)");
59 59
60#define DBG_LEVEL 0 60#define DBG_LEVEL 0
61 61
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index da6639707ea3..7ba31770d773 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -128,6 +128,8 @@ struct omap_i2c_dev {
128 size_t buf_len; 128 size_t buf_len;
129 struct i2c_adapter adapter; 129 struct i2c_adapter adapter;
130 unsigned rev1:1; 130 unsigned rev1:1;
131 unsigned idle:1;
132 u16 iestate; /* Saved interrupt register */
131}; 133};
132 134
133static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, 135static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev,
@@ -174,18 +176,30 @@ static void omap_i2c_put_clocks(struct omap_i2c_dev *dev)
174 } 176 }
175} 177}
176 178
177static void omap_i2c_enable_clocks(struct omap_i2c_dev *dev) 179static void omap_i2c_unidle(struct omap_i2c_dev *dev)
178{ 180{
179 if (dev->iclk != NULL) 181 if (dev->iclk != NULL)
180 clk_enable(dev->iclk); 182 clk_enable(dev->iclk);
181 clk_enable(dev->fclk); 183 clk_enable(dev->fclk);
184 if (dev->iestate)
185 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
186 dev->idle = 0;
182} 187}
183 188
184static void omap_i2c_disable_clocks(struct omap_i2c_dev *dev) 189static void omap_i2c_idle(struct omap_i2c_dev *dev)
185{ 190{
191 u16 iv;
192
193 dev->idle = 1;
194 dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
195 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0);
196 if (dev->rev1)
197 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */
198 else
199 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate);
200 clk_disable(dev->fclk);
186 if (dev->iclk != NULL) 201 if (dev->iclk != NULL)
187 clk_disable(dev->iclk); 202 clk_disable(dev->iclk);
188 clk_disable(dev->fclk);
189} 203}
190 204
191static int omap_i2c_init(struct omap_i2c_dev *dev) 205static int omap_i2c_init(struct omap_i2c_dev *dev)
@@ -360,7 +374,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
360 int i; 374 int i;
361 int r; 375 int r;
362 376
363 omap_i2c_enable_clocks(dev); 377 omap_i2c_unidle(dev);
364 378
365 if ((r = omap_i2c_wait_for_bb(dev)) < 0) 379 if ((r = omap_i2c_wait_for_bb(dev)) < 0)
366 goto out; 380 goto out;
@@ -374,7 +388,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
374 if (r == 0) 388 if (r == 0)
375 r = num; 389 r = num;
376out: 390out:
377 omap_i2c_disable_clocks(dev); 391 omap_i2c_idle(dev);
378 return r; 392 return r;
379} 393}
380 394
@@ -403,6 +417,9 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id)
403 struct omap_i2c_dev *dev = dev_id; 417 struct omap_i2c_dev *dev = dev_id;
404 u16 iv, w; 418 u16 iv, w;
405 419
420 if (dev->idle)
421 return IRQ_NONE;
422
406 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); 423 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG);
407 switch (iv) { 424 switch (iv) {
408 case 0x00: /* None */ 425 case 0x00: /* None */
@@ -457,6 +474,9 @@ omap_i2c_isr(int this_irq, void *dev_id)
457 u16 stat, w; 474 u16 stat, w;
458 int count = 0; 475 int count = 0;
459 476
477 if (dev->idle)
478 return IRQ_NONE;
479
460 bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); 480 bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
461 while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) { 481 while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) {
462 dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat); 482 dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat);
@@ -575,7 +595,7 @@ omap_i2c_probe(struct platform_device *pdev)
575 if ((r = omap_i2c_get_clocks(dev)) != 0) 595 if ((r = omap_i2c_get_clocks(dev)) != 0)
576 goto err_free_mem; 596 goto err_free_mem;
577 597
578 omap_i2c_enable_clocks(dev); 598 omap_i2c_unidle(dev);
579 599
580 if (cpu_is_omap15xx()) 600 if (cpu_is_omap15xx())
581 dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20; 601 dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20;
@@ -610,7 +630,7 @@ omap_i2c_probe(struct platform_device *pdev)
610 goto err_free_irq; 630 goto err_free_irq;
611 } 631 }
612 632
613 omap_i2c_disable_clocks(dev); 633 omap_i2c_idle(dev);
614 634
615 return 0; 635 return 0;
616 636
@@ -618,7 +638,7 @@ err_free_irq:
618 free_irq(dev->irq, dev); 638 free_irq(dev->irq, dev);
619err_unuse_clocks: 639err_unuse_clocks:
620 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 640 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
621 omap_i2c_disable_clocks(dev); 641 omap_i2c_idle(dev);
622 omap_i2c_put_clocks(dev); 642 omap_i2c_put_clocks(dev);
623err_free_mem: 643err_free_mem:
624 platform_set_drvdata(pdev, NULL); 644 platform_set_drvdata(pdev, NULL);
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index cb9abe7565a7..b1c050ff311d 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -131,11 +131,15 @@ static const struct i2c_algorithm usb_algorithm = {
131 131
132/* ----- begin of usb layer ---------------------------------------------- */ 132/* ----- begin of usb layer ---------------------------------------------- */
133 133
134/* The usb i2c interface uses a vid/pid pair donated by */ 134/*
135/* Future Technology Devices International Ltd. */ 135 * Initially the usb i2c interface uses a vid/pid pair donated by
136 * Future Technology Devices International Ltd., later a pair was
137 * bought from EZPrototypes
138 */
136static struct usb_device_id i2c_tiny_usb_table [] = { 139static struct usb_device_id i2c_tiny_usb_table [] = {
137 { USB_DEVICE(0x0403, 0xc631) }, 140 { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */
138 { } /* Terminating entry */ 141 { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */
142 { } /* Terminating entry */
139}; 143};
140 144
141MODULE_DEVICE_TABLE(usb, i2c_tiny_usb_table); 145MODULE_DEVICE_TABLE(usb, i2c_tiny_usb_table);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index fd84b2a36338..8b645c6b2cb5 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -489,8 +489,8 @@ EXPORT_SYMBOL(i2c_add_adapter);
489 * Context: can sleep 489 * Context: can sleep
490 * 490 *
491 * This routine is used to declare an I2C adapter when its bus number 491 * This routine is used to declare an I2C adapter when its bus number
492 * matters. Example: for I2C adapters from system-on-chip CPUs, or 492 * matters. For example, use it for I2C adapters from system-on-chip CPUs,
493 * otherwise built in to the system's mainboard, and where i2c_board_info 493 * or otherwise built in to the system's mainboard, and where i2c_board_info
494 * is used to properly configure I2C devices. 494 * is used to properly configure I2C devices.
495 * 495 *
496 * If no devices have pre-been declared for this bus, then be sure to 496 * If no devices have pre-been declared for this bus, then be sure to