aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/stmpe.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@st.com>2011-11-07 23:14:06 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2012-01-08 18:37:29 -0500
commit73de16db43f8dcb833ab032ed274b60b23676680 (patch)
tree235da8693adb626d93c59634c3543742d5c63907 /drivers/mfd/stmpe.c
parent42ab84fb0a3db786567158bf0006a35131714eb5 (diff)
mfd: Add support for irq over gpio pin to stmpe
On many boards, stmpe is present as an separate device (not as part of SoC). Here gpio lines are mostly used for getting interrupts. This patch adds in support to handle irq over gpio pin. Signed-off-by: Viresh Kumar <viresh.kumar@st.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/stmpe.c')
-rw-r--r--drivers/mfd/stmpe.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 2963689cf45c..39efa629a19d 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -5,6 +5,7 @@
5 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 5 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
6 */ 6 */
7 7
8#include <linux/gpio.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
9#include <linux/module.h> 10#include <linux/module.h>
10#include <linux/interrupt.h> 11#include <linux/interrupt.h>
@@ -877,9 +878,10 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe)
877static int stmpe_suspend(struct device *dev) 878static int stmpe_suspend(struct device *dev)
878{ 879{
879 struct i2c_client *i2c = to_i2c_client(dev); 880 struct i2c_client *i2c = to_i2c_client(dev);
881 struct stmpe *stmpe = i2c_get_clientdata(i2c);
880 882
881 if (device_may_wakeup(&i2c->dev)) 883 if (device_may_wakeup(&i2c->dev))
882 enable_irq_wake(i2c->irq); 884 enable_irq_wake(stmpe->irq);
883 885
884 return 0; 886 return 0;
885} 887}
@@ -887,9 +889,10 @@ static int stmpe_suspend(struct device *dev)
887static int stmpe_resume(struct device *dev) 889static int stmpe_resume(struct device *dev)
888{ 890{
889 struct i2c_client *i2c = to_i2c_client(dev); 891 struct i2c_client *i2c = to_i2c_client(dev);
892 struct stmpe *stmpe = i2c_get_clientdata(i2c);
890 893
891 if (device_may_wakeup(&i2c->dev)) 894 if (device_may_wakeup(&i2c->dev))
892 disable_irq_wake(i2c->irq); 895 disable_irq_wake(stmpe->irq);
893 896
894 return 0; 897 return 0;
895} 898}
@@ -925,15 +928,28 @@ static int __devinit stmpe_probe(struct i2c_client *i2c,
925 928
926 i2c_set_clientdata(i2c, stmpe); 929 i2c_set_clientdata(i2c, stmpe);
927 930
931 if (pdata->irq_over_gpio) {
932 ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe");
933 if (ret) {
934 dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",
935 ret);
936 goto out_free;
937 }
938
939 stmpe->irq = gpio_to_irq(pdata->irq_gpio);
940 } else {
941 stmpe->irq = i2c->irq;
942 }
943
928 ret = stmpe_chip_init(stmpe); 944 ret = stmpe_chip_init(stmpe);
929 if (ret) 945 if (ret)
930 goto out_free; 946 goto free_gpio;
931 947
932 ret = stmpe_irq_init(stmpe); 948 ret = stmpe_irq_init(stmpe);
933 if (ret) 949 if (ret)
934 goto out_free; 950 goto free_gpio;
935 951
936 ret = request_threaded_irq(stmpe->i2c->irq, NULL, stmpe_irq, 952 ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
937 pdata->irq_trigger | IRQF_ONESHOT, 953 pdata->irq_trigger | IRQF_ONESHOT,
938 "stmpe", stmpe); 954 "stmpe", stmpe);
939 if (ret) { 955 if (ret) {
@@ -951,9 +967,12 @@ static int __devinit stmpe_probe(struct i2c_client *i2c,
951 967
952out_removedevs: 968out_removedevs:
953 mfd_remove_devices(stmpe->dev); 969 mfd_remove_devices(stmpe->dev);
954 free_irq(stmpe->i2c->irq, stmpe); 970 free_irq(stmpe->irq, stmpe);
955out_removeirq: 971out_removeirq:
956 stmpe_irq_remove(stmpe); 972 stmpe_irq_remove(stmpe);
973free_gpio:
974 if (pdata->irq_over_gpio)
975 gpio_free(pdata->irq_gpio);
957out_free: 976out_free:
958 kfree(stmpe); 977 kfree(stmpe);
959 return ret; 978 return ret;
@@ -965,9 +984,12 @@ static int __devexit stmpe_remove(struct i2c_client *client)
965 984
966 mfd_remove_devices(stmpe->dev); 985 mfd_remove_devices(stmpe->dev);
967 986
968 free_irq(stmpe->i2c->irq, stmpe); 987 free_irq(stmpe->irq, stmpe);
969 stmpe_irq_remove(stmpe); 988 stmpe_irq_remove(stmpe);
970 989
990 if (stmpe->pdata->irq_over_gpio)
991 gpio_free(stmpe->pdata->irq_gpio);
992
971 kfree(stmpe); 993 kfree(stmpe);
972 994
973 return 0; 995 return 0;