aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/stmpe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/stmpe.c')
-rw-r--r--drivers/mfd/stmpe.c72
1 files changed, 52 insertions, 20 deletions
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 0754c5e91995..7ab7746631d4 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -699,16 +699,16 @@ static irqreturn_t stmpe_irq(int irq, void *data)
699 return IRQ_HANDLED; 699 return IRQ_HANDLED;
700} 700}
701 701
702static void stmpe_irq_lock(unsigned int irq) 702static void stmpe_irq_lock(struct irq_data *data)
703{ 703{
704 struct stmpe *stmpe = get_irq_chip_data(irq); 704 struct stmpe *stmpe = irq_data_get_irq_chip_data(data);
705 705
706 mutex_lock(&stmpe->irq_lock); 706 mutex_lock(&stmpe->irq_lock);
707} 707}
708 708
709static void stmpe_irq_sync_unlock(unsigned int irq) 709static void stmpe_irq_sync_unlock(struct irq_data *data)
710{ 710{
711 struct stmpe *stmpe = get_irq_chip_data(irq); 711 struct stmpe *stmpe = irq_data_get_irq_chip_data(data);
712 struct stmpe_variant_info *variant = stmpe->variant; 712 struct stmpe_variant_info *variant = stmpe->variant;
713 int num = DIV_ROUND_UP(variant->num_irqs, 8); 713 int num = DIV_ROUND_UP(variant->num_irqs, 8);
714 int i; 714 int i;
@@ -727,20 +727,20 @@ static void stmpe_irq_sync_unlock(unsigned int irq)
727 mutex_unlock(&stmpe->irq_lock); 727 mutex_unlock(&stmpe->irq_lock);
728} 728}
729 729
730static void stmpe_irq_mask(unsigned int irq) 730static void stmpe_irq_mask(struct irq_data *data)
731{ 731{
732 struct stmpe *stmpe = get_irq_chip_data(irq); 732 struct stmpe *stmpe = irq_data_get_irq_chip_data(data);
733 int offset = irq - stmpe->irq_base; 733 int offset = data->irq - stmpe->irq_base;
734 int regoffset = offset / 8; 734 int regoffset = offset / 8;
735 int mask = 1 << (offset % 8); 735 int mask = 1 << (offset % 8);
736 736
737 stmpe->ier[regoffset] &= ~mask; 737 stmpe->ier[regoffset] &= ~mask;
738} 738}
739 739
740static void stmpe_irq_unmask(unsigned int irq) 740static void stmpe_irq_unmask(struct irq_data *data)
741{ 741{
742 struct stmpe *stmpe = get_irq_chip_data(irq); 742 struct stmpe *stmpe = irq_data_get_irq_chip_data(data);
743 int offset = irq - stmpe->irq_base; 743 int offset = data->irq - stmpe->irq_base;
744 int regoffset = offset / 8; 744 int regoffset = offset / 8;
745 int mask = 1 << (offset % 8); 745 int mask = 1 << (offset % 8);
746 746
@@ -749,10 +749,10 @@ static void stmpe_irq_unmask(unsigned int irq)
749 749
750static struct irq_chip stmpe_irq_chip = { 750static struct irq_chip stmpe_irq_chip = {
751 .name = "stmpe", 751 .name = "stmpe",
752 .bus_lock = stmpe_irq_lock, 752 .irq_bus_lock = stmpe_irq_lock,
753 .bus_sync_unlock = stmpe_irq_sync_unlock, 753 .irq_bus_sync_unlock = stmpe_irq_sync_unlock,
754 .mask = stmpe_irq_mask, 754 .irq_mask = stmpe_irq_mask,
755 .unmask = stmpe_irq_unmask, 755 .irq_unmask = stmpe_irq_unmask,
756}; 756};
757 757
758static int __devinit stmpe_irq_init(struct stmpe *stmpe) 758static int __devinit stmpe_irq_init(struct stmpe *stmpe)
@@ -762,14 +762,14 @@ static int __devinit stmpe_irq_init(struct stmpe *stmpe)
762 int irq; 762 int irq;
763 763
764 for (irq = base; irq < base + num_irqs; irq++) { 764 for (irq = base; irq < base + num_irqs; irq++) {
765 set_irq_chip_data(irq, stmpe); 765 irq_set_chip_data(irq, stmpe);
766 set_irq_chip_and_handler(irq, &stmpe_irq_chip, 766 irq_set_chip_and_handler(irq, &stmpe_irq_chip,
767 handle_edge_irq); 767 handle_edge_irq);
768 set_irq_nested_thread(irq, 1); 768 irq_set_nested_thread(irq, 1);
769#ifdef CONFIG_ARM 769#ifdef CONFIG_ARM
770 set_irq_flags(irq, IRQF_VALID); 770 set_irq_flags(irq, IRQF_VALID);
771#else 771#else
772 set_irq_noprobe(irq); 772 irq_set_noprobe(irq);
773#endif 773#endif
774 } 774 }
775 775
@@ -786,8 +786,8 @@ static void stmpe_irq_remove(struct stmpe *stmpe)
786#ifdef CONFIG_ARM 786#ifdef CONFIG_ARM
787 set_irq_flags(irq, 0); 787 set_irq_flags(irq, 0);
788#endif 788#endif
789 set_irq_chip_and_handler(irq, NULL, NULL); 789 irq_set_chip_and_handler(irq, NULL, NULL);
790 set_irq_chip_data(irq, NULL); 790 irq_set_chip_data(irq, NULL);
791 } 791 }
792} 792}
793 793
@@ -873,6 +873,28 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe)
873 return ret; 873 return ret;
874} 874}
875 875
876#ifdef CONFIG_PM
877static int stmpe_suspend(struct device *dev)
878{
879 struct i2c_client *i2c = to_i2c_client(dev);
880
881 if (device_may_wakeup(&i2c->dev))
882 enable_irq_wake(i2c->irq);
883
884 return 0;
885}
886
887static int stmpe_resume(struct device *dev)
888{
889 struct i2c_client *i2c = to_i2c_client(dev);
890
891 if (device_may_wakeup(&i2c->dev))
892 disable_irq_wake(i2c->irq);
893
894 return 0;
895}
896#endif
897
876static int __devinit stmpe_probe(struct i2c_client *i2c, 898static int __devinit stmpe_probe(struct i2c_client *i2c,
877 const struct i2c_device_id *id) 899 const struct i2c_device_id *id)
878{ 900{
@@ -960,9 +982,19 @@ static const struct i2c_device_id stmpe_id[] = {
960}; 982};
961MODULE_DEVICE_TABLE(i2c, stmpe_id); 983MODULE_DEVICE_TABLE(i2c, stmpe_id);
962 984
985#ifdef CONFIG_PM
986static const struct dev_pm_ops stmpe_dev_pm_ops = {
987 .suspend = stmpe_suspend,
988 .resume = stmpe_resume,
989};
990#endif
991
963static struct i2c_driver stmpe_driver = { 992static struct i2c_driver stmpe_driver = {
964 .driver.name = "stmpe", 993 .driver.name = "stmpe",
965 .driver.owner = THIS_MODULE, 994 .driver.owner = THIS_MODULE,
995#ifdef CONFIG_PM
996 .driver.pm = &stmpe_dev_pm_ops,
997#endif
966 .probe = stmpe_probe, 998 .probe = stmpe_probe,
967 .remove = __devexit_p(stmpe_remove), 999 .remove = __devexit_p(stmpe_remove),
968 .id_table = stmpe_id, 1000 .id_table = stmpe_id,