* [PATCH] mfd/stmpe: Add support for no-interrupt config
@ 2012-01-24 10:18 Linus Walleij
2012-01-24 11:34 ` Viresh Kumar
2012-02-20 17:06 ` Samuel Ortiz
0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2012-01-24 10:18 UTC (permalink / raw)
To: Samuel Ortiz, linux-kernel
Cc: Viresh Kumar, Michel Jaouen, Chris Blair, Linus Walleij
From: Chris Blair <chris.blair@stericsson.com>
Adds support for boards which have an STMPE device without the
interrupt pin connected.
Cc: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Chris Blair <chris.blair@stericsson.com>
Tested-by: Michel Jaouen <michel.jaouen@stericsson.com>
Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/mfd/stmpe.c | 72 +++++++++++++++++++++++++--------------------
include/linux/mfd/stmpe.h | 2 +
2 files changed, 42 insertions(+), 32 deletions(-)
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index e07947e..7c98e61 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -864,7 +864,7 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe)
unsigned int irq_trigger = stmpe->pdata->irq_trigger;
int autosleep_timeout = stmpe->pdata->autosleep_timeout;
struct stmpe_variant_info *variant = stmpe->variant;
- u8 icr;
+ u8 icr = 0;
unsigned int id;
u8 data[2];
int ret;
@@ -887,31 +887,33 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe)
if (ret)
return ret;
- if (id == STMPE801_ID)
- icr = STMPE801_REG_SYS_CTRL_INT_EN;
- else
- icr = STMPE_ICR_LSB_GIM;
-
- /* STMPE801 doesn't support Edge interrupts */
- if (id != STMPE801_ID) {
- if (irq_trigger == IRQF_TRIGGER_FALLING ||
- irq_trigger == IRQF_TRIGGER_RISING)
- icr |= STMPE_ICR_LSB_EDGE;
- }
-
- if (irq_trigger == IRQF_TRIGGER_RISING ||
- irq_trigger == IRQF_TRIGGER_HIGH) {
+ if (!stmpe->pdata->no_irq) {
if (id == STMPE801_ID)
- icr |= STMPE801_REG_SYS_CTRL_INT_HI;
+ icr = STMPE801_REG_SYS_CTRL_INT_EN;
else
- icr |= STMPE_ICR_LSB_HIGH;
- }
+ icr = STMPE_ICR_LSB_GIM;
- if (stmpe->pdata->irq_invert_polarity) {
- if (id == STMPE801_ID)
- icr ^= STMPE801_REG_SYS_CTRL_INT_HI;
- else
- icr ^= STMPE_ICR_LSB_HIGH;
+ /* STMPE801 doesn't support Edge interrupts */
+ if (id != STMPE801_ID) {
+ if (irq_trigger == IRQF_TRIGGER_FALLING ||
+ irq_trigger == IRQF_TRIGGER_RISING)
+ icr |= STMPE_ICR_LSB_EDGE;
+ }
+
+ if (irq_trigger == IRQF_TRIGGER_RISING ||
+ irq_trigger == IRQF_TRIGGER_HIGH) {
+ if (id == STMPE801_ID)
+ icr |= STMPE801_REG_SYS_CTRL_INT_HI;
+ else
+ icr |= STMPE_ICR_LSB_HIGH;
+ }
+
+ if (stmpe->pdata->irq_invert_polarity) {
+ if (id == STMPE801_ID)
+ icr ^= STMPE801_REG_SYS_CTRL_INT_HI;
+ else
+ icr ^= STMPE_ICR_LSB_HIGH;
+ }
}
if (stmpe->pdata->autosleep) {
@@ -988,7 +990,7 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
if (ci->init)
ci->init(stmpe);
- if (pdata->irq_over_gpio) {
+ if (!pdata->no_irq && 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",
@@ -1005,15 +1007,21 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
if (ret)
goto free_gpio;
- ret = stmpe_irq_init(stmpe);
- if (ret)
- goto free_gpio;
+ if (pdata->no_irq) {
+ dev_info(stmpe->dev,
+ "board config says IRQs are not supported\n");
+ } else {
+ ret = stmpe_irq_init(stmpe);
+ if (ret)
+ goto free_gpio;
- ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
- pdata->irq_trigger | IRQF_ONESHOT, "stmpe", stmpe);
- if (ret) {
- dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret);
- goto out_removeirq;
+ ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
+ pdata->irq_trigger | IRQF_ONESHOT,
+ "stmpe", stmpe);
+ if (ret) {
+ dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret);
+ goto out_removeirq;
+ }
}
ret = stmpe_devices_init(stmpe);
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index ca1d7a3..c4b45fd 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -188,6 +188,7 @@ struct stmpe_ts_platform_data {
* @irq_invert_polarity: IRQ line is connected with reversed polarity
* @autosleep: bool to enable/disable stmpe autosleep
* @autosleep_timeout: inactivity timeout in milliseconds for autosleep
+ * @no_irq: IRQs are not supported on this board
* @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or
* %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used.
* @irq_over_gpio: true if gpio is used to get irq
@@ -200,6 +201,7 @@ struct stmpe_ts_platform_data {
struct stmpe_platform_data {
int id;
unsigned int blocks;
+ bool no_irq;
int irq_base;
unsigned int irq_trigger;
bool irq_invert_polarity;
--
1.7.8
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mfd/stmpe: Add support for no-interrupt config
2012-01-24 10:18 [PATCH] mfd/stmpe: Add support for no-interrupt config Linus Walleij
@ 2012-01-24 11:34 ` Viresh Kumar
2012-02-20 17:06 ` Samuel Ortiz
1 sibling, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2012-01-24 11:34 UTC (permalink / raw)
To: Christopher BLAIR
Cc: Linus WALLEIJ, Samuel Ortiz, linux-kernel, Michel JAOUEN,
Linus Walleij, Shiraz HASHIM, Armando VISCONTI
On 1/24/2012 3:48 PM, Linus WALLEIJ wrote:
> From: Chris Blair <chris.blair@stericsson.com>
>
> Adds support for boards which have an STMPE device without the
> interrupt pin connected.
>
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Signed-off-by: Chris Blair <chris.blair@stericsson.com>
> Tested-by: Michel Jaouen <michel.jaouen@stericsson.com>
> Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/mfd/stmpe.c | 72 +++++++++++++++++++++++++--------------------
> include/linux/mfd/stmpe.h | 2 +
> 2 files changed, 42 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> @@ -988,7 +990,7 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
> if (ci->init)
> ci->init(stmpe);
>
> - if (pdata->irq_over_gpio) {
> + if (!pdata->no_irq && 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",
[I will add the actual code present here after this change to describe the concern]
if (!pdata->no_irq && 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 = ci->irq;
}
Actually you want neither of them to work for no_irq case, if and else.
But with this code, if you pass no_irq = true, then else part will get called.
> @@ -1005,15 +1007,21 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
> if (ret)
> goto free_gpio;
>
> - ret = stmpe_irq_init(stmpe);
> - if (ret)
> - goto free_gpio;
> + if (pdata->no_irq) {
> + dev_info(stmpe->dev,
> + "board config says IRQs are not supported\n");
> + } else {
> + ret = stmpe_irq_init(stmpe);
> + if (ret)
> + goto free_gpio;
>
There are few more cases to handle in error part of probe and remove, where
following routines are called.
free_irq(stmpe->irq, stmpe);
stmpe_irq_remove(stmpe);
if (pdata->irq_over_gpio)
gpio_free(pdata->irq_gpio);
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mfd/stmpe: Add support for no-interrupt config
2012-01-24 10:18 [PATCH] mfd/stmpe: Add support for no-interrupt config Linus Walleij
2012-01-24 11:34 ` Viresh Kumar
@ 2012-02-20 17:06 ` Samuel Ortiz
2012-02-20 17:11 ` Samuel Ortiz
1 sibling, 1 reply; 4+ messages in thread
From: Samuel Ortiz @ 2012-02-20 17:06 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-kernel, Viresh Kumar, Michel Jaouen, Chris Blair, Linus Walleij
Hi Linus,
On Tue, Jan 24, 2012 at 11:18:34AM +0100, Linus Walleij wrote:
> From: Chris Blair <chris.blair@stericsson.com>
>
> Adds support for boards which have an STMPE device without the
> interrupt pin connected.
Applied, thanks.
Cheers,
Samuel.
> Cc: Viresh Kumar <viresh.kumar@st.com>
> Signed-off-by: Chris Blair <chris.blair@stericsson.com>
> Tested-by: Michel Jaouen <michel.jaouen@stericsson.com>
> Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/mfd/stmpe.c | 72 +++++++++++++++++++++++++--------------------
> include/linux/mfd/stmpe.h | 2 +
> 2 files changed, 42 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index e07947e..7c98e61 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -864,7 +864,7 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe)
> unsigned int irq_trigger = stmpe->pdata->irq_trigger;
> int autosleep_timeout = stmpe->pdata->autosleep_timeout;
> struct stmpe_variant_info *variant = stmpe->variant;
> - u8 icr;
> + u8 icr = 0;
> unsigned int id;
> u8 data[2];
> int ret;
> @@ -887,31 +887,33 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe)
> if (ret)
> return ret;
>
> - if (id == STMPE801_ID)
> - icr = STMPE801_REG_SYS_CTRL_INT_EN;
> - else
> - icr = STMPE_ICR_LSB_GIM;
> -
> - /* STMPE801 doesn't support Edge interrupts */
> - if (id != STMPE801_ID) {
> - if (irq_trigger == IRQF_TRIGGER_FALLING ||
> - irq_trigger == IRQF_TRIGGER_RISING)
> - icr |= STMPE_ICR_LSB_EDGE;
> - }
> -
> - if (irq_trigger == IRQF_TRIGGER_RISING ||
> - irq_trigger == IRQF_TRIGGER_HIGH) {
> + if (!stmpe->pdata->no_irq) {
> if (id == STMPE801_ID)
> - icr |= STMPE801_REG_SYS_CTRL_INT_HI;
> + icr = STMPE801_REG_SYS_CTRL_INT_EN;
> else
> - icr |= STMPE_ICR_LSB_HIGH;
> - }
> + icr = STMPE_ICR_LSB_GIM;
>
> - if (stmpe->pdata->irq_invert_polarity) {
> - if (id == STMPE801_ID)
> - icr ^= STMPE801_REG_SYS_CTRL_INT_HI;
> - else
> - icr ^= STMPE_ICR_LSB_HIGH;
> + /* STMPE801 doesn't support Edge interrupts */
> + if (id != STMPE801_ID) {
> + if (irq_trigger == IRQF_TRIGGER_FALLING ||
> + irq_trigger == IRQF_TRIGGER_RISING)
> + icr |= STMPE_ICR_LSB_EDGE;
> + }
> +
> + if (irq_trigger == IRQF_TRIGGER_RISING ||
> + irq_trigger == IRQF_TRIGGER_HIGH) {
> + if (id == STMPE801_ID)
> + icr |= STMPE801_REG_SYS_CTRL_INT_HI;
> + else
> + icr |= STMPE_ICR_LSB_HIGH;
> + }
> +
> + if (stmpe->pdata->irq_invert_polarity) {
> + if (id == STMPE801_ID)
> + icr ^= STMPE801_REG_SYS_CTRL_INT_HI;
> + else
> + icr ^= STMPE_ICR_LSB_HIGH;
> + }
> }
>
> if (stmpe->pdata->autosleep) {
> @@ -988,7 +990,7 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
> if (ci->init)
> ci->init(stmpe);
>
> - if (pdata->irq_over_gpio) {
> + if (!pdata->no_irq && 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",
> @@ -1005,15 +1007,21 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
> if (ret)
> goto free_gpio;
>
> - ret = stmpe_irq_init(stmpe);
> - if (ret)
> - goto free_gpio;
> + if (pdata->no_irq) {
> + dev_info(stmpe->dev,
> + "board config says IRQs are not supported\n");
> + } else {
> + ret = stmpe_irq_init(stmpe);
> + if (ret)
> + goto free_gpio;
>
> - ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
> - pdata->irq_trigger | IRQF_ONESHOT, "stmpe", stmpe);
> - if (ret) {
> - dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret);
> - goto out_removeirq;
> + ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
> + pdata->irq_trigger | IRQF_ONESHOT,
> + "stmpe", stmpe);
> + if (ret) {
> + dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret);
> + goto out_removeirq;
> + }
> }
>
> ret = stmpe_devices_init(stmpe);
> diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
> index ca1d7a3..c4b45fd 100644
> --- a/include/linux/mfd/stmpe.h
> +++ b/include/linux/mfd/stmpe.h
> @@ -188,6 +188,7 @@ struct stmpe_ts_platform_data {
> * @irq_invert_polarity: IRQ line is connected with reversed polarity
> * @autosleep: bool to enable/disable stmpe autosleep
> * @autosleep_timeout: inactivity timeout in milliseconds for autosleep
> + * @no_irq: IRQs are not supported on this board
> * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or
> * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used.
> * @irq_over_gpio: true if gpio is used to get irq
> @@ -200,6 +201,7 @@ struct stmpe_ts_platform_data {
> struct stmpe_platform_data {
> int id;
> unsigned int blocks;
> + bool no_irq;
> int irq_base;
> unsigned int irq_trigger;
> bool irq_invert_polarity;
> --
> 1.7.8
>
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mfd/stmpe: Add support for no-interrupt config
2012-02-20 17:06 ` Samuel Ortiz
@ 2012-02-20 17:11 ` Samuel Ortiz
0 siblings, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2012-02-20 17:11 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-kernel, Viresh Kumar, Michel Jaouen, Chris Blair, Linus Walleij
On Mon, Feb 20, 2012 at 06:06:20PM +0100, Samuel Ortiz wrote:
> Hi Linus,
>
> On Tue, Jan 24, 2012 at 11:18:34AM +0100, Linus Walleij wrote:
> > From: Chris Blair <chris.blair@stericsson.com>
> >
> > Adds support for boards which have an STMPE device without the
> > interrupt pin connected.
> Applied, thanks.
I applied v3 of this patch...
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-20 17:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 10:18 [PATCH] mfd/stmpe: Add support for no-interrupt config Linus Walleij
2012-01-24 11:34 ` Viresh Kumar
2012-02-20 17:06 ` Samuel Ortiz
2012-02-20 17:11 ` Samuel Ortiz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).