diff options
author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-09-12 11:14:33 -0400 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2012-09-12 11:14:33 -0400 |
commit | 25a765b7f05cb8460fa01b54568894b20e184862 (patch) | |
tree | 0b56db57b4d9f912393ab303c269e0fe6cdf8635 /drivers/i2c | |
parent | 9d2be9287107695708e6aae5105a8a518a6cb4d0 (diff) | |
parent | 64282278989d5b0398dcb3ba7904cb00c621dc35 (diff) |
Merge branch 'x86/platform' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into stable/for-linus-3.7
* 'x86/platform' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (9690 commits)
x86: Document x86_init.paging.pagetable_init()
x86: xen: Cleanup and remove x86_init.paging.pagetable_setup_done()
x86: Move paging_init() call to x86_init.paging.pagetable_init()
x86: Rename pagetable_setup_start() to pagetable_init()
x86: Remove base argument from x86_init.paging.pagetable_setup_start
Linux 3.6-rc5
HID: tpkbd: work even if the new Lenovo Keyboard driver is not configured
Remove user-triggerable BUG from mpol_to_str
xen/pciback: Fix proper FLR steps.
uml: fix compile error in deliver_alarm()
dj: memory scribble in logi_dj
Fix order of arguments to compat_put_time[spec|val]
xen: Use correct masking in xen_swiotlb_alloc_coherent.
xen: fix logical error in tlb flushing
xen/p2m: Fix one-off error in checking the P2M tree directory.
powerpc: Don't use __put_user() in patch_instruction
powerpc: Make sure IPI handlers see data written by IPI senders
powerpc: Restore correct DSCR in context switch
powerpc: Fix DSCR inheritance in copy_thread()
powerpc: Keep thread.dscr and thread.dscr_inherit in sync
...
Diffstat (limited to 'drivers/i2c')
40 files changed, 1310 insertions, 992 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 7244c8be6063..b4aaa1bd6728 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -133,7 +133,7 @@ config I2C_PIIX4 | |||
133 | ATI IXP300 | 133 | ATI IXP300 |
134 | ATI IXP400 | 134 | ATI IXP400 |
135 | ATI SB600 | 135 | ATI SB600 |
136 | ATI SB700 | 136 | ATI SB700/SP5100 |
137 | ATI SB800 | 137 | ATI SB800 |
138 | AMD Hudson-2 | 138 | AMD Hudson-2 |
139 | Serverworks OSB4 | 139 | Serverworks OSB4 |
@@ -143,6 +143,10 @@ config I2C_PIIX4 | |||
143 | Serverworks HT-1100 | 143 | Serverworks HT-1100 |
144 | SMSC Victory66 | 144 | SMSC Victory66 |
145 | 145 | ||
146 | Some AMD chipsets contain two PIIX4-compatible SMBus | ||
147 | controllers. This driver will attempt to use both controllers | ||
148 | on the SB700/SP5100, if they have been initialized by the BIOS. | ||
149 | |||
146 | This driver can also be built as a module. If so, the module | 150 | This driver can also be built as a module. If so, the module |
147 | will be called i2c-piix4. | 151 | will be called i2c-piix4. |
148 | 152 | ||
@@ -458,7 +462,7 @@ config I2C_MPC | |||
458 | 462 | ||
459 | config I2C_MV64XXX | 463 | config I2C_MV64XXX |
460 | tristate "Marvell mv64xxx I2C Controller" | 464 | tristate "Marvell mv64xxx I2C Controller" |
461 | depends on (MV64X60 || PLAT_ORION) && EXPERIMENTAL | 465 | depends on (MV64X60 || PLAT_ORION) |
462 | help | 466 | help |
463 | If you say yes to this option, support will be included for the | 467 | If you say yes to this option, support will be included for the |
464 | built-in I2C interface on the Marvell 64xxx line of host bridges. | 468 | built-in I2C interface on the Marvell 64xxx line of host bridges. |
@@ -479,10 +483,11 @@ config I2C_MXS | |||
479 | 483 | ||
480 | config I2C_NOMADIK | 484 | config I2C_NOMADIK |
481 | tristate "ST-Ericsson Nomadik/Ux500 I2C Controller" | 485 | tristate "ST-Ericsson Nomadik/Ux500 I2C Controller" |
482 | depends on PLAT_NOMADIK | 486 | depends on ARM_AMBA |
483 | help | 487 | help |
484 | If you say yes to this option, support will be included for the | 488 | If you say yes to this option, support will be included for the |
485 | I2C interface from ST-Ericsson's Nomadik and Ux500 architectures. | 489 | I2C interface from ST-Ericsson's Nomadik and Ux500 architectures, |
490 | as well as the STA2X11 PCIe I/O HUB. | ||
486 | 491 | ||
487 | config I2C_NUC900 | 492 | config I2C_NUC900 |
488 | tristate "NUC900 I2C Driver" | 493 | tristate "NUC900 I2C Driver" |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index e66d248fc126..125cd8e0ad25 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -531,15 +531,7 @@ static struct pci_driver ali1535_driver = { | |||
531 | .remove = __devexit_p(ali1535_remove), | 531 | .remove = __devexit_p(ali1535_remove), |
532 | }; | 532 | }; |
533 | 533 | ||
534 | static int __init i2c_ali1535_init(void) | 534 | module_pci_driver(ali1535_driver); |
535 | { | ||
536 | return pci_register_driver(&ali1535_driver); | ||
537 | } | ||
538 | |||
539 | static void __exit i2c_ali1535_exit(void) | ||
540 | { | ||
541 | pci_unregister_driver(&ali1535_driver); | ||
542 | } | ||
543 | 535 | ||
544 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, " | 536 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, " |
545 | "Philip Edelbrock <phil@netroedge.com>, " | 537 | "Philip Edelbrock <phil@netroedge.com>, " |
@@ -547,6 +539,3 @@ MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, " | |||
547 | "and Dan Eaton <dan.eaton@rocketlogix.com>"); | 539 | "and Dan Eaton <dan.eaton@rocketlogix.com>"); |
548 | MODULE_DESCRIPTION("ALI1535 SMBus driver"); | 540 | MODULE_DESCRIPTION("ALI1535 SMBus driver"); |
549 | MODULE_LICENSE("GPL"); | 541 | MODULE_LICENSE("GPL"); |
550 | |||
551 | module_init(i2c_ali1535_init); | ||
552 | module_exit(i2c_ali1535_exit); | ||
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 47ae0091e027..e02d9f86c6a0 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -431,18 +431,6 @@ static struct pci_driver ali1563_pci_driver = { | |||
431 | .remove = __devexit_p(ali1563_remove), | 431 | .remove = __devexit_p(ali1563_remove), |
432 | }; | 432 | }; |
433 | 433 | ||
434 | static int __init ali1563_init(void) | 434 | module_pci_driver(ali1563_pci_driver); |
435 | { | ||
436 | return pci_register_driver(&ali1563_pci_driver); | ||
437 | } | ||
438 | |||
439 | module_init(ali1563_init); | ||
440 | |||
441 | static void __exit ali1563_exit(void) | ||
442 | { | ||
443 | pci_unregister_driver(&ali1563_pci_driver); | ||
444 | } | ||
445 | |||
446 | module_exit(ali1563_exit); | ||
447 | 435 | ||
448 | MODULE_LICENSE("GPL"); | 436 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 087ea9caa74d..ce8d26d053a5 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -513,21 +513,10 @@ static struct pci_driver ali15x3_driver = { | |||
513 | .remove = __devexit_p(ali15x3_remove), | 513 | .remove = __devexit_p(ali15x3_remove), |
514 | }; | 514 | }; |
515 | 515 | ||
516 | static int __init i2c_ali15x3_init(void) | 516 | module_pci_driver(ali15x3_driver); |
517 | { | ||
518 | return pci_register_driver(&ali15x3_driver); | ||
519 | } | ||
520 | |||
521 | static void __exit i2c_ali15x3_exit(void) | ||
522 | { | ||
523 | pci_unregister_driver(&ali15x3_driver); | ||
524 | } | ||
525 | 517 | ||
526 | MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl>, " | 518 | MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl>, " |
527 | "Philip Edelbrock <phil@netroedge.com>, " | 519 | "Philip Edelbrock <phil@netroedge.com>, " |
528 | "and Mark D. Studebaker <mdsxyz123@yahoo.com>"); | 520 | "and Mark D. Studebaker <mdsxyz123@yahoo.com>"); |
529 | MODULE_DESCRIPTION("ALI15X3 SMBus driver"); | 521 | MODULE_DESCRIPTION("ALI15X3 SMBus driver"); |
530 | MODULE_LICENSE("GPL"); | 522 | MODULE_LICENSE("GPL"); |
531 | |||
532 | module_init(i2c_ali15x3_init); | ||
533 | module_exit(i2c_ali15x3_exit); | ||
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index eb778bf15c18..304aa03b57b2 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -410,21 +410,10 @@ static struct pci_driver amd756_driver = { | |||
410 | .remove = __devexit_p(amd756_remove), | 410 | .remove = __devexit_p(amd756_remove), |
411 | }; | 411 | }; |
412 | 412 | ||
413 | static int __init amd756_init(void) | 413 | module_pci_driver(amd756_driver); |
414 | { | ||
415 | return pci_register_driver(&amd756_driver); | ||
416 | } | ||
417 | |||
418 | static void __exit amd756_exit(void) | ||
419 | { | ||
420 | pci_unregister_driver(&amd756_driver); | ||
421 | } | ||
422 | 414 | ||
423 | MODULE_AUTHOR("Merlin Hughes <merlin@merlin.org>"); | 415 | MODULE_AUTHOR("Merlin Hughes <merlin@merlin.org>"); |
424 | MODULE_DESCRIPTION("AMD756/766/768/8111 and nVidia nForce SMBus driver"); | 416 | MODULE_DESCRIPTION("AMD756/766/768/8111 and nVidia nForce SMBus driver"); |
425 | MODULE_LICENSE("GPL"); | 417 | MODULE_LICENSE("GPL"); |
426 | 418 | ||
427 | EXPORT_SYMBOL(amd756_smbus); | 419 | EXPORT_SYMBOL(amd756_smbus); |
428 | |||
429 | module_init(amd756_init) | ||
430 | module_exit(amd756_exit) | ||
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index e5ac53b99b04..0919ac1d99aa 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -491,15 +491,4 @@ static struct pci_driver amd8111_driver = { | |||
491 | .remove = __devexit_p(amd8111_remove), | 491 | .remove = __devexit_p(amd8111_remove), |
492 | }; | 492 | }; |
493 | 493 | ||
494 | static int __init i2c_amd8111_init(void) | 494 | module_pci_driver(amd8111_driver); |
495 | { | ||
496 | return pci_register_driver(&amd8111_driver); | ||
497 | } | ||
498 | |||
499 | static void __exit i2c_amd8111_exit(void) | ||
500 | { | ||
501 | pci_unregister_driver(&amd8111_driver); | ||
502 | } | ||
503 | |||
504 | module_init(i2c_amd8111_init); | ||
505 | module_exit(i2c_amd8111_exit); | ||
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 1679deef9c89..e24484beef07 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -279,30 +279,31 @@ static int __devexit at91_i2c_remove(struct platform_device *pdev) | |||
279 | 279 | ||
280 | /* NOTE: could save a few mA by keeping clock off outside of at91_xfer... */ | 280 | /* NOTE: could save a few mA by keeping clock off outside of at91_xfer... */ |
281 | 281 | ||
282 | static int at91_i2c_suspend(struct platform_device *pdev, pm_message_t mesg) | 282 | static int at91_i2c_suspend(struct device *dev) |
283 | { | 283 | { |
284 | clk_disable(twi_clk); | 284 | clk_disable(twi_clk); |
285 | return 0; | 285 | return 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | static int at91_i2c_resume(struct platform_device *pdev) | 288 | static int at91_i2c_resume(struct device *dev) |
289 | { | 289 | { |
290 | return clk_enable(twi_clk); | 290 | return clk_enable(twi_clk); |
291 | } | 291 | } |
292 | 292 | ||
293 | static SIMPLE_DEV_PM_OPS(at91_i2c_pm, at91_i2c_suspend, at91_i2c_resume); | ||
294 | #define AT91_I2C_PM (&at91_i2c_pm) | ||
295 | |||
293 | #else | 296 | #else |
294 | #define at91_i2c_suspend NULL | 297 | #define AT91_I2C_PM NULL |
295 | #define at91_i2c_resume NULL | ||
296 | #endif | 298 | #endif |
297 | 299 | ||
298 | static struct platform_driver at91_i2c_driver = { | 300 | static struct platform_driver at91_i2c_driver = { |
299 | .probe = at91_i2c_probe, | 301 | .probe = at91_i2c_probe, |
300 | .remove = __devexit_p(at91_i2c_remove), | 302 | .remove = __devexit_p(at91_i2c_remove), |
301 | .suspend = at91_i2c_suspend, | ||
302 | .resume = at91_i2c_resume, | ||
303 | .driver = { | 303 | .driver = { |
304 | .name = "at91_i2c", | 304 | .name = "at91_i2c", |
305 | .owner = THIS_MODULE, | 305 | .owner = THIS_MODULE, |
306 | .pm = AT91_I2C_PM, | ||
306 | }, | 307 | }, |
307 | }; | 308 | }; |
308 | 309 | ||
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index cdb59e5b23f7..0cf780fd6ef1 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <asm/blackfin.h> | 25 | #include <asm/blackfin.h> |
26 | #include <asm/portmux.h> | 26 | #include <asm/portmux.h> |
27 | #include <asm/irq.h> | 27 | #include <asm/irq.h> |
28 | #include <asm/bfin_twi.h> | ||
28 | 29 | ||
29 | /* SMBus mode*/ | 30 | /* SMBus mode*/ |
30 | #define TWI_I2C_MODE_STANDARD 1 | 31 | #define TWI_I2C_MODE_STANDARD 1 |
@@ -32,56 +33,6 @@ | |||
32 | #define TWI_I2C_MODE_COMBINED 3 | 33 | #define TWI_I2C_MODE_COMBINED 3 |
33 | #define TWI_I2C_MODE_REPEAT 4 | 34 | #define TWI_I2C_MODE_REPEAT 4 |
34 | 35 | ||
35 | struct bfin_twi_iface { | ||
36 | int irq; | ||
37 | spinlock_t lock; | ||
38 | char read_write; | ||
39 | u8 command; | ||
40 | u8 *transPtr; | ||
41 | int readNum; | ||
42 | int writeNum; | ||
43 | int cur_mode; | ||
44 | int manual_stop; | ||
45 | int result; | ||
46 | struct i2c_adapter adap; | ||
47 | struct completion complete; | ||
48 | struct i2c_msg *pmsg; | ||
49 | int msg_num; | ||
50 | int cur_msg; | ||
51 | u16 saved_clkdiv; | ||
52 | u16 saved_control; | ||
53 | void __iomem *regs_base; | ||
54 | }; | ||
55 | |||
56 | |||
57 | #define DEFINE_TWI_REG(reg, off) \ | ||
58 | static inline u16 read_##reg(struct bfin_twi_iface *iface) \ | ||
59 | { return bfin_read16(iface->regs_base + (off)); } \ | ||
60 | static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \ | ||
61 | { bfin_write16(iface->regs_base + (off), v); } | ||
62 | |||
63 | DEFINE_TWI_REG(CLKDIV, 0x00) | ||
64 | DEFINE_TWI_REG(CONTROL, 0x04) | ||
65 | DEFINE_TWI_REG(SLAVE_CTL, 0x08) | ||
66 | DEFINE_TWI_REG(SLAVE_STAT, 0x0C) | ||
67 | DEFINE_TWI_REG(SLAVE_ADDR, 0x10) | ||
68 | DEFINE_TWI_REG(MASTER_CTL, 0x14) | ||
69 | DEFINE_TWI_REG(MASTER_STAT, 0x18) | ||
70 | DEFINE_TWI_REG(MASTER_ADDR, 0x1C) | ||
71 | DEFINE_TWI_REG(INT_STAT, 0x20) | ||
72 | DEFINE_TWI_REG(INT_MASK, 0x24) | ||
73 | DEFINE_TWI_REG(FIFO_CTL, 0x28) | ||
74 | DEFINE_TWI_REG(FIFO_STAT, 0x2C) | ||
75 | DEFINE_TWI_REG(XMT_DATA8, 0x80) | ||
76 | DEFINE_TWI_REG(XMT_DATA16, 0x84) | ||
77 | DEFINE_TWI_REG(RCV_DATA8, 0x88) | ||
78 | DEFINE_TWI_REG(RCV_DATA16, 0x8C) | ||
79 | |||
80 | static const u16 pin_req[2][3] = { | ||
81 | {P_TWI0_SCL, P_TWI0_SDA, 0}, | ||
82 | {P_TWI1_SCL, P_TWI1_SDA, 0}, | ||
83 | }; | ||
84 | |||
85 | static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | 36 | static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, |
86 | unsigned short twi_int_status) | 37 | unsigned short twi_int_status) |
87 | { | 38 | { |
@@ -99,7 +50,7 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
99 | */ | 50 | */ |
100 | else if (iface->cur_mode == TWI_I2C_MODE_COMBINED) | 51 | else if (iface->cur_mode == TWI_I2C_MODE_COMBINED) |
101 | write_MASTER_CTL(iface, | 52 | write_MASTER_CTL(iface, |
102 | read_MASTER_CTL(iface) | MDIR | RSTART); | 53 | read_MASTER_CTL(iface) | MDIR); |
103 | else if (iface->manual_stop) | 54 | else if (iface->manual_stop) |
104 | write_MASTER_CTL(iface, | 55 | write_MASTER_CTL(iface, |
105 | read_MASTER_CTL(iface) | STOP); | 56 | read_MASTER_CTL(iface) | STOP); |
@@ -107,10 +58,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
107 | iface->cur_msg + 1 < iface->msg_num) { | 58 | iface->cur_msg + 1 < iface->msg_num) { |
108 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) | 59 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) |
109 | write_MASTER_CTL(iface, | 60 | write_MASTER_CTL(iface, |
110 | read_MASTER_CTL(iface) | RSTART | MDIR); | 61 | read_MASTER_CTL(iface) | MDIR); |
111 | else | 62 | else |
112 | write_MASTER_CTL(iface, | 63 | write_MASTER_CTL(iface, |
113 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); | 64 | read_MASTER_CTL(iface) & ~MDIR); |
114 | } | 65 | } |
115 | } | 66 | } |
116 | if (twi_int_status & RCVSERV) { | 67 | if (twi_int_status & RCVSERV) { |
@@ -130,17 +81,25 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
130 | } | 81 | } |
131 | iface->transPtr++; | 82 | iface->transPtr++; |
132 | iface->readNum--; | 83 | iface->readNum--; |
133 | } else if (iface->manual_stop) { | 84 | } |
134 | write_MASTER_CTL(iface, | 85 | |
135 | read_MASTER_CTL(iface) | STOP); | 86 | if (iface->readNum == 0) { |
136 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && | 87 | if (iface->manual_stop) { |
137 | iface->cur_msg + 1 < iface->msg_num) { | 88 | /* Temporary workaround to avoid possible bus stall - |
138 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) | 89 | * Flush FIFO before issuing the STOP condition |
139 | write_MASTER_CTL(iface, | 90 | */ |
140 | read_MASTER_CTL(iface) | RSTART | MDIR); | 91 | read_RCV_DATA16(iface); |
141 | else | ||
142 | write_MASTER_CTL(iface, | 92 | write_MASTER_CTL(iface, |
143 | (read_MASTER_CTL(iface) | RSTART) & ~MDIR); | 93 | read_MASTER_CTL(iface) | STOP); |
94 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && | ||
95 | iface->cur_msg + 1 < iface->msg_num) { | ||
96 | if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) | ||
97 | write_MASTER_CTL(iface, | ||
98 | read_MASTER_CTL(iface) | MDIR); | ||
99 | else | ||
100 | write_MASTER_CTL(iface, | ||
101 | read_MASTER_CTL(iface) & ~MDIR); | ||
102 | } | ||
144 | } | 103 | } |
145 | } | 104 | } |
146 | if (twi_int_status & MERR) { | 105 | if (twi_int_status & MERR) { |
@@ -193,7 +152,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
193 | return; | 152 | return; |
194 | } | 153 | } |
195 | if (twi_int_status & MCOMP) { | 154 | if (twi_int_status & MCOMP) { |
196 | if ((read_MASTER_CTL(iface) & MEN) == 0 && | 155 | if (twi_int_status & (XMTSERV | RCVSERV) && |
156 | (read_MASTER_CTL(iface) & MEN) == 0 && | ||
197 | (iface->cur_mode == TWI_I2C_MODE_REPEAT || | 157 | (iface->cur_mode == TWI_I2C_MODE_REPEAT || |
198 | iface->cur_mode == TWI_I2C_MODE_COMBINED)) { | 158 | iface->cur_mode == TWI_I2C_MODE_COMBINED)) { |
199 | iface->result = -1; | 159 | iface->result = -1; |
@@ -221,7 +181,7 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
221 | write_MASTER_CTL(iface, | 181 | write_MASTER_CTL(iface, |
222 | read_MASTER_CTL(iface) & ~RSTART); | 182 | read_MASTER_CTL(iface) & ~RSTART); |
223 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && | 183 | } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT && |
224 | iface->cur_msg+1 < iface->msg_num) { | 184 | iface->cur_msg + 1 < iface->msg_num) { |
225 | iface->cur_msg++; | 185 | iface->cur_msg++; |
226 | iface->transPtr = iface->pmsg[iface->cur_msg].buf; | 186 | iface->transPtr = iface->pmsg[iface->cur_msg].buf; |
227 | iface->writeNum = iface->readNum = | 187 | iface->writeNum = iface->readNum = |
@@ -241,27 +201,29 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, | |||
241 | } | 201 | } |
242 | } | 202 | } |
243 | 203 | ||
244 | if (iface->pmsg[iface->cur_msg].len <= 255) | 204 | if (iface->pmsg[iface->cur_msg].len <= 255) { |
245 | write_MASTER_CTL(iface, | 205 | write_MASTER_CTL(iface, |
246 | (read_MASTER_CTL(iface) & | 206 | (read_MASTER_CTL(iface) & |
247 | (~(0xff << 6))) | | 207 | (~(0xff << 6))) | |
248 | (iface->pmsg[iface->cur_msg].len << 6)); | 208 | (iface->pmsg[iface->cur_msg].len << 6)); |
249 | else { | 209 | iface->manual_stop = 0; |
210 | } else { | ||
250 | write_MASTER_CTL(iface, | 211 | write_MASTER_CTL(iface, |
251 | (read_MASTER_CTL(iface) | | 212 | (read_MASTER_CTL(iface) | |
252 | (0xff << 6))); | 213 | (0xff << 6))); |
253 | iface->manual_stop = 1; | 214 | iface->manual_stop = 1; |
254 | } | 215 | } |
255 | /* remove restart bit and enable master receive */ | 216 | /* remove restart bit before last message */ |
256 | write_MASTER_CTL(iface, | 217 | if (iface->cur_msg + 1 == iface->msg_num) |
257 | read_MASTER_CTL(iface) & ~RSTART); | 218 | write_MASTER_CTL(iface, |
219 | read_MASTER_CTL(iface) & ~RSTART); | ||
258 | } else { | 220 | } else { |
259 | iface->result = 1; | 221 | iface->result = 1; |
260 | write_INT_MASK(iface, 0); | 222 | write_INT_MASK(iface, 0); |
261 | write_MASTER_CTL(iface, 0); | 223 | write_MASTER_CTL(iface, 0); |
262 | } | 224 | } |
225 | complete(&iface->complete); | ||
263 | } | 226 | } |
264 | complete(&iface->complete); | ||
265 | } | 227 | } |
266 | 228 | ||
267 | /* Interrupt handler */ | 229 | /* Interrupt handler */ |
@@ -298,8 +260,8 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap, | |||
298 | if (!(read_CONTROL(iface) & TWI_ENA)) | 260 | if (!(read_CONTROL(iface) & TWI_ENA)) |
299 | return -ENXIO; | 261 | return -ENXIO; |
300 | 262 | ||
301 | while (read_MASTER_STAT(iface) & BUSBUSY) | 263 | if (read_MASTER_STAT(iface) & BUSBUSY) |
302 | yield(); | 264 | return -EAGAIN; |
303 | 265 | ||
304 | iface->pmsg = msgs; | 266 | iface->pmsg = msgs; |
305 | iface->msg_num = num; | 267 | iface->msg_num = num; |
@@ -311,7 +273,8 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap, | |||
311 | return -EINVAL; | 273 | return -EINVAL; |
312 | } | 274 | } |
313 | 275 | ||
314 | iface->cur_mode = TWI_I2C_MODE_REPEAT; | 276 | if (iface->msg_num > 1) |
277 | iface->cur_mode = TWI_I2C_MODE_REPEAT; | ||
315 | iface->manual_stop = 0; | 278 | iface->manual_stop = 0; |
316 | iface->transPtr = pmsg->buf; | 279 | iface->transPtr = pmsg->buf; |
317 | iface->writeNum = iface->readNum = pmsg->len; | 280 | iface->writeNum = iface->readNum = pmsg->len; |
@@ -356,6 +319,7 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap, | |||
356 | 319 | ||
357 | /* Master enable */ | 320 | /* Master enable */ |
358 | write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | | 321 | write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | |
322 | (iface->msg_num > 1 ? RSTART : 0) | | ||
359 | ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) | | 323 | ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) | |
360 | ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0)); | 324 | ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0)); |
361 | SSYNC(); | 325 | SSYNC(); |
@@ -398,8 +362,8 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
398 | if (!(read_CONTROL(iface) & TWI_ENA)) | 362 | if (!(read_CONTROL(iface) & TWI_ENA)) |
399 | return -ENXIO; | 363 | return -ENXIO; |
400 | 364 | ||
401 | while (read_MASTER_STAT(iface) & BUSBUSY) | 365 | if (read_MASTER_STAT(iface) & BUSBUSY) |
402 | yield(); | 366 | return -EAGAIN; |
403 | 367 | ||
404 | iface->writeNum = 0; | 368 | iface->writeNum = 0; |
405 | iface->readNum = 0; | 369 | iface->readNum = 0; |
@@ -520,7 +484,7 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr, | |||
520 | else | 484 | else |
521 | write_MASTER_CTL(iface, 0x1 << 6); | 485 | write_MASTER_CTL(iface, 0x1 << 6); |
522 | /* Master enable */ | 486 | /* Master enable */ |
523 | write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | | 487 | write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | RSTART | |
524 | ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ>100) ? FAST : 0)); | 488 | ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ>100) ? FAST : 0)); |
525 | break; | 489 | break; |
526 | default: | 490 | default: |
@@ -611,9 +575,9 @@ static struct i2c_algorithm bfin_twi_algorithm = { | |||
611 | .functionality = bfin_twi_functionality, | 575 | .functionality = bfin_twi_functionality, |
612 | }; | 576 | }; |
613 | 577 | ||
614 | static int i2c_bfin_twi_suspend(struct platform_device *pdev, pm_message_t state) | 578 | static int i2c_bfin_twi_suspend(struct device *dev) |
615 | { | 579 | { |
616 | struct bfin_twi_iface *iface = platform_get_drvdata(pdev); | 580 | struct bfin_twi_iface *iface = dev_get_drvdata(dev); |
617 | 581 | ||
618 | iface->saved_clkdiv = read_CLKDIV(iface); | 582 | iface->saved_clkdiv = read_CLKDIV(iface); |
619 | iface->saved_control = read_CONTROL(iface); | 583 | iface->saved_control = read_CONTROL(iface); |
@@ -626,14 +590,14 @@ static int i2c_bfin_twi_suspend(struct platform_device *pdev, pm_message_t state | |||
626 | return 0; | 590 | return 0; |
627 | } | 591 | } |
628 | 592 | ||
629 | static int i2c_bfin_twi_resume(struct platform_device *pdev) | 593 | static int i2c_bfin_twi_resume(struct device *dev) |
630 | { | 594 | { |
631 | struct bfin_twi_iface *iface = platform_get_drvdata(pdev); | 595 | struct bfin_twi_iface *iface = dev_get_drvdata(dev); |
632 | 596 | ||
633 | int rc = request_irq(iface->irq, bfin_twi_interrupt_entry, | 597 | int rc = request_irq(iface->irq, bfin_twi_interrupt_entry, |
634 | 0, pdev->name, iface); | 598 | 0, to_platform_device(dev)->name, iface); |
635 | if (rc) { | 599 | if (rc) { |
636 | dev_err(&pdev->dev, "Can't get IRQ %d !\n", iface->irq); | 600 | dev_err(dev, "Can't get IRQ %d !\n", iface->irq); |
637 | return -ENODEV; | 601 | return -ENODEV; |
638 | } | 602 | } |
639 | 603 | ||
@@ -646,6 +610,9 @@ static int i2c_bfin_twi_resume(struct platform_device *pdev) | |||
646 | return 0; | 610 | return 0; |
647 | } | 611 | } |
648 | 612 | ||
613 | static SIMPLE_DEV_PM_OPS(i2c_bfin_twi_pm, | ||
614 | i2c_bfin_twi_suspend, i2c_bfin_twi_resume); | ||
615 | |||
649 | static int i2c_bfin_twi_probe(struct platform_device *pdev) | 616 | static int i2c_bfin_twi_probe(struct platform_device *pdev) |
650 | { | 617 | { |
651 | struct bfin_twi_iface *iface; | 618 | struct bfin_twi_iface *iface; |
@@ -695,7 +662,8 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) | |||
695 | p_adap->timeout = 5 * HZ; | 662 | p_adap->timeout = 5 * HZ; |
696 | p_adap->retries = 3; | 663 | p_adap->retries = 3; |
697 | 664 | ||
698 | rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi"); | 665 | rc = peripheral_request_list((unsigned short *)pdev->dev.platform_data, |
666 | "i2c-bfin-twi"); | ||
699 | if (rc) { | 667 | if (rc) { |
700 | dev_err(&pdev->dev, "Can't setup pin mux!\n"); | 668 | dev_err(&pdev->dev, "Can't setup pin mux!\n"); |
701 | goto out_error_pin_mux; | 669 | goto out_error_pin_mux; |
@@ -742,7 +710,7 @@ out_error_add_adapter: | |||
742 | free_irq(iface->irq, iface); | 710 | free_irq(iface->irq, iface); |
743 | out_error_req_irq: | 711 | out_error_req_irq: |
744 | out_error_no_irq: | 712 | out_error_no_irq: |
745 | peripheral_free_list(pin_req[pdev->id]); | 713 | peripheral_free_list((unsigned short *)pdev->dev.platform_data); |
746 | out_error_pin_mux: | 714 | out_error_pin_mux: |
747 | iounmap(iface->regs_base); | 715 | iounmap(iface->regs_base); |
748 | out_error_ioremap: | 716 | out_error_ioremap: |
@@ -760,7 +728,7 @@ static int i2c_bfin_twi_remove(struct platform_device *pdev) | |||
760 | 728 | ||
761 | i2c_del_adapter(&(iface->adap)); | 729 | i2c_del_adapter(&(iface->adap)); |
762 | free_irq(iface->irq, iface); | 730 | free_irq(iface->irq, iface); |
763 | peripheral_free_list(pin_req[pdev->id]); | 731 | peripheral_free_list((unsigned short *)pdev->dev.platform_data); |
764 | iounmap(iface->regs_base); | 732 | iounmap(iface->regs_base); |
765 | kfree(iface); | 733 | kfree(iface); |
766 | 734 | ||
@@ -770,11 +738,10 @@ static int i2c_bfin_twi_remove(struct platform_device *pdev) | |||
770 | static struct platform_driver i2c_bfin_twi_driver = { | 738 | static struct platform_driver i2c_bfin_twi_driver = { |
771 | .probe = i2c_bfin_twi_probe, | 739 | .probe = i2c_bfin_twi_probe, |
772 | .remove = i2c_bfin_twi_remove, | 740 | .remove = i2c_bfin_twi_remove, |
773 | .suspend = i2c_bfin_twi_suspend, | ||
774 | .resume = i2c_bfin_twi_resume, | ||
775 | .driver = { | 741 | .driver = { |
776 | .name = "i2c-bfin-twi", | 742 | .name = "i2c-bfin-twi", |
777 | .owner = THIS_MODULE, | 743 | .owner = THIS_MODULE, |
744 | .pm = &i2c_bfin_twi_pm, | ||
778 | }, | 745 | }, |
779 | }; | 746 | }; |
780 | 747 | ||
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index 00e8f213f56e..92a1e2c15baa 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c | |||
@@ -374,17 +374,7 @@ static struct pci_driver dw_i2c_driver = { | |||
374 | }, | 374 | }, |
375 | }; | 375 | }; |
376 | 376 | ||
377 | static int __init dw_i2c_init_driver(void) | 377 | module_pci_driver(dw_i2c_driver); |
378 | { | ||
379 | return pci_register_driver(&dw_i2c_driver); | ||
380 | } | ||
381 | module_init(dw_i2c_init_driver); | ||
382 | |||
383 | static void __exit dw_i2c_exit_driver(void) | ||
384 | { | ||
385 | pci_unregister_driver(&dw_i2c_driver); | ||
386 | } | ||
387 | module_exit(dw_i2c_exit_driver); | ||
388 | 378 | ||
389 | MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); | 379 | MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); |
390 | MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter"); | 380 | MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter"); |
diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c index 7eb19a5222f2..dae3ddfe7619 100644 --- a/drivers/i2c/busses/i2c-diolan-u2c.c +++ b/drivers/i2c/busses/i2c-diolan-u2c.c | |||
@@ -405,6 +405,7 @@ static int diolan_usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, | |||
405 | } | 405 | } |
406 | } | 406 | } |
407 | } | 407 | } |
408 | ret = num; | ||
408 | abort: | 409 | abort: |
409 | sret = diolan_i2c_stop(dev); | 410 | sret = diolan_i2c_stop(dev); |
410 | if (sret < 0 && ret >= 0) | 411 | if (sret < 0 && ret >= 0) |
@@ -517,6 +518,6 @@ static struct usb_driver diolan_u2c_driver = { | |||
517 | 518 | ||
518 | module_usb_driver(diolan_u2c_driver); | 519 | module_usb_driver(diolan_u2c_driver); |
519 | 520 | ||
520 | MODULE_AUTHOR("Guenter Roeck <guenter.roeck@ericsson.com>"); | 521 | MODULE_AUTHOR("Guenter Roeck <linux@roeck-us.net>"); |
521 | MODULE_DESCRIPTION(DRIVER_NAME " driver"); | 522 | MODULE_DESCRIPTION(DRIVER_NAME " driver"); |
522 | MODULE_LICENSE("GPL"); | 523 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c index 2f74ae872e1e..259f7697bf25 100644 --- a/drivers/i2c/busses/i2c-eg20t.c +++ b/drivers/i2c/busses/i2c-eg20t.c | |||
@@ -953,17 +953,7 @@ static struct pci_driver pch_pcidriver = { | |||
953 | .resume = pch_i2c_resume | 953 | .resume = pch_i2c_resume |
954 | }; | 954 | }; |
955 | 955 | ||
956 | static int __init pch_pci_init(void) | 956 | module_pci_driver(pch_pcidriver); |
957 | { | ||
958 | return pci_register_driver(&pch_pcidriver); | ||
959 | } | ||
960 | module_init(pch_pci_init); | ||
961 | |||
962 | static void __exit pch_pci_exit(void) | ||
963 | { | ||
964 | pci_unregister_driver(&pch_pcidriver); | ||
965 | } | ||
966 | module_exit(pch_pci_exit); | ||
967 | 957 | ||
968 | MODULE_DESCRIPTION("Intel EG20T PCH/LAPIS Semico ML7213/ML7223/ML7831 IOH I2C"); | 958 | MODULE_DESCRIPTION("Intel EG20T PCH/LAPIS Semico ML7213/ML7223/ML7831 IOH I2C"); |
969 | MODULE_LICENSE("GPL"); | 959 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c index c527de17db4f..c9f95e1666a8 100644 --- a/drivers/i2c/busses/i2c-hydra.c +++ b/drivers/i2c/busses/i2c-hydra.c | |||
@@ -156,23 +156,8 @@ static struct pci_driver hydra_driver = { | |||
156 | .remove = __devexit_p(hydra_remove), | 156 | .remove = __devexit_p(hydra_remove), |
157 | }; | 157 | }; |
158 | 158 | ||
159 | static int __init i2c_hydra_init(void) | 159 | module_pci_driver(hydra_driver); |
160 | { | ||
161 | return pci_register_driver(&hydra_driver); | ||
162 | } | ||
163 | |||
164 | |||
165 | static void __exit i2c_hydra_exit(void) | ||
166 | { | ||
167 | pci_unregister_driver(&hydra_driver); | ||
168 | } | ||
169 | |||
170 | |||
171 | 160 | ||
172 | MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>"); | 161 | MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>"); |
173 | MODULE_DESCRIPTION("i2c for Apple Hydra Mac I/O"); | 162 | MODULE_DESCRIPTION("i2c for Apple Hydra Mac I/O"); |
174 | MODULE_LICENSE("GPL"); | 163 | MODULE_LICENSE("GPL"); |
175 | |||
176 | module_init(i2c_hydra_init); | ||
177 | module_exit(i2c_hydra_exit); | ||
178 | |||
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index ae2945a5e007..898dcf9c7ade 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -60,10 +60,12 @@ | |||
60 | Block process call transaction no | 60 | Block process call transaction no |
61 | I2C block read transaction yes (doesn't use the block buffer) | 61 | I2C block read transaction yes (doesn't use the block buffer) |
62 | Slave mode no | 62 | Slave mode no |
63 | Interrupt processing yes | ||
63 | 64 | ||
64 | See the file Documentation/i2c/busses/i2c-i801 for details. | 65 | See the file Documentation/i2c/busses/i2c-i801 for details. |
65 | */ | 66 | */ |
66 | 67 | ||
68 | #include <linux/interrupt.h> | ||
67 | #include <linux/module.h> | 69 | #include <linux/module.h> |
68 | #include <linux/pci.h> | 70 | #include <linux/pci.h> |
69 | #include <linux/kernel.h> | 71 | #include <linux/kernel.h> |
@@ -76,6 +78,7 @@ | |||
76 | #include <linux/io.h> | 78 | #include <linux/io.h> |
77 | #include <linux/dmi.h> | 79 | #include <linux/dmi.h> |
78 | #include <linux/slab.h> | 80 | #include <linux/slab.h> |
81 | #include <linux/wait.h> | ||
79 | 82 | ||
80 | /* I801 SMBus address offsets */ | 83 | /* I801 SMBus address offsets */ |
81 | #define SMBHSTSTS(p) (0 + (p)->smba) | 84 | #define SMBHSTSTS(p) (0 + (p)->smba) |
@@ -91,8 +94,12 @@ | |||
91 | 94 | ||
92 | /* PCI Address Constants */ | 95 | /* PCI Address Constants */ |
93 | #define SMBBAR 4 | 96 | #define SMBBAR 4 |
97 | #define SMBPCISTS 0x006 | ||
94 | #define SMBHSTCFG 0x040 | 98 | #define SMBHSTCFG 0x040 |
95 | 99 | ||
100 | /* Host status bits for SMBPCISTS */ | ||
101 | #define SMBPCISTS_INTS 0x08 | ||
102 | |||
96 | /* Host configuration bits for SMBHSTCFG */ | 103 | /* Host configuration bits for SMBHSTCFG */ |
97 | #define SMBHSTCFG_HST_EN 1 | 104 | #define SMBHSTCFG_HST_EN 1 |
98 | #define SMBHSTCFG_SMB_SMI_EN 2 | 105 | #define SMBHSTCFG_SMB_SMI_EN 2 |
@@ -102,12 +109,8 @@ | |||
102 | #define SMBAUXCTL_CRC 1 | 109 | #define SMBAUXCTL_CRC 1 |
103 | #define SMBAUXCTL_E32B 2 | 110 | #define SMBAUXCTL_E32B 2 |
104 | 111 | ||
105 | /* kill bit for SMBHSTCNT */ | ||
106 | #define SMBHSTCNT_KILL 2 | ||
107 | |||
108 | /* Other settings */ | 112 | /* Other settings */ |
109 | #define MAX_RETRIES 400 | 113 | #define MAX_RETRIES 400 |
110 | #define ENABLE_INT9 0 /* set to 0x01 to enable - untested */ | ||
111 | 114 | ||
112 | /* I801 command constants */ | 115 | /* I801 command constants */ |
113 | #define I801_QUICK 0x00 | 116 | #define I801_QUICK 0x00 |
@@ -117,10 +120,13 @@ | |||
117 | #define I801_PROC_CALL 0x10 /* unimplemented */ | 120 | #define I801_PROC_CALL 0x10 /* unimplemented */ |
118 | #define I801_BLOCK_DATA 0x14 | 121 | #define I801_BLOCK_DATA 0x14 |
119 | #define I801_I2C_BLOCK_DATA 0x18 /* ICH5 and later */ | 122 | #define I801_I2C_BLOCK_DATA 0x18 /* ICH5 and later */ |
120 | #define I801_BLOCK_LAST 0x34 | 123 | |
121 | #define I801_I2C_BLOCK_LAST 0x38 /* ICH5 and later */ | 124 | /* I801 Host Control register bits */ |
122 | #define I801_START 0x40 | 125 | #define SMBHSTCNT_INTREN 0x01 |
123 | #define I801_PEC_EN 0x80 /* ICH3 and later */ | 126 | #define SMBHSTCNT_KILL 0x02 |
127 | #define SMBHSTCNT_LAST_BYTE 0x20 | ||
128 | #define SMBHSTCNT_START 0x40 | ||
129 | #define SMBHSTCNT_PEC_EN 0x80 /* ICH3 and later */ | ||
124 | 130 | ||
125 | /* I801 Hosts Status register bits */ | 131 | /* I801 Hosts Status register bits */ |
126 | #define SMBHSTSTS_BYTE_DONE 0x80 | 132 | #define SMBHSTSTS_BYTE_DONE 0x80 |
@@ -132,9 +138,11 @@ | |||
132 | #define SMBHSTSTS_INTR 0x02 | 138 | #define SMBHSTSTS_INTR 0x02 |
133 | #define SMBHSTSTS_HOST_BUSY 0x01 | 139 | #define SMBHSTSTS_HOST_BUSY 0x01 |
134 | 140 | ||
135 | #define STATUS_FLAGS (SMBHSTSTS_BYTE_DONE | SMBHSTSTS_FAILED | \ | 141 | #define STATUS_ERROR_FLAGS (SMBHSTSTS_FAILED | SMBHSTSTS_BUS_ERR | \ |
136 | SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \ | 142 | SMBHSTSTS_DEV_ERR) |
137 | SMBHSTSTS_INTR) | 143 | |
144 | #define STATUS_FLAGS (SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR | \ | ||
145 | STATUS_ERROR_FLAGS) | ||
138 | 146 | ||
139 | /* Older devices have their ID defined in <linux/pci_ids.h> */ | 147 | /* Older devices have their ID defined in <linux/pci_ids.h> */ |
140 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22 | 148 | #define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22 |
@@ -154,6 +162,17 @@ struct i801_priv { | |||
154 | unsigned char original_hstcfg; | 162 | unsigned char original_hstcfg; |
155 | struct pci_dev *pci_dev; | 163 | struct pci_dev *pci_dev; |
156 | unsigned int features; | 164 | unsigned int features; |
165 | |||
166 | /* isr processing */ | ||
167 | wait_queue_head_t waitq; | ||
168 | u8 status; | ||
169 | |||
170 | /* Command state used by isr for byte-by-byte block transactions */ | ||
171 | u8 cmd; | ||
172 | bool is_read; | ||
173 | int count; | ||
174 | int len; | ||
175 | u8 *data; | ||
157 | }; | 176 | }; |
158 | 177 | ||
159 | static struct pci_driver i801_driver; | 178 | static struct pci_driver i801_driver; |
@@ -162,6 +181,7 @@ static struct pci_driver i801_driver; | |||
162 | #define FEATURE_BLOCK_BUFFER (1 << 1) | 181 | #define FEATURE_BLOCK_BUFFER (1 << 1) |
163 | #define FEATURE_BLOCK_PROC (1 << 2) | 182 | #define FEATURE_BLOCK_PROC (1 << 2) |
164 | #define FEATURE_I2C_BLOCK_READ (1 << 3) | 183 | #define FEATURE_I2C_BLOCK_READ (1 << 3) |
184 | #define FEATURE_IRQ (1 << 4) | ||
165 | /* Not really a feature, but it's convenient to handle it as such */ | 185 | /* Not really a feature, but it's convenient to handle it as such */ |
166 | #define FEATURE_IDF (1 << 15) | 186 | #define FEATURE_IDF (1 << 15) |
167 | 187 | ||
@@ -170,6 +190,7 @@ static const char *i801_feature_names[] = { | |||
170 | "Block buffer", | 190 | "Block buffer", |
171 | "Block process call", | 191 | "Block process call", |
172 | "I2C block read", | 192 | "I2C block read", |
193 | "Interrupt", | ||
173 | }; | 194 | }; |
174 | 195 | ||
175 | static unsigned int disable_features; | 196 | static unsigned int disable_features; |
@@ -205,13 +226,22 @@ static int i801_check_pre(struct i801_priv *priv) | |||
205 | return 0; | 226 | return 0; |
206 | } | 227 | } |
207 | 228 | ||
208 | /* Convert the status register to an error code, and clear it. */ | 229 | /* |
209 | static int i801_check_post(struct i801_priv *priv, int status, int timeout) | 230 | * Convert the status register to an error code, and clear it. |
231 | * Note that status only contains the bits we want to clear, not the | ||
232 | * actual register value. | ||
233 | */ | ||
234 | static int i801_check_post(struct i801_priv *priv, int status) | ||
210 | { | 235 | { |
211 | int result = 0; | 236 | int result = 0; |
212 | 237 | ||
213 | /* If the SMBus is still busy, we give up */ | 238 | /* |
214 | if (timeout) { | 239 | * If the SMBus is still busy, we give up |
240 | * Note: This timeout condition only happens when using polling | ||
241 | * transactions. For interrupt operation, NAK/timeout is indicated by | ||
242 | * DEV_ERR. | ||
243 | */ | ||
244 | if (unlikely(status < 0)) { | ||
215 | dev_err(&priv->pci_dev->dev, "Transaction timeout\n"); | 245 | dev_err(&priv->pci_dev->dev, "Transaction timeout\n"); |
216 | /* try to stop the current command */ | 246 | /* try to stop the current command */ |
217 | dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n"); | 247 | dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n"); |
@@ -244,64 +274,76 @@ static int i801_check_post(struct i801_priv *priv, int status, int timeout) | |||
244 | dev_dbg(&priv->pci_dev->dev, "Lost arbitration\n"); | 274 | dev_dbg(&priv->pci_dev->dev, "Lost arbitration\n"); |
245 | } | 275 | } |
246 | 276 | ||
247 | if (result) { | 277 | /* Clear status flags except BYTE_DONE, to be cleared by caller */ |
248 | /* Clear error flags */ | 278 | outb_p(status, SMBHSTSTS(priv)); |
249 | outb_p(status & STATUS_FLAGS, SMBHSTSTS(priv)); | ||
250 | status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; | ||
251 | if (status) { | ||
252 | dev_warn(&priv->pci_dev->dev, "Failed clearing status " | ||
253 | "flags at end of transaction (%02x)\n", | ||
254 | status); | ||
255 | } | ||
256 | } | ||
257 | 279 | ||
258 | return result; | 280 | return result; |
259 | } | 281 | } |
260 | 282 | ||
261 | static int i801_transaction(struct i801_priv *priv, int xact) | 283 | /* Wait for BUSY being cleared and either INTR or an error flag being set */ |
284 | static int i801_wait_intr(struct i801_priv *priv) | ||
262 | { | 285 | { |
263 | int status; | ||
264 | int result; | ||
265 | int timeout = 0; | 286 | int timeout = 0; |
266 | 287 | int status; | |
267 | result = i801_check_pre(priv); | ||
268 | if (result < 0) | ||
269 | return result; | ||
270 | |||
271 | /* the current contents of SMBHSTCNT can be overwritten, since PEC, | ||
272 | * INTREN, SMBSCMD are passed in xact */ | ||
273 | outb_p(xact | I801_START, SMBHSTCNT(priv)); | ||
274 | 288 | ||
275 | /* We will always wait for a fraction of a second! */ | 289 | /* We will always wait for a fraction of a second! */ |
276 | do { | 290 | do { |
277 | usleep_range(250, 500); | 291 | usleep_range(250, 500); |
278 | status = inb_p(SMBHSTSTS(priv)); | 292 | status = inb_p(SMBHSTSTS(priv)); |
279 | } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_RETRIES)); | 293 | } while (((status & SMBHSTSTS_HOST_BUSY) || |
294 | !(status & (STATUS_ERROR_FLAGS | SMBHSTSTS_INTR))) && | ||
295 | (timeout++ < MAX_RETRIES)); | ||
280 | 296 | ||
281 | result = i801_check_post(priv, status, timeout > MAX_RETRIES); | 297 | if (timeout > MAX_RETRIES) { |
282 | if (result < 0) | 298 | dev_dbg(&priv->pci_dev->dev, "INTR Timeout!\n"); |
283 | return result; | 299 | return -ETIMEDOUT; |
284 | 300 | } | |
285 | outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); | 301 | return status & (STATUS_ERROR_FLAGS | SMBHSTSTS_INTR); |
286 | return 0; | ||
287 | } | 302 | } |
288 | 303 | ||
289 | /* wait for INTR bit as advised by Intel */ | 304 | /* Wait for either BYTE_DONE or an error flag being set */ |
290 | static void i801_wait_hwpec(struct i801_priv *priv) | 305 | static int i801_wait_byte_done(struct i801_priv *priv) |
291 | { | 306 | { |
292 | int timeout = 0; | 307 | int timeout = 0; |
293 | int status; | 308 | int status; |
294 | 309 | ||
310 | /* We will always wait for a fraction of a second! */ | ||
295 | do { | 311 | do { |
296 | usleep_range(250, 500); | 312 | usleep_range(250, 500); |
297 | status = inb_p(SMBHSTSTS(priv)); | 313 | status = inb_p(SMBHSTSTS(priv)); |
298 | } while ((!(status & SMBHSTSTS_INTR)) | 314 | } while (!(status & (STATUS_ERROR_FLAGS | SMBHSTSTS_BYTE_DONE)) && |
299 | && (timeout++ < MAX_RETRIES)); | 315 | (timeout++ < MAX_RETRIES)); |
300 | 316 | ||
301 | if (timeout > MAX_RETRIES) | 317 | if (timeout > MAX_RETRIES) { |
302 | dev_dbg(&priv->pci_dev->dev, "PEC Timeout!\n"); | 318 | dev_dbg(&priv->pci_dev->dev, "BYTE_DONE Timeout!\n"); |
319 | return -ETIMEDOUT; | ||
320 | } | ||
321 | return status & STATUS_ERROR_FLAGS; | ||
322 | } | ||
303 | 323 | ||
304 | outb_p(status, SMBHSTSTS(priv)); | 324 | static int i801_transaction(struct i801_priv *priv, int xact) |
325 | { | ||
326 | int status; | ||
327 | int result; | ||
328 | |||
329 | result = i801_check_pre(priv); | ||
330 | if (result < 0) | ||
331 | return result; | ||
332 | |||
333 | if (priv->features & FEATURE_IRQ) { | ||
334 | outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START, | ||
335 | SMBHSTCNT(priv)); | ||
336 | wait_event(priv->waitq, (status = priv->status)); | ||
337 | priv->status = 0; | ||
338 | return i801_check_post(priv, status); | ||
339 | } | ||
340 | |||
341 | /* the current contents of SMBHSTCNT can be overwritten, since PEC, | ||
342 | * SMBSCMD are passed in xact */ | ||
343 | outb_p(xact | SMBHSTCNT_START, SMBHSTCNT(priv)); | ||
344 | |||
345 | status = i801_wait_intr(priv); | ||
346 | return i801_check_post(priv, status); | ||
305 | } | 347 | } |
306 | 348 | ||
307 | static int i801_block_transaction_by_block(struct i801_priv *priv, | 349 | static int i801_block_transaction_by_block(struct i801_priv *priv, |
@@ -321,8 +363,8 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, | |||
321 | outb_p(data->block[i+1], SMBBLKDAT(priv)); | 363 | outb_p(data->block[i+1], SMBBLKDAT(priv)); |
322 | } | 364 | } |
323 | 365 | ||
324 | status = i801_transaction(priv, I801_BLOCK_DATA | ENABLE_INT9 | | 366 | status = i801_transaction(priv, I801_BLOCK_DATA | |
325 | I801_PEC_EN * hwpec); | 367 | (hwpec ? SMBHSTCNT_PEC_EN : 0)); |
326 | if (status) | 368 | if (status) |
327 | return status; | 369 | return status; |
328 | 370 | ||
@@ -338,6 +380,98 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, | |||
338 | return 0; | 380 | return 0; |
339 | } | 381 | } |
340 | 382 | ||
383 | static void i801_isr_byte_done(struct i801_priv *priv) | ||
384 | { | ||
385 | if (priv->is_read) { | ||
386 | /* For SMBus block reads, length is received with first byte */ | ||
387 | if (((priv->cmd & 0x1c) == I801_BLOCK_DATA) && | ||
388 | (priv->count == 0)) { | ||
389 | priv->len = inb_p(SMBHSTDAT0(priv)); | ||
390 | if (priv->len < 1 || priv->len > I2C_SMBUS_BLOCK_MAX) { | ||
391 | dev_err(&priv->pci_dev->dev, | ||
392 | "Illegal SMBus block read size %d\n", | ||
393 | priv->len); | ||
394 | /* FIXME: Recover */ | ||
395 | priv->len = I2C_SMBUS_BLOCK_MAX; | ||
396 | } else { | ||
397 | dev_dbg(&priv->pci_dev->dev, | ||
398 | "SMBus block read size is %d\n", | ||
399 | priv->len); | ||
400 | } | ||
401 | priv->data[-1] = priv->len; | ||
402 | } | ||
403 | |||
404 | /* Read next byte */ | ||
405 | if (priv->count < priv->len) | ||
406 | priv->data[priv->count++] = inb(SMBBLKDAT(priv)); | ||
407 | else | ||
408 | dev_dbg(&priv->pci_dev->dev, | ||
409 | "Discarding extra byte on block read\n"); | ||
410 | |||
411 | /* Set LAST_BYTE for last byte of read transaction */ | ||
412 | if (priv->count == priv->len - 1) | ||
413 | outb_p(priv->cmd | SMBHSTCNT_LAST_BYTE, | ||
414 | SMBHSTCNT(priv)); | ||
415 | } else if (priv->count < priv->len - 1) { | ||
416 | /* Write next byte, except for IRQ after last byte */ | ||
417 | outb_p(priv->data[++priv->count], SMBBLKDAT(priv)); | ||
418 | } | ||
419 | |||
420 | /* Clear BYTE_DONE to continue with next byte */ | ||
421 | outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); | ||
422 | } | ||
423 | |||
424 | /* | ||
425 | * There are two kinds of interrupts: | ||
426 | * | ||
427 | * 1) i801 signals transaction completion with one of these interrupts: | ||
428 | * INTR - Success | ||
429 | * DEV_ERR - Invalid command, NAK or communication timeout | ||
430 | * BUS_ERR - SMI# transaction collision | ||
431 | * FAILED - transaction was canceled due to a KILL request | ||
432 | * When any of these occur, update ->status and wake up the waitq. | ||
433 | * ->status must be cleared before kicking off the next transaction. | ||
434 | * | ||
435 | * 2) For byte-by-byte (I2C read/write) transactions, one BYTE_DONE interrupt | ||
436 | * occurs for each byte of a byte-by-byte to prepare the next byte. | ||
437 | */ | ||
438 | static irqreturn_t i801_isr(int irq, void *dev_id) | ||
439 | { | ||
440 | struct i801_priv *priv = dev_id; | ||
441 | u16 pcists; | ||
442 | u8 status; | ||
443 | |||
444 | /* Confirm this is our interrupt */ | ||
445 | pci_read_config_word(priv->pci_dev, SMBPCISTS, &pcists); | ||
446 | if (!(pcists & SMBPCISTS_INTS)) | ||
447 | return IRQ_NONE; | ||
448 | |||
449 | status = inb_p(SMBHSTSTS(priv)); | ||
450 | if (status != 0x42) | ||
451 | dev_dbg(&priv->pci_dev->dev, "irq: status = %02x\n", status); | ||
452 | |||
453 | if (status & SMBHSTSTS_BYTE_DONE) | ||
454 | i801_isr_byte_done(priv); | ||
455 | |||
456 | /* | ||
457 | * Clear irq sources and report transaction result. | ||
458 | * ->status must be cleared before the next transaction is started. | ||
459 | */ | ||
460 | status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS; | ||
461 | if (status) { | ||
462 | outb_p(status, SMBHSTSTS(priv)); | ||
463 | priv->status |= status; | ||
464 | wake_up(&priv->waitq); | ||
465 | } | ||
466 | |||
467 | return IRQ_HANDLED; | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | * For "byte-by-byte" block transactions: | ||
472 | * I2C write uses cmd=I801_BLOCK_DATA, I2C_EN=1 | ||
473 | * I2C read uses cmd=I801_I2C_BLOCK_DATA | ||
474 | */ | ||
341 | static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, | 475 | static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, |
342 | union i2c_smbus_data *data, | 476 | union i2c_smbus_data *data, |
343 | char read_write, int command, | 477 | char read_write, int command, |
@@ -347,7 +481,6 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, | |||
347 | int smbcmd; | 481 | int smbcmd; |
348 | int status; | 482 | int status; |
349 | int result; | 483 | int result; |
350 | int timeout; | ||
351 | 484 | ||
352 | result = i801_check_pre(priv); | 485 | result = i801_check_pre(priv); |
353 | if (result < 0) | 486 | if (result < 0) |
@@ -360,36 +493,39 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, | |||
360 | outb_p(data->block[1], SMBBLKDAT(priv)); | 493 | outb_p(data->block[1], SMBBLKDAT(priv)); |
361 | } | 494 | } |
362 | 495 | ||
496 | if (command == I2C_SMBUS_I2C_BLOCK_DATA && | ||
497 | read_write == I2C_SMBUS_READ) | ||
498 | smbcmd = I801_I2C_BLOCK_DATA; | ||
499 | else | ||
500 | smbcmd = I801_BLOCK_DATA; | ||
501 | |||
502 | if (priv->features & FEATURE_IRQ) { | ||
503 | priv->is_read = (read_write == I2C_SMBUS_READ); | ||
504 | if (len == 1 && priv->is_read) | ||
505 | smbcmd |= SMBHSTCNT_LAST_BYTE; | ||
506 | priv->cmd = smbcmd | SMBHSTCNT_INTREN; | ||
507 | priv->len = len; | ||
508 | priv->count = 0; | ||
509 | priv->data = &data->block[1]; | ||
510 | |||
511 | outb_p(priv->cmd | SMBHSTCNT_START, SMBHSTCNT(priv)); | ||
512 | wait_event(priv->waitq, (status = priv->status)); | ||
513 | priv->status = 0; | ||
514 | return i801_check_post(priv, status); | ||
515 | } | ||
516 | |||
363 | for (i = 1; i <= len; i++) { | 517 | for (i = 1; i <= len; i++) { |
364 | if (i == len && read_write == I2C_SMBUS_READ) { | 518 | if (i == len && read_write == I2C_SMBUS_READ) |
365 | if (command == I2C_SMBUS_I2C_BLOCK_DATA) | 519 | smbcmd |= SMBHSTCNT_LAST_BYTE; |
366 | smbcmd = I801_I2C_BLOCK_LAST; | 520 | outb_p(smbcmd, SMBHSTCNT(priv)); |
367 | else | ||
368 | smbcmd = I801_BLOCK_LAST; | ||
369 | } else { | ||
370 | if (command == I2C_SMBUS_I2C_BLOCK_DATA | ||
371 | && read_write == I2C_SMBUS_READ) | ||
372 | smbcmd = I801_I2C_BLOCK_DATA; | ||
373 | else | ||
374 | smbcmd = I801_BLOCK_DATA; | ||
375 | } | ||
376 | outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT(priv)); | ||
377 | 521 | ||
378 | if (i == 1) | 522 | if (i == 1) |
379 | outb_p(inb(SMBHSTCNT(priv)) | I801_START, | 523 | outb_p(inb(SMBHSTCNT(priv)) | SMBHSTCNT_START, |
380 | SMBHSTCNT(priv)); | 524 | SMBHSTCNT(priv)); |
381 | 525 | ||
382 | /* We will always wait for a fraction of a second! */ | 526 | status = i801_wait_byte_done(priv); |
383 | timeout = 0; | 527 | if (status) |
384 | do { | 528 | goto exit; |
385 | usleep_range(250, 500); | ||
386 | status = inb_p(SMBHSTSTS(priv)); | ||
387 | } while ((!(status & SMBHSTSTS_BYTE_DONE)) | ||
388 | && (timeout++ < MAX_RETRIES)); | ||
389 | |||
390 | result = i801_check_post(priv, status, timeout > MAX_RETRIES); | ||
391 | if (result < 0) | ||
392 | return result; | ||
393 | 529 | ||
394 | if (i == 1 && read_write == I2C_SMBUS_READ | 530 | if (i == 1 && read_write == I2C_SMBUS_READ |
395 | && command != I2C_SMBUS_I2C_BLOCK_DATA) { | 531 | && command != I2C_SMBUS_I2C_BLOCK_DATA) { |
@@ -416,10 +552,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, | |||
416 | outb_p(data->block[i+1], SMBBLKDAT(priv)); | 552 | outb_p(data->block[i+1], SMBBLKDAT(priv)); |
417 | 553 | ||
418 | /* signals SMBBLKDAT ready */ | 554 | /* signals SMBBLKDAT ready */ |
419 | outb_p(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR, SMBHSTSTS(priv)); | 555 | outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); |
420 | } | 556 | } |
421 | 557 | ||
422 | return 0; | 558 | status = i801_wait_intr(priv); |
559 | exit: | ||
560 | return i801_check_post(priv, status); | ||
423 | } | 561 | } |
424 | 562 | ||
425 | static int i801_set_block_buffer_mode(struct i801_priv *priv) | 563 | static int i801_set_block_buffer_mode(struct i801_priv *priv) |
@@ -474,9 +612,6 @@ static int i801_block_transaction(struct i801_priv *priv, | |||
474 | read_write, | 612 | read_write, |
475 | command, hwpec); | 613 | command, hwpec); |
476 | 614 | ||
477 | if (result == 0 && hwpec) | ||
478 | i801_wait_hwpec(priv); | ||
479 | |||
480 | if (command == I2C_SMBUS_I2C_BLOCK_DATA | 615 | if (command == I2C_SMBUS_I2C_BLOCK_DATA |
481 | && read_write == I2C_SMBUS_WRITE) { | 616 | && read_write == I2C_SMBUS_WRITE) { |
482 | /* restore saved configuration register value */ | 617 | /* restore saved configuration register value */ |
@@ -564,7 +699,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, | |||
564 | ret = i801_block_transaction(priv, data, read_write, size, | 699 | ret = i801_block_transaction(priv, data, read_write, size, |
565 | hwpec); | 700 | hwpec); |
566 | else | 701 | else |
567 | ret = i801_transaction(priv, xact | ENABLE_INT9); | 702 | ret = i801_transaction(priv, xact); |
568 | 703 | ||
569 | /* Some BIOSes don't like it when PEC is enabled at reboot or resume | 704 | /* Some BIOSes don't like it when PEC is enabled at reboot or resume |
570 | time, so we forcibly disable it after every transaction. Turn off | 705 | time, so we forcibly disable it after every transaction. Turn off |
@@ -799,6 +934,16 @@ static int __devinit i801_probe(struct pci_dev *dev, | |||
799 | break; | 934 | break; |
800 | } | 935 | } |
801 | 936 | ||
937 | /* IRQ processing tested on CougarPoint PCH, ICH5, ICH7-M and ICH10 */ | ||
938 | if (dev->device == PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS || | ||
939 | dev->device == PCI_DEVICE_ID_INTEL_82801EB_3 || | ||
940 | dev->device == PCI_DEVICE_ID_INTEL_ICH7_17 || | ||
941 | dev->device == PCI_DEVICE_ID_INTEL_ICH8_5 || | ||
942 | dev->device == PCI_DEVICE_ID_INTEL_ICH9_6 || | ||
943 | dev->device == PCI_DEVICE_ID_INTEL_ICH10_4 || | ||
944 | dev->device == PCI_DEVICE_ID_INTEL_ICH10_5) | ||
945 | priv->features |= FEATURE_IRQ; | ||
946 | |||
802 | /* Disable features on user request */ | 947 | /* Disable features on user request */ |
803 | for (i = 0; i < ARRAY_SIZE(i801_feature_names); i++) { | 948 | for (i = 0; i < ARRAY_SIZE(i801_feature_names); i++) { |
804 | if (priv->features & disable_features & (1 << i)) | 949 | if (priv->features & disable_features & (1 << i)) |
@@ -846,16 +991,30 @@ static int __devinit i801_probe(struct pci_dev *dev, | |||
846 | } | 991 | } |
847 | pci_write_config_byte(priv->pci_dev, SMBHSTCFG, temp); | 992 | pci_write_config_byte(priv->pci_dev, SMBHSTCFG, temp); |
848 | 993 | ||
849 | if (temp & SMBHSTCFG_SMB_SMI_EN) | 994 | if (temp & SMBHSTCFG_SMB_SMI_EN) { |
850 | dev_dbg(&dev->dev, "SMBus using interrupt SMI#\n"); | 995 | dev_dbg(&dev->dev, "SMBus using interrupt SMI#\n"); |
851 | else | 996 | /* Disable SMBus interrupt feature if SMBus using SMI# */ |
852 | dev_dbg(&dev->dev, "SMBus using PCI Interrupt\n"); | 997 | priv->features &= ~FEATURE_IRQ; |
998 | } | ||
853 | 999 | ||
854 | /* Clear special mode bits */ | 1000 | /* Clear special mode bits */ |
855 | if (priv->features & (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER)) | 1001 | if (priv->features & (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER)) |
856 | outb_p(inb_p(SMBAUXCTL(priv)) & | 1002 | outb_p(inb_p(SMBAUXCTL(priv)) & |
857 | ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); | 1003 | ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); |
858 | 1004 | ||
1005 | if (priv->features & FEATURE_IRQ) { | ||
1006 | init_waitqueue_head(&priv->waitq); | ||
1007 | |||
1008 | err = request_irq(dev->irq, i801_isr, IRQF_SHARED, | ||
1009 | i801_driver.name, priv); | ||
1010 | if (err) { | ||
1011 | dev_err(&dev->dev, "Failed to allocate irq %d: %d\n", | ||
1012 | dev->irq, err); | ||
1013 | goto exit_release; | ||
1014 | } | ||
1015 | dev_info(&dev->dev, "SMBus using PCI Interrupt\n"); | ||
1016 | } | ||
1017 | |||
859 | /* set up the sysfs linkage to our parent device */ | 1018 | /* set up the sysfs linkage to our parent device */ |
860 | priv->adapter.dev.parent = &dev->dev; | 1019 | priv->adapter.dev.parent = &dev->dev; |
861 | 1020 | ||
@@ -867,14 +1026,18 @@ static int __devinit i801_probe(struct pci_dev *dev, | |||
867 | err = i2c_add_adapter(&priv->adapter); | 1026 | err = i2c_add_adapter(&priv->adapter); |
868 | if (err) { | 1027 | if (err) { |
869 | dev_err(&dev->dev, "Failed to add SMBus adapter\n"); | 1028 | dev_err(&dev->dev, "Failed to add SMBus adapter\n"); |
870 | goto exit_release; | 1029 | goto exit_free_irq; |
871 | } | 1030 | } |
872 | 1031 | ||
873 | i801_probe_optional_slaves(priv); | 1032 | i801_probe_optional_slaves(priv); |
874 | 1033 | ||
875 | pci_set_drvdata(dev, priv); | 1034 | pci_set_drvdata(dev, priv); |
1035 | |||
876 | return 0; | 1036 | return 0; |
877 | 1037 | ||
1038 | exit_free_irq: | ||
1039 | if (priv->features & FEATURE_IRQ) | ||
1040 | free_irq(dev->irq, priv); | ||
878 | exit_release: | 1041 | exit_release: |
879 | pci_release_region(dev, SMBBAR); | 1042 | pci_release_region(dev, SMBBAR); |
880 | exit: | 1043 | exit: |
@@ -888,7 +1051,11 @@ static void __devexit i801_remove(struct pci_dev *dev) | |||
888 | 1051 | ||
889 | i2c_del_adapter(&priv->adapter); | 1052 | i2c_del_adapter(&priv->adapter); |
890 | pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); | 1053 | pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); |
1054 | |||
1055 | if (priv->features & FEATURE_IRQ) | ||
1056 | free_irq(dev->irq, priv); | ||
891 | pci_release_region(dev, SMBBAR); | 1057 | pci_release_region(dev, SMBBAR); |
1058 | |||
892 | pci_set_drvdata(dev, NULL); | 1059 | pci_set_drvdata(dev, NULL); |
893 | kfree(priv); | 1060 | kfree(priv); |
894 | /* | 1061 | /* |
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 8d6b504d65c4..0722f869465c 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include <linux/of_i2c.h> | 53 | #include <linux/of_i2c.h> |
54 | #include <linux/pinctrl/consumer.h> | 54 | #include <linux/pinctrl/consumer.h> |
55 | 55 | ||
56 | #include <mach/irqs.h> | ||
57 | #include <mach/hardware.h> | 56 | #include <mach/hardware.h> |
58 | #include <mach/i2c.h> | 57 | #include <mach/i2c.h> |
59 | 58 | ||
@@ -118,10 +117,8 @@ static u16 __initdata i2c_clk_div[50][2] = { | |||
118 | 117 | ||
119 | struct imx_i2c_struct { | 118 | struct imx_i2c_struct { |
120 | struct i2c_adapter adapter; | 119 | struct i2c_adapter adapter; |
121 | struct resource *res; | ||
122 | struct clk *clk; | 120 | struct clk *clk; |
123 | void __iomem *base; | 121 | void __iomem *base; |
124 | int irq; | ||
125 | wait_queue_head_t queue; | 122 | wait_queue_head_t queue; |
126 | unsigned long i2csr; | 123 | unsigned long i2csr; |
127 | unsigned int disable_delay; | 124 | unsigned int disable_delay; |
@@ -473,9 +470,8 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
473 | struct imxi2c_platform_data *pdata = pdev->dev.platform_data; | 470 | struct imxi2c_platform_data *pdata = pdev->dev.platform_data; |
474 | struct pinctrl *pinctrl; | 471 | struct pinctrl *pinctrl; |
475 | void __iomem *base; | 472 | void __iomem *base; |
476 | resource_size_t res_size; | 473 | int irq, ret; |
477 | int irq, bitrate; | 474 | u32 bitrate; |
478 | int ret; | ||
479 | 475 | ||
480 | dev_dbg(&pdev->dev, "<%s>\n", __func__); | 476 | dev_dbg(&pdev->dev, "<%s>\n", __func__); |
481 | 477 | ||
@@ -490,25 +486,15 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
490 | return -ENOENT; | 486 | return -ENOENT; |
491 | } | 487 | } |
492 | 488 | ||
493 | res_size = resource_size(res); | 489 | base = devm_request_and_ioremap(&pdev->dev, res); |
494 | 490 | if (!base) | |
495 | if (!request_mem_region(res->start, res_size, DRIVER_NAME)) { | ||
496 | dev_err(&pdev->dev, "request_mem_region failed\n"); | ||
497 | return -EBUSY; | 491 | return -EBUSY; |
498 | } | ||
499 | |||
500 | base = ioremap(res->start, res_size); | ||
501 | if (!base) { | ||
502 | dev_err(&pdev->dev, "ioremap failed\n"); | ||
503 | ret = -EIO; | ||
504 | goto fail1; | ||
505 | } | ||
506 | 492 | ||
507 | i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL); | 493 | i2c_imx = devm_kzalloc(&pdev->dev, sizeof(struct imx_i2c_struct), |
494 | GFP_KERNEL); | ||
508 | if (!i2c_imx) { | 495 | if (!i2c_imx) { |
509 | dev_err(&pdev->dev, "can't allocate interface\n"); | 496 | dev_err(&pdev->dev, "can't allocate interface\n"); |
510 | ret = -ENOMEM; | 497 | return -ENOMEM; |
511 | goto fail2; | ||
512 | } | 498 | } |
513 | 499 | ||
514 | /* Setup i2c_imx driver structure */ | 500 | /* Setup i2c_imx driver structure */ |
@@ -518,29 +504,27 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
518 | i2c_imx->adapter.dev.parent = &pdev->dev; | 504 | i2c_imx->adapter.dev.parent = &pdev->dev; |
519 | i2c_imx->adapter.nr = pdev->id; | 505 | i2c_imx->adapter.nr = pdev->id; |
520 | i2c_imx->adapter.dev.of_node = pdev->dev.of_node; | 506 | i2c_imx->adapter.dev.of_node = pdev->dev.of_node; |
521 | i2c_imx->irq = irq; | ||
522 | i2c_imx->base = base; | 507 | i2c_imx->base = base; |
523 | i2c_imx->res = res; | ||
524 | 508 | ||
525 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); | 509 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); |
526 | if (IS_ERR(pinctrl)) { | 510 | if (IS_ERR(pinctrl)) { |
527 | ret = PTR_ERR(pinctrl); | 511 | dev_err(&pdev->dev, "can't get/select pinctrl\n"); |
528 | goto fail3; | 512 | return PTR_ERR(pinctrl); |
529 | } | 513 | } |
530 | 514 | ||
531 | /* Get I2C clock */ | 515 | /* Get I2C clock */ |
532 | i2c_imx->clk = clk_get(&pdev->dev, "i2c_clk"); | 516 | i2c_imx->clk = devm_clk_get(&pdev->dev, NULL); |
533 | if (IS_ERR(i2c_imx->clk)) { | 517 | if (IS_ERR(i2c_imx->clk)) { |
534 | ret = PTR_ERR(i2c_imx->clk); | ||
535 | dev_err(&pdev->dev, "can't get I2C clock\n"); | 518 | dev_err(&pdev->dev, "can't get I2C clock\n"); |
536 | goto fail3; | 519 | return PTR_ERR(i2c_imx->clk); |
537 | } | 520 | } |
538 | 521 | ||
539 | /* Request IRQ */ | 522 | /* Request IRQ */ |
540 | ret = request_irq(i2c_imx->irq, i2c_imx_isr, 0, pdev->name, i2c_imx); | 523 | ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, 0, |
524 | pdev->name, i2c_imx); | ||
541 | if (ret) { | 525 | if (ret) { |
542 | dev_err(&pdev->dev, "can't claim irq %d\n", i2c_imx->irq); | 526 | dev_err(&pdev->dev, "can't claim irq %d\n", irq); |
543 | goto fail4; | 527 | return ret; |
544 | } | 528 | } |
545 | 529 | ||
546 | /* Init queue */ | 530 | /* Init queue */ |
@@ -565,7 +549,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
565 | ret = i2c_add_numbered_adapter(&i2c_imx->adapter); | 549 | ret = i2c_add_numbered_adapter(&i2c_imx->adapter); |
566 | if (ret < 0) { | 550 | if (ret < 0) { |
567 | dev_err(&pdev->dev, "registration failed\n"); | 551 | dev_err(&pdev->dev, "registration failed\n"); |
568 | goto fail5; | 552 | return ret; |
569 | } | 553 | } |
570 | 554 | ||
571 | of_i2c_register_devices(&i2c_imx->adapter); | 555 | of_i2c_register_devices(&i2c_imx->adapter); |
@@ -573,28 +557,16 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
573 | /* Set up platform driver data */ | 557 | /* Set up platform driver data */ |
574 | platform_set_drvdata(pdev, i2c_imx); | 558 | platform_set_drvdata(pdev, i2c_imx); |
575 | 559 | ||
576 | dev_dbg(&i2c_imx->adapter.dev, "claimed irq %d\n", i2c_imx->irq); | 560 | dev_dbg(&i2c_imx->adapter.dev, "claimed irq %d\n", irq); |
577 | dev_dbg(&i2c_imx->adapter.dev, "device resources from 0x%x to 0x%x\n", | 561 | dev_dbg(&i2c_imx->adapter.dev, "device resources from 0x%x to 0x%x\n", |
578 | i2c_imx->res->start, i2c_imx->res->end); | 562 | res->start, res->end); |
579 | dev_dbg(&i2c_imx->adapter.dev, "allocated %d bytes at 0x%x \n", | 563 | dev_dbg(&i2c_imx->adapter.dev, "allocated %d bytes at 0x%x\n", |
580 | res_size, i2c_imx->res->start); | 564 | resource_size(res), res->start); |
581 | dev_dbg(&i2c_imx->adapter.dev, "adapter name: \"%s\"\n", | 565 | dev_dbg(&i2c_imx->adapter.dev, "adapter name: \"%s\"\n", |
582 | i2c_imx->adapter.name); | 566 | i2c_imx->adapter.name); |
583 | dev_dbg(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n"); | 567 | dev_dbg(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n"); |
584 | 568 | ||
585 | return 0; /* Return OK */ | 569 | return 0; /* Return OK */ |
586 | |||
587 | fail5: | ||
588 | free_irq(i2c_imx->irq, i2c_imx); | ||
589 | fail4: | ||
590 | clk_put(i2c_imx->clk); | ||
591 | fail3: | ||
592 | kfree(i2c_imx); | ||
593 | fail2: | ||
594 | iounmap(base); | ||
595 | fail1: | ||
596 | release_mem_region(res->start, resource_size(res)); | ||
597 | return ret; /* Return error number */ | ||
598 | } | 570 | } |
599 | 571 | ||
600 | static int __exit i2c_imx_remove(struct platform_device *pdev) | 572 | static int __exit i2c_imx_remove(struct platform_device *pdev) |
@@ -606,20 +578,12 @@ static int __exit i2c_imx_remove(struct platform_device *pdev) | |||
606 | i2c_del_adapter(&i2c_imx->adapter); | 578 | i2c_del_adapter(&i2c_imx->adapter); |
607 | platform_set_drvdata(pdev, NULL); | 579 | platform_set_drvdata(pdev, NULL); |
608 | 580 | ||
609 | /* free interrupt */ | ||
610 | free_irq(i2c_imx->irq, i2c_imx); | ||
611 | |||
612 | /* setup chip registers to defaults */ | 581 | /* setup chip registers to defaults */ |
613 | writeb(0, i2c_imx->base + IMX_I2C_IADR); | 582 | writeb(0, i2c_imx->base + IMX_I2C_IADR); |
614 | writeb(0, i2c_imx->base + IMX_I2C_IFDR); | 583 | writeb(0, i2c_imx->base + IMX_I2C_IFDR); |
615 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); | 584 | writeb(0, i2c_imx->base + IMX_I2C_I2CR); |
616 | writeb(0, i2c_imx->base + IMX_I2C_I2SR); | 585 | writeb(0, i2c_imx->base + IMX_I2C_I2SR); |
617 | 586 | ||
618 | clk_put(i2c_imx->clk); | ||
619 | |||
620 | iounmap(i2c_imx->base); | ||
621 | release_mem_region(i2c_imx->res->start, resource_size(i2c_imx->res)); | ||
622 | kfree(i2c_imx); | ||
623 | return 0; | 587 | return 0; |
624 | } | 588 | } |
625 | 589 | ||
diff --git a/drivers/i2c/busses/i2c-intel-mid.c b/drivers/i2c/busses/i2c-intel-mid.c index 365bad5b890b..7c28f10f95ca 100644 --- a/drivers/i2c/busses/i2c-intel-mid.c +++ b/drivers/i2c/busses/i2c-intel-mid.c | |||
@@ -1116,18 +1116,7 @@ static struct pci_driver intel_mid_i2c_driver = { | |||
1116 | .remove = __devexit_p(intel_mid_i2c_remove), | 1116 | .remove = __devexit_p(intel_mid_i2c_remove), |
1117 | }; | 1117 | }; |
1118 | 1118 | ||
1119 | static int __init intel_mid_i2c_init(void) | 1119 | module_pci_driver(intel_mid_i2c_driver); |
1120 | { | ||
1121 | return pci_register_driver(&intel_mid_i2c_driver); | ||
1122 | } | ||
1123 | |||
1124 | static void __exit intel_mid_i2c_exit(void) | ||
1125 | { | ||
1126 | pci_unregister_driver(&intel_mid_i2c_driver); | ||
1127 | } | ||
1128 | |||
1129 | module_init(intel_mid_i2c_init); | ||
1130 | module_exit(intel_mid_i2c_exit); | ||
1131 | 1120 | ||
1132 | MODULE_AUTHOR("Ba Zheng <zheng.ba@intel.com>"); | 1121 | MODULE_AUTHOR("Ba Zheng <zheng.ba@intel.com>"); |
1133 | MODULE_DESCRIPTION("I2C driver for Moorestown Platform"); | 1122 | MODULE_DESCRIPTION("I2C driver for Moorestown Platform"); |
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 4f44a33017b0..2e9d56719e99 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -18,6 +18,11 @@ | |||
18 | #include <linux/mv643xx_i2c.h> | 18 | #include <linux/mv643xx_i2c.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/of.h> | ||
22 | #include <linux/of_irq.h> | ||
23 | #include <linux/of_i2c.h> | ||
24 | #include <linux/clk.h> | ||
25 | #include <linux/err.h> | ||
21 | 26 | ||
22 | /* Register defines */ | 27 | /* Register defines */ |
23 | #define MV64XXX_I2C_REG_SLAVE_ADDR 0x00 | 28 | #define MV64XXX_I2C_REG_SLAVE_ADDR 0x00 |
@@ -98,6 +103,9 @@ struct mv64xxx_i2c_data { | |||
98 | int rc; | 103 | int rc; |
99 | u32 freq_m; | 104 | u32 freq_m; |
100 | u32 freq_n; | 105 | u32 freq_n; |
106 | #if defined(CONFIG_HAVE_CLK) | ||
107 | struct clk *clk; | ||
108 | #endif | ||
101 | wait_queue_head_t waitq; | 109 | wait_queue_head_t waitq; |
102 | spinlock_t lock; | 110 | spinlock_t lock; |
103 | struct i2c_msg *msg; | 111 | struct i2c_msg *msg; |
@@ -521,6 +529,82 @@ mv64xxx_i2c_unmap_regs(struct mv64xxx_i2c_data *drv_data) | |||
521 | drv_data->reg_base_p = 0; | 529 | drv_data->reg_base_p = 0; |
522 | } | 530 | } |
523 | 531 | ||
532 | #ifdef CONFIG_OF | ||
533 | static int __devinit | ||
534 | mv64xxx_calc_freq(const int tclk, const int n, const int m) | ||
535 | { | ||
536 | return tclk / (10 * (m + 1) * (2 << n)); | ||
537 | } | ||
538 | |||
539 | static bool __devinit | ||
540 | mv64xxx_find_baud_factors(const u32 req_freq, const u32 tclk, u32 *best_n, | ||
541 | u32 *best_m) | ||
542 | { | ||
543 | int freq, delta, best_delta = INT_MAX; | ||
544 | int m, n; | ||
545 | |||
546 | for (n = 0; n <= 7; n++) | ||
547 | for (m = 0; m <= 15; m++) { | ||
548 | freq = mv64xxx_calc_freq(tclk, n, m); | ||
549 | delta = req_freq - freq; | ||
550 | if (delta >= 0 && delta < best_delta) { | ||
551 | *best_m = m; | ||
552 | *best_n = n; | ||
553 | best_delta = delta; | ||
554 | } | ||
555 | if (best_delta == 0) | ||
556 | return true; | ||
557 | } | ||
558 | if (best_delta == INT_MAX) | ||
559 | return false; | ||
560 | return true; | ||
561 | } | ||
562 | |||
563 | static int __devinit | ||
564 | mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, | ||
565 | struct device_node *np) | ||
566 | { | ||
567 | u32 bus_freq, tclk; | ||
568 | int rc = 0; | ||
569 | |||
570 | /* CLK is mandatory when using DT to describe the i2c bus. We | ||
571 | * need to know tclk in order to calculate bus clock | ||
572 | * factors. | ||
573 | */ | ||
574 | #if !defined(CONFIG_HAVE_CLK) | ||
575 | /* Have OF but no CLK */ | ||
576 | return -ENODEV; | ||
577 | #else | ||
578 | if (IS_ERR(drv_data->clk)) { | ||
579 | rc = -ENODEV; | ||
580 | goto out; | ||
581 | } | ||
582 | tclk = clk_get_rate(drv_data->clk); | ||
583 | of_property_read_u32(np, "clock-frequency", &bus_freq); | ||
584 | if (!mv64xxx_find_baud_factors(bus_freq, tclk, | ||
585 | &drv_data->freq_n, &drv_data->freq_m)) { | ||
586 | rc = -EINVAL; | ||
587 | goto out; | ||
588 | } | ||
589 | drv_data->irq = irq_of_parse_and_map(np, 0); | ||
590 | |||
591 | /* Its not yet defined how timeouts will be specified in device tree. | ||
592 | * So hard code the value to 1 second. | ||
593 | */ | ||
594 | drv_data->adapter.timeout = HZ; | ||
595 | out: | ||
596 | return rc; | ||
597 | #endif | ||
598 | } | ||
599 | #else /* CONFIG_OF */ | ||
600 | static int __devinit | ||
601 | mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, | ||
602 | struct device_node *np) | ||
603 | { | ||
604 | return -ENODEV; | ||
605 | } | ||
606 | #endif /* CONFIG_OF */ | ||
607 | |||
524 | static int __devinit | 608 | static int __devinit |
525 | mv64xxx_i2c_probe(struct platform_device *pd) | 609 | mv64xxx_i2c_probe(struct platform_device *pd) |
526 | { | 610 | { |
@@ -528,7 +612,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
528 | struct mv64xxx_i2c_pdata *pdata = pd->dev.platform_data; | 612 | struct mv64xxx_i2c_pdata *pdata = pd->dev.platform_data; |
529 | int rc; | 613 | int rc; |
530 | 614 | ||
531 | if ((pd->id != 0) || !pdata) | 615 | if ((!pdata && !pd->dev.of_node)) |
532 | return -ENODEV; | 616 | return -ENODEV; |
533 | 617 | ||
534 | drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); | 618 | drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); |
@@ -546,19 +630,35 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
546 | init_waitqueue_head(&drv_data->waitq); | 630 | init_waitqueue_head(&drv_data->waitq); |
547 | spin_lock_init(&drv_data->lock); | 631 | spin_lock_init(&drv_data->lock); |
548 | 632 | ||
549 | drv_data->freq_m = pdata->freq_m; | 633 | #if defined(CONFIG_HAVE_CLK) |
550 | drv_data->freq_n = pdata->freq_n; | 634 | /* Not all platforms have a clk */ |
551 | drv_data->irq = platform_get_irq(pd, 0); | 635 | drv_data->clk = clk_get(&pd->dev, NULL); |
636 | if (!IS_ERR(drv_data->clk)) { | ||
637 | clk_prepare(drv_data->clk); | ||
638 | clk_enable(drv_data->clk); | ||
639 | } | ||
640 | #endif | ||
641 | if (pdata) { | ||
642 | drv_data->freq_m = pdata->freq_m; | ||
643 | drv_data->freq_n = pdata->freq_n; | ||
644 | drv_data->irq = platform_get_irq(pd, 0); | ||
645 | drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout); | ||
646 | } else if (pd->dev.of_node) { | ||
647 | rc = mv64xxx_of_config(drv_data, pd->dev.of_node); | ||
648 | if (rc) | ||
649 | goto exit_unmap_regs; | ||
650 | } | ||
552 | if (drv_data->irq < 0) { | 651 | if (drv_data->irq < 0) { |
553 | rc = -ENXIO; | 652 | rc = -ENXIO; |
554 | goto exit_unmap_regs; | 653 | goto exit_unmap_regs; |
555 | } | 654 | } |
655 | |||
556 | drv_data->adapter.dev.parent = &pd->dev; | 656 | drv_data->adapter.dev.parent = &pd->dev; |
557 | drv_data->adapter.algo = &mv64xxx_i2c_algo; | 657 | drv_data->adapter.algo = &mv64xxx_i2c_algo; |
558 | drv_data->adapter.owner = THIS_MODULE; | 658 | drv_data->adapter.owner = THIS_MODULE; |
559 | drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | 659 | drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
560 | drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout); | ||
561 | drv_data->adapter.nr = pd->id; | 660 | drv_data->adapter.nr = pd->id; |
661 | drv_data->adapter.dev.of_node = pd->dev.of_node; | ||
562 | platform_set_drvdata(pd, drv_data); | 662 | platform_set_drvdata(pd, drv_data); |
563 | i2c_set_adapdata(&drv_data->adapter, drv_data); | 663 | i2c_set_adapdata(&drv_data->adapter, drv_data); |
564 | 664 | ||
@@ -577,11 +677,20 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
577 | goto exit_free_irq; | 677 | goto exit_free_irq; |
578 | } | 678 | } |
579 | 679 | ||
680 | of_i2c_register_devices(&drv_data->adapter); | ||
681 | |||
580 | return 0; | 682 | return 0; |
581 | 683 | ||
582 | exit_free_irq: | 684 | exit_free_irq: |
583 | free_irq(drv_data->irq, drv_data); | 685 | free_irq(drv_data->irq, drv_data); |
584 | exit_unmap_regs: | 686 | exit_unmap_regs: |
687 | #if defined(CONFIG_HAVE_CLK) | ||
688 | /* Not all platforms have a clk */ | ||
689 | if (!IS_ERR(drv_data->clk)) { | ||
690 | clk_disable(drv_data->clk); | ||
691 | clk_unprepare(drv_data->clk); | ||
692 | } | ||
693 | #endif | ||
585 | mv64xxx_i2c_unmap_regs(drv_data); | 694 | mv64xxx_i2c_unmap_regs(drv_data); |
586 | exit_kfree: | 695 | exit_kfree: |
587 | kfree(drv_data); | 696 | kfree(drv_data); |
@@ -597,17 +706,31 @@ mv64xxx_i2c_remove(struct platform_device *dev) | |||
597 | rc = i2c_del_adapter(&drv_data->adapter); | 706 | rc = i2c_del_adapter(&drv_data->adapter); |
598 | free_irq(drv_data->irq, drv_data); | 707 | free_irq(drv_data->irq, drv_data); |
599 | mv64xxx_i2c_unmap_regs(drv_data); | 708 | mv64xxx_i2c_unmap_regs(drv_data); |
709 | #if defined(CONFIG_HAVE_CLK) | ||
710 | /* Not all platforms have a clk */ | ||
711 | if (!IS_ERR(drv_data->clk)) { | ||
712 | clk_disable(drv_data->clk); | ||
713 | clk_unprepare(drv_data->clk); | ||
714 | } | ||
715 | #endif | ||
600 | kfree(drv_data); | 716 | kfree(drv_data); |
601 | 717 | ||
602 | return rc; | 718 | return rc; |
603 | } | 719 | } |
604 | 720 | ||
721 | static const struct of_device_id mv64xxx_i2c_of_match_table[] __devinitdata = { | ||
722 | { .compatible = "marvell,mv64xxx-i2c", }, | ||
723 | {} | ||
724 | }; | ||
725 | MODULE_DEVICE_TABLE(of, mv64xxx_i2c_of_match_table); | ||
726 | |||
605 | static struct platform_driver mv64xxx_i2c_driver = { | 727 | static struct platform_driver mv64xxx_i2c_driver = { |
606 | .probe = mv64xxx_i2c_probe, | 728 | .probe = mv64xxx_i2c_probe, |
607 | .remove = __devexit_p(mv64xxx_i2c_remove), | 729 | .remove = __devexit_p(mv64xxx_i2c_remove), |
608 | .driver = { | 730 | .driver = { |
609 | .owner = THIS_MODULE, | 731 | .owner = THIS_MODULE, |
610 | .name = MV64XXX_I2C_CTLR_NAME, | 732 | .name = MV64XXX_I2C_CTLR_NAME, |
733 | .of_match_table = of_match_ptr(mv64xxx_i2c_of_match_table), | ||
611 | }, | 734 | }, |
612 | }; | 735 | }; |
613 | 736 | ||
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c index 04eb441b6ce1..088c5c1ed17d 100644 --- a/drivers/i2c/busses/i2c-mxs.c +++ b/drivers/i2c/busses/i2c-mxs.c | |||
@@ -46,6 +46,10 @@ | |||
46 | #define MXS_I2C_CTRL0_DIRECTION 0x00010000 | 46 | #define MXS_I2C_CTRL0_DIRECTION 0x00010000 |
47 | #define MXS_I2C_CTRL0_XFER_COUNT(v) ((v) & 0x0000FFFF) | 47 | #define MXS_I2C_CTRL0_XFER_COUNT(v) ((v) & 0x0000FFFF) |
48 | 48 | ||
49 | #define MXS_I2C_TIMING0 (0x10) | ||
50 | #define MXS_I2C_TIMING1 (0x20) | ||
51 | #define MXS_I2C_TIMING2 (0x30) | ||
52 | |||
49 | #define MXS_I2C_CTRL1 (0x40) | 53 | #define MXS_I2C_CTRL1 (0x40) |
50 | #define MXS_I2C_CTRL1_SET (0x44) | 54 | #define MXS_I2C_CTRL1_SET (0x44) |
51 | #define MXS_I2C_CTRL1_CLR (0x48) | 55 | #define MXS_I2C_CTRL1_CLR (0x48) |
@@ -97,6 +101,35 @@ | |||
97 | #define MXS_CMD_I2C_READ (MXS_I2C_CTRL0_SEND_NAK_ON_LAST | \ | 101 | #define MXS_CMD_I2C_READ (MXS_I2C_CTRL0_SEND_NAK_ON_LAST | \ |
98 | MXS_I2C_CTRL0_MASTER_MODE) | 102 | MXS_I2C_CTRL0_MASTER_MODE) |
99 | 103 | ||
104 | struct mxs_i2c_speed_config { | ||
105 | uint32_t timing0; | ||
106 | uint32_t timing1; | ||
107 | uint32_t timing2; | ||
108 | }; | ||
109 | |||
110 | /* | ||
111 | * Timing values for the default 24MHz clock supplied into the i2c block. | ||
112 | * | ||
113 | * The bus can operate at 95kHz or at 400kHz with the following timing | ||
114 | * register configurations. The 100kHz mode isn't present because it's | ||
115 | * values are not stated in the i.MX233/i.MX28 datasheet. The 95kHz mode | ||
116 | * shall be close enough replacement. Therefore when the bus is configured | ||
117 | * for 100kHz operation, 95kHz timing settings are actually loaded. | ||
118 | * | ||
119 | * For details, see i.MX233 [25.4.2 - 25.4.4] and i.MX28 [27.5.2 - 27.5.4]. | ||
120 | */ | ||
121 | static const struct mxs_i2c_speed_config mxs_i2c_95kHz_config = { | ||
122 | .timing0 = 0x00780030, | ||
123 | .timing1 = 0x00800030, | ||
124 | .timing2 = 0x00300030, | ||
125 | }; | ||
126 | |||
127 | static const struct mxs_i2c_speed_config mxs_i2c_400kHz_config = { | ||
128 | .timing0 = 0x000f0007, | ||
129 | .timing1 = 0x001f000f, | ||
130 | .timing2 = 0x00300030, | ||
131 | }; | ||
132 | |||
100 | /** | 133 | /** |
101 | * struct mxs_i2c_dev - per device, private MXS-I2C data | 134 | * struct mxs_i2c_dev - per device, private MXS-I2C data |
102 | * | 135 | * |
@@ -112,11 +145,17 @@ struct mxs_i2c_dev { | |||
112 | struct completion cmd_complete; | 145 | struct completion cmd_complete; |
113 | u32 cmd_err; | 146 | u32 cmd_err; |
114 | struct i2c_adapter adapter; | 147 | struct i2c_adapter adapter; |
148 | const struct mxs_i2c_speed_config *speed; | ||
115 | }; | 149 | }; |
116 | 150 | ||
117 | static void mxs_i2c_reset(struct mxs_i2c_dev *i2c) | 151 | static void mxs_i2c_reset(struct mxs_i2c_dev *i2c) |
118 | { | 152 | { |
119 | stmp_reset_block(i2c->regs); | 153 | stmp_reset_block(i2c->regs); |
154 | |||
155 | writel(i2c->speed->timing0, i2c->regs + MXS_I2C_TIMING0); | ||
156 | writel(i2c->speed->timing1, i2c->regs + MXS_I2C_TIMING1); | ||
157 | writel(i2c->speed->timing2, i2c->regs + MXS_I2C_TIMING2); | ||
158 | |||
120 | writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); | 159 | writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); |
121 | writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE, | 160 | writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE, |
122 | i2c->regs + MXS_I2C_QUEUECTRL_SET); | 161 | i2c->regs + MXS_I2C_QUEUECTRL_SET); |
@@ -193,7 +232,7 @@ static int mxs_i2c_wait_for_data(struct mxs_i2c_dev *i2c) | |||
193 | 232 | ||
194 | static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len) | 233 | static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len) |
195 | { | 234 | { |
196 | u32 data; | 235 | u32 uninitialized_var(data); |
197 | int i; | 236 | int i; |
198 | 237 | ||
199 | for (i = 0; i < len; i++) { | 238 | for (i = 0; i < len; i++) { |
@@ -319,6 +358,28 @@ static const struct i2c_algorithm mxs_i2c_algo = { | |||
319 | .functionality = mxs_i2c_func, | 358 | .functionality = mxs_i2c_func, |
320 | }; | 359 | }; |
321 | 360 | ||
361 | static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c) | ||
362 | { | ||
363 | uint32_t speed; | ||
364 | struct device *dev = i2c->dev; | ||
365 | struct device_node *node = dev->of_node; | ||
366 | int ret; | ||
367 | |||
368 | if (!node) | ||
369 | return -EINVAL; | ||
370 | |||
371 | i2c->speed = &mxs_i2c_95kHz_config; | ||
372 | ret = of_property_read_u32(node, "clock-frequency", &speed); | ||
373 | if (ret) | ||
374 | dev_warn(dev, "No I2C speed selected, using 100kHz\n"); | ||
375 | else if (speed == 400000) | ||
376 | i2c->speed = &mxs_i2c_400kHz_config; | ||
377 | else if (speed != 100000) | ||
378 | dev_warn(dev, "Unsupported I2C speed selected, using 100kHz\n"); | ||
379 | |||
380 | return 0; | ||
381 | } | ||
382 | |||
322 | static int __devinit mxs_i2c_probe(struct platform_device *pdev) | 383 | static int __devinit mxs_i2c_probe(struct platform_device *pdev) |
323 | { | 384 | { |
324 | struct device *dev = &pdev->dev; | 385 | struct device *dev = &pdev->dev; |
@@ -358,6 +419,11 @@ static int __devinit mxs_i2c_probe(struct platform_device *pdev) | |||
358 | return err; | 419 | return err; |
359 | 420 | ||
360 | i2c->dev = dev; | 421 | i2c->dev = dev; |
422 | |||
423 | err = mxs_i2c_get_ofdata(i2c); | ||
424 | if (err) | ||
425 | return err; | ||
426 | |||
361 | platform_set_drvdata(pdev, i2c); | 427 | platform_set_drvdata(pdev, i2c); |
362 | 428 | ||
363 | /* Do reset to enforce correct startup after pinmuxing */ | 429 | /* Do reset to enforce correct startup after pinmuxing */ |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 43a96a123920..392303b4be07 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -453,16 +453,4 @@ static struct pci_driver nforce2_driver = { | |||
453 | .remove = __devexit_p(nforce2_remove), | 453 | .remove = __devexit_p(nforce2_remove), |
454 | }; | 454 | }; |
455 | 455 | ||
456 | static int __init nforce2_init(void) | 456 | module_pci_driver(nforce2_driver); |
457 | { | ||
458 | return pci_register_driver(&nforce2_driver); | ||
459 | } | ||
460 | |||
461 | static void __exit nforce2_exit(void) | ||
462 | { | ||
463 | pci_unregister_driver(&nforce2_driver); | ||
464 | } | ||
465 | |||
466 | module_init(nforce2_init); | ||
467 | module_exit(nforce2_exit); | ||
468 | |||
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 5267ab93d550..61b00edacb08 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -14,7 +14,8 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/amba/bus.h> |
18 | #include <linux/atomic.h> | ||
18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
19 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
20 | #include <linux/i2c.h> | 21 | #include <linux/i2c.h> |
@@ -23,8 +24,7 @@ | |||
23 | #include <linux/io.h> | 24 | #include <linux/io.h> |
24 | #include <linux/regulator/consumer.h> | 25 | #include <linux/regulator/consumer.h> |
25 | #include <linux/pm_runtime.h> | 26 | #include <linux/pm_runtime.h> |
26 | 27 | #include <linux/platform_data/i2c-nomadik.h> | |
27 | #include <plat/i2c.h> | ||
28 | 28 | ||
29 | #define DRIVER_NAME "nmk-i2c" | 29 | #define DRIVER_NAME "nmk-i2c" |
30 | 30 | ||
@@ -136,7 +136,7 @@ struct i2c_nmk_client { | |||
136 | 136 | ||
137 | /** | 137 | /** |
138 | * struct nmk_i2c_dev - private data structure of the controller. | 138 | * struct nmk_i2c_dev - private data structure of the controller. |
139 | * @pdev: parent platform device. | 139 | * @adev: parent amba device. |
140 | * @adap: corresponding I2C adapter. | 140 | * @adap: corresponding I2C adapter. |
141 | * @irq: interrupt line for the controller. | 141 | * @irq: interrupt line for the controller. |
142 | * @virtbase: virtual io memory area. | 142 | * @virtbase: virtual io memory area. |
@@ -150,7 +150,7 @@ struct i2c_nmk_client { | |||
150 | * @busy: Busy doing transfer. | 150 | * @busy: Busy doing transfer. |
151 | */ | 151 | */ |
152 | struct nmk_i2c_dev { | 152 | struct nmk_i2c_dev { |
153 | struct platform_device *pdev; | 153 | struct amba_device *adev; |
154 | struct i2c_adapter adap; | 154 | struct i2c_adapter adap; |
155 | int irq; | 155 | int irq; |
156 | void __iomem *virtbase; | 156 | void __iomem *virtbase; |
@@ -217,7 +217,7 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *dev) | |||
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | dev_err(&dev->pdev->dev, | 220 | dev_err(&dev->adev->dev, |
221 | "flushing operation timed out giving up after %d attempts", | 221 | "flushing operation timed out giving up after %d attempts", |
222 | LOOP_ATTEMPTS); | 222 | LOOP_ATTEMPTS); |
223 | 223 | ||
@@ -276,15 +276,32 @@ exit: | |||
276 | /** | 276 | /** |
277 | * load_i2c_mcr_reg() - load the MCR register | 277 | * load_i2c_mcr_reg() - load the MCR register |
278 | * @dev: private data of controller | 278 | * @dev: private data of controller |
279 | * @flags: message flags | ||
279 | */ | 280 | */ |
280 | static u32 load_i2c_mcr_reg(struct nmk_i2c_dev *dev) | 281 | static u32 load_i2c_mcr_reg(struct nmk_i2c_dev *dev, u16 flags) |
281 | { | 282 | { |
282 | u32 mcr = 0; | 283 | u32 mcr = 0; |
284 | unsigned short slave_adr_3msb_bits; | ||
283 | 285 | ||
284 | /* 7-bit address transaction */ | ||
285 | mcr |= GEN_MASK(1, I2C_MCR_AM, 12); | ||
286 | mcr |= GEN_MASK(dev->cli.slave_adr, I2C_MCR_A7, 1); | 286 | mcr |= GEN_MASK(dev->cli.slave_adr, I2C_MCR_A7, 1); |
287 | 287 | ||
288 | if (unlikely(flags & I2C_M_TEN)) { | ||
289 | /* 10-bit address transaction */ | ||
290 | mcr |= GEN_MASK(2, I2C_MCR_AM, 12); | ||
291 | /* | ||
292 | * Get the top 3 bits. | ||
293 | * EA10 represents extended address in MCR. This includes | ||
294 | * the extension (MSB bits) of the 7 bit address loaded | ||
295 | * in A7 | ||
296 | */ | ||
297 | slave_adr_3msb_bits = (dev->cli.slave_adr >> 7) & 0x7; | ||
298 | |||
299 | mcr |= GEN_MASK(slave_adr_3msb_bits, I2C_MCR_EA10, 8); | ||
300 | } else { | ||
301 | /* 7-bit address transaction */ | ||
302 | mcr |= GEN_MASK(1, I2C_MCR_AM, 12); | ||
303 | } | ||
304 | |||
288 | /* start byte procedure not applied */ | 305 | /* start byte procedure not applied */ |
289 | mcr |= GEN_MASK(0, I2C_MCR_SB, 11); | 306 | mcr |= GEN_MASK(0, I2C_MCR_SB, 11); |
290 | 307 | ||
@@ -333,10 +350,6 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev) | |||
333 | 350 | ||
334 | i2c_clk = clk_get_rate(dev->clk); | 351 | i2c_clk = clk_get_rate(dev->clk); |
335 | 352 | ||
336 | /* fallback to std. mode if machine has not provided it */ | ||
337 | if (dev->cfg.clk_freq == 0) | ||
338 | dev->cfg.clk_freq = 100000; | ||
339 | |||
340 | /* | 353 | /* |
341 | * The spec says, in case of std. mode the divider is | 354 | * The spec says, in case of std. mode the divider is |
342 | * 2 whereas it is 3 for fast and fastplus mode of | 355 | * 2 whereas it is 3 for fast and fastplus mode of |
@@ -364,7 +377,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev) | |||
364 | * and high speed (up to 3.4 Mb/s) | 377 | * and high speed (up to 3.4 Mb/s) |
365 | */ | 378 | */ |
366 | if (dev->cfg.sm > I2C_FREQ_MODE_FAST) { | 379 | if (dev->cfg.sm > I2C_FREQ_MODE_FAST) { |
367 | dev_err(&dev->pdev->dev, | 380 | dev_err(&dev->adev->dev, |
368 | "do not support this mode defaulting to std. mode\n"); | 381 | "do not support this mode defaulting to std. mode\n"); |
369 | brcr2 = i2c_clk/(100000 * 2) & 0xffff; | 382 | brcr2 = i2c_clk/(100000 * 2) & 0xffff; |
370 | writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR); | 383 | writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR); |
@@ -381,19 +394,20 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev) | |||
381 | /** | 394 | /** |
382 | * read_i2c() - Read from I2C client device | 395 | * read_i2c() - Read from I2C client device |
383 | * @dev: private data of I2C Driver | 396 | * @dev: private data of I2C Driver |
397 | * @flags: message flags | ||
384 | * | 398 | * |
385 | * This function reads from i2c client device when controller is in | 399 | * This function reads from i2c client device when controller is in |
386 | * master mode. There is a completion timeout. If there is no transfer | 400 | * master mode. There is a completion timeout. If there is no transfer |
387 | * before timeout error is returned. | 401 | * before timeout error is returned. |
388 | */ | 402 | */ |
389 | static int read_i2c(struct nmk_i2c_dev *dev) | 403 | static int read_i2c(struct nmk_i2c_dev *dev, u16 flags) |
390 | { | 404 | { |
391 | u32 status = 0; | 405 | u32 status = 0; |
392 | u32 mcr; | 406 | u32 mcr; |
393 | u32 irq_mask = 0; | 407 | u32 irq_mask = 0; |
394 | int timeout; | 408 | int timeout; |
395 | 409 | ||
396 | mcr = load_i2c_mcr_reg(dev); | 410 | mcr = load_i2c_mcr_reg(dev, flags); |
397 | writel(mcr, dev->virtbase + I2C_MCR); | 411 | writel(mcr, dev->virtbase + I2C_MCR); |
398 | 412 | ||
399 | /* load the current CR value */ | 413 | /* load the current CR value */ |
@@ -423,7 +437,7 @@ static int read_i2c(struct nmk_i2c_dev *dev) | |||
423 | &dev->xfer_complete, dev->adap.timeout); | 437 | &dev->xfer_complete, dev->adap.timeout); |
424 | 438 | ||
425 | if (timeout < 0) { | 439 | if (timeout < 0) { |
426 | dev_err(&dev->pdev->dev, | 440 | dev_err(&dev->adev->dev, |
427 | "wait_for_completion_timeout " | 441 | "wait_for_completion_timeout " |
428 | "returned %d waiting for event\n", timeout); | 442 | "returned %d waiting for event\n", timeout); |
429 | status = timeout; | 443 | status = timeout; |
@@ -431,7 +445,7 @@ static int read_i2c(struct nmk_i2c_dev *dev) | |||
431 | 445 | ||
432 | if (timeout == 0) { | 446 | if (timeout == 0) { |
433 | /* Controller timed out */ | 447 | /* Controller timed out */ |
434 | dev_err(&dev->pdev->dev, "read from slave 0x%x timed out\n", | 448 | dev_err(&dev->adev->dev, "read from slave 0x%x timed out\n", |
435 | dev->cli.slave_adr); | 449 | dev->cli.slave_adr); |
436 | status = -ETIMEDOUT; | 450 | status = -ETIMEDOUT; |
437 | } | 451 | } |
@@ -459,17 +473,18 @@ static void fill_tx_fifo(struct nmk_i2c_dev *dev, int no_bytes) | |||
459 | /** | 473 | /** |
460 | * write_i2c() - Write data to I2C client. | 474 | * write_i2c() - Write data to I2C client. |
461 | * @dev: private data of I2C Driver | 475 | * @dev: private data of I2C Driver |
476 | * @flags: message flags | ||
462 | * | 477 | * |
463 | * This function writes data to I2C client | 478 | * This function writes data to I2C client |
464 | */ | 479 | */ |
465 | static int write_i2c(struct nmk_i2c_dev *dev) | 480 | static int write_i2c(struct nmk_i2c_dev *dev, u16 flags) |
466 | { | 481 | { |
467 | u32 status = 0; | 482 | u32 status = 0; |
468 | u32 mcr; | 483 | u32 mcr; |
469 | u32 irq_mask = 0; | 484 | u32 irq_mask = 0; |
470 | int timeout; | 485 | int timeout; |
471 | 486 | ||
472 | mcr = load_i2c_mcr_reg(dev); | 487 | mcr = load_i2c_mcr_reg(dev, flags); |
473 | 488 | ||
474 | writel(mcr, dev->virtbase + I2C_MCR); | 489 | writel(mcr, dev->virtbase + I2C_MCR); |
475 | 490 | ||
@@ -510,7 +525,7 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
510 | &dev->xfer_complete, dev->adap.timeout); | 525 | &dev->xfer_complete, dev->adap.timeout); |
511 | 526 | ||
512 | if (timeout < 0) { | 527 | if (timeout < 0) { |
513 | dev_err(&dev->pdev->dev, | 528 | dev_err(&dev->adev->dev, |
514 | "wait_for_completion_timeout " | 529 | "wait_for_completion_timeout " |
515 | "returned %d waiting for event\n", timeout); | 530 | "returned %d waiting for event\n", timeout); |
516 | status = timeout; | 531 | status = timeout; |
@@ -518,7 +533,7 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
518 | 533 | ||
519 | if (timeout == 0) { | 534 | if (timeout == 0) { |
520 | /* Controller timed out */ | 535 | /* Controller timed out */ |
521 | dev_err(&dev->pdev->dev, "write to slave 0x%x timed out\n", | 536 | dev_err(&dev->adev->dev, "write to slave 0x%x timed out\n", |
522 | dev->cli.slave_adr); | 537 | dev->cli.slave_adr); |
523 | status = -ETIMEDOUT; | 538 | status = -ETIMEDOUT; |
524 | } | 539 | } |
@@ -538,11 +553,11 @@ static int nmk_i2c_xfer_one(struct nmk_i2c_dev *dev, u16 flags) | |||
538 | if (flags & I2C_M_RD) { | 553 | if (flags & I2C_M_RD) { |
539 | /* read operation */ | 554 | /* read operation */ |
540 | dev->cli.operation = I2C_READ; | 555 | dev->cli.operation = I2C_READ; |
541 | status = read_i2c(dev); | 556 | status = read_i2c(dev, flags); |
542 | } else { | 557 | } else { |
543 | /* write operation */ | 558 | /* write operation */ |
544 | dev->cli.operation = I2C_WRITE; | 559 | dev->cli.operation = I2C_WRITE; |
545 | status = write_i2c(dev); | 560 | status = write_i2c(dev, flags); |
546 | } | 561 | } |
547 | 562 | ||
548 | if (status || (dev->result)) { | 563 | if (status || (dev->result)) { |
@@ -557,7 +572,7 @@ static int nmk_i2c_xfer_one(struct nmk_i2c_dev *dev, u16 flags) | |||
557 | if (((i2c_sr >> 2) & 0x3) == 0x3) { | 572 | if (((i2c_sr >> 2) & 0x3) == 0x3) { |
558 | /* get the abort cause */ | 573 | /* get the abort cause */ |
559 | cause = (i2c_sr >> 4) & 0x7; | 574 | cause = (i2c_sr >> 4) & 0x7; |
560 | dev_err(&dev->pdev->dev, "%s\n", | 575 | dev_err(&dev->adev->dev, "%s\n", |
561 | cause >= ARRAY_SIZE(abort_causes) ? | 576 | cause >= ARRAY_SIZE(abort_causes) ? |
562 | "unknown reason" : | 577 | "unknown reason" : |
563 | abort_causes[cause]); | 578 | abort_causes[cause]); |
@@ -630,7 +645,7 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
630 | 645 | ||
631 | if (dev->regulator) | 646 | if (dev->regulator) |
632 | regulator_enable(dev->regulator); | 647 | regulator_enable(dev->regulator); |
633 | pm_runtime_get_sync(&dev->pdev->dev); | 648 | pm_runtime_get_sync(&dev->adev->dev); |
634 | 649 | ||
635 | clk_enable(dev->clk); | 650 | clk_enable(dev->clk); |
636 | 651 | ||
@@ -644,13 +659,6 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
644 | setup_i2c_controller(dev); | 659 | setup_i2c_controller(dev); |
645 | 660 | ||
646 | for (i = 0; i < num_msgs; i++) { | 661 | for (i = 0; i < num_msgs; i++) { |
647 | if (unlikely(msgs[i].flags & I2C_M_TEN)) { | ||
648 | dev_err(&dev->pdev->dev, | ||
649 | "10 bit addressing not supported\n"); | ||
650 | |||
651 | status = -EINVAL; | ||
652 | goto out; | ||
653 | } | ||
654 | dev->cli.slave_adr = msgs[i].addr; | 662 | dev->cli.slave_adr = msgs[i].addr; |
655 | dev->cli.buffer = msgs[i].buf; | 663 | dev->cli.buffer = msgs[i].buf; |
656 | dev->cli.count = msgs[i].len; | 664 | dev->cli.count = msgs[i].len; |
@@ -667,7 +675,7 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
667 | 675 | ||
668 | out: | 676 | out: |
669 | clk_disable(dev->clk); | 677 | clk_disable(dev->clk); |
670 | pm_runtime_put_sync(&dev->pdev->dev); | 678 | pm_runtime_put_sync(&dev->adev->dev); |
671 | if (dev->regulator) | 679 | if (dev->regulator) |
672 | regulator_disable(dev->regulator); | 680 | regulator_disable(dev->regulator); |
673 | 681 | ||
@@ -790,7 +798,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
790 | 798 | ||
791 | if (dev->cli.count) { | 799 | if (dev->cli.count) { |
792 | dev->result = -EIO; | 800 | dev->result = -EIO; |
793 | dev_err(&dev->pdev->dev, | 801 | dev_err(&dev->adev->dev, |
794 | "%lu bytes still remain to be xfered\n", | 802 | "%lu bytes still remain to be xfered\n", |
795 | dev->cli.count); | 803 | dev->cli.count); |
796 | (void) init_hw(dev); | 804 | (void) init_hw(dev); |
@@ -834,7 +842,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
834 | dev->result = -EIO; | 842 | dev->result = -EIO; |
835 | (void) init_hw(dev); | 843 | (void) init_hw(dev); |
836 | 844 | ||
837 | dev_err(&dev->pdev->dev, "Tx Fifo Over run\n"); | 845 | dev_err(&dev->adev->dev, "Tx Fifo Over run\n"); |
838 | complete(&dev->xfer_complete); | 846 | complete(&dev->xfer_complete); |
839 | 847 | ||
840 | break; | 848 | break; |
@@ -847,10 +855,10 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
847 | case I2C_IT_RFSE: | 855 | case I2C_IT_RFSE: |
848 | case I2C_IT_WTSR: | 856 | case I2C_IT_WTSR: |
849 | case I2C_IT_STD: | 857 | case I2C_IT_STD: |
850 | dev_err(&dev->pdev->dev, "unhandled Interrupt\n"); | 858 | dev_err(&dev->adev->dev, "unhandled Interrupt\n"); |
851 | break; | 859 | break; |
852 | default: | 860 | default: |
853 | dev_err(&dev->pdev->dev, "spurious Interrupt..\n"); | 861 | dev_err(&dev->adev->dev, "spurious Interrupt..\n"); |
854 | break; | 862 | break; |
855 | } | 863 | } |
856 | 864 | ||
@@ -861,8 +869,8 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
861 | #ifdef CONFIG_PM | 869 | #ifdef CONFIG_PM |
862 | static int nmk_i2c_suspend(struct device *dev) | 870 | static int nmk_i2c_suspend(struct device *dev) |
863 | { | 871 | { |
864 | struct platform_device *pdev = to_platform_device(dev); | 872 | struct amba_device *adev = to_amba_device(dev); |
865 | struct nmk_i2c_dev *nmk_i2c = platform_get_drvdata(pdev); | 873 | struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev); |
866 | 874 | ||
867 | if (nmk_i2c->busy) | 875 | if (nmk_i2c->busy) |
868 | return -EBUSY; | 876 | return -EBUSY; |
@@ -891,7 +899,7 @@ static const struct dev_pm_ops nmk_i2c_pm = { | |||
891 | 899 | ||
892 | static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) | 900 | static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) |
893 | { | 901 | { |
894 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | 902 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; |
895 | } | 903 | } |
896 | 904 | ||
897 | static const struct i2c_algorithm nmk_i2c_algo = { | 905 | static const struct i2c_algorithm nmk_i2c_algo = { |
@@ -899,79 +907,81 @@ static const struct i2c_algorithm nmk_i2c_algo = { | |||
899 | .functionality = nmk_i2c_functionality | 907 | .functionality = nmk_i2c_functionality |
900 | }; | 908 | }; |
901 | 909 | ||
902 | static int __devinit nmk_i2c_probe(struct platform_device *pdev) | 910 | static struct nmk_i2c_controller u8500_i2c = { |
911 | /* | ||
912 | * Slave data setup time; 250ns, 100ns, and 10ns, which | ||
913 | * is 14, 6 and 2 respectively for a 48Mhz i2c clock. | ||
914 | */ | ||
915 | .slsu = 0xe, | ||
916 | .tft = 1, /* Tx FIFO threshold */ | ||
917 | .rft = 8, /* Rx FIFO threshold */ | ||
918 | .clk_freq = 400000, /* fast mode operation */ | ||
919 | .timeout = 200, /* Slave response timeout(ms) */ | ||
920 | .sm = I2C_FREQ_MODE_FAST, | ||
921 | }; | ||
922 | |||
923 | static atomic_t adapter_id = ATOMIC_INIT(0); | ||
924 | |||
925 | static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) | ||
903 | { | 926 | { |
904 | int ret = 0; | 927 | int ret = 0; |
905 | struct resource *res; | 928 | struct nmk_i2c_controller *pdata = adev->dev.platform_data; |
906 | struct nmk_i2c_controller *pdata = | ||
907 | pdev->dev.platform_data; | ||
908 | struct nmk_i2c_dev *dev; | 929 | struct nmk_i2c_dev *dev; |
909 | struct i2c_adapter *adap; | 930 | struct i2c_adapter *adap; |
910 | 931 | ||
932 | if (!pdata) | ||
933 | /* No i2c configuration found, using the default. */ | ||
934 | pdata = &u8500_i2c; | ||
935 | |||
911 | dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL); | 936 | dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL); |
912 | if (!dev) { | 937 | if (!dev) { |
913 | dev_err(&pdev->dev, "cannot allocate memory\n"); | 938 | dev_err(&adev->dev, "cannot allocate memory\n"); |
914 | ret = -ENOMEM; | 939 | ret = -ENOMEM; |
915 | goto err_no_mem; | 940 | goto err_no_mem; |
916 | } | 941 | } |
917 | dev->busy = false; | 942 | dev->busy = false; |
918 | dev->pdev = pdev; | 943 | dev->adev = adev; |
919 | platform_set_drvdata(pdev, dev); | 944 | amba_set_drvdata(adev, dev); |
920 | |||
921 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
922 | if (!res) { | ||
923 | ret = -ENOENT; | ||
924 | goto err_no_resource; | ||
925 | } | ||
926 | |||
927 | if (request_mem_region(res->start, resource_size(res), | ||
928 | DRIVER_NAME "I/O region") == NULL) { | ||
929 | ret = -EBUSY; | ||
930 | goto err_no_region; | ||
931 | } | ||
932 | 945 | ||
933 | dev->virtbase = ioremap(res->start, resource_size(res)); | 946 | dev->virtbase = ioremap(adev->res.start, resource_size(&adev->res)); |
934 | if (!dev->virtbase) { | 947 | if (!dev->virtbase) { |
935 | ret = -ENOMEM; | 948 | ret = -ENOMEM; |
936 | goto err_no_ioremap; | 949 | goto err_no_ioremap; |
937 | } | 950 | } |
938 | 951 | ||
939 | dev->irq = platform_get_irq(pdev, 0); | 952 | dev->irq = adev->irq[0]; |
940 | ret = request_irq(dev->irq, i2c_irq_handler, 0, | 953 | ret = request_irq(dev->irq, i2c_irq_handler, 0, |
941 | DRIVER_NAME, dev); | 954 | DRIVER_NAME, dev); |
942 | if (ret) { | 955 | if (ret) { |
943 | dev_err(&pdev->dev, "cannot claim the irq %d\n", dev->irq); | 956 | dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq); |
944 | goto err_irq; | 957 | goto err_irq; |
945 | } | 958 | } |
946 | 959 | ||
947 | dev->regulator = regulator_get(&pdev->dev, "v-i2c"); | 960 | dev->regulator = regulator_get(&adev->dev, "v-i2c"); |
948 | if (IS_ERR(dev->regulator)) { | 961 | if (IS_ERR(dev->regulator)) { |
949 | dev_warn(&pdev->dev, "could not get i2c regulator\n"); | 962 | dev_warn(&adev->dev, "could not get i2c regulator\n"); |
950 | dev->regulator = NULL; | 963 | dev->regulator = NULL; |
951 | } | 964 | } |
952 | 965 | ||
953 | pm_suspend_ignore_children(&pdev->dev, true); | 966 | pm_suspend_ignore_children(&adev->dev, true); |
954 | pm_runtime_enable(&pdev->dev); | ||
955 | 967 | ||
956 | dev->clk = clk_get(&pdev->dev, NULL); | 968 | dev->clk = clk_get(&adev->dev, NULL); |
957 | if (IS_ERR(dev->clk)) { | 969 | if (IS_ERR(dev->clk)) { |
958 | dev_err(&pdev->dev, "could not get i2c clock\n"); | 970 | dev_err(&adev->dev, "could not get i2c clock\n"); |
959 | ret = PTR_ERR(dev->clk); | 971 | ret = PTR_ERR(dev->clk); |
960 | goto err_no_clk; | 972 | goto err_no_clk; |
961 | } | 973 | } |
962 | 974 | ||
963 | adap = &dev->adap; | 975 | adap = &dev->adap; |
964 | adap->dev.parent = &pdev->dev; | 976 | adap->dev.parent = &adev->dev; |
965 | adap->owner = THIS_MODULE; | 977 | adap->owner = THIS_MODULE; |
966 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | 978 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
967 | adap->algo = &nmk_i2c_algo; | 979 | adap->algo = &nmk_i2c_algo; |
968 | adap->timeout = pdata->timeout ? msecs_to_jiffies(pdata->timeout) : | 980 | adap->timeout = msecs_to_jiffies(pdata->timeout); |
969 | msecs_to_jiffies(20000); | 981 | adap->nr = atomic_read(&adapter_id); |
970 | snprintf(adap->name, sizeof(adap->name), | 982 | snprintf(adap->name, sizeof(adap->name), |
971 | "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start); | 983 | "Nomadik I2C%d at %pR", adap->nr, &adev->res); |
972 | 984 | atomic_inc(&adapter_id); | |
973 | /* fetch the controller id */ | ||
974 | adap->nr = pdev->id; | ||
975 | 985 | ||
976 | /* fetch the controller configuration from machine */ | 986 | /* fetch the controller configuration from machine */ |
977 | dev->cfg.clk_freq = pdata->clk_freq; | 987 | dev->cfg.clk_freq = pdata->clk_freq; |
@@ -982,16 +992,18 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
982 | 992 | ||
983 | i2c_set_adapdata(adap, dev); | 993 | i2c_set_adapdata(adap, dev); |
984 | 994 | ||
985 | dev_info(&pdev->dev, | 995 | dev_info(&adev->dev, |
986 | "initialize %s on virtual base %p\n", | 996 | "initialize %s on virtual base %p\n", |
987 | adap->name, dev->virtbase); | 997 | adap->name, dev->virtbase); |
988 | 998 | ||
989 | ret = i2c_add_numbered_adapter(adap); | 999 | ret = i2c_add_numbered_adapter(adap); |
990 | if (ret) { | 1000 | if (ret) { |
991 | dev_err(&pdev->dev, "failed to add adapter\n"); | 1001 | dev_err(&adev->dev, "failed to add adapter\n"); |
992 | goto err_add_adap; | 1002 | goto err_add_adap; |
993 | } | 1003 | } |
994 | 1004 | ||
1005 | pm_runtime_put(&adev->dev); | ||
1006 | |||
995 | return 0; | 1007 | return 0; |
996 | 1008 | ||
997 | err_add_adap: | 1009 | err_add_adap: |
@@ -999,25 +1011,21 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
999 | err_no_clk: | 1011 | err_no_clk: |
1000 | if (dev->regulator) | 1012 | if (dev->regulator) |
1001 | regulator_put(dev->regulator); | 1013 | regulator_put(dev->regulator); |
1002 | pm_runtime_disable(&pdev->dev); | ||
1003 | free_irq(dev->irq, dev); | 1014 | free_irq(dev->irq, dev); |
1004 | err_irq: | 1015 | err_irq: |
1005 | iounmap(dev->virtbase); | 1016 | iounmap(dev->virtbase); |
1006 | err_no_ioremap: | 1017 | err_no_ioremap: |
1007 | release_mem_region(res->start, resource_size(res)); | 1018 | amba_set_drvdata(adev, NULL); |
1008 | err_no_region: | ||
1009 | platform_set_drvdata(pdev, NULL); | ||
1010 | err_no_resource: | ||
1011 | kfree(dev); | 1019 | kfree(dev); |
1012 | err_no_mem: | 1020 | err_no_mem: |
1013 | 1021 | ||
1014 | return ret; | 1022 | return ret; |
1015 | } | 1023 | } |
1016 | 1024 | ||
1017 | static int __devexit nmk_i2c_remove(struct platform_device *pdev) | 1025 | static int nmk_i2c_remove(struct amba_device *adev) |
1018 | { | 1026 | { |
1019 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1027 | struct resource *res = &adev->res; |
1020 | struct nmk_i2c_dev *dev = platform_get_drvdata(pdev); | 1028 | struct nmk_i2c_dev *dev = amba_get_drvdata(adev); |
1021 | 1029 | ||
1022 | i2c_del_adapter(&dev->adap); | 1030 | i2c_del_adapter(&dev->adap); |
1023 | flush_i2c_fifo(dev); | 1031 | flush_i2c_fifo(dev); |
@@ -1032,31 +1040,46 @@ static int __devexit nmk_i2c_remove(struct platform_device *pdev) | |||
1032 | clk_put(dev->clk); | 1040 | clk_put(dev->clk); |
1033 | if (dev->regulator) | 1041 | if (dev->regulator) |
1034 | regulator_put(dev->regulator); | 1042 | regulator_put(dev->regulator); |
1035 | pm_runtime_disable(&pdev->dev); | 1043 | pm_runtime_disable(&adev->dev); |
1036 | platform_set_drvdata(pdev, NULL); | 1044 | amba_set_drvdata(adev, NULL); |
1037 | kfree(dev); | 1045 | kfree(dev); |
1038 | 1046 | ||
1039 | return 0; | 1047 | return 0; |
1040 | } | 1048 | } |
1041 | 1049 | ||
1042 | static struct platform_driver nmk_i2c_driver = { | 1050 | static struct amba_id nmk_i2c_ids[] = { |
1043 | .driver = { | 1051 | { |
1052 | .id = 0x00180024, | ||
1053 | .mask = 0x00ffffff, | ||
1054 | }, | ||
1055 | { | ||
1056 | .id = 0x00380024, | ||
1057 | .mask = 0x00ffffff, | ||
1058 | }, | ||
1059 | {}, | ||
1060 | }; | ||
1061 | |||
1062 | MODULE_DEVICE_TABLE(amba, nmk_i2c_ids); | ||
1063 | |||
1064 | static struct amba_driver nmk_i2c_driver = { | ||
1065 | .drv = { | ||
1044 | .owner = THIS_MODULE, | 1066 | .owner = THIS_MODULE, |
1045 | .name = DRIVER_NAME, | 1067 | .name = DRIVER_NAME, |
1046 | .pm = &nmk_i2c_pm, | 1068 | .pm = &nmk_i2c_pm, |
1047 | }, | 1069 | }, |
1070 | .id_table = nmk_i2c_ids, | ||
1048 | .probe = nmk_i2c_probe, | 1071 | .probe = nmk_i2c_probe, |
1049 | .remove = __devexit_p(nmk_i2c_remove), | 1072 | .remove = nmk_i2c_remove, |
1050 | }; | 1073 | }; |
1051 | 1074 | ||
1052 | static int __init nmk_i2c_init(void) | 1075 | static int __init nmk_i2c_init(void) |
1053 | { | 1076 | { |
1054 | return platform_driver_register(&nmk_i2c_driver); | 1077 | return amba_driver_register(&nmk_i2c_driver); |
1055 | } | 1078 | } |
1056 | 1079 | ||
1057 | static void __exit nmk_i2c_exit(void) | 1080 | static void __exit nmk_i2c_exit(void) |
1058 | { | 1081 | { |
1059 | platform_driver_unregister(&nmk_i2c_driver); | 1082 | amba_driver_unregister(&nmk_i2c_driver); |
1060 | } | 1083 | } |
1061 | 1084 | ||
1062 | subsys_initcall(nmk_i2c_init); | 1085 | subsys_initcall(nmk_i2c_init); |
@@ -1065,4 +1088,3 @@ module_exit(nmk_i2c_exit); | |||
1065 | MODULE_AUTHOR("Sachin Verma, Srinidhi KASAGAR"); | 1088 | MODULE_AUTHOR("Sachin Verma, Srinidhi KASAGAR"); |
1066 | MODULE_DESCRIPTION("Nomadik/Ux500 I2C driver"); | 1089 | MODULE_DESCRIPTION("Nomadik/Ux500 I2C driver"); |
1067 | MODULE_LICENSE("GPL"); | 1090 | MODULE_LICENSE("GPL"); |
1068 | MODULE_ALIAS("platform:" DRIVER_NAME); | ||
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index 75194c579b6d..bffd5501ac2d 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c | |||
@@ -10,40 +10,9 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | /* | 12 | /* |
13 | * Device tree configuration: | 13 | * This driver can be used from the device tree, see |
14 | * | 14 | * Documentation/devicetree/bindings/i2c/ocore-i2c.txt |
15 | * Required properties: | ||
16 | * - compatible : "opencores,i2c-ocores" | ||
17 | * - reg : bus address start and address range size of device | ||
18 | * - interrupts : interrupt number | ||
19 | * - regstep : size of device registers in bytes | ||
20 | * - clock-frequency : frequency of bus clock in Hz | ||
21 | * | ||
22 | * Example: | ||
23 | * | ||
24 | * i2c0: ocores@a0000000 { | ||
25 | * compatible = "opencores,i2c-ocores"; | ||
26 | * reg = <0xa0000000 0x8>; | ||
27 | * interrupts = <10>; | ||
28 | * | ||
29 | * regstep = <1>; | ||
30 | * clock-frequency = <20000000>; | ||
31 | * | ||
32 | * -- Devices connected on this I2C bus get | ||
33 | * -- defined here; address- and size-cells | ||
34 | * -- apply to these child devices | ||
35 | * | ||
36 | * #address-cells = <1>; | ||
37 | * #size-cells = <0>; | ||
38 | * | ||
39 | * dummy@60 { | ||
40 | * compatible = "dummy"; | ||
41 | * reg = <60>; | ||
42 | * }; | ||
43 | * }; | ||
44 | * | ||
45 | */ | 15 | */ |
46 | |||
47 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
48 | #include <linux/module.h> | 17 | #include <linux/module.h> |
49 | #include <linux/init.h> | 18 | #include <linux/init.h> |
@@ -56,10 +25,12 @@ | |||
56 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
57 | #include <linux/io.h> | 26 | #include <linux/io.h> |
58 | #include <linux/of_i2c.h> | 27 | #include <linux/of_i2c.h> |
28 | #include <linux/log2.h> | ||
59 | 29 | ||
60 | struct ocores_i2c { | 30 | struct ocores_i2c { |
61 | void __iomem *base; | 31 | void __iomem *base; |
62 | int regstep; | 32 | u32 reg_shift; |
33 | u32 reg_io_width; | ||
63 | wait_queue_head_t wait; | 34 | wait_queue_head_t wait; |
64 | struct i2c_adapter adap; | 35 | struct i2c_adapter adap; |
65 | struct i2c_msg *msg; | 36 | struct i2c_msg *msg; |
@@ -102,12 +73,22 @@ struct ocores_i2c { | |||
102 | 73 | ||
103 | static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) | 74 | static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) |
104 | { | 75 | { |
105 | iowrite8(value, i2c->base + reg * i2c->regstep); | 76 | if (i2c->reg_io_width == 4) |
77 | iowrite32(value, i2c->base + (reg << i2c->reg_shift)); | ||
78 | else if (i2c->reg_io_width == 2) | ||
79 | iowrite16(value, i2c->base + (reg << i2c->reg_shift)); | ||
80 | else | ||
81 | iowrite8(value, i2c->base + (reg << i2c->reg_shift)); | ||
106 | } | 82 | } |
107 | 83 | ||
108 | static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg) | 84 | static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg) |
109 | { | 85 | { |
110 | return ioread8(i2c->base + reg * i2c->regstep); | 86 | if (i2c->reg_io_width == 4) |
87 | return ioread32(i2c->base + (reg << i2c->reg_shift)); | ||
88 | else if (i2c->reg_io_width == 2) | ||
89 | return ioread16(i2c->base + (reg << i2c->reg_shift)); | ||
90 | else | ||
91 | return ioread8(i2c->base + (reg << i2c->reg_shift)); | ||
111 | } | 92 | } |
112 | 93 | ||
113 | static void ocores_process(struct ocores_i2c *i2c) | 94 | static void ocores_process(struct ocores_i2c *i2c) |
@@ -247,26 +228,35 @@ static struct i2c_adapter ocores_adapter = { | |||
247 | }; | 228 | }; |
248 | 229 | ||
249 | #ifdef CONFIG_OF | 230 | #ifdef CONFIG_OF |
250 | static int ocores_i2c_of_probe(struct platform_device* pdev, | 231 | static int ocores_i2c_of_probe(struct platform_device *pdev, |
251 | struct ocores_i2c* i2c) | 232 | struct ocores_i2c *i2c) |
252 | { | 233 | { |
253 | const __be32* val; | 234 | struct device_node *np = pdev->dev.of_node; |
254 | 235 | u32 val; | |
255 | val = of_get_property(pdev->dev.of_node, "regstep", NULL); | 236 | |
256 | if (!val) { | 237 | if (of_property_read_u32(np, "reg-shift", &i2c->reg_shift)) { |
257 | dev_err(&pdev->dev, "Missing required parameter 'regstep'"); | 238 | /* no 'reg-shift', check for deprecated 'regstep' */ |
258 | return -ENODEV; | 239 | if (!of_property_read_u32(np, "regstep", &val)) { |
240 | if (!is_power_of_2(val)) { | ||
241 | dev_err(&pdev->dev, "invalid regstep %d\n", | ||
242 | val); | ||
243 | return -EINVAL; | ||
244 | } | ||
245 | i2c->reg_shift = ilog2(val); | ||
246 | dev_warn(&pdev->dev, | ||
247 | "regstep property deprecated, use reg-shift\n"); | ||
248 | } | ||
259 | } | 249 | } |
260 | i2c->regstep = be32_to_cpup(val); | ||
261 | 250 | ||
262 | val = of_get_property(pdev->dev.of_node, "clock-frequency", NULL); | 251 | if (of_property_read_u32(np, "clock-frequency", &val)) { |
263 | if (!val) { | ||
264 | dev_err(&pdev->dev, | 252 | dev_err(&pdev->dev, |
265 | "Missing required parameter 'clock-frequency'"); | 253 | "Missing required parameter 'clock-frequency'\n"); |
266 | return -ENODEV; | 254 | return -ENODEV; |
267 | } | 255 | } |
268 | i2c->clock_khz = be32_to_cpup(val) / 1000; | 256 | i2c->clock_khz = val / 1000; |
269 | 257 | ||
258 | of_property_read_u32(pdev->dev.of_node, "reg-io-width", | ||
259 | &i2c->reg_io_width); | ||
270 | return 0; | 260 | return 0; |
271 | } | 261 | } |
272 | #else | 262 | #else |
@@ -308,7 +298,8 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev) | |||
308 | 298 | ||
309 | pdata = pdev->dev.platform_data; | 299 | pdata = pdev->dev.platform_data; |
310 | if (pdata) { | 300 | if (pdata) { |
311 | i2c->regstep = pdata->regstep; | 301 | i2c->reg_shift = pdata->reg_shift; |
302 | i2c->reg_io_width = pdata->reg_io_width; | ||
312 | i2c->clock_khz = pdata->clock_khz; | 303 | i2c->clock_khz = pdata->clock_khz; |
313 | } else { | 304 | } else { |
314 | ret = ocores_i2c_of_probe(pdev, i2c); | 305 | ret = ocores_i2c_of_probe(pdev, i2c); |
@@ -316,6 +307,9 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev) | |||
316 | return ret; | 307 | return ret; |
317 | } | 308 | } |
318 | 309 | ||
310 | if (i2c->reg_io_width == 0) | ||
311 | i2c->reg_io_width = 1; /* Set to default value */ | ||
312 | |||
319 | ocores_init(i2c); | 313 | ocores_init(i2c); |
320 | 314 | ||
321 | init_waitqueue_head(&i2c->wait); | 315 | init_waitqueue_head(&i2c->wait); |
@@ -351,7 +345,7 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev) | |||
351 | return 0; | 345 | return 0; |
352 | } | 346 | } |
353 | 347 | ||
354 | static int __devexit ocores_i2c_remove(struct platform_device* pdev) | 348 | static int __devexit ocores_i2c_remove(struct platform_device *pdev) |
355 | { | 349 | { |
356 | struct ocores_i2c *i2c = platform_get_drvdata(pdev); | 350 | struct ocores_i2c *i2c = platform_get_drvdata(pdev); |
357 | 351 | ||
@@ -367,9 +361,9 @@ static int __devexit ocores_i2c_remove(struct platform_device* pdev) | |||
367 | } | 361 | } |
368 | 362 | ||
369 | #ifdef CONFIG_PM | 363 | #ifdef CONFIG_PM |
370 | static int ocores_i2c_suspend(struct platform_device *pdev, pm_message_t state) | 364 | static int ocores_i2c_suspend(struct device *dev) |
371 | { | 365 | { |
372 | struct ocores_i2c *i2c = platform_get_drvdata(pdev); | 366 | struct ocores_i2c *i2c = dev_get_drvdata(dev); |
373 | u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); | 367 | u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); |
374 | 368 | ||
375 | /* make sure the device is disabled */ | 369 | /* make sure the device is disabled */ |
@@ -378,17 +372,19 @@ static int ocores_i2c_suspend(struct platform_device *pdev, pm_message_t state) | |||
378 | return 0; | 372 | return 0; |
379 | } | 373 | } |
380 | 374 | ||
381 | static int ocores_i2c_resume(struct platform_device *pdev) | 375 | static int ocores_i2c_resume(struct device *dev) |
382 | { | 376 | { |
383 | struct ocores_i2c *i2c = platform_get_drvdata(pdev); | 377 | struct ocores_i2c *i2c = dev_get_drvdata(dev); |
384 | 378 | ||
385 | ocores_init(i2c); | 379 | ocores_init(i2c); |
386 | 380 | ||
387 | return 0; | 381 | return 0; |
388 | } | 382 | } |
383 | |||
384 | static SIMPLE_DEV_PM_OPS(ocores_i2c_pm, ocores_i2c_suspend, ocores_i2c_resume); | ||
385 | #define OCORES_I2C_PM (&ocores_i2c_pm) | ||
389 | #else | 386 | #else |
390 | #define ocores_i2c_suspend NULL | 387 | #define OCORES_I2C_PM NULL |
391 | #define ocores_i2c_resume NULL | ||
392 | #endif | 388 | #endif |
393 | 389 | ||
394 | static struct of_device_id ocores_i2c_match[] = { | 390 | static struct of_device_id ocores_i2c_match[] = { |
@@ -400,12 +396,11 @@ MODULE_DEVICE_TABLE(of, ocores_i2c_match); | |||
400 | static struct platform_driver ocores_i2c_driver = { | 396 | static struct platform_driver ocores_i2c_driver = { |
401 | .probe = ocores_i2c_probe, | 397 | .probe = ocores_i2c_probe, |
402 | .remove = __devexit_p(ocores_i2c_remove), | 398 | .remove = __devexit_p(ocores_i2c_remove), |
403 | .suspend = ocores_i2c_suspend, | ||
404 | .resume = ocores_i2c_resume, | ||
405 | .driver = { | 399 | .driver = { |
406 | .owner = THIS_MODULE, | 400 | .owner = THIS_MODULE, |
407 | .name = "ocores-i2c", | 401 | .name = "ocores-i2c", |
408 | .of_match_table = ocores_i2c_match, | 402 | .of_match_table = ocores_i2c_match, |
403 | .pm = OCORES_I2C_PM, | ||
409 | }, | 404 | }, |
410 | }; | 405 | }; |
411 | 406 | ||
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c index ee139a598814..f44c83549fe5 100644 --- a/drivers/i2c/busses/i2c-octeon.c +++ b/drivers/i2c/busses/i2c-octeon.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * (C) Copyright 2009-2010 | 2 | * (C) Copyright 2009-2010 |
3 | * Nokia Siemens Networks, michael.lawnick.ext@nsn.com | 3 | * Nokia Siemens Networks, michael.lawnick.ext@nsn.com |
4 | * | 4 | * |
5 | * Portions Copyright (C) 2010 Cavium Networks, Inc. | 5 | * Portions Copyright (C) 2010, 2011 Cavium Networks, Inc. |
6 | * | 6 | * |
7 | * This is a driver for the i2c adapter in Cavium Networks' OCTEON processors. | 7 | * This is a driver for the i2c adapter in Cavium Networks' OCTEON processors. |
8 | * | 8 | * |
@@ -11,17 +11,18 @@ | |||
11 | * warranty of any kind, whether express or implied. | 11 | * warranty of any kind, whether express or implied. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/interrupt.h> | ||
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/of_i2c.h> | ||
19 | #include <linux/delay.h> | ||
16 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
17 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
18 | #include <linux/init.h> | 22 | #include <linux/init.h> |
19 | |||
20 | #include <linux/io.h> | ||
21 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
22 | #include <linux/interrupt.h> | 24 | #include <linux/io.h> |
23 | #include <linux/delay.h> | 25 | #include <linux/of.h> |
24 | #include <linux/platform_device.h> | ||
25 | 26 | ||
26 | #include <asm/octeon/octeon.h> | 27 | #include <asm/octeon/octeon.h> |
27 | 28 | ||
@@ -65,7 +66,7 @@ struct octeon_i2c { | |||
65 | wait_queue_head_t queue; | 66 | wait_queue_head_t queue; |
66 | struct i2c_adapter adap; | 67 | struct i2c_adapter adap; |
67 | int irq; | 68 | int irq; |
68 | int twsi_freq; | 69 | u32 twsi_freq; |
69 | int sys_freq; | 70 | int sys_freq; |
70 | resource_size_t twsi_phys; | 71 | resource_size_t twsi_phys; |
71 | void __iomem *twsi_base; | 72 | void __iomem *twsi_base; |
@@ -121,10 +122,8 @@ static u8 octeon_i2c_read_sw(struct octeon_i2c *i2c, u64 eop_reg) | |||
121 | */ | 122 | */ |
122 | static void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data) | 123 | static void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data) |
123 | { | 124 | { |
124 | u64 tmp; | ||
125 | |||
126 | __raw_writeq(data, i2c->twsi_base + TWSI_INT); | 125 | __raw_writeq(data, i2c->twsi_base + TWSI_INT); |
127 | tmp = __raw_readq(i2c->twsi_base + TWSI_INT); | 126 | __raw_readq(i2c->twsi_base + TWSI_INT); |
128 | } | 127 | } |
129 | 128 | ||
130 | /** | 129 | /** |
@@ -515,7 +514,6 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev) | |||
515 | { | 514 | { |
516 | int irq, result = 0; | 515 | int irq, result = 0; |
517 | struct octeon_i2c *i2c; | 516 | struct octeon_i2c *i2c; |
518 | struct octeon_i2c_data *i2c_data; | ||
519 | struct resource *res_mem; | 517 | struct resource *res_mem; |
520 | 518 | ||
521 | /* All adaptors have an irq. */ | 519 | /* All adaptors have an irq. */ |
@@ -523,86 +521,90 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev) | |||
523 | if (irq < 0) | 521 | if (irq < 0) |
524 | return irq; | 522 | return irq; |
525 | 523 | ||
526 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); | 524 | i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); |
527 | if (!i2c) { | 525 | if (!i2c) { |
528 | dev_err(&pdev->dev, "kzalloc failed\n"); | 526 | dev_err(&pdev->dev, "kzalloc failed\n"); |
529 | result = -ENOMEM; | 527 | result = -ENOMEM; |
530 | goto out; | 528 | goto out; |
531 | } | 529 | } |
532 | i2c->dev = &pdev->dev; | 530 | i2c->dev = &pdev->dev; |
533 | i2c_data = pdev->dev.platform_data; | ||
534 | 531 | ||
535 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 532 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
536 | 533 | ||
537 | if (res_mem == NULL) { | 534 | if (res_mem == NULL) { |
538 | dev_err(i2c->dev, "found no memory resource\n"); | 535 | dev_err(i2c->dev, "found no memory resource\n"); |
539 | result = -ENXIO; | 536 | result = -ENXIO; |
540 | goto fail_region; | 537 | goto out; |
541 | } | 538 | } |
539 | i2c->twsi_phys = res_mem->start; | ||
540 | i2c->regsize = resource_size(res_mem); | ||
542 | 541 | ||
543 | if (i2c_data == NULL) { | 542 | /* |
544 | dev_err(i2c->dev, "no I2C frequency data\n"); | 543 | * "clock-rate" is a legacy binding, the official binding is |
544 | * "clock-frequency". Try the official one first and then | ||
545 | * fall back if it doesn't exist. | ||
546 | */ | ||
547 | if (of_property_read_u32(pdev->dev.of_node, | ||
548 | "clock-frequency", &i2c->twsi_freq) && | ||
549 | of_property_read_u32(pdev->dev.of_node, | ||
550 | "clock-rate", &i2c->twsi_freq)) { | ||
551 | dev_err(i2c->dev, | ||
552 | "no I2C 'clock-rate' or 'clock-frequency' property\n"); | ||
545 | result = -ENXIO; | 553 | result = -ENXIO; |
546 | goto fail_region; | 554 | goto out; |
547 | } | 555 | } |
548 | 556 | ||
549 | i2c->twsi_phys = res_mem->start; | 557 | i2c->sys_freq = octeon_get_io_clock_rate(); |
550 | i2c->regsize = resource_size(res_mem); | ||
551 | i2c->twsi_freq = i2c_data->i2c_freq; | ||
552 | i2c->sys_freq = i2c_data->sys_freq; | ||
553 | 558 | ||
554 | if (!request_mem_region(i2c->twsi_phys, i2c->regsize, res_mem->name)) { | 559 | if (!devm_request_mem_region(&pdev->dev, i2c->twsi_phys, i2c->regsize, |
560 | res_mem->name)) { | ||
555 | dev_err(i2c->dev, "request_mem_region failed\n"); | 561 | dev_err(i2c->dev, "request_mem_region failed\n"); |
556 | goto fail_region; | 562 | goto out; |
557 | } | 563 | } |
558 | i2c->twsi_base = ioremap(i2c->twsi_phys, i2c->regsize); | 564 | i2c->twsi_base = devm_ioremap(&pdev->dev, i2c->twsi_phys, i2c->regsize); |
559 | 565 | ||
560 | init_waitqueue_head(&i2c->queue); | 566 | init_waitqueue_head(&i2c->queue); |
561 | 567 | ||
562 | i2c->irq = irq; | 568 | i2c->irq = irq; |
563 | 569 | ||
564 | result = request_irq(i2c->irq, octeon_i2c_isr, 0, DRV_NAME, i2c); | 570 | result = devm_request_irq(&pdev->dev, i2c->irq, |
571 | octeon_i2c_isr, 0, DRV_NAME, i2c); | ||
565 | if (result < 0) { | 572 | if (result < 0) { |
566 | dev_err(i2c->dev, "failed to attach interrupt\n"); | 573 | dev_err(i2c->dev, "failed to attach interrupt\n"); |
567 | goto fail_irq; | 574 | goto out; |
568 | } | 575 | } |
569 | 576 | ||
570 | result = octeon_i2c_initlowlevel(i2c); | 577 | result = octeon_i2c_initlowlevel(i2c); |
571 | if (result) { | 578 | if (result) { |
572 | dev_err(i2c->dev, "init low level failed\n"); | 579 | dev_err(i2c->dev, "init low level failed\n"); |
573 | goto fail_add; | 580 | goto out; |
574 | } | 581 | } |
575 | 582 | ||
576 | result = octeon_i2c_setclock(i2c); | 583 | result = octeon_i2c_setclock(i2c); |
577 | if (result) { | 584 | if (result) { |
578 | dev_err(i2c->dev, "clock init failed\n"); | 585 | dev_err(i2c->dev, "clock init failed\n"); |
579 | goto fail_add; | 586 | goto out; |
580 | } | 587 | } |
581 | 588 | ||
582 | i2c->adap = octeon_i2c_ops; | 589 | i2c->adap = octeon_i2c_ops; |
583 | i2c->adap.dev.parent = &pdev->dev; | 590 | i2c->adap.dev.parent = &pdev->dev; |
584 | i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0; | 591 | i2c->adap.dev.of_node = pdev->dev.of_node; |
585 | i2c_set_adapdata(&i2c->adap, i2c); | 592 | i2c_set_adapdata(&i2c->adap, i2c); |
586 | platform_set_drvdata(pdev, i2c); | 593 | platform_set_drvdata(pdev, i2c); |
587 | 594 | ||
588 | result = i2c_add_numbered_adapter(&i2c->adap); | 595 | result = i2c_add_adapter(&i2c->adap); |
589 | if (result < 0) { | 596 | if (result < 0) { |
590 | dev_err(i2c->dev, "failed to add adapter\n"); | 597 | dev_err(i2c->dev, "failed to add adapter\n"); |
591 | goto fail_add; | 598 | goto fail_add; |
592 | } | 599 | } |
593 | |||
594 | dev_info(i2c->dev, "version %s\n", DRV_VERSION); | 600 | dev_info(i2c->dev, "version %s\n", DRV_VERSION); |
595 | 601 | ||
596 | return result; | 602 | of_i2c_register_devices(&i2c->adap); |
603 | |||
604 | return 0; | ||
597 | 605 | ||
598 | fail_add: | 606 | fail_add: |
599 | platform_set_drvdata(pdev, NULL); | 607 | platform_set_drvdata(pdev, NULL); |
600 | free_irq(i2c->irq, i2c); | ||
601 | fail_irq: | ||
602 | iounmap(i2c->twsi_base); | ||
603 | release_mem_region(i2c->twsi_phys, i2c->regsize); | ||
604 | fail_region: | ||
605 | kfree(i2c); | ||
606 | out: | 608 | out: |
607 | return result; | 609 | return result; |
608 | }; | 610 | }; |
@@ -613,19 +615,24 @@ static int __devexit octeon_i2c_remove(struct platform_device *pdev) | |||
613 | 615 | ||
614 | i2c_del_adapter(&i2c->adap); | 616 | i2c_del_adapter(&i2c->adap); |
615 | platform_set_drvdata(pdev, NULL); | 617 | platform_set_drvdata(pdev, NULL); |
616 | free_irq(i2c->irq, i2c); | ||
617 | iounmap(i2c->twsi_base); | ||
618 | release_mem_region(i2c->twsi_phys, i2c->regsize); | ||
619 | kfree(i2c); | ||
620 | return 0; | 618 | return 0; |
621 | }; | 619 | }; |
622 | 620 | ||
621 | static struct of_device_id octeon_i2c_match[] = { | ||
622 | { | ||
623 | .compatible = "cavium,octeon-3860-twsi", | ||
624 | }, | ||
625 | {}, | ||
626 | }; | ||
627 | MODULE_DEVICE_TABLE(of, octeon_i2c_match); | ||
628 | |||
623 | static struct platform_driver octeon_i2c_driver = { | 629 | static struct platform_driver octeon_i2c_driver = { |
624 | .probe = octeon_i2c_probe, | 630 | .probe = octeon_i2c_probe, |
625 | .remove = __devexit_p(octeon_i2c_remove), | 631 | .remove = __devexit_p(octeon_i2c_remove), |
626 | .driver = { | 632 | .driver = { |
627 | .owner = THIS_MODULE, | 633 | .owner = THIS_MODULE, |
628 | .name = DRV_NAME, | 634 | .name = DRV_NAME, |
635 | .of_match_table = octeon_i2c_match, | ||
629 | }, | 636 | }, |
630 | }; | 637 | }; |
631 | 638 | ||
@@ -635,4 +642,3 @@ MODULE_AUTHOR("Michael Lawnick <michael.lawnick.ext@nsn.com>"); | |||
635 | MODULE_DESCRIPTION("I2C-Bus adapter for Cavium OCTEON processors"); | 642 | MODULE_DESCRIPTION("I2C-Bus adapter for Cavium OCTEON processors"); |
636 | MODULE_LICENSE("GPL"); | 643 | MODULE_LICENSE("GPL"); |
637 | MODULE_VERSION(DRV_VERSION); | 644 | MODULE_VERSION(DRV_VERSION); |
638 | MODULE_ALIAS("platform:" DRV_NAME); | ||
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 801df6000e9b..5d19a49803c1 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -49,8 +49,8 @@ | |||
49 | 49 | ||
50 | /* I2C controller revisions present on specific hardware */ | 50 | /* I2C controller revisions present on specific hardware */ |
51 | #define OMAP_I2C_REV_ON_2430 0x36 | 51 | #define OMAP_I2C_REV_ON_2430 0x36 |
52 | #define OMAP_I2C_REV_ON_3430 0x3C | 52 | #define OMAP_I2C_REV_ON_3430_3530 0x3C |
53 | #define OMAP_I2C_REV_ON_3530_4430 0x40 | 53 | #define OMAP_I2C_REV_ON_3630_4430 0x40 |
54 | 54 | ||
55 | /* timeout waiting for the controller to respond */ | 55 | /* timeout waiting for the controller to respond */ |
56 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) | 56 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) |
@@ -173,7 +173,7 @@ enum { | |||
173 | 173 | ||
174 | /* Errata definitions */ | 174 | /* Errata definitions */ |
175 | #define I2C_OMAP_ERRATA_I207 (1 << 0) | 175 | #define I2C_OMAP_ERRATA_I207 (1 << 0) |
176 | #define I2C_OMAP3_1P153 (1 << 1) | 176 | #define I2C_OMAP_ERRATA_I462 (1 << 1) |
177 | 177 | ||
178 | struct omap_i2c_dev { | 178 | struct omap_i2c_dev { |
179 | struct device *dev; | 179 | struct device *dev; |
@@ -269,47 +269,6 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) | |||
269 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); | 269 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); |
270 | } | 270 | } |
271 | 271 | ||
272 | static void omap_i2c_unidle(struct omap_i2c_dev *dev) | ||
273 | { | ||
274 | if (dev->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) { | ||
275 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | ||
276 | omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate); | ||
277 | omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate); | ||
278 | omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate); | ||
279 | omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate); | ||
280 | omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, dev->syscstate); | ||
281 | omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate); | ||
282 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); | ||
283 | } | ||
284 | |||
285 | /* | ||
286 | * Don't write to this register if the IE state is 0 as it can | ||
287 | * cause deadlock. | ||
288 | */ | ||
289 | if (dev->iestate) | ||
290 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate); | ||
291 | } | ||
292 | |||
293 | static void omap_i2c_idle(struct omap_i2c_dev *dev) | ||
294 | { | ||
295 | u16 iv; | ||
296 | |||
297 | dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); | ||
298 | if (dev->dtrev == OMAP_I2C_IP_VERSION_2) | ||
299 | omap_i2c_write_reg(dev, OMAP_I2C_IP_V2_IRQENABLE_CLR, 1); | ||
300 | else | ||
301 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); | ||
302 | |||
303 | if (dev->rev < OMAP_I2C_OMAP1_REV_2) { | ||
304 | iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ | ||
305 | } else { | ||
306 | omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate); | ||
307 | |||
308 | /* Flush posted write */ | ||
309 | omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); | ||
310 | } | ||
311 | } | ||
312 | |||
313 | static int omap_i2c_init(struct omap_i2c_dev *dev) | 272 | static int omap_i2c_init(struct omap_i2c_dev *dev) |
314 | { | 273 | { |
315 | u16 psc = 0, scll = 0, sclh = 0, buf = 0; | 274 | u16 psc = 0, scll = 0, sclh = 0, buf = 0; |
@@ -346,7 +305,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
346 | omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, | 305 | omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, |
347 | SYSC_AUTOIDLE_MASK); | 306 | SYSC_AUTOIDLE_MASK); |
348 | 307 | ||
349 | } else if (dev->rev >= OMAP_I2C_REV_ON_3430) { | 308 | } else if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) { |
350 | dev->syscstate = SYSC_AUTOIDLE_MASK; | 309 | dev->syscstate = SYSC_AUTOIDLE_MASK; |
351 | dev->syscstate |= SYSC_ENAWAKEUP_MASK; | 310 | dev->syscstate |= SYSC_ENAWAKEUP_MASK; |
352 | dev->syscstate |= (SYSC_IDLEMODE_SMART << | 311 | dev->syscstate |= (SYSC_IDLEMODE_SMART << |
@@ -468,11 +427,6 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
468 | /* Take the I2C module out of reset: */ | 427 | /* Take the I2C module out of reset: */ |
469 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); | 428 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); |
470 | 429 | ||
471 | dev->errata = 0; | ||
472 | |||
473 | if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207) | ||
474 | dev->errata |= I2C_OMAP_ERRATA_I207; | ||
475 | |||
476 | /* Enable interrupts */ | 430 | /* Enable interrupts */ |
477 | dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | | 431 | dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | |
478 | OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | | 432 | OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | |
@@ -514,7 +468,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
514 | struct i2c_msg *msg, int stop) | 468 | struct i2c_msg *msg, int stop) |
515 | { | 469 | { |
516 | struct omap_i2c_dev *dev = i2c_get_adapdata(adap); | 470 | struct omap_i2c_dev *dev = i2c_get_adapdata(adap); |
517 | int r; | 471 | unsigned long timeout; |
518 | u16 w; | 472 | u16 w; |
519 | 473 | ||
520 | dev_dbg(dev->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n", | 474 | dev_dbg(dev->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n", |
@@ -536,7 +490,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
536 | w |= OMAP_I2C_BUF_RXFIF_CLR | OMAP_I2C_BUF_TXFIF_CLR; | 490 | w |= OMAP_I2C_BUF_RXFIF_CLR | OMAP_I2C_BUF_TXFIF_CLR; |
537 | omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, w); | 491 | omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, w); |
538 | 492 | ||
539 | init_completion(&dev->cmd_complete); | 493 | INIT_COMPLETION(dev->cmd_complete); |
540 | dev->cmd_err = 0; | 494 | dev->cmd_err = 0; |
541 | 495 | ||
542 | w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT; | 496 | w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT; |
@@ -545,6 +499,8 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
545 | if (dev->speed > 400) | 499 | if (dev->speed > 400) |
546 | w |= OMAP_I2C_CON_OPMODE_HS; | 500 | w |= OMAP_I2C_CON_OPMODE_HS; |
547 | 501 | ||
502 | if (msg->flags & I2C_M_STOP) | ||
503 | stop = 1; | ||
548 | if (msg->flags & I2C_M_TEN) | 504 | if (msg->flags & I2C_M_TEN) |
549 | w |= OMAP_I2C_CON_XA; | 505 | w |= OMAP_I2C_CON_XA; |
550 | if (!(msg->flags & I2C_M_RD)) | 506 | if (!(msg->flags & I2C_M_RD)) |
@@ -582,12 +538,10 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
582 | * REVISIT: We should abort the transfer on signals, but the bus goes | 538 | * REVISIT: We should abort the transfer on signals, but the bus goes |
583 | * into arbitration and we're currently unable to recover from it. | 539 | * into arbitration and we're currently unable to recover from it. |
584 | */ | 540 | */ |
585 | r = wait_for_completion_timeout(&dev->cmd_complete, | 541 | timeout = wait_for_completion_timeout(&dev->cmd_complete, |
586 | OMAP_I2C_TIMEOUT); | 542 | OMAP_I2C_TIMEOUT); |
587 | dev->buf_len = 0; | 543 | dev->buf_len = 0; |
588 | if (r < 0) | 544 | if (timeout == 0) { |
589 | return r; | ||
590 | if (r == 0) { | ||
591 | dev_err(dev->dev, "controller timed out\n"); | 545 | dev_err(dev->dev, "controller timed out\n"); |
592 | omap_i2c_init(dev); | 546 | omap_i2c_init(dev); |
593 | return -ETIMEDOUT; | 547 | return -ETIMEDOUT; |
@@ -628,7 +582,9 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) | |||
628 | int i; | 582 | int i; |
629 | int r; | 583 | int r; |
630 | 584 | ||
631 | pm_runtime_get_sync(dev->dev); | 585 | r = pm_runtime_get_sync(dev->dev); |
586 | if (IS_ERR_VALUE(r)) | ||
587 | goto out; | ||
632 | 588 | ||
633 | r = omap_i2c_wait_for_bb(dev); | 589 | r = omap_i2c_wait_for_bb(dev); |
634 | if (r < 0) | 590 | if (r < 0) |
@@ -658,7 +614,8 @@ out: | |||
658 | static u32 | 614 | static u32 |
659 | omap_i2c_func(struct i2c_adapter *adap) | 615 | omap_i2c_func(struct i2c_adapter *adap) |
660 | { | 616 | { |
661 | return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK); | 617 | return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK) | |
618 | I2C_FUNC_PROTOCOL_MANGLING; | ||
662 | } | 619 | } |
663 | 620 | ||
664 | static inline void | 621 | static inline void |
@@ -764,11 +721,11 @@ omap_i2c_omap1_isr(int this_irq, void *dev_id) | |||
764 | #endif | 721 | #endif |
765 | 722 | ||
766 | /* | 723 | /* |
767 | * OMAP3430 Errata 1.153: When an XRDY/XDR is hit, wait for XUDF before writing | 724 | * OMAP3430 Errata i462: When an XRDY/XDR is hit, wait for XUDF before writing |
768 | * data to DATA_REG. Otherwise some data bytes can be lost while transferring | 725 | * data to DATA_REG. Otherwise some data bytes can be lost while transferring |
769 | * them from the memory to the I2C interface. | 726 | * them from the memory to the I2C interface. |
770 | */ | 727 | */ |
771 | static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err) | 728 | static int errata_omap3_i462(struct omap_i2c_dev *dev, u16 *stat, int *err) |
772 | { | 729 | { |
773 | unsigned long timeout = 10000; | 730 | unsigned long timeout = 10000; |
774 | 731 | ||
@@ -776,7 +733,6 @@ static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err) | |||
776 | if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { | 733 | if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { |
777 | omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY | | 734 | omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY | |
778 | OMAP_I2C_STAT_XDR)); | 735 | OMAP_I2C_STAT_XDR)); |
779 | *err |= OMAP_I2C_STAT_XUDF; | ||
780 | return -ETIMEDOUT; | 736 | return -ETIMEDOUT; |
781 | } | 737 | } |
782 | 738 | ||
@@ -789,6 +745,7 @@ static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err) | |||
789 | return 0; | 745 | return 0; |
790 | } | 746 | } |
791 | 747 | ||
748 | *err |= OMAP_I2C_STAT_XUDF; | ||
792 | return 0; | 749 | return 0; |
793 | } | 750 | } |
794 | 751 | ||
@@ -927,8 +884,8 @@ complete: | |||
927 | break; | 884 | break; |
928 | } | 885 | } |
929 | 886 | ||
930 | if ((dev->errata & I2C_OMAP3_1P153) && | 887 | if ((dev->errata & I2C_OMAP_ERRATA_I462) && |
931 | errata_omap3_1p153(dev, &stat, &err)) | 888 | errata_omap3_i462(dev, &stat, &err)) |
932 | goto complete; | 889 | goto complete; |
933 | 890 | ||
934 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); | 891 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); |
@@ -1045,6 +1002,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1045 | } | 1002 | } |
1046 | 1003 | ||
1047 | platform_set_drvdata(pdev, dev); | 1004 | platform_set_drvdata(pdev, dev); |
1005 | init_completion(&dev->cmd_complete); | ||
1048 | 1006 | ||
1049 | dev->reg_shift = (dev->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3; | 1007 | dev->reg_shift = (dev->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3; |
1050 | 1008 | ||
@@ -1054,12 +1012,19 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1054 | dev->regs = (u8 *)reg_map_ip_v1; | 1012 | dev->regs = (u8 *)reg_map_ip_v1; |
1055 | 1013 | ||
1056 | pm_runtime_enable(dev->dev); | 1014 | pm_runtime_enable(dev->dev); |
1057 | pm_runtime_get_sync(dev->dev); | 1015 | r = pm_runtime_get_sync(dev->dev); |
1016 | if (IS_ERR_VALUE(r)) | ||
1017 | goto err_free_mem; | ||
1058 | 1018 | ||
1059 | dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; | 1019 | dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; |
1060 | 1020 | ||
1061 | if (dev->rev <= OMAP_I2C_REV_ON_3430) | 1021 | dev->errata = 0; |
1062 | dev->errata |= I2C_OMAP3_1P153; | 1022 | |
1023 | if (dev->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207) | ||
1024 | dev->errata |= I2C_OMAP_ERRATA_I207; | ||
1025 | |||
1026 | if (dev->rev <= OMAP_I2C_REV_ON_3430_3530) | ||
1027 | dev->errata |= I2C_OMAP_ERRATA_I462; | ||
1063 | 1028 | ||
1064 | if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) { | 1029 | if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) { |
1065 | u16 s; | 1030 | u16 s; |
@@ -1076,7 +1041,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1076 | 1041 | ||
1077 | dev->fifo_size = (dev->fifo_size / 2); | 1042 | dev->fifo_size = (dev->fifo_size / 2); |
1078 | 1043 | ||
1079 | if (dev->rev >= OMAP_I2C_REV_ON_3530_4430) | 1044 | if (dev->rev >= OMAP_I2C_REV_ON_3630_4430) |
1080 | dev->b_hw = 0; /* Disable hardware fixes */ | 1045 | dev->b_hw = 0; /* Disable hardware fixes */ |
1081 | else | 1046 | else |
1082 | dev->b_hw = 1; /* Enable hardware fixes */ | 1047 | dev->b_hw = 1; /* Enable hardware fixes */ |
@@ -1092,7 +1057,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1092 | 1057 | ||
1093 | isr = (dev->rev < OMAP_I2C_OMAP1_REV_2) ? omap_i2c_omap1_isr : | 1058 | isr = (dev->rev < OMAP_I2C_OMAP1_REV_2) ? omap_i2c_omap1_isr : |
1094 | omap_i2c_isr; | 1059 | omap_i2c_isr; |
1095 | r = request_irq(dev->irq, isr, 0, pdev->name, dev); | 1060 | r = request_irq(dev->irq, isr, IRQF_NO_SUSPEND, pdev->name, dev); |
1096 | 1061 | ||
1097 | if (r) { | 1062 | if (r) { |
1098 | dev_err(dev->dev, "failure requesting irq %i\n", dev->irq); | 1063 | dev_err(dev->dev, "failure requesting irq %i\n", dev->irq); |
@@ -1102,8 +1067,6 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1102 | dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", pdev->id, | 1067 | dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", pdev->id, |
1103 | dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed); | 1068 | dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed); |
1104 | 1069 | ||
1105 | pm_runtime_put(dev->dev); | ||
1106 | |||
1107 | adap = &dev->adapter; | 1070 | adap = &dev->adapter; |
1108 | i2c_set_adapdata(adap, dev); | 1071 | i2c_set_adapdata(adap, dev); |
1109 | adap->owner = THIS_MODULE; | 1072 | adap->owner = THIS_MODULE; |
@@ -1123,6 +1086,8 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1123 | 1086 | ||
1124 | of_i2c_register_devices(adap); | 1087 | of_i2c_register_devices(adap); |
1125 | 1088 | ||
1089 | pm_runtime_put(dev->dev); | ||
1090 | |||
1126 | return 0; | 1091 | return 0; |
1127 | 1092 | ||
1128 | err_free_irq: | 1093 | err_free_irq: |
@@ -1131,6 +1096,7 @@ err_unuse_clocks: | |||
1131 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 1096 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
1132 | pm_runtime_put(dev->dev); | 1097 | pm_runtime_put(dev->dev); |
1133 | iounmap(dev->base); | 1098 | iounmap(dev->base); |
1099 | pm_runtime_disable(&pdev->dev); | ||
1134 | err_free_mem: | 1100 | err_free_mem: |
1135 | platform_set_drvdata(pdev, NULL); | 1101 | platform_set_drvdata(pdev, NULL); |
1136 | kfree(dev); | 1102 | kfree(dev); |
@@ -1140,17 +1106,23 @@ err_release_region: | |||
1140 | return r; | 1106 | return r; |
1141 | } | 1107 | } |
1142 | 1108 | ||
1143 | static int | 1109 | static int __devexit omap_i2c_remove(struct platform_device *pdev) |
1144 | omap_i2c_remove(struct platform_device *pdev) | ||
1145 | { | 1110 | { |
1146 | struct omap_i2c_dev *dev = platform_get_drvdata(pdev); | 1111 | struct omap_i2c_dev *dev = platform_get_drvdata(pdev); |
1147 | struct resource *mem; | 1112 | struct resource *mem; |
1113 | int ret; | ||
1148 | 1114 | ||
1149 | platform_set_drvdata(pdev, NULL); | 1115 | platform_set_drvdata(pdev, NULL); |
1150 | 1116 | ||
1151 | free_irq(dev->irq, dev); | 1117 | free_irq(dev->irq, dev); |
1152 | i2c_del_adapter(&dev->adapter); | 1118 | i2c_del_adapter(&dev->adapter); |
1119 | ret = pm_runtime_get_sync(&pdev->dev); | ||
1120 | if (IS_ERR_VALUE(ret)) | ||
1121 | return ret; | ||
1122 | |||
1153 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 1123 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
1124 | pm_runtime_put(&pdev->dev); | ||
1125 | pm_runtime_disable(&pdev->dev); | ||
1154 | iounmap(dev->base); | 1126 | iounmap(dev->base); |
1155 | kfree(dev); | 1127 | kfree(dev); |
1156 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1128 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -1158,13 +1130,26 @@ omap_i2c_remove(struct platform_device *pdev) | |||
1158 | return 0; | 1130 | return 0; |
1159 | } | 1131 | } |
1160 | 1132 | ||
1133 | #ifdef CONFIG_PM | ||
1161 | #ifdef CONFIG_PM_RUNTIME | 1134 | #ifdef CONFIG_PM_RUNTIME |
1162 | static int omap_i2c_runtime_suspend(struct device *dev) | 1135 | static int omap_i2c_runtime_suspend(struct device *dev) |
1163 | { | 1136 | { |
1164 | struct platform_device *pdev = to_platform_device(dev); | 1137 | struct platform_device *pdev = to_platform_device(dev); |
1165 | struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); | 1138 | struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); |
1139 | u16 iv; | ||
1140 | |||
1141 | _dev->iestate = omap_i2c_read_reg(_dev, OMAP_I2C_IE_REG); | ||
1142 | |||
1143 | omap_i2c_write_reg(_dev, OMAP_I2C_IE_REG, 0); | ||
1166 | 1144 | ||
1167 | omap_i2c_idle(_dev); | 1145 | if (_dev->rev < OMAP_I2C_OMAP1_REV_2) { |
1146 | iv = omap_i2c_read_reg(_dev, OMAP_I2C_IV_REG); /* Read clears */ | ||
1147 | } else { | ||
1148 | omap_i2c_write_reg(_dev, OMAP_I2C_STAT_REG, _dev->iestate); | ||
1149 | |||
1150 | /* Flush posted write */ | ||
1151 | omap_i2c_read_reg(_dev, OMAP_I2C_STAT_REG); | ||
1152 | } | ||
1168 | 1153 | ||
1169 | return 0; | 1154 | return 0; |
1170 | } | 1155 | } |
@@ -1174,23 +1159,40 @@ static int omap_i2c_runtime_resume(struct device *dev) | |||
1174 | struct platform_device *pdev = to_platform_device(dev); | 1159 | struct platform_device *pdev = to_platform_device(dev); |
1175 | struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); | 1160 | struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); |
1176 | 1161 | ||
1177 | omap_i2c_unidle(_dev); | 1162 | if (_dev->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) { |
1163 | omap_i2c_write_reg(_dev, OMAP_I2C_CON_REG, 0); | ||
1164 | omap_i2c_write_reg(_dev, OMAP_I2C_PSC_REG, _dev->pscstate); | ||
1165 | omap_i2c_write_reg(_dev, OMAP_I2C_SCLL_REG, _dev->scllstate); | ||
1166 | omap_i2c_write_reg(_dev, OMAP_I2C_SCLH_REG, _dev->sclhstate); | ||
1167 | omap_i2c_write_reg(_dev, OMAP_I2C_BUF_REG, _dev->bufstate); | ||
1168 | omap_i2c_write_reg(_dev, OMAP_I2C_SYSC_REG, _dev->syscstate); | ||
1169 | omap_i2c_write_reg(_dev, OMAP_I2C_WE_REG, _dev->westate); | ||
1170 | omap_i2c_write_reg(_dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); | ||
1171 | } | ||
1172 | |||
1173 | /* | ||
1174 | * Don't write to this register if the IE state is 0 as it can | ||
1175 | * cause deadlock. | ||
1176 | */ | ||
1177 | if (_dev->iestate) | ||
1178 | omap_i2c_write_reg(_dev, OMAP_I2C_IE_REG, _dev->iestate); | ||
1178 | 1179 | ||
1179 | return 0; | 1180 | return 0; |
1180 | } | 1181 | } |
1182 | #endif /* CONFIG_PM_RUNTIME */ | ||
1181 | 1183 | ||
1182 | static struct dev_pm_ops omap_i2c_pm_ops = { | 1184 | static struct dev_pm_ops omap_i2c_pm_ops = { |
1183 | .runtime_suspend = omap_i2c_runtime_suspend, | 1185 | SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, |
1184 | .runtime_resume = omap_i2c_runtime_resume, | 1186 | omap_i2c_runtime_resume, NULL) |
1185 | }; | 1187 | }; |
1186 | #define OMAP_I2C_PM_OPS (&omap_i2c_pm_ops) | 1188 | #define OMAP_I2C_PM_OPS (&omap_i2c_pm_ops) |
1187 | #else | 1189 | #else |
1188 | #define OMAP_I2C_PM_OPS NULL | 1190 | #define OMAP_I2C_PM_OPS NULL |
1189 | #endif | 1191 | #endif /* CONFIG_PM */ |
1190 | 1192 | ||
1191 | static struct platform_driver omap_i2c_driver = { | 1193 | static struct platform_driver omap_i2c_driver = { |
1192 | .probe = omap_i2c_probe, | 1194 | .probe = omap_i2c_probe, |
1193 | .remove = omap_i2c_remove, | 1195 | .remove = __devexit_p(omap_i2c_remove), |
1194 | .driver = { | 1196 | .driver = { |
1195 | .name = "omap_i2c", | 1197 | .name = "omap_i2c", |
1196 | .owner = THIS_MODULE, | 1198 | .owner = THIS_MODULE, |
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index eaaea73209c5..12edefd4183a 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c | |||
@@ -415,19 +415,8 @@ static struct pci_driver pasemi_smb_driver = { | |||
415 | .remove = __devexit_p(pasemi_smb_remove), | 415 | .remove = __devexit_p(pasemi_smb_remove), |
416 | }; | 416 | }; |
417 | 417 | ||
418 | static int __init pasemi_smb_init(void) | 418 | module_pci_driver(pasemi_smb_driver); |
419 | { | ||
420 | return pci_register_driver(&pasemi_smb_driver); | ||
421 | } | ||
422 | |||
423 | static void __exit pasemi_smb_exit(void) | ||
424 | { | ||
425 | pci_unregister_driver(&pasemi_smb_driver); | ||
426 | } | ||
427 | 419 | ||
428 | MODULE_LICENSE("GPL"); | 420 | MODULE_LICENSE("GPL"); |
429 | MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>"); | 421 | MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>"); |
430 | MODULE_DESCRIPTION("PA Semi PWRficient SMBus driver"); | 422 | MODULE_DESCRIPTION("PA Semi PWRficient SMBus driver"); |
431 | |||
432 | module_init(pasemi_smb_init); | ||
433 | module_exit(pasemi_smb_exit); | ||
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index c14d48dd601a..ef511df2c965 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -21,11 +21,12 @@ | |||
21 | Supports: | 21 | Supports: |
22 | Intel PIIX4, 440MX | 22 | Intel PIIX4, 440MX |
23 | Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100 | 23 | Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100 |
24 | ATI IXP200, IXP300, IXP400, SB600, SB700, SB800 | 24 | ATI IXP200, IXP300, IXP400, SB600, SB700/SP5100, SB800 |
25 | AMD Hudson-2 | 25 | AMD Hudson-2 |
26 | SMSC Victory66 | 26 | SMSC Victory66 |
27 | 27 | ||
28 | Note: we assume there can only be one device, with one SMBus interface. | 28 | Note: we assume there can only be one device, with one or more |
29 | SMBus interfaces. | ||
29 | */ | 30 | */ |
30 | 31 | ||
31 | #include <linux/module.h> | 32 | #include <linux/module.h> |
@@ -94,10 +95,8 @@ MODULE_PARM_DESC(force_addr, | |||
94 | "Forcibly enable the PIIX4 at the given address. " | 95 | "Forcibly enable the PIIX4 at the given address. " |
95 | "EXTREMELY DANGEROUS!"); | 96 | "EXTREMELY DANGEROUS!"); |
96 | 97 | ||
97 | static unsigned short piix4_smba; | ||
98 | static int srvrworks_csb5_delay; | 98 | static int srvrworks_csb5_delay; |
99 | static struct pci_driver piix4_driver; | 99 | static struct pci_driver piix4_driver; |
100 | static struct i2c_adapter piix4_adapter; | ||
101 | 100 | ||
102 | static struct dmi_system_id __devinitdata piix4_dmi_blacklist[] = { | 101 | static struct dmi_system_id __devinitdata piix4_dmi_blacklist[] = { |
103 | { | 102 | { |
@@ -127,10 +126,15 @@ static struct dmi_system_id __devinitdata piix4_dmi_ibm[] = { | |||
127 | { }, | 126 | { }, |
128 | }; | 127 | }; |
129 | 128 | ||
129 | struct i2c_piix4_adapdata { | ||
130 | unsigned short smba; | ||
131 | }; | ||
132 | |||
130 | static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, | 133 | static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, |
131 | const struct pci_device_id *id) | 134 | const struct pci_device_id *id) |
132 | { | 135 | { |
133 | unsigned char temp; | 136 | unsigned char temp; |
137 | unsigned short piix4_smba; | ||
134 | 138 | ||
135 | if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && | 139 | if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && |
136 | (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5)) | 140 | (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5)) |
@@ -206,7 +210,6 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, | |||
206 | dev_err(&PIIX4_dev->dev, | 210 | dev_err(&PIIX4_dev->dev, |
207 | "Host SMBus controller not enabled!\n"); | 211 | "Host SMBus controller not enabled!\n"); |
208 | release_region(piix4_smba, SMBIOSIZE); | 212 | release_region(piix4_smba, SMBIOSIZE); |
209 | piix4_smba = 0; | ||
210 | return -ENODEV; | 213 | return -ENODEV; |
211 | } | 214 | } |
212 | } | 215 | } |
@@ -224,12 +227,13 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev, | |||
224 | "SMBus Host Controller at 0x%x, revision %d\n", | 227 | "SMBus Host Controller at 0x%x, revision %d\n", |
225 | piix4_smba, temp); | 228 | piix4_smba, temp); |
226 | 229 | ||
227 | return 0; | 230 | return piix4_smba; |
228 | } | 231 | } |
229 | 232 | ||
230 | static int __devinit piix4_setup_sb800(struct pci_dev *PIIX4_dev, | 233 | static int __devinit piix4_setup_sb800(struct pci_dev *PIIX4_dev, |
231 | const struct pci_device_id *id) | 234 | const struct pci_device_id *id) |
232 | { | 235 | { |
236 | unsigned short piix4_smba; | ||
233 | unsigned short smba_idx = 0xcd6; | 237 | unsigned short smba_idx = 0xcd6; |
234 | u8 smba_en_lo, smba_en_hi, i2ccfg, i2ccfg_offset = 0x10, smb_en = 0x2c; | 238 | u8 smba_en_lo, smba_en_hi, i2ccfg, i2ccfg_offset = 0x10, smb_en = 0x2c; |
235 | 239 | ||
@@ -273,7 +277,6 @@ static int __devinit piix4_setup_sb800(struct pci_dev *PIIX4_dev, | |||
273 | dev_err(&PIIX4_dev->dev, "SMBus I2C bus config region " | 277 | dev_err(&PIIX4_dev->dev, "SMBus I2C bus config region " |
274 | "0x%x already in use!\n", piix4_smba + i2ccfg_offset); | 278 | "0x%x already in use!\n", piix4_smba + i2ccfg_offset); |
275 | release_region(piix4_smba, SMBIOSIZE); | 279 | release_region(piix4_smba, SMBIOSIZE); |
276 | piix4_smba = 0; | ||
277 | return -EBUSY; | 280 | return -EBUSY; |
278 | } | 281 | } |
279 | i2ccfg = inb_p(piix4_smba + i2ccfg_offset); | 282 | i2ccfg = inb_p(piix4_smba + i2ccfg_offset); |
@@ -288,30 +291,72 @@ static int __devinit piix4_setup_sb800(struct pci_dev *PIIX4_dev, | |||
288 | "SMBus Host Controller at 0x%x, revision %d\n", | 291 | "SMBus Host Controller at 0x%x, revision %d\n", |
289 | piix4_smba, i2ccfg >> 4); | 292 | piix4_smba, i2ccfg >> 4); |
290 | 293 | ||
291 | return 0; | 294 | return piix4_smba; |
295 | } | ||
296 | |||
297 | static int __devinit piix4_setup_aux(struct pci_dev *PIIX4_dev, | ||
298 | const struct pci_device_id *id, | ||
299 | unsigned short base_reg_addr) | ||
300 | { | ||
301 | /* Set up auxiliary SMBus controllers found on some | ||
302 | * AMD chipsets e.g. SP5100 (SB700 derivative) */ | ||
303 | |||
304 | unsigned short piix4_smba; | ||
305 | |||
306 | /* Read address of auxiliary SMBus controller */ | ||
307 | pci_read_config_word(PIIX4_dev, base_reg_addr, &piix4_smba); | ||
308 | if ((piix4_smba & 1) == 0) { | ||
309 | dev_dbg(&PIIX4_dev->dev, | ||
310 | "Auxiliary SMBus controller not enabled\n"); | ||
311 | return -ENODEV; | ||
312 | } | ||
313 | |||
314 | piix4_smba &= 0xfff0; | ||
315 | if (piix4_smba == 0) { | ||
316 | dev_dbg(&PIIX4_dev->dev, | ||
317 | "Auxiliary SMBus base address uninitialized\n"); | ||
318 | return -ENODEV; | ||
319 | } | ||
320 | |||
321 | if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) | ||
322 | return -ENODEV; | ||
323 | |||
324 | if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) { | ||
325 | dev_err(&PIIX4_dev->dev, "Auxiliary SMBus region 0x%x " | ||
326 | "already in use!\n", piix4_smba); | ||
327 | return -EBUSY; | ||
328 | } | ||
329 | |||
330 | dev_info(&PIIX4_dev->dev, | ||
331 | "Auxiliary SMBus Host Controller at 0x%x\n", | ||
332 | piix4_smba); | ||
333 | |||
334 | return piix4_smba; | ||
292 | } | 335 | } |
293 | 336 | ||
294 | static int piix4_transaction(void) | 337 | static int piix4_transaction(struct i2c_adapter *piix4_adapter) |
295 | { | 338 | { |
339 | struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(piix4_adapter); | ||
340 | unsigned short piix4_smba = adapdata->smba; | ||
296 | int temp; | 341 | int temp; |
297 | int result = 0; | 342 | int result = 0; |
298 | int timeout = 0; | 343 | int timeout = 0; |
299 | 344 | ||
300 | dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " | 345 | dev_dbg(&piix4_adapter->dev, "Transaction (pre): CNT=%02x, CMD=%02x, " |
301 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), | 346 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), |
302 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | 347 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), |
303 | inb_p(SMBHSTDAT1)); | 348 | inb_p(SMBHSTDAT1)); |
304 | 349 | ||
305 | /* Make sure the SMBus host is ready to start transmitting */ | 350 | /* Make sure the SMBus host is ready to start transmitting */ |
306 | if ((temp = inb_p(SMBHSTSTS)) != 0x00) { | 351 | if ((temp = inb_p(SMBHSTSTS)) != 0x00) { |
307 | dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). " | 352 | dev_dbg(&piix4_adapter->dev, "SMBus busy (%02x). " |
308 | "Resetting...\n", temp); | 353 | "Resetting...\n", temp); |
309 | outb_p(temp, SMBHSTSTS); | 354 | outb_p(temp, SMBHSTSTS); |
310 | if ((temp = inb_p(SMBHSTSTS)) != 0x00) { | 355 | if ((temp = inb_p(SMBHSTSTS)) != 0x00) { |
311 | dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); | 356 | dev_err(&piix4_adapter->dev, "Failed! (%02x)\n", temp); |
312 | return -EBUSY; | 357 | return -EBUSY; |
313 | } else { | 358 | } else { |
314 | dev_dbg(&piix4_adapter.dev, "Successful!\n"); | 359 | dev_dbg(&piix4_adapter->dev, "Successful!\n"); |
315 | } | 360 | } |
316 | } | 361 | } |
317 | 362 | ||
@@ -330,35 +375,35 @@ static int piix4_transaction(void) | |||
330 | 375 | ||
331 | /* If the SMBus is still busy, we give up */ | 376 | /* If the SMBus is still busy, we give up */ |
332 | if (timeout == MAX_TIMEOUT) { | 377 | if (timeout == MAX_TIMEOUT) { |
333 | dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); | 378 | dev_err(&piix4_adapter->dev, "SMBus Timeout!\n"); |
334 | result = -ETIMEDOUT; | 379 | result = -ETIMEDOUT; |
335 | } | 380 | } |
336 | 381 | ||
337 | if (temp & 0x10) { | 382 | if (temp & 0x10) { |
338 | result = -EIO; | 383 | result = -EIO; |
339 | dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n"); | 384 | dev_err(&piix4_adapter->dev, "Error: Failed bus transaction\n"); |
340 | } | 385 | } |
341 | 386 | ||
342 | if (temp & 0x08) { | 387 | if (temp & 0x08) { |
343 | result = -EIO; | 388 | result = -EIO; |
344 | dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be " | 389 | dev_dbg(&piix4_adapter->dev, "Bus collision! SMBus may be " |
345 | "locked until next hard reset. (sorry!)\n"); | 390 | "locked until next hard reset. (sorry!)\n"); |
346 | /* Clock stops and slave is stuck in mid-transmission */ | 391 | /* Clock stops and slave is stuck in mid-transmission */ |
347 | } | 392 | } |
348 | 393 | ||
349 | if (temp & 0x04) { | 394 | if (temp & 0x04) { |
350 | result = -ENXIO; | 395 | result = -ENXIO; |
351 | dev_dbg(&piix4_adapter.dev, "Error: no response!\n"); | 396 | dev_dbg(&piix4_adapter->dev, "Error: no response!\n"); |
352 | } | 397 | } |
353 | 398 | ||
354 | if (inb_p(SMBHSTSTS) != 0x00) | 399 | if (inb_p(SMBHSTSTS) != 0x00) |
355 | outb_p(inb(SMBHSTSTS), SMBHSTSTS); | 400 | outb_p(inb(SMBHSTSTS), SMBHSTSTS); |
356 | 401 | ||
357 | if ((temp = inb_p(SMBHSTSTS)) != 0x00) { | 402 | if ((temp = inb_p(SMBHSTSTS)) != 0x00) { |
358 | dev_err(&piix4_adapter.dev, "Failed reset at end of " | 403 | dev_err(&piix4_adapter->dev, "Failed reset at end of " |
359 | "transaction (%02x)\n", temp); | 404 | "transaction (%02x)\n", temp); |
360 | } | 405 | } |
361 | dev_dbg(&piix4_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " | 406 | dev_dbg(&piix4_adapter->dev, "Transaction (post): CNT=%02x, CMD=%02x, " |
362 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), | 407 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), |
363 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | 408 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), |
364 | inb_p(SMBHSTDAT1)); | 409 | inb_p(SMBHSTDAT1)); |
@@ -370,6 +415,8 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, | |||
370 | unsigned short flags, char read_write, | 415 | unsigned short flags, char read_write, |
371 | u8 command, int size, union i2c_smbus_data * data) | 416 | u8 command, int size, union i2c_smbus_data * data) |
372 | { | 417 | { |
418 | struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(adap); | ||
419 | unsigned short piix4_smba = adapdata->smba; | ||
373 | int i, len; | 420 | int i, len; |
374 | int status; | 421 | int status; |
375 | 422 | ||
@@ -426,7 +473,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, | |||
426 | 473 | ||
427 | outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); | 474 | outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); |
428 | 475 | ||
429 | status = piix4_transaction(); | 476 | status = piix4_transaction(adap); |
430 | if (status) | 477 | if (status) |
431 | return status; | 478 | return status; |
432 | 479 | ||
@@ -466,12 +513,6 @@ static const struct i2c_algorithm smbus_algorithm = { | |||
466 | .functionality = piix4_func, | 513 | .functionality = piix4_func, |
467 | }; | 514 | }; |
468 | 515 | ||
469 | static struct i2c_adapter piix4_adapter = { | ||
470 | .owner = THIS_MODULE, | ||
471 | .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, | ||
472 | .algo = &smbus_algorithm, | ||
473 | }; | ||
474 | |||
475 | static DEFINE_PCI_DEVICE_TABLE(piix4_ids) = { | 516 | static DEFINE_PCI_DEVICE_TABLE(piix4_ids) = { |
476 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) }, | 517 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) }, |
477 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3) }, | 518 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3) }, |
@@ -496,6 +537,57 @@ static DEFINE_PCI_DEVICE_TABLE(piix4_ids) = { | |||
496 | 537 | ||
497 | MODULE_DEVICE_TABLE (pci, piix4_ids); | 538 | MODULE_DEVICE_TABLE (pci, piix4_ids); |
498 | 539 | ||
540 | static struct i2c_adapter *piix4_main_adapter; | ||
541 | static struct i2c_adapter *piix4_aux_adapter; | ||
542 | |||
543 | static int __devinit piix4_add_adapter(struct pci_dev *dev, | ||
544 | unsigned short smba, | ||
545 | struct i2c_adapter **padap) | ||
546 | { | ||
547 | struct i2c_adapter *adap; | ||
548 | struct i2c_piix4_adapdata *adapdata; | ||
549 | int retval; | ||
550 | |||
551 | adap = kzalloc(sizeof(*adap), GFP_KERNEL); | ||
552 | if (adap == NULL) { | ||
553 | release_region(smba, SMBIOSIZE); | ||
554 | return -ENOMEM; | ||
555 | } | ||
556 | |||
557 | adap->owner = THIS_MODULE; | ||
558 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | ||
559 | adap->algo = &smbus_algorithm; | ||
560 | |||
561 | adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL); | ||
562 | if (adapdata == NULL) { | ||
563 | kfree(adap); | ||
564 | release_region(smba, SMBIOSIZE); | ||
565 | return -ENOMEM; | ||
566 | } | ||
567 | |||
568 | adapdata->smba = smba; | ||
569 | |||
570 | /* set up the sysfs linkage to our parent device */ | ||
571 | adap->dev.parent = &dev->dev; | ||
572 | |||
573 | snprintf(adap->name, sizeof(adap->name), | ||
574 | "SMBus PIIX4 adapter at %04x", smba); | ||
575 | |||
576 | i2c_set_adapdata(adap, adapdata); | ||
577 | |||
578 | retval = i2c_add_adapter(adap); | ||
579 | if (retval) { | ||
580 | dev_err(&dev->dev, "Couldn't register adapter!\n"); | ||
581 | kfree(adapdata); | ||
582 | kfree(adap); | ||
583 | release_region(smba, SMBIOSIZE); | ||
584 | return retval; | ||
585 | } | ||
586 | |||
587 | *padap = adap; | ||
588 | return 0; | ||
589 | } | ||
590 | |||
499 | static int __devinit piix4_probe(struct pci_dev *dev, | 591 | static int __devinit piix4_probe(struct pci_dev *dev, |
500 | const struct pci_device_id *id) | 592 | const struct pci_device_id *id) |
501 | { | 593 | { |
@@ -510,30 +602,52 @@ static int __devinit piix4_probe(struct pci_dev *dev, | |||
510 | else | 602 | else |
511 | retval = piix4_setup(dev, id); | 603 | retval = piix4_setup(dev, id); |
512 | 604 | ||
513 | if (retval) | 605 | /* If no main SMBus found, give up */ |
606 | if (retval < 0) | ||
514 | return retval; | 607 | return retval; |
515 | 608 | ||
516 | /* set up the sysfs linkage to our parent device */ | 609 | /* Try to register main SMBus adapter, give up if we can't */ |
517 | piix4_adapter.dev.parent = &dev->dev; | 610 | retval = piix4_add_adapter(dev, retval, &piix4_main_adapter); |
518 | 611 | if (retval < 0) | |
519 | snprintf(piix4_adapter.name, sizeof(piix4_adapter.name), | 612 | return retval; |
520 | "SMBus PIIX4 adapter at %04x", piix4_smba); | ||
521 | 613 | ||
522 | if ((retval = i2c_add_adapter(&piix4_adapter))) { | 614 | /* Check for auxiliary SMBus on some AMD chipsets */ |
523 | dev_err(&dev->dev, "Couldn't register adapter!\n"); | 615 | if (dev->vendor == PCI_VENDOR_ID_ATI && |
524 | release_region(piix4_smba, SMBIOSIZE); | 616 | dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && |
525 | piix4_smba = 0; | 617 | dev->revision < 0x40) { |
618 | retval = piix4_setup_aux(dev, id, 0x58); | ||
619 | if (retval > 0) { | ||
620 | /* Try to add the aux adapter if it exists, | ||
621 | * piix4_add_adapter will clean up if this fails */ | ||
622 | piix4_add_adapter(dev, retval, &piix4_aux_adapter); | ||
623 | } | ||
526 | } | 624 | } |
527 | 625 | ||
528 | return retval; | 626 | return 0; |
627 | } | ||
628 | |||
629 | static void __devexit piix4_adap_remove(struct i2c_adapter *adap) | ||
630 | { | ||
631 | struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(adap); | ||
632 | |||
633 | if (adapdata->smba) { | ||
634 | i2c_del_adapter(adap); | ||
635 | release_region(adapdata->smba, SMBIOSIZE); | ||
636 | kfree(adapdata); | ||
637 | kfree(adap); | ||
638 | } | ||
529 | } | 639 | } |
530 | 640 | ||
531 | static void __devexit piix4_remove(struct pci_dev *dev) | 641 | static void __devexit piix4_remove(struct pci_dev *dev) |
532 | { | 642 | { |
533 | if (piix4_smba) { | 643 | if (piix4_main_adapter) { |
534 | i2c_del_adapter(&piix4_adapter); | 644 | piix4_adap_remove(piix4_main_adapter); |
535 | release_region(piix4_smba, SMBIOSIZE); | 645 | piix4_main_adapter = NULL; |
536 | piix4_smba = 0; | 646 | } |
647 | |||
648 | if (piix4_aux_adapter) { | ||
649 | piix4_adap_remove(piix4_aux_adapter); | ||
650 | piix4_aux_adapter = NULL; | ||
537 | } | 651 | } |
538 | } | 652 | } |
539 | 653 | ||
@@ -544,20 +658,9 @@ static struct pci_driver piix4_driver = { | |||
544 | .remove = __devexit_p(piix4_remove), | 658 | .remove = __devexit_p(piix4_remove), |
545 | }; | 659 | }; |
546 | 660 | ||
547 | static int __init i2c_piix4_init(void) | 661 | module_pci_driver(piix4_driver); |
548 | { | ||
549 | return pci_register_driver(&piix4_driver); | ||
550 | } | ||
551 | |||
552 | static void __exit i2c_piix4_exit(void) | ||
553 | { | ||
554 | pci_unregister_driver(&piix4_driver); | ||
555 | } | ||
556 | 662 | ||
557 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and " | 663 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and " |
558 | "Philip Edelbrock <phil@netroedge.com>"); | 664 | "Philip Edelbrock <phil@netroedge.com>"); |
559 | MODULE_DESCRIPTION("PIIX4 SMBus driver"); | 665 | MODULE_DESCRIPTION("PIIX4 SMBus driver"); |
560 | MODULE_LICENSE("GPL"); | 666 | MODULE_LICENSE("GPL"); |
561 | |||
562 | module_init(i2c_piix4_init); | ||
563 | module_exit(i2c_piix4_exit); | ||
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c index 07b7447ecbc9..3d71395ae1f7 100644 --- a/drivers/i2c/busses/i2c-pmcmsp.c +++ b/drivers/i2c/busses/i2c-pmcmsp.c | |||
@@ -306,8 +306,7 @@ static int __devinit pmcmsptwi_probe(struct platform_device *pldev) | |||
306 | pmcmsptwi_data.irq = platform_get_irq(pldev, 0); | 306 | pmcmsptwi_data.irq = platform_get_irq(pldev, 0); |
307 | if (pmcmsptwi_data.irq) { | 307 | if (pmcmsptwi_data.irq) { |
308 | rc = request_irq(pmcmsptwi_data.irq, &pmcmsptwi_interrupt, | 308 | rc = request_irq(pmcmsptwi_data.irq, &pmcmsptwi_interrupt, |
309 | IRQF_SHARED | IRQF_SAMPLE_RANDOM, | 309 | IRQF_SHARED, pldev->name, &pmcmsptwi_data); |
310 | pldev->name, &pmcmsptwi_data); | ||
311 | if (rc == 0) { | 310 | if (rc == 0) { |
312 | /* | 311 | /* |
313 | * Enable 'DONE' interrupt only. | 312 | * Enable 'DONE' interrupt only. |
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 99389d2eae51..5d54416770b0 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -587,25 +587,27 @@ static struct i2c_algorithm pnx_algorithm = { | |||
587 | }; | 587 | }; |
588 | 588 | ||
589 | #ifdef CONFIG_PM | 589 | #ifdef CONFIG_PM |
590 | static int i2c_pnx_controller_suspend(struct platform_device *pdev, | 590 | static int i2c_pnx_controller_suspend(struct device *dev) |
591 | pm_message_t state) | ||
592 | { | 591 | { |
593 | struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); | 592 | struct i2c_pnx_algo_data *alg_data = dev_get_drvdata(dev); |
594 | 593 | ||
595 | clk_disable(alg_data->clk); | 594 | clk_disable(alg_data->clk); |
596 | 595 | ||
597 | return 0; | 596 | return 0; |
598 | } | 597 | } |
599 | 598 | ||
600 | static int i2c_pnx_controller_resume(struct platform_device *pdev) | 599 | static int i2c_pnx_controller_resume(struct device *dev) |
601 | { | 600 | { |
602 | struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); | 601 | struct i2c_pnx_algo_data *alg_data = dev_get_drvdata(dev); |
603 | 602 | ||
604 | return clk_enable(alg_data->clk); | 603 | return clk_enable(alg_data->clk); |
605 | } | 604 | } |
605 | |||
606 | static SIMPLE_DEV_PM_OPS(i2c_pnx_pm, | ||
607 | i2c_pnx_controller_suspend, i2c_pnx_controller_resume); | ||
608 | #define PNX_I2C_PM (&i2c_pnx_pm) | ||
606 | #else | 609 | #else |
607 | #define i2c_pnx_controller_suspend NULL | 610 | #define PNX_I2C_PM NULL |
608 | #define i2c_pnx_controller_resume NULL | ||
609 | #endif | 611 | #endif |
610 | 612 | ||
611 | static int __devinit i2c_pnx_probe(struct platform_device *pdev) | 613 | static int __devinit i2c_pnx_probe(struct platform_device *pdev) |
@@ -783,11 +785,10 @@ static struct platform_driver i2c_pnx_driver = { | |||
783 | .name = "pnx-i2c", | 785 | .name = "pnx-i2c", |
784 | .owner = THIS_MODULE, | 786 | .owner = THIS_MODULE, |
785 | .of_match_table = of_match_ptr(i2c_pnx_of_match), | 787 | .of_match_table = of_match_ptr(i2c_pnx_of_match), |
788 | .pm = PNX_I2C_PM, | ||
786 | }, | 789 | }, |
787 | .probe = i2c_pnx_probe, | 790 | .probe = i2c_pnx_probe, |
788 | .remove = __devexit_p(i2c_pnx_remove), | 791 | .remove = __devexit_p(i2c_pnx_remove), |
789 | .suspend = i2c_pnx_controller_suspend, | ||
790 | .resume = i2c_pnx_controller_resume, | ||
791 | }; | 792 | }; |
792 | 793 | ||
793 | static int __init i2c_adap_pnx_init(void) | 794 | static int __init i2c_adap_pnx_init(void) |
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 31c47e18d83c..5285f8565de4 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -227,28 +227,138 @@ static int __devexit i2c_powermac_remove(struct platform_device *dev) | |||
227 | return 0; | 227 | return 0; |
228 | } | 228 | } |
229 | 229 | ||
230 | static u32 __devinit i2c_powermac_get_addr(struct i2c_adapter *adap, | ||
231 | struct pmac_i2c_bus *bus, | ||
232 | struct device_node *node) | ||
233 | { | ||
234 | const __be32 *prop; | ||
235 | int len; | ||
236 | |||
237 | /* First check for valid "reg" */ | ||
238 | prop = of_get_property(node, "reg", &len); | ||
239 | if (prop && (len >= sizeof(int))) | ||
240 | return (be32_to_cpup(prop) & 0xff) >> 1; | ||
241 | |||
242 | /* Then check old-style "i2c-address" */ | ||
243 | prop = of_get_property(node, "i2c-address", &len); | ||
244 | if (prop && (len >= sizeof(int))) | ||
245 | return (be32_to_cpup(prop) & 0xff) >> 1; | ||
246 | |||
247 | /* Now handle some devices with missing "reg" properties */ | ||
248 | if (!strcmp(node->name, "cereal")) | ||
249 | return 0x60; | ||
250 | else if (!strcmp(node->name, "deq")) | ||
251 | return 0x34; | ||
252 | |||
253 | dev_warn(&adap->dev, "No i2c address for %s\n", node->full_name); | ||
254 | |||
255 | return 0xffffffff; | ||
256 | } | ||
257 | |||
258 | static void __devinit i2c_powermac_create_one(struct i2c_adapter *adap, | ||
259 | const char *type, | ||
260 | u32 addr) | ||
261 | { | ||
262 | struct i2c_board_info info = {}; | ||
263 | struct i2c_client *newdev; | ||
264 | |||
265 | strncpy(info.type, type, sizeof(info.type)); | ||
266 | info.addr = addr; | ||
267 | newdev = i2c_new_device(adap, &info); | ||
268 | if (!newdev) | ||
269 | dev_err(&adap->dev, | ||
270 | "i2c-powermac: Failure to register missing %s\n", | ||
271 | type); | ||
272 | } | ||
273 | |||
274 | static void __devinit i2c_powermac_add_missing(struct i2c_adapter *adap, | ||
275 | struct pmac_i2c_bus *bus, | ||
276 | bool found_onyx) | ||
277 | { | ||
278 | struct device_node *busnode = pmac_i2c_get_bus_node(bus); | ||
279 | int rc; | ||
280 | |||
281 | /* Check for the onyx audio codec */ | ||
282 | #define ONYX_REG_CONTROL 67 | ||
283 | if (of_device_is_compatible(busnode, "k2-i2c") && !found_onyx) { | ||
284 | union i2c_smbus_data data; | ||
285 | |||
286 | rc = i2c_smbus_xfer(adap, 0x46, 0, I2C_SMBUS_READ, | ||
287 | ONYX_REG_CONTROL, I2C_SMBUS_BYTE_DATA, | ||
288 | &data); | ||
289 | if (rc >= 0) | ||
290 | i2c_powermac_create_one(adap, "MAC,pcm3052", 0x46); | ||
291 | |||
292 | rc = i2c_smbus_xfer(adap, 0x47, 0, I2C_SMBUS_READ, | ||
293 | ONYX_REG_CONTROL, I2C_SMBUS_BYTE_DATA, | ||
294 | &data); | ||
295 | if (rc >= 0) | ||
296 | i2c_powermac_create_one(adap, "MAC,pcm3052", 0x47); | ||
297 | } | ||
298 | } | ||
299 | |||
300 | static bool __devinit i2c_powermac_get_type(struct i2c_adapter *adap, | ||
301 | struct device_node *node, | ||
302 | u32 addr, char *type, int type_size) | ||
303 | { | ||
304 | char tmp[16]; | ||
305 | |||
306 | /* Note: we to _NOT_ want the standard | ||
307 | * i2c drivers to match with any of our powermac stuff | ||
308 | * unless they have been specifically modified to handle | ||
309 | * it on a case by case basis. For example, for thermal | ||
310 | * control, things like lm75 etc... shall match with their | ||
311 | * corresponding windfarm drivers, _NOT_ the generic ones, | ||
312 | * so we force a prefix of AAPL, onto the modalias to | ||
313 | * make that happen | ||
314 | */ | ||
315 | |||
316 | /* First try proper modalias */ | ||
317 | if (of_modalias_node(node, tmp, sizeof(tmp)) >= 0) { | ||
318 | snprintf(type, type_size, "MAC,%s", tmp); | ||
319 | return true; | ||
320 | } | ||
321 | |||
322 | /* Now look for known workarounds */ | ||
323 | if (!strcmp(node->name, "deq")) { | ||
324 | /* Apple uses address 0x34 for TAS3001 and 0x35 for TAS3004 */ | ||
325 | if (addr == 0x34) { | ||
326 | snprintf(type, type_size, "MAC,tas3001"); | ||
327 | return true; | ||
328 | } else if (addr == 0x35) { | ||
329 | snprintf(type, type_size, "MAC,tas3004"); | ||
330 | return true; | ||
331 | } | ||
332 | } | ||
333 | |||
334 | dev_err(&adap->dev, "i2c-powermac: modalias failure" | ||
335 | " on %s\n", node->full_name); | ||
336 | return false; | ||
337 | } | ||
338 | |||
230 | static void __devinit i2c_powermac_register_devices(struct i2c_adapter *adap, | 339 | static void __devinit i2c_powermac_register_devices(struct i2c_adapter *adap, |
231 | struct pmac_i2c_bus *bus) | 340 | struct pmac_i2c_bus *bus) |
232 | { | 341 | { |
233 | struct i2c_client *newdev; | 342 | struct i2c_client *newdev; |
234 | struct device_node *node; | 343 | struct device_node *node; |
344 | bool found_onyx = 0; | ||
345 | |||
346 | /* | ||
347 | * In some cases we end up with the via-pmu node itself, in this | ||
348 | * case we skip this function completely as the device-tree will | ||
349 | * not contain anything useful. | ||
350 | */ | ||
351 | if (!strcmp(adap->dev.of_node->name, "via-pmu")) | ||
352 | return; | ||
235 | 353 | ||
236 | for_each_child_of_node(adap->dev.of_node, node) { | 354 | for_each_child_of_node(adap->dev.of_node, node) { |
237 | struct i2c_board_info info = {}; | 355 | struct i2c_board_info info = {}; |
238 | struct dev_archdata dev_ad = {}; | ||
239 | const __be32 *reg; | ||
240 | char tmp[16]; | ||
241 | u32 addr; | 356 | u32 addr; |
242 | int len; | ||
243 | 357 | ||
244 | /* Get address & channel */ | 358 | /* Get address & channel */ |
245 | reg = of_get_property(node, "reg", &len); | 359 | addr = i2c_powermac_get_addr(adap, bus, node); |
246 | if (!reg || (len < sizeof(int))) { | 360 | if (addr == 0xffffffff) |
247 | dev_err(&adap->dev, "i2c-powermac: invalid reg on %s\n", | ||
248 | node->full_name); | ||
249 | continue; | 361 | continue; |
250 | } | ||
251 | addr = be32_to_cpup(reg); | ||
252 | 362 | ||
253 | /* Multibus setup, check channel */ | 363 | /* Multibus setup, check channel */ |
254 | if (!pmac_i2c_match_adapter(node, adap)) | 364 | if (!pmac_i2c_match_adapter(node, adap)) |
@@ -257,27 +367,23 @@ static void __devinit i2c_powermac_register_devices(struct i2c_adapter *adap, | |||
257 | dev_dbg(&adap->dev, "i2c-powermac: register %s\n", | 367 | dev_dbg(&adap->dev, "i2c-powermac: register %s\n", |
258 | node->full_name); | 368 | node->full_name); |
259 | 369 | ||
260 | /* Make up a modalias. Note: we to _NOT_ want the standard | 370 | /* |
261 | * i2c drivers to match with any of our powermac stuff | 371 | * Keep track of some device existence to handle |
262 | * unless they have been specifically modified to handle | 372 | * workarounds later. |
263 | * it on a case by case basis. For example, for thermal | ||
264 | * control, things like lm75 etc... shall match with their | ||
265 | * corresponding windfarm drivers, _NOT_ the generic ones, | ||
266 | * so we force a prefix of AAPL, onto the modalias to | ||
267 | * make that happen | ||
268 | */ | 373 | */ |
269 | if (of_modalias_node(node, tmp, sizeof(tmp)) < 0) { | 374 | if (of_device_is_compatible(node, "pcm3052")) |
270 | dev_err(&adap->dev, "i2c-powermac: modalias failure" | 375 | found_onyx = true; |
271 | " on %s\n", node->full_name); | 376 | |
377 | /* Make up a modalias */ | ||
378 | if (!i2c_powermac_get_type(adap, node, addr, | ||
379 | info.type, sizeof(info.type))) { | ||
272 | continue; | 380 | continue; |
273 | } | 381 | } |
274 | snprintf(info.type, sizeof(info.type), "MAC,%s", tmp); | ||
275 | 382 | ||
276 | /* Fill out the rest of the info structure */ | 383 | /* Fill out the rest of the info structure */ |
277 | info.addr = (addr & 0xff) >> 1; | 384 | info.addr = addr; |
278 | info.irq = irq_of_parse_and_map(node, 0); | 385 | info.irq = irq_of_parse_and_map(node, 0); |
279 | info.of_node = of_node_get(node); | 386 | info.of_node = of_node_get(node); |
280 | info.archdata = &dev_ad; | ||
281 | 387 | ||
282 | newdev = i2c_new_device(adap, &info); | 388 | newdev = i2c_new_device(adap, &info); |
283 | if (!newdev) { | 389 | if (!newdev) { |
@@ -292,6 +398,9 @@ static void __devinit i2c_powermac_register_devices(struct i2c_adapter *adap, | |||
292 | continue; | 398 | continue; |
293 | } | 399 | } |
294 | } | 400 | } |
401 | |||
402 | /* Additional workarounds */ | ||
403 | i2c_powermac_add_missing(adap, bus, found_onyx); | ||
295 | } | 404 | } |
296 | 405 | ||
297 | static int __devinit i2c_powermac_probe(struct platform_device *dev) | 406 | static int __devinit i2c_powermac_probe(struct platform_device *dev) |
diff --git a/drivers/i2c/busses/i2c-puv3.c b/drivers/i2c/busses/i2c-puv3.c index 93709fbe30eb..d8515be00b98 100644 --- a/drivers/i2c/busses/i2c-puv3.c +++ b/drivers/i2c/busses/i2c-puv3.c | |||
@@ -254,7 +254,7 @@ static int __devexit puv3_i2c_remove(struct platform_device *pdev) | |||
254 | } | 254 | } |
255 | 255 | ||
256 | #ifdef CONFIG_PM | 256 | #ifdef CONFIG_PM |
257 | static int puv3_i2c_suspend(struct platform_device *dev, pm_message_t state) | 257 | static int puv3_i2c_suspend(struct device *dev) |
258 | { | 258 | { |
259 | int poll_count; | 259 | int poll_count; |
260 | /* Disable the IIC */ | 260 | /* Disable the IIC */ |
@@ -267,23 +267,20 @@ static int puv3_i2c_suspend(struct platform_device *dev, pm_message_t state) | |||
267 | return 0; | 267 | return 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | static int puv3_i2c_resume(struct platform_device *dev) | 270 | static SIMPLE_DEV_PM_OPS(puv3_i2c_pm, puv3_i2c_suspend, NULL); |
271 | { | 271 | #define PUV3_I2C_PM (&puv3_i2c_pm) |
272 | return 0 ; | 272 | |
273 | } | ||
274 | #else | 273 | #else |
275 | #define puv3_i2c_suspend NULL | 274 | #define PUV3_I2C_PM NULL |
276 | #define puv3_i2c_resume NULL | ||
277 | #endif | 275 | #endif |
278 | 276 | ||
279 | static struct platform_driver puv3_i2c_driver = { | 277 | static struct platform_driver puv3_i2c_driver = { |
280 | .probe = puv3_i2c_probe, | 278 | .probe = puv3_i2c_probe, |
281 | .remove = __devexit_p(puv3_i2c_remove), | 279 | .remove = __devexit_p(puv3_i2c_remove), |
282 | .suspend = puv3_i2c_suspend, | ||
283 | .resume = puv3_i2c_resume, | ||
284 | .driver = { | 280 | .driver = { |
285 | .name = "PKUnity-v3-I2C", | 281 | .name = "PKUnity-v3-I2C", |
286 | .owner = THIS_MODULE, | 282 | .owner = THIS_MODULE, |
283 | .pm = PUV3_I2C_PM, | ||
287 | } | 284 | } |
288 | }; | 285 | }; |
289 | 286 | ||
diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c index a05817980556..4dc9bef17d77 100644 --- a/drivers/i2c/busses/i2c-pxa-pci.c +++ b/drivers/i2c/busses/i2c-pxa-pci.c | |||
@@ -163,17 +163,7 @@ static struct pci_driver ce4100_i2c_driver = { | |||
163 | .remove = __devexit_p(ce4100_i2c_remove), | 163 | .remove = __devexit_p(ce4100_i2c_remove), |
164 | }; | 164 | }; |
165 | 165 | ||
166 | static int __init ce4100_i2c_init(void) | 166 | module_pci_driver(ce4100_i2c_driver); |
167 | { | ||
168 | return pci_register_driver(&ce4100_i2c_driver); | ||
169 | } | ||
170 | module_init(ce4100_i2c_init); | ||
171 | |||
172 | static void __exit ce4100_i2c_exit(void) | ||
173 | { | ||
174 | pci_unregister_driver(&ce4100_i2c_driver); | ||
175 | } | ||
176 | module_exit(ce4100_i2c_exit); | ||
177 | 167 | ||
178 | MODULE_DESCRIPTION("CE4100 PCI-I2C glue code for PXA's driver"); | 168 | MODULE_DESCRIPTION("CE4100 PCI-I2C glue code for PXA's driver"); |
179 | MODULE_LICENSE("GPL v2"); | 169 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index a997c7d3f95d..1034d93fb838 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -41,13 +41,6 @@ | |||
41 | 41 | ||
42 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
43 | 43 | ||
44 | #ifndef CONFIG_HAVE_CLK | ||
45 | #define clk_get(dev, id) NULL | ||
46 | #define clk_put(clk) do { } while (0) | ||
47 | #define clk_disable(clk) do { } while (0) | ||
48 | #define clk_enable(clk) do { } while (0) | ||
49 | #endif | ||
50 | |||
51 | struct pxa_reg_layout { | 44 | struct pxa_reg_layout { |
52 | u32 ibmr; | 45 | u32 ibmr; |
53 | u32 idbr; | 46 | u32 idbr; |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 01959154572d..5ae3b0236bd3 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -122,7 +122,7 @@ static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pde | |||
122 | { | 122 | { |
123 | if (pdev->dev.of_node) { | 123 | if (pdev->dev.of_node) { |
124 | const struct of_device_id *match; | 124 | const struct of_device_id *match; |
125 | match = of_match_node(&s3c24xx_i2c_match, pdev->dev.of_node); | 125 | match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node); |
126 | return (unsigned int)match->data; | 126 | return (unsigned int)match->data; |
127 | } | 127 | } |
128 | 128 | ||
@@ -609,7 +609,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, | |||
609 | 609 | ||
610 | if (ret != -EAGAIN) { | 610 | if (ret != -EAGAIN) { |
611 | clk_disable(i2c->clk); | 611 | clk_disable(i2c->clk); |
612 | pm_runtime_put_sync(&adap->dev); | 612 | pm_runtime_put(&adap->dev); |
613 | return ret; | 613 | return ret; |
614 | } | 614 | } |
615 | 615 | ||
@@ -619,7 +619,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, | |||
619 | } | 619 | } |
620 | 620 | ||
621 | clk_disable(i2c->clk); | 621 | clk_disable(i2c->clk); |
622 | pm_runtime_put_sync(&adap->dev); | 622 | pm_runtime_put(&adap->dev); |
623 | return -EREMOTEIO; | 623 | return -EREMOTEIO; |
624 | } | 624 | } |
625 | 625 | ||
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 15cf78f65ce0..5d6723b7525e 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -513,21 +513,8 @@ static struct pci_driver sis630_driver = { | |||
513 | .remove = __devexit_p(sis630_remove), | 513 | .remove = __devexit_p(sis630_remove), |
514 | }; | 514 | }; |
515 | 515 | ||
516 | static int __init i2c_sis630_init(void) | 516 | module_pci_driver(sis630_driver); |
517 | { | ||
518 | return pci_register_driver(&sis630_driver); | ||
519 | } | ||
520 | |||
521 | |||
522 | static void __exit i2c_sis630_exit(void) | ||
523 | { | ||
524 | pci_unregister_driver(&sis630_driver); | ||
525 | } | ||
526 | |||
527 | 517 | ||
528 | MODULE_LICENSE("GPL"); | 518 | MODULE_LICENSE("GPL"); |
529 | MODULE_AUTHOR("Alexander Malysh <amalysh@web.de>"); | 519 | MODULE_AUTHOR("Alexander Malysh <amalysh@web.de>"); |
530 | MODULE_DESCRIPTION("SIS630 SMBus driver"); | 520 | MODULE_DESCRIPTION("SIS630 SMBus driver"); |
531 | |||
532 | module_init(i2c_sis630_init); | ||
533 | module_exit(i2c_sis630_exit); | ||
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index cc5d149413f7..7b72614a9bc0 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -324,21 +324,8 @@ static struct pci_driver sis96x_driver = { | |||
324 | .remove = __devexit_p(sis96x_remove), | 324 | .remove = __devexit_p(sis96x_remove), |
325 | }; | 325 | }; |
326 | 326 | ||
327 | static int __init i2c_sis96x_init(void) | 327 | module_pci_driver(sis96x_driver); |
328 | { | ||
329 | return pci_register_driver(&sis96x_driver); | ||
330 | } | ||
331 | |||
332 | static void __exit i2c_sis96x_exit(void) | ||
333 | { | ||
334 | pci_unregister_driver(&sis96x_driver); | ||
335 | } | ||
336 | 328 | ||
337 | MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>"); | 329 | MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>"); |
338 | MODULE_DESCRIPTION("SiS96x SMBus driver"); | 330 | MODULE_DESCRIPTION("SiS96x SMBus driver"); |
339 | MODULE_LICENSE("GPL"); | 331 | MODULE_LICENSE("GPL"); |
340 | |||
341 | /* Register initialization functions using helper macros */ | ||
342 | module_init(i2c_sis96x_init); | ||
343 | module_exit(i2c_sis96x_exit); | ||
344 | |||
diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c index 4d44af181f37..580a0c04cb42 100644 --- a/drivers/i2c/busses/i2c-stu300.c +++ b/drivers/i2c/busses/i2c-stu300.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2009 ST-Ericsson AB | 2 | * Copyright (C) 2007-2012 ST-Ericsson AB |
3 | * License terms: GNU General Public License (GPL) version 2 | 3 | * License terms: GNU General Public License (GPL) version 2 |
4 | * ST DDC I2C master mode driver, used in e.g. U300 series platforms. | 4 | * ST DDC I2C master mode driver, used in e.g. U300 series platforms. |
5 | * Author: Linus Walleij <linus.walleij@stericsson.com> | 5 | * Author: Linus Walleij <linus.walleij@stericsson.com> |
@@ -139,8 +139,6 @@ module_param(scl_frequency, uint, 0644); | |||
139 | * struct stu300_dev - the stu300 driver state holder | 139 | * struct stu300_dev - the stu300 driver state holder |
140 | * @pdev: parent platform device | 140 | * @pdev: parent platform device |
141 | * @adapter: corresponding I2C adapter | 141 | * @adapter: corresponding I2C adapter |
142 | * @phybase: location of I/O area in memory | ||
143 | * @physize: size of I/O area in memory | ||
144 | * @clk: hardware block clock | 142 | * @clk: hardware block clock |
145 | * @irq: assigned interrupt line | 143 | * @irq: assigned interrupt line |
146 | * @cmd_issue_lock: this locks the following cmd_ variables | 144 | * @cmd_issue_lock: this locks the following cmd_ variables |
@@ -155,8 +153,6 @@ module_param(scl_frequency, uint, 0644); | |||
155 | struct stu300_dev { | 153 | struct stu300_dev { |
156 | struct platform_device *pdev; | 154 | struct platform_device *pdev; |
157 | struct i2c_adapter adapter; | 155 | struct i2c_adapter adapter; |
158 | resource_size_t phybase; | ||
159 | resource_size_t physize; | ||
160 | void __iomem *virtbase; | 156 | void __iomem *virtbase; |
161 | struct clk *clk; | 157 | struct clk *clk; |
162 | int irq; | 158 | int irq; |
@@ -873,64 +869,44 @@ stu300_probe(struct platform_device *pdev) | |||
873 | int ret = 0; | 869 | int ret = 0; |
874 | char clk_name[] = "I2C0"; | 870 | char clk_name[] = "I2C0"; |
875 | 871 | ||
876 | dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL); | 872 | dev = devm_kzalloc(&pdev->dev, sizeof(struct stu300_dev), GFP_KERNEL); |
877 | if (!dev) { | 873 | if (!dev) { |
878 | dev_err(&pdev->dev, "could not allocate device struct\n"); | 874 | dev_err(&pdev->dev, "could not allocate device struct\n"); |
879 | ret = -ENOMEM; | 875 | return -ENOMEM; |
880 | goto err_no_devmem; | ||
881 | } | 876 | } |
882 | 877 | ||
883 | bus_nr = pdev->id; | 878 | bus_nr = pdev->id; |
884 | clk_name[3] += (char)bus_nr; | 879 | clk_name[3] += (char)bus_nr; |
885 | dev->clk = clk_get(&pdev->dev, clk_name); | 880 | dev->clk = devm_clk_get(&pdev->dev, clk_name); |
886 | if (IS_ERR(dev->clk)) { | 881 | if (IS_ERR(dev->clk)) { |
887 | ret = PTR_ERR(dev->clk); | ||
888 | dev_err(&pdev->dev, "could not retrieve i2c bus clock\n"); | 882 | dev_err(&pdev->dev, "could not retrieve i2c bus clock\n"); |
889 | goto err_no_clk; | 883 | return PTR_ERR(dev->clk); |
890 | } | 884 | } |
891 | 885 | ||
892 | dev->pdev = pdev; | 886 | dev->pdev = pdev; |
893 | platform_set_drvdata(pdev, dev); | ||
894 | |||
895 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 887 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
896 | if (!res) { | 888 | if (!res) |
897 | ret = -ENOENT; | 889 | return -ENOENT; |
898 | goto err_no_resource; | ||
899 | } | ||
900 | |||
901 | dev->phybase = res->start; | ||
902 | dev->physize = resource_size(res); | ||
903 | |||
904 | if (request_mem_region(dev->phybase, dev->physize, | ||
905 | NAME " I/O Area") == NULL) { | ||
906 | ret = -EBUSY; | ||
907 | goto err_no_ioregion; | ||
908 | } | ||
909 | 890 | ||
910 | dev->virtbase = ioremap(dev->phybase, dev->physize); | 891 | dev->virtbase = devm_request_and_ioremap(&pdev->dev, res); |
911 | dev_dbg(&pdev->dev, "initialize bus device I2C%d on virtual " | 892 | dev_dbg(&pdev->dev, "initialize bus device I2C%d on virtual " |
912 | "base %p\n", bus_nr, dev->virtbase); | 893 | "base %p\n", bus_nr, dev->virtbase); |
913 | if (!dev->virtbase) { | 894 | if (!dev->virtbase) |
914 | ret = -ENOMEM; | 895 | return -ENOMEM; |
915 | goto err_no_ioremap; | ||
916 | } | ||
917 | 896 | ||
918 | dev->irq = platform_get_irq(pdev, 0); | 897 | dev->irq = platform_get_irq(pdev, 0); |
919 | if (request_irq(dev->irq, stu300_irh, 0, | 898 | ret = devm_request_irq(&pdev->dev, dev->irq, stu300_irh, 0, NAME, dev); |
920 | NAME, dev)) { | 899 | if (ret < 0) |
921 | ret = -EIO; | 900 | return ret; |
922 | goto err_no_irq; | ||
923 | } | ||
924 | 901 | ||
925 | dev->speed = scl_frequency; | 902 | dev->speed = scl_frequency; |
926 | 903 | ||
927 | clk_enable(dev->clk); | 904 | clk_prepare_enable(dev->clk); |
928 | ret = stu300_init_hw(dev); | 905 | ret = stu300_init_hw(dev); |
929 | clk_disable(dev->clk); | 906 | clk_disable(dev->clk); |
930 | |||
931 | if (ret != 0) { | 907 | if (ret != 0) { |
932 | dev_err(&dev->pdev->dev, "error initializing hardware.\n"); | 908 | dev_err(&dev->pdev->dev, "error initializing hardware.\n"); |
933 | goto err_init_hw; | 909 | return -EIO; |
934 | } | 910 | } |
935 | 911 | ||
936 | /* IRQ event handling initialization */ | 912 | /* IRQ event handling initialization */ |
@@ -952,57 +928,43 @@ stu300_probe(struct platform_device *pdev) | |||
952 | /* i2c device drivers may be active on return from add_adapter() */ | 928 | /* i2c device drivers may be active on return from add_adapter() */ |
953 | ret = i2c_add_numbered_adapter(adap); | 929 | ret = i2c_add_numbered_adapter(adap); |
954 | if (ret) { | 930 | if (ret) { |
955 | dev_err(&dev->pdev->dev, "failure adding ST Micro DDC " | 931 | dev_err(&pdev->dev, "failure adding ST Micro DDC " |
956 | "I2C adapter\n"); | 932 | "I2C adapter\n"); |
957 | goto err_add_adapter; | 933 | return ret; |
958 | } | 934 | } |
959 | return 0; | ||
960 | 935 | ||
961 | err_add_adapter: | 936 | platform_set_drvdata(pdev, dev); |
962 | err_init_hw: | 937 | return 0; |
963 | free_irq(dev->irq, dev); | ||
964 | err_no_irq: | ||
965 | iounmap(dev->virtbase); | ||
966 | err_no_ioremap: | ||
967 | release_mem_region(dev->phybase, dev->physize); | ||
968 | err_no_ioregion: | ||
969 | platform_set_drvdata(pdev, NULL); | ||
970 | err_no_resource: | ||
971 | clk_put(dev->clk); | ||
972 | err_no_clk: | ||
973 | kfree(dev); | ||
974 | err_no_devmem: | ||
975 | dev_err(&pdev->dev, "failed to add " NAME " adapter: %d\n", | ||
976 | pdev->id); | ||
977 | return ret; | ||
978 | } | 938 | } |
979 | 939 | ||
980 | #ifdef CONFIG_PM | 940 | #ifdef CONFIG_PM |
981 | static int stu300_suspend(struct platform_device *pdev, pm_message_t state) | 941 | static int stu300_suspend(struct device *device) |
982 | { | 942 | { |
983 | struct stu300_dev *dev = platform_get_drvdata(pdev); | 943 | struct stu300_dev *dev = dev_get_drvdata(device); |
984 | 944 | ||
985 | /* Turn off everything */ | 945 | /* Turn off everything */ |
986 | stu300_wr8(0x00, dev->virtbase + I2C_CR); | 946 | stu300_wr8(0x00, dev->virtbase + I2C_CR); |
987 | return 0; | 947 | return 0; |
988 | } | 948 | } |
989 | 949 | ||
990 | static int stu300_resume(struct platform_device *pdev) | 950 | static int stu300_resume(struct device *device) |
991 | { | 951 | { |
992 | int ret = 0; | 952 | int ret = 0; |
993 | struct stu300_dev *dev = platform_get_drvdata(pdev); | 953 | struct stu300_dev *dev = dev_get_drvdata(device); |
994 | 954 | ||
995 | clk_enable(dev->clk); | 955 | clk_enable(dev->clk); |
996 | ret = stu300_init_hw(dev); | 956 | ret = stu300_init_hw(dev); |
997 | clk_disable(dev->clk); | 957 | clk_disable(dev->clk); |
998 | 958 | ||
999 | if (ret != 0) | 959 | if (ret != 0) |
1000 | dev_err(&pdev->dev, "error re-initializing hardware.\n"); | 960 | dev_err(device, "error re-initializing hardware.\n"); |
1001 | return ret; | 961 | return ret; |
1002 | } | 962 | } |
963 | |||
964 | static SIMPLE_DEV_PM_OPS(stu300_pm, stu300_suspend, stu300_resume); | ||
965 | #define STU300_I2C_PM (&stu300_pm) | ||
1003 | #else | 966 | #else |
1004 | #define stu300_suspend NULL | 967 | #define STU300_I2C_PM NULL |
1005 | #define stu300_resume NULL | ||
1006 | #endif | 968 | #endif |
1007 | 969 | ||
1008 | static int __exit | 970 | static int __exit |
@@ -1013,12 +975,7 @@ stu300_remove(struct platform_device *pdev) | |||
1013 | i2c_del_adapter(&dev->adapter); | 975 | i2c_del_adapter(&dev->adapter); |
1014 | /* Turn off everything */ | 976 | /* Turn off everything */ |
1015 | stu300_wr8(0x00, dev->virtbase + I2C_CR); | 977 | stu300_wr8(0x00, dev->virtbase + I2C_CR); |
1016 | free_irq(dev->irq, dev); | ||
1017 | iounmap(dev->virtbase); | ||
1018 | release_mem_region(dev->phybase, dev->physize); | ||
1019 | clk_put(dev->clk); | ||
1020 | platform_set_drvdata(pdev, NULL); | 978 | platform_set_drvdata(pdev, NULL); |
1021 | kfree(dev); | ||
1022 | return 0; | 979 | return 0; |
1023 | } | 980 | } |
1024 | 981 | ||
@@ -1026,10 +983,9 @@ static struct platform_driver stu300_i2c_driver = { | |||
1026 | .driver = { | 983 | .driver = { |
1027 | .name = NAME, | 984 | .name = NAME, |
1028 | .owner = THIS_MODULE, | 985 | .owner = THIS_MODULE, |
986 | .pm = STU300_I2C_PM, | ||
1029 | }, | 987 | }, |
1030 | .remove = __exit_p(stu300_remove), | 988 | .remove = __exit_p(stu300_remove), |
1031 | .suspend = stu300_suspend, | ||
1032 | .resume = stu300_resume, | ||
1033 | 989 | ||
1034 | }; | 990 | }; |
1035 | 991 | ||
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 8b2e555a9563..9a08c57bc936 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c | |||
@@ -97,8 +97,21 @@ | |||
97 | #define I2C_HEADER_10BIT_ADDR (1<<18) | 97 | #define I2C_HEADER_10BIT_ADDR (1<<18) |
98 | #define I2C_HEADER_IE_ENABLE (1<<17) | 98 | #define I2C_HEADER_IE_ENABLE (1<<17) |
99 | #define I2C_HEADER_REPEAT_START (1<<16) | 99 | #define I2C_HEADER_REPEAT_START (1<<16) |
100 | #define I2C_HEADER_CONTINUE_XFER (1<<15) | ||
100 | #define I2C_HEADER_MASTER_ADDR_SHIFT 12 | 101 | #define I2C_HEADER_MASTER_ADDR_SHIFT 12 |
101 | #define I2C_HEADER_SLAVE_ADDR_SHIFT 1 | 102 | #define I2C_HEADER_SLAVE_ADDR_SHIFT 1 |
103 | /* | ||
104 | * msg_end_type: The bus control which need to be send at end of transfer. | ||
105 | * @MSG_END_STOP: Send stop pulse at end of transfer. | ||
106 | * @MSG_END_REPEAT_START: Send repeat start at end of transfer. | ||
107 | * @MSG_END_CONTINUE: The following on message is coming and so do not send | ||
108 | * stop or repeat start. | ||
109 | */ | ||
110 | enum msg_end_type { | ||
111 | MSG_END_STOP, | ||
112 | MSG_END_REPEAT_START, | ||
113 | MSG_END_CONTINUE, | ||
114 | }; | ||
102 | 115 | ||
103 | /** | 116 | /** |
104 | * struct tegra_i2c_dev - per device i2c context | 117 | * struct tegra_i2c_dev - per device i2c context |
@@ -106,7 +119,6 @@ | |||
106 | * @adapter: core i2c layer adapter information | 119 | * @adapter: core i2c layer adapter information |
107 | * @clk: clock reference for i2c controller | 120 | * @clk: clock reference for i2c controller |
108 | * @i2c_clk: clock reference for i2c bus | 121 | * @i2c_clk: clock reference for i2c bus |
109 | * @iomem: memory resource for registers | ||
110 | * @base: ioremapped registers cookie | 122 | * @base: ioremapped registers cookie |
111 | * @cont_id: i2c controller id, used for for packet header | 123 | * @cont_id: i2c controller id, used for for packet header |
112 | * @irq: irq number of transfer complete interrupt | 124 | * @irq: irq number of transfer complete interrupt |
@@ -124,7 +136,6 @@ struct tegra_i2c_dev { | |||
124 | struct i2c_adapter adapter; | 136 | struct i2c_adapter adapter; |
125 | struct clk *clk; | 137 | struct clk *clk; |
126 | struct clk *i2c_clk; | 138 | struct clk *i2c_clk; |
127 | struct resource *iomem; | ||
128 | void __iomem *base; | 139 | void __iomem *base; |
129 | int cont_id; | 140 | int cont_id; |
130 | int irq; | 141 | int irq; |
@@ -165,6 +176,10 @@ static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val, | |||
165 | unsigned long reg) | 176 | unsigned long reg) |
166 | { | 177 | { |
167 | writel(val, i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); | 178 | writel(val, i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); |
179 | |||
180 | /* Read back register to make sure that register writes completed */ | ||
181 | if (reg != I2C_TX_FIFO) | ||
182 | readl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg)); | ||
168 | } | 183 | } |
169 | 184 | ||
170 | static u32 i2c_readl(struct tegra_i2c_dev *i2c_dev, unsigned long reg) | 185 | static u32 i2c_readl(struct tegra_i2c_dev *i2c_dev, unsigned long reg) |
@@ -341,7 +356,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | |||
341 | u32 val; | 356 | u32 val; |
342 | int err = 0; | 357 | int err = 0; |
343 | 358 | ||
344 | clk_enable(i2c_dev->clk); | 359 | clk_prepare_enable(i2c_dev->clk); |
345 | 360 | ||
346 | tegra_periph_reset_assert(i2c_dev->clk); | 361 | tegra_periph_reset_assert(i2c_dev->clk); |
347 | udelay(2); | 362 | udelay(2); |
@@ -372,7 +387,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | |||
372 | if (tegra_i2c_flush_fifos(i2c_dev)) | 387 | if (tegra_i2c_flush_fifos(i2c_dev)) |
373 | err = -ETIMEDOUT; | 388 | err = -ETIMEDOUT; |
374 | 389 | ||
375 | clk_disable(i2c_dev->clk); | 390 | clk_disable_unprepare(i2c_dev->clk); |
376 | 391 | ||
377 | if (i2c_dev->irq_disabled) { | 392 | if (i2c_dev->irq_disabled) { |
378 | i2c_dev->irq_disabled = 0; | 393 | i2c_dev->irq_disabled = 0; |
@@ -449,7 +464,7 @@ err: | |||
449 | } | 464 | } |
450 | 465 | ||
451 | static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, | 466 | static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, |
452 | struct i2c_msg *msg, int stop) | 467 | struct i2c_msg *msg, enum msg_end_type end_state) |
453 | { | 468 | { |
454 | u32 packet_header; | 469 | u32 packet_header; |
455 | u32 int_mask; | 470 | u32 int_mask; |
@@ -476,7 +491,9 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, | |||
476 | i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); | 491 | i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); |
477 | 492 | ||
478 | packet_header = I2C_HEADER_IE_ENABLE; | 493 | packet_header = I2C_HEADER_IE_ENABLE; |
479 | if (!stop) | 494 | if (end_state == MSG_END_CONTINUE) |
495 | packet_header |= I2C_HEADER_CONTINUE_XFER; | ||
496 | else if (end_state == MSG_END_REPEAT_START) | ||
480 | packet_header |= I2C_HEADER_REPEAT_START; | 497 | packet_header |= I2C_HEADER_REPEAT_START; |
481 | if (msg->flags & I2C_M_TEN) { | 498 | if (msg->flags & I2C_M_TEN) { |
482 | packet_header |= msg->addr; | 499 | packet_header |= msg->addr; |
@@ -546,20 +563,27 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], | |||
546 | if (i2c_dev->is_suspended) | 563 | if (i2c_dev->is_suspended) |
547 | return -EBUSY; | 564 | return -EBUSY; |
548 | 565 | ||
549 | clk_enable(i2c_dev->clk); | 566 | clk_prepare_enable(i2c_dev->clk); |
550 | for (i = 0; i < num; i++) { | 567 | for (i = 0; i < num; i++) { |
551 | int stop = (i == (num - 1)) ? 1 : 0; | 568 | enum msg_end_type end_type = MSG_END_STOP; |
552 | ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], stop); | 569 | if (i < (num - 1)) { |
570 | if (msgs[i + 1].flags & I2C_M_NOSTART) | ||
571 | end_type = MSG_END_CONTINUE; | ||
572 | else | ||
573 | end_type = MSG_END_REPEAT_START; | ||
574 | } | ||
575 | ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type); | ||
553 | if (ret) | 576 | if (ret) |
554 | break; | 577 | break; |
555 | } | 578 | } |
556 | clk_disable(i2c_dev->clk); | 579 | clk_disable_unprepare(i2c_dev->clk); |
557 | return ret ?: i; | 580 | return ret ?: i; |
558 | } | 581 | } |
559 | 582 | ||
560 | static u32 tegra_i2c_func(struct i2c_adapter *adap) | 583 | static u32 tegra_i2c_func(struct i2c_adapter *adap) |
561 | { | 584 | { |
562 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; | 585 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | |
586 | I2C_FUNC_PROTOCOL_MANGLING | I2C_FUNC_NOSTART; | ||
563 | } | 587 | } |
564 | 588 | ||
565 | static const struct i2c_algorithm tegra_i2c_algo = { | 589 | static const struct i2c_algorithm tegra_i2c_algo = { |
@@ -572,7 +596,6 @@ static int __devinit tegra_i2c_probe(struct platform_device *pdev) | |||
572 | struct tegra_i2c_dev *i2c_dev; | 596 | struct tegra_i2c_dev *i2c_dev; |
573 | struct tegra_i2c_platform_data *pdata = pdev->dev.platform_data; | 597 | struct tegra_i2c_platform_data *pdata = pdev->dev.platform_data; |
574 | struct resource *res; | 598 | struct resource *res; |
575 | struct resource *iomem; | ||
576 | struct clk *clk; | 599 | struct clk *clk; |
577 | struct clk *i2c_clk; | 600 | struct clk *i2c_clk; |
578 | const unsigned int *prop; | 601 | const unsigned int *prop; |
@@ -585,50 +608,41 @@ static int __devinit tegra_i2c_probe(struct platform_device *pdev) | |||
585 | dev_err(&pdev->dev, "no mem resource\n"); | 608 | dev_err(&pdev->dev, "no mem resource\n"); |
586 | return -EINVAL; | 609 | return -EINVAL; |
587 | } | 610 | } |
588 | iomem = request_mem_region(res->start, resource_size(res), pdev->name); | ||
589 | if (!iomem) { | ||
590 | dev_err(&pdev->dev, "I2C region already claimed\n"); | ||
591 | return -EBUSY; | ||
592 | } | ||
593 | 611 | ||
594 | base = ioremap(iomem->start, resource_size(iomem)); | 612 | base = devm_request_and_ioremap(&pdev->dev, res); |
595 | if (!base) { | 613 | if (!base) { |
596 | dev_err(&pdev->dev, "Cannot ioremap I2C region\n"); | 614 | dev_err(&pdev->dev, "Cannot request/ioremap I2C registers\n"); |
597 | return -ENOMEM; | 615 | return -EADDRNOTAVAIL; |
598 | } | 616 | } |
599 | 617 | ||
600 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 618 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
601 | if (!res) { | 619 | if (!res) { |
602 | dev_err(&pdev->dev, "no irq resource\n"); | 620 | dev_err(&pdev->dev, "no irq resource\n"); |
603 | ret = -EINVAL; | 621 | return -EINVAL; |
604 | goto err_iounmap; | ||
605 | } | 622 | } |
606 | irq = res->start; | 623 | irq = res->start; |
607 | 624 | ||
608 | clk = clk_get(&pdev->dev, NULL); | 625 | clk = devm_clk_get(&pdev->dev, NULL); |
609 | if (IS_ERR(clk)) { | 626 | if (IS_ERR(clk)) { |
610 | dev_err(&pdev->dev, "missing controller clock"); | 627 | dev_err(&pdev->dev, "missing controller clock"); |
611 | ret = PTR_ERR(clk); | 628 | return PTR_ERR(clk); |
612 | goto err_release_region; | ||
613 | } | 629 | } |
614 | 630 | ||
615 | i2c_clk = clk_get(&pdev->dev, "i2c"); | 631 | i2c_clk = devm_clk_get(&pdev->dev, "i2c"); |
616 | if (IS_ERR(i2c_clk)) { | 632 | if (IS_ERR(i2c_clk)) { |
617 | dev_err(&pdev->dev, "missing bus clock"); | 633 | dev_err(&pdev->dev, "missing bus clock"); |
618 | ret = PTR_ERR(i2c_clk); | 634 | return PTR_ERR(i2c_clk); |
619 | goto err_clk_put; | ||
620 | } | 635 | } |
621 | 636 | ||
622 | i2c_dev = kzalloc(sizeof(struct tegra_i2c_dev), GFP_KERNEL); | 637 | i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL); |
623 | if (!i2c_dev) { | 638 | if (!i2c_dev) { |
624 | ret = -ENOMEM; | 639 | dev_err(&pdev->dev, "Could not allocate struct tegra_i2c_dev"); |
625 | goto err_i2c_clk_put; | 640 | return -ENOMEM; |
626 | } | 641 | } |
627 | 642 | ||
628 | i2c_dev->base = base; | 643 | i2c_dev->base = base; |
629 | i2c_dev->clk = clk; | 644 | i2c_dev->clk = clk; |
630 | i2c_dev->i2c_clk = i2c_clk; | 645 | i2c_dev->i2c_clk = i2c_clk; |
631 | i2c_dev->iomem = iomem; | ||
632 | i2c_dev->adapter.algo = &tegra_i2c_algo; | 646 | i2c_dev->adapter.algo = &tegra_i2c_algo; |
633 | i2c_dev->irq = irq; | 647 | i2c_dev->irq = irq; |
634 | i2c_dev->cont_id = pdev->id; | 648 | i2c_dev->cont_id = pdev->id; |
@@ -657,16 +671,17 @@ static int __devinit tegra_i2c_probe(struct platform_device *pdev) | |||
657 | ret = tegra_i2c_init(i2c_dev); | 671 | ret = tegra_i2c_init(i2c_dev); |
658 | if (ret) { | 672 | if (ret) { |
659 | dev_err(&pdev->dev, "Failed to initialize i2c controller"); | 673 | dev_err(&pdev->dev, "Failed to initialize i2c controller"); |
660 | goto err_free; | 674 | return ret; |
661 | } | 675 | } |
662 | 676 | ||
663 | ret = request_irq(i2c_dev->irq, tegra_i2c_isr, 0, pdev->name, i2c_dev); | 677 | ret = devm_request_irq(&pdev->dev, i2c_dev->irq, |
678 | tegra_i2c_isr, 0, pdev->name, i2c_dev); | ||
664 | if (ret) { | 679 | if (ret) { |
665 | dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq); | 680 | dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq); |
666 | goto err_free; | 681 | return ret; |
667 | } | 682 | } |
668 | 683 | ||
669 | clk_enable(i2c_dev->i2c_clk); | 684 | clk_prepare_enable(i2c_dev->i2c_clk); |
670 | 685 | ||
671 | i2c_set_adapdata(&i2c_dev->adapter, i2c_dev); | 686 | i2c_set_adapdata(&i2c_dev->adapter, i2c_dev); |
672 | i2c_dev->adapter.owner = THIS_MODULE; | 687 | i2c_dev->adapter.owner = THIS_MODULE; |
@@ -681,45 +696,26 @@ static int __devinit tegra_i2c_probe(struct platform_device *pdev) | |||
681 | ret = i2c_add_numbered_adapter(&i2c_dev->adapter); | 696 | ret = i2c_add_numbered_adapter(&i2c_dev->adapter); |
682 | if (ret) { | 697 | if (ret) { |
683 | dev_err(&pdev->dev, "Failed to add I2C adapter\n"); | 698 | dev_err(&pdev->dev, "Failed to add I2C adapter\n"); |
684 | goto err_free_irq; | 699 | clk_disable_unprepare(i2c_dev->i2c_clk); |
700 | return ret; | ||
685 | } | 701 | } |
686 | 702 | ||
687 | of_i2c_register_devices(&i2c_dev->adapter); | 703 | of_i2c_register_devices(&i2c_dev->adapter); |
688 | 704 | ||
689 | return 0; | 705 | return 0; |
690 | err_free_irq: | ||
691 | free_irq(i2c_dev->irq, i2c_dev); | ||
692 | err_free: | ||
693 | kfree(i2c_dev); | ||
694 | err_i2c_clk_put: | ||
695 | clk_put(i2c_clk); | ||
696 | err_clk_put: | ||
697 | clk_put(clk); | ||
698 | err_release_region: | ||
699 | release_mem_region(iomem->start, resource_size(iomem)); | ||
700 | err_iounmap: | ||
701 | iounmap(base); | ||
702 | return ret; | ||
703 | } | 706 | } |
704 | 707 | ||
705 | static int __devexit tegra_i2c_remove(struct platform_device *pdev) | 708 | static int __devexit tegra_i2c_remove(struct platform_device *pdev) |
706 | { | 709 | { |
707 | struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev); | 710 | struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev); |
708 | i2c_del_adapter(&i2c_dev->adapter); | 711 | i2c_del_adapter(&i2c_dev->adapter); |
709 | free_irq(i2c_dev->irq, i2c_dev); | ||
710 | clk_put(i2c_dev->i2c_clk); | ||
711 | clk_put(i2c_dev->clk); | ||
712 | release_mem_region(i2c_dev->iomem->start, | ||
713 | resource_size(i2c_dev->iomem)); | ||
714 | iounmap(i2c_dev->base); | ||
715 | kfree(i2c_dev); | ||
716 | return 0; | 712 | return 0; |
717 | } | 713 | } |
718 | 714 | ||
719 | #ifdef CONFIG_PM | 715 | #ifdef CONFIG_PM_SLEEP |
720 | static int tegra_i2c_suspend(struct platform_device *pdev, pm_message_t state) | 716 | static int tegra_i2c_suspend(struct device *dev) |
721 | { | 717 | { |
722 | struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev); | 718 | struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); |
723 | 719 | ||
724 | i2c_lock_adapter(&i2c_dev->adapter); | 720 | i2c_lock_adapter(&i2c_dev->adapter); |
725 | i2c_dev->is_suspended = true; | 721 | i2c_dev->is_suspended = true; |
@@ -728,9 +724,9 @@ static int tegra_i2c_suspend(struct platform_device *pdev, pm_message_t state) | |||
728 | return 0; | 724 | return 0; |
729 | } | 725 | } |
730 | 726 | ||
731 | static int tegra_i2c_resume(struct platform_device *pdev) | 727 | static int tegra_i2c_resume(struct device *dev) |
732 | { | 728 | { |
733 | struct tegra_i2c_dev *i2c_dev = platform_get_drvdata(pdev); | 729 | struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); |
734 | int ret; | 730 | int ret; |
735 | 731 | ||
736 | i2c_lock_adapter(&i2c_dev->adapter); | 732 | i2c_lock_adapter(&i2c_dev->adapter); |
@@ -748,6 +744,11 @@ static int tegra_i2c_resume(struct platform_device *pdev) | |||
748 | 744 | ||
749 | return 0; | 745 | return 0; |
750 | } | 746 | } |
747 | |||
748 | static SIMPLE_DEV_PM_OPS(tegra_i2c_pm, tegra_i2c_suspend, tegra_i2c_resume); | ||
749 | #define TEGRA_I2C_PM (&tegra_i2c_pm) | ||
750 | #else | ||
751 | #define TEGRA_I2C_PM NULL | ||
751 | #endif | 752 | #endif |
752 | 753 | ||
753 | #if defined(CONFIG_OF) | 754 | #if defined(CONFIG_OF) |
@@ -758,21 +759,16 @@ static const struct of_device_id tegra_i2c_of_match[] __devinitconst = { | |||
758 | {}, | 759 | {}, |
759 | }; | 760 | }; |
760 | MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); | 761 | MODULE_DEVICE_TABLE(of, tegra_i2c_of_match); |
761 | #else | ||
762 | #define tegra_i2c_of_match NULL | ||
763 | #endif | 762 | #endif |
764 | 763 | ||
765 | static struct platform_driver tegra_i2c_driver = { | 764 | static struct platform_driver tegra_i2c_driver = { |
766 | .probe = tegra_i2c_probe, | 765 | .probe = tegra_i2c_probe, |
767 | .remove = __devexit_p(tegra_i2c_remove), | 766 | .remove = __devexit_p(tegra_i2c_remove), |
768 | #ifdef CONFIG_PM | ||
769 | .suspend = tegra_i2c_suspend, | ||
770 | .resume = tegra_i2c_resume, | ||
771 | #endif | ||
772 | .driver = { | 767 | .driver = { |
773 | .name = "tegra-i2c", | 768 | .name = "tegra-i2c", |
774 | .owner = THIS_MODULE, | 769 | .owner = THIS_MODULE, |
775 | .of_match_table = tegra_i2c_of_match, | 770 | .of_match_table = of_match_ptr(tegra_i2c_of_match), |
771 | .pm = TEGRA_I2C_PM, | ||
776 | }, | 772 | }, |
777 | }; | 773 | }; |
778 | 774 | ||
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c index f07307ff360d..05106368d405 100644 --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c | |||
@@ -143,6 +143,7 @@ static const struct i2c_algorithm usb_algorithm = { | |||
143 | static const struct usb_device_id i2c_tiny_usb_table[] = { | 143 | static const struct usb_device_id i2c_tiny_usb_table[] = { |
144 | { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */ | 144 | { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */ |
145 | { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */ | 145 | { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */ |
146 | { USB_DEVICE(0x1964, 0x0001) }, /* Robofuzz OSIF */ | ||
146 | { } /* Terminating entry */ | 147 | { } /* Terminating entry */ |
147 | }; | 148 | }; |
148 | 149 | ||
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 713d31ade26b..7ffee71ca190 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -161,20 +161,8 @@ static struct pci_driver vt586b_driver = { | |||
161 | .remove = __devexit_p(vt586b_remove), | 161 | .remove = __devexit_p(vt586b_remove), |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static int __init i2c_vt586b_init(void) | 164 | module_pci_driver(vt586b_driver); |
165 | { | ||
166 | return pci_register_driver(&vt586b_driver); | ||
167 | } | ||
168 | |||
169 | static void __exit i2c_vt586b_exit(void) | ||
170 | { | ||
171 | pci_unregister_driver(&vt586b_driver); | ||
172 | } | ||
173 | |||
174 | 165 | ||
175 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>"); | 166 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>"); |
176 | MODULE_DESCRIPTION("i2c for Via vt82c586b southbridge"); | 167 | MODULE_DESCRIPTION("i2c for Via vt82c586b southbridge"); |
177 | MODULE_LICENSE("GPL"); | 168 | MODULE_LICENSE("GPL"); |
178 | |||
179 | module_init(i2c_vt586b_init); | ||
180 | module_exit(i2c_vt586b_exit); | ||
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index a6ad32bc0a96..2efa56c5ff2c 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -1312,6 +1312,37 @@ module_exit(i2c_exit); | |||
1312 | */ | 1312 | */ |
1313 | 1313 | ||
1314 | /** | 1314 | /** |
1315 | * __i2c_transfer - unlocked flavor of i2c_transfer | ||
1316 | * @adap: Handle to I2C bus | ||
1317 | * @msgs: One or more messages to execute before STOP is issued to | ||
1318 | * terminate the operation; each message begins with a START. | ||
1319 | * @num: Number of messages to be executed. | ||
1320 | * | ||
1321 | * Returns negative errno, else the number of messages executed. | ||
1322 | * | ||
1323 | * Adapter lock must be held when calling this function. No debug logging | ||
1324 | * takes place. adap->algo->master_xfer existence isn't checked. | ||
1325 | */ | ||
1326 | int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | ||
1327 | { | ||
1328 | unsigned long orig_jiffies; | ||
1329 | int ret, try; | ||
1330 | |||
1331 | /* Retry automatically on arbitration loss */ | ||
1332 | orig_jiffies = jiffies; | ||
1333 | for (ret = 0, try = 0; try <= adap->retries; try++) { | ||
1334 | ret = adap->algo->master_xfer(adap, msgs, num); | ||
1335 | if (ret != -EAGAIN) | ||
1336 | break; | ||
1337 | if (time_after(jiffies, orig_jiffies + adap->timeout)) | ||
1338 | break; | ||
1339 | } | ||
1340 | |||
1341 | return ret; | ||
1342 | } | ||
1343 | EXPORT_SYMBOL(__i2c_transfer); | ||
1344 | |||
1345 | /** | ||
1315 | * i2c_transfer - execute a single or combined I2C message | 1346 | * i2c_transfer - execute a single or combined I2C message |
1316 | * @adap: Handle to I2C bus | 1347 | * @adap: Handle to I2C bus |
1317 | * @msgs: One or more messages to execute before STOP is issued to | 1348 | * @msgs: One or more messages to execute before STOP is issued to |
@@ -1325,8 +1356,7 @@ module_exit(i2c_exit); | |||
1325 | */ | 1356 | */ |
1326 | int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | 1357 | int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) |
1327 | { | 1358 | { |
1328 | unsigned long orig_jiffies; | 1359 | int ret; |
1329 | int ret, try; | ||
1330 | 1360 | ||
1331 | /* REVISIT the fault reporting model here is weak: | 1361 | /* REVISIT the fault reporting model here is weak: |
1332 | * | 1362 | * |
@@ -1364,15 +1394,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
1364 | i2c_lock_adapter(adap); | 1394 | i2c_lock_adapter(adap); |
1365 | } | 1395 | } |
1366 | 1396 | ||
1367 | /* Retry automatically on arbitration loss */ | 1397 | ret = __i2c_transfer(adap, msgs, num); |
1368 | orig_jiffies = jiffies; | ||
1369 | for (ret = 0, try = 0; try <= adap->retries; try++) { | ||
1370 | ret = adap->algo->master_xfer(adap, msgs, num); | ||
1371 | if (ret != -EAGAIN) | ||
1372 | break; | ||
1373 | if (time_after(jiffies, orig_jiffies + adap->timeout)) | ||
1374 | break; | ||
1375 | } | ||
1376 | i2c_unlock_adapter(adap); | 1398 | i2c_unlock_adapter(adap); |
1377 | 1399 | ||
1378 | return ret; | 1400 | return ret; |
@@ -2122,7 +2144,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, | |||
2122 | int try; | 2144 | int try; |
2123 | s32 res; | 2145 | s32 res; |
2124 | 2146 | ||
2125 | flags &= I2C_M_TEN | I2C_CLIENT_PEC; | 2147 | flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB; |
2126 | 2148 | ||
2127 | if (adapter->algo->smbus_xfer) { | 2149 | if (adapter->algo->smbus_xfer) { |
2128 | i2c_lock_adapter(adapter); | 2150 | i2c_lock_adapter(adapter); |
@@ -2140,11 +2162,17 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, | |||
2140 | break; | 2162 | break; |
2141 | } | 2163 | } |
2142 | i2c_unlock_adapter(adapter); | 2164 | i2c_unlock_adapter(adapter); |
2143 | } else | ||
2144 | res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, | ||
2145 | command, protocol, data); | ||
2146 | 2165 | ||
2147 | return res; | 2166 | if (res != -EOPNOTSUPP || !adapter->algo->master_xfer) |
2167 | return res; | ||
2168 | /* | ||
2169 | * Fall back to i2c_smbus_xfer_emulated if the adapter doesn't | ||
2170 | * implement native support for the SMBus operation. | ||
2171 | */ | ||
2172 | } | ||
2173 | |||
2174 | return i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, | ||
2175 | command, protocol, data); | ||
2148 | } | 2176 | } |
2149 | EXPORT_SYMBOL(i2c_smbus_xfer); | 2177 | EXPORT_SYMBOL(i2c_smbus_xfer); |
2150 | 2178 | ||
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index 9836d08f7a77..df3e0bf31eb3 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c | |||
@@ -245,18 +245,7 @@ int i2c_handle_smbus_alert(struct i2c_client *ara) | |||
245 | } | 245 | } |
246 | EXPORT_SYMBOL_GPL(i2c_handle_smbus_alert); | 246 | EXPORT_SYMBOL_GPL(i2c_handle_smbus_alert); |
247 | 247 | ||
248 | static int __init i2c_smbus_init(void) | 248 | module_i2c_driver(smbalert_driver); |
249 | { | ||
250 | return i2c_add_driver(&smbalert_driver); | ||
251 | } | ||
252 | |||
253 | static void __exit i2c_smbus_exit(void) | ||
254 | { | ||
255 | i2c_del_driver(&smbalert_driver); | ||
256 | } | ||
257 | |||
258 | module_init(i2c_smbus_init); | ||
259 | module_exit(i2c_smbus_exit); | ||
260 | 249 | ||
261 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | 250 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); |
262 | MODULE_DESCRIPTION("SMBus protocol extensions support"); | 251 | MODULE_DESCRIPTION("SMBus protocol extensions support"); |
diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c index 8aacde1516ac..f8f72f39e0b5 100644 --- a/drivers/i2c/muxes/i2c-mux-pca9541.c +++ b/drivers/i2c/muxes/i2c-mux-pca9541.c | |||
@@ -396,6 +396,6 @@ static struct i2c_driver pca9541_driver = { | |||
396 | 396 | ||
397 | module_i2c_driver(pca9541_driver); | 397 | module_i2c_driver(pca9541_driver); |
398 | 398 | ||
399 | MODULE_AUTHOR("Guenter Roeck <guenter.roeck@ericsson.com>"); | 399 | MODULE_AUTHOR("Guenter Roeck <linux@roeck-us.net>"); |
400 | MODULE_DESCRIPTION("PCA9541 I2C master selector driver"); | 400 | MODULE_DESCRIPTION("PCA9541 I2C master selector driver"); |
401 | MODULE_LICENSE("GPL v2"); | 401 | MODULE_LICENSE("GPL v2"); |