aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/mfd/stmpe.c36
-rw-r--r--include/linux/mfd/stmpe.h7
2 files changed, 36 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;
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index be1af7c42e57..270d6613aadf 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -61,6 +61,7 @@ struct stmpe_variant_info;
61 * @variant: the detected STMPE model number 61 * @variant: the detected STMPE model number
62 * @regs: list of addresses of registers which are at different addresses on 62 * @regs: list of addresses of registers which are at different addresses on
63 * different variants. Indexed by one of STMPE_IDX_*. 63 * different variants. Indexed by one of STMPE_IDX_*.
64 * @irq: irq number for stmpe
64 * @irq_base: starting IRQ number for internal IRQs 65 * @irq_base: starting IRQ number for internal IRQs
65 * @num_gpios: number of gpios, differs for variants 66 * @num_gpios: number of gpios, differs for variants
66 * @ier: cache of IER registers for bus_lock 67 * @ier: cache of IER registers for bus_lock
@@ -76,6 +77,7 @@ struct stmpe {
76 struct stmpe_variant_info *variant; 77 struct stmpe_variant_info *variant;
77 const u8 *regs; 78 const u8 *regs;
78 79
80 int irq;
79 int irq_base; 81 int irq_base;
80 int num_gpios; 82 int num_gpios;
81 u8 ier[2]; 83 u8 ier[2];
@@ -183,6 +185,9 @@ struct stmpe_ts_platform_data {
183 * @autosleep_timeout: inactivity timeout in milliseconds for autosleep 185 * @autosleep_timeout: inactivity timeout in milliseconds for autosleep
184 * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or 186 * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or
185 * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used. 187 * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used.
188 * @irq_over_gpio: true if gpio is used to get irq
189 * @irq_gpio: gpio number over which irq will be requested (significant only if
190 * irq_over_gpio is true)
186 * @gpio: GPIO-specific platform data 191 * @gpio: GPIO-specific platform data
187 * @keypad: keypad-specific platform data 192 * @keypad: keypad-specific platform data
188 * @ts: touchscreen-specific platform data 193 * @ts: touchscreen-specific platform data
@@ -194,6 +199,8 @@ struct stmpe_platform_data {
194 unsigned int irq_trigger; 199 unsigned int irq_trigger;
195 bool irq_invert_polarity; 200 bool irq_invert_polarity;
196 bool autosleep; 201 bool autosleep;
202 bool irq_over_gpio;
203 int irq_gpio;
197 int autosleep_timeout; 204 int autosleep_timeout;
198 205
199 struct stmpe_gpio_platform_data *gpio; 206 struct stmpe_gpio_platform_data *gpio;