diff options
| -rw-r--r-- | drivers/i2c/busses/i2c-bfin-twi.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index 48d084bdf7c8..3c855ff2992f 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
| @@ -49,6 +49,8 @@ struct bfin_twi_iface { | |||
| 49 | struct i2c_msg *pmsg; | 49 | struct i2c_msg *pmsg; |
| 50 | int msg_num; | 50 | int msg_num; |
| 51 | int cur_msg; | 51 | int cur_msg; |
| 52 | u16 saved_clkdiv; | ||
| 53 | u16 saved_control; | ||
| 52 | void __iomem *regs_base; | 54 | void __iomem *regs_base; |
| 53 | }; | 55 | }; |
| 54 | 56 | ||
| @@ -565,32 +567,43 @@ static u32 bfin_twi_functionality(struct i2c_adapter *adap) | |||
| 565 | I2C_FUNC_I2C; | 567 | I2C_FUNC_I2C; |
| 566 | } | 568 | } |
| 567 | 569 | ||
| 568 | |||
| 569 | static struct i2c_algorithm bfin_twi_algorithm = { | 570 | static struct i2c_algorithm bfin_twi_algorithm = { |
| 570 | .master_xfer = bfin_twi_master_xfer, | 571 | .master_xfer = bfin_twi_master_xfer, |
| 571 | .smbus_xfer = bfin_twi_smbus_xfer, | 572 | .smbus_xfer = bfin_twi_smbus_xfer, |
| 572 | .functionality = bfin_twi_functionality, | 573 | .functionality = bfin_twi_functionality, |
| 573 | }; | 574 | }; |
| 574 | 575 | ||
| 575 | 576 | static int i2c_bfin_twi_suspend(struct platform_device *pdev, pm_message_t state) | |
| 576 | static int i2c_bfin_twi_suspend(struct platform_device *dev, pm_message_t state) | ||
| 577 | { | 577 | { |
| 578 | struct bfin_twi_iface *iface = platform_get_drvdata(dev); | 578 | struct bfin_twi_iface *iface = platform_get_drvdata(pdev); |
| 579 | |||
| 580 | iface->saved_clkdiv = read_CLKDIV(iface); | ||
| 581 | iface->saved_control = read_CONTROL(iface); | ||
| 582 | |||
| 583 | free_irq(iface->irq, iface); | ||
| 579 | 584 | ||
| 580 | /* Disable TWI */ | 585 | /* Disable TWI */ |
| 581 | write_CONTROL(iface, read_CONTROL(iface) & ~TWI_ENA); | 586 | write_CONTROL(iface, iface->saved_control & ~TWI_ENA); |
| 582 | SSYNC(); | ||
| 583 | 587 | ||
| 584 | return 0; | 588 | return 0; |
| 585 | } | 589 | } |
| 586 | 590 | ||
| 587 | static int i2c_bfin_twi_resume(struct platform_device *dev) | 591 | static int i2c_bfin_twi_resume(struct platform_device *pdev) |
| 588 | { | 592 | { |
| 589 | struct bfin_twi_iface *iface = platform_get_drvdata(dev); | 593 | struct bfin_twi_iface *iface = platform_get_drvdata(pdev); |
| 590 | 594 | ||
| 591 | /* Enable TWI */ | 595 | int rc = request_irq(iface->irq, bfin_twi_interrupt_entry, |
| 592 | write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA); | 596 | IRQF_DISABLED, pdev->name, iface); |
| 593 | SSYNC(); | 597 | if (rc) { |
| 598 | dev_err(&pdev->dev, "Can't get IRQ %d !\n", iface->irq); | ||
| 599 | return -ENODEV; | ||
| 600 | } | ||
| 601 | |||
| 602 | /* Resume TWI interface clock as specified */ | ||
| 603 | write_CLKDIV(iface, iface->saved_clkdiv); | ||
| 604 | |||
| 605 | /* Resume TWI */ | ||
| 606 | write_CONTROL(iface, iface->saved_control); | ||
| 594 | 607 | ||
| 595 | return 0; | 608 | return 0; |
| 596 | } | 609 | } |
