提交 73de16db 编写于 作者: V Viresh Kumar 提交者: Samuel Ortiz

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: NViresh Kumar <viresh.kumar@st.com>
Acked-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 42ab84fb
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
*/ */
#include <linux/gpio.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -877,9 +878,10 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe) ...@@ -877,9 +878,10 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe)
static int stmpe_suspend(struct device *dev) static int stmpe_suspend(struct device *dev)
{ {
struct i2c_client *i2c = to_i2c_client(dev); struct i2c_client *i2c = to_i2c_client(dev);
struct stmpe *stmpe = i2c_get_clientdata(i2c);
if (device_may_wakeup(&i2c->dev)) if (device_may_wakeup(&i2c->dev))
enable_irq_wake(i2c->irq); enable_irq_wake(stmpe->irq);
return 0; return 0;
} }
...@@ -887,9 +889,10 @@ static int stmpe_suspend(struct device *dev) ...@@ -887,9 +889,10 @@ static int stmpe_suspend(struct device *dev)
static int stmpe_resume(struct device *dev) static int stmpe_resume(struct device *dev)
{ {
struct i2c_client *i2c = to_i2c_client(dev); struct i2c_client *i2c = to_i2c_client(dev);
struct stmpe *stmpe = i2c_get_clientdata(i2c);
if (device_may_wakeup(&i2c->dev)) if (device_may_wakeup(&i2c->dev))
disable_irq_wake(i2c->irq); disable_irq_wake(stmpe->irq);
return 0; return 0;
} }
...@@ -925,15 +928,28 @@ static int __devinit stmpe_probe(struct i2c_client *i2c, ...@@ -925,15 +928,28 @@ static int __devinit stmpe_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, stmpe); i2c_set_clientdata(i2c, stmpe);
if (pdata->irq_over_gpio) {
ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe");
if (ret) {
dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",
ret);
goto out_free;
}
stmpe->irq = gpio_to_irq(pdata->irq_gpio);
} else {
stmpe->irq = i2c->irq;
}
ret = stmpe_chip_init(stmpe); ret = stmpe_chip_init(stmpe);
if (ret) if (ret)
goto out_free; goto free_gpio;
ret = stmpe_irq_init(stmpe); ret = stmpe_irq_init(stmpe);
if (ret) if (ret)
goto out_free; goto free_gpio;
ret = request_threaded_irq(stmpe->i2c->irq, NULL, stmpe_irq, ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
pdata->irq_trigger | IRQF_ONESHOT, pdata->irq_trigger | IRQF_ONESHOT,
"stmpe", stmpe); "stmpe", stmpe);
if (ret) { if (ret) {
...@@ -951,9 +967,12 @@ static int __devinit stmpe_probe(struct i2c_client *i2c, ...@@ -951,9 +967,12 @@ static int __devinit stmpe_probe(struct i2c_client *i2c,
out_removedevs: out_removedevs:
mfd_remove_devices(stmpe->dev); mfd_remove_devices(stmpe->dev);
free_irq(stmpe->i2c->irq, stmpe); free_irq(stmpe->irq, stmpe);
out_removeirq: out_removeirq:
stmpe_irq_remove(stmpe); stmpe_irq_remove(stmpe);
free_gpio:
if (pdata->irq_over_gpio)
gpio_free(pdata->irq_gpio);
out_free: out_free:
kfree(stmpe); kfree(stmpe);
return ret; return ret;
...@@ -965,9 +984,12 @@ static int __devexit stmpe_remove(struct i2c_client *client) ...@@ -965,9 +984,12 @@ static int __devexit stmpe_remove(struct i2c_client *client)
mfd_remove_devices(stmpe->dev); mfd_remove_devices(stmpe->dev);
free_irq(stmpe->i2c->irq, stmpe); free_irq(stmpe->irq, stmpe);
stmpe_irq_remove(stmpe); stmpe_irq_remove(stmpe);
if (stmpe->pdata->irq_over_gpio)
gpio_free(stmpe->pdata->irq_gpio);
kfree(stmpe); kfree(stmpe);
return 0; return 0;
......
...@@ -61,6 +61,7 @@ struct stmpe_variant_info; ...@@ -61,6 +61,7 @@ struct stmpe_variant_info;
* @variant: the detected STMPE model number * @variant: the detected STMPE model number
* @regs: list of addresses of registers which are at different addresses on * @regs: list of addresses of registers which are at different addresses on
* different variants. Indexed by one of STMPE_IDX_*. * different variants. Indexed by one of STMPE_IDX_*.
* @irq: irq number for stmpe
* @irq_base: starting IRQ number for internal IRQs * @irq_base: starting IRQ number for internal IRQs
* @num_gpios: number of gpios, differs for variants * @num_gpios: number of gpios, differs for variants
* @ier: cache of IER registers for bus_lock * @ier: cache of IER registers for bus_lock
...@@ -76,6 +77,7 @@ struct stmpe { ...@@ -76,6 +77,7 @@ struct stmpe {
struct stmpe_variant_info *variant; struct stmpe_variant_info *variant;
const u8 *regs; const u8 *regs;
int irq;
int irq_base; int irq_base;
int num_gpios; int num_gpios;
u8 ier[2]; u8 ier[2];
...@@ -183,6 +185,9 @@ struct stmpe_ts_platform_data { ...@@ -183,6 +185,9 @@ struct stmpe_ts_platform_data {
* @autosleep_timeout: inactivity timeout in milliseconds for autosleep * @autosleep_timeout: inactivity timeout in milliseconds for autosleep
* @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or
* %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used. * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used.
* @irq_over_gpio: true if gpio is used to get irq
* @irq_gpio: gpio number over which irq will be requested (significant only if
* irq_over_gpio is true)
* @gpio: GPIO-specific platform data * @gpio: GPIO-specific platform data
* @keypad: keypad-specific platform data * @keypad: keypad-specific platform data
* @ts: touchscreen-specific platform data * @ts: touchscreen-specific platform data
...@@ -194,6 +199,8 @@ struct stmpe_platform_data { ...@@ -194,6 +199,8 @@ struct stmpe_platform_data {
unsigned int irq_trigger; unsigned int irq_trigger;
bool irq_invert_polarity; bool irq_invert_polarity;
bool autosleep; bool autosleep;
bool irq_over_gpio;
int irq_gpio;
int autosleep_timeout; int autosleep_timeout;
struct stmpe_gpio_platform_data *gpio; struct stmpe_gpio_platform_data *gpio;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册