@@ -28,6 +28,9 @@
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/input/mt.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
/*
* Mouse Mode: some panel may configure the controller to mouse mode,
@@ -62,6 +65,7 @@
struct egalax_ts {
struct i2c_client *client;
struct input_dev *input_dev;
+ int gpio_irq;
};
static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
@@ -122,7 +126,8 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
/* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client)
{
- int gpio = irq_to_gpio(client->irq);
+ struct egalax_ts *ts = i2c_get_clientdata(client);
+ int gpio = ts->gpio_irq;
int ret;
ret = gpio_request(gpio, "egalax_irq");
@@ -159,6 +164,7 @@ static int __devinit egalax_firmware_version(struct i2c_client *client)
static int __devinit egalax_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct device_node *n = client->dev.of_node;
struct egalax_ts *ts;
struct input_dev *input_dev;
int ret;
@@ -179,6 +185,13 @@ static int __devinit egalax_ts_probe(struct i2c_client *client,
ts->client = client;
ts->input_dev = input_dev;
+ ts->gpio_irq = of_get_named_gpio(n, "interrupt-gpio", 0);
+ if (!gpio_is_valid(ts->gpio_irq))
+ dev_warn(&client->dev, "invalid interrupt GPIO\n");
+ else
+ dev_info(&client->dev, "valid interrupt GPIO:%d\n", ts->gpio_irq);
+
+ i2c_set_clientdata(client, ts);
/* controller may be in sleep, wake it up. */
egalax_wake_up_device(client);
@@ -214,13 +227,31 @@ static int __devinit egalax_ts_probe(struct i2c_client *client,
if (error < 0) {
dev_err(&client->dev, "Failed to register interrupt\n");
goto err_free_dev;
+ }else{
+ dev_info(&client->dev, "register interrupt: %d\n", client->irq);
}
error = input_register_device(ts->input_dev);
if (error)
goto err_free_irq;
- i2c_set_clientdata(client, ts);
+//#define POLLTEST
+#ifdef POLLTEST
+ while(1){
+ if(!gpio_get_value(ts->gpio_irq)){
+ u8 buf[MAX_I2C_DATA_LEN];
+ int i, ret, tries = 0;
+ do {
+ ret = i2c_master_recv(client, buf, MAX_I2C_DATA_LEN);
+
+ for(i=0; i<ret; ++i)
+ printk("0x%02X ", buf[i]);
+
+ printk("\n");
+ } while (ret == -EAGAIN && tries++ < EGALAX_MAX_TRIES);
+ }
+ }
+#endif
return 0;
err_free_irq:
@@ -251,6 +282,12 @@ static const struct i2c_device_id egalax_ts_id[] = {
};
MODULE_DEVICE_TABLE(i2c, egalax_ts_id);
+static struct of_device_id egalax_dt_ids[] = {
+ { .compatible = "eeti,egalax" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx_uart_dt_ids);
+
#ifdef CONFIG_PM_SLEEP
static int egalax_ts_suspend(struct device *dev)
{
@@ -279,6 +316,7 @@ static struct i2c_driver egalax_ts_driver = {
.name = "egalax_ts",
.owner = THIS_MODULE,
.pm = &egalax_ts_pm_ops,
+ .of_match_table = egalax_dt_ids,
},
.id_table = egalax_ts_id,
.probe = egalax_ts_probe,