Skip to content

Commit 25a70e3

Browse files
Daniel Mackdtor
authored andcommitted
Input: eeti_ts - allow active high irq lines
This adds a struct eeti_ts_platform_data which currently holds only one value to specify the interrupt polarity. The driver has a fallback if no platform data is passed in via the i2c_board_info, so no regression is caused. Signed-off-by: Daniel Mack <daniel@caiaq.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent 09113ae commit 25a70e3

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

‎drivers/input/touchscreen/eeti_ts.c‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/i2c.h>
3333
#include <linux/timer.h>
3434
#include <linux/gpio.h>
35+
#include <linux/input/eeti_ts.h>
3536

3637
static int flip_x;
3738
module_param(flip_x, bool, 0644);
@@ -46,7 +47,7 @@ struct eeti_ts_priv {
4647
struct input_dev *input;
4748
struct work_struct work;
4849
struct mutex mutex;
49-
int irq;
50+
int irq, irq_active_high;
5051
};
5152

5253
#define EETI_TS_BITDEPTH (11)
@@ -58,6 +59,11 @@ struct eeti_ts_priv {
5859
#define REPORT_BIT_HAS_PRESSURE (1 << 6)
5960
#define REPORT_RES_BITS(v) (((v) >> 1) + EETI_TS_BITDEPTH)
6061

62+
static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv)
63+
{
64+
return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high;
65+
}
66+
6167
static void eeti_ts_read(struct work_struct *work)
6268
{
6369
char buf[6];
@@ -67,7 +73,7 @@ static void eeti_ts_read(struct work_struct *work)
6773

6874
mutex_lock(&priv->mutex);
6975

70-
while (!gpio_get_value(irq_to_gpio(priv->irq)) && --to)
76+
while (eeti_ts_irq_active(priv) && --to)
7177
i2c_master_recv(priv->client, buf, sizeof(buf));
7278

7379
if (!to) {
@@ -140,8 +146,10 @@ static void eeti_ts_close(struct input_dev *dev)
140146
static int __devinit eeti_ts_probe(struct i2c_client *client,
141147
const struct i2c_device_id *idp)
142148
{
149+
struct eeti_ts_platform_data *pdata;
143150
struct eeti_ts_priv *priv;
144151
struct input_dev *input;
152+
unsigned int irq_flags;
145153
int err = -ENOMEM;
146154

147155
/* In contrast to what's described in the datasheet, there seems
@@ -180,6 +188,14 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
180188
priv->input = input;
181189
priv->irq = client->irq;
182190

191+
pdata = client->dev.platform_data;
192+
193+
if (pdata)
194+
priv->irq_active_high = pdata->irq_active_high;
195+
196+
irq_flags = priv->irq_active_high ?
197+
IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
198+
183199
INIT_WORK(&priv->work, eeti_ts_read);
184200
i2c_set_clientdata(client, priv);
185201
input_set_drvdata(input, priv);
@@ -188,7 +204,7 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
188204
if (err)
189205
goto err1;
190206

191-
err = request_irq(priv->irq, eeti_ts_isr, IRQF_TRIGGER_FALLING,
207+
err = request_irq(priv->irq, eeti_ts_isr, irq_flags,
192208
client->name, priv);
193209
if (err) {
194210
dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");

‎include/linux/input/eeti_ts.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef LINUX_INPUT_EETI_TS_H
2+
#define LINUX_INPUT_EETI_TS_H
3+
4+
struct eeti_ts_platform_data {
5+
unsigned int irq_active_high;
6+
};
7+
8+
#endif /* LINUX_INPUT_EETI_TS_H */
9+

0 commit comments

Comments
 (0)