diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2008-07-27 02:41:54 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2008-07-28 07:41:03 -0400 |
commit | 958585f58f675a3c2855c7d91b6fdd2875552d0b (patch) | |
tree | 02c8f69429c9efce17e88515a3c2fef83c0452cd /drivers/i2c | |
parent | 31321b76e1a2c70f4eb4c0e19f9f860dcd0ef2ce (diff) |
i2c: Blackfin I2C Driver: Functional power management support
PM_SUSPEND_MEM: Blackfin does not maintain register state through
Hibernate. Save and restore peripheral base initialization during
PM transitions.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-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 | } |