summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2014-01-24 17:29:43 +0100
committerStefan Agner <stefan.agner@toradex.com>2014-01-27 14:30:20 +0100
commit5b64bbd1134938891b848604abd75dfe2a345f50 (patch)
tree7ef6f973d1ae6dc3883f69491dcd032cc29836f2
parent79b001606a26055f4a4a7131c2e09b13ce8bcf99 (diff)
input: touchscreen: added platform data for Fusion touchscreen
Added platform data struct to define interrupt and reset GPIO. This allows to initialize the touchscreen controller inside the driver rather then in each platform and use the driver as a module.
-rw-r--r--drivers/input/touchscreen/fusion_F0710A.c47
-rw-r--r--include/linux/input/fusion_F0710A.h20
2 files changed, 67 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/fusion_F0710A.c b/drivers/input/touchscreen/fusion_F0710A.c
index 44942b3dbcb4..75c7011a36e3 100644
--- a/drivers/input/touchscreen/fusion_F0710A.c
+++ b/drivers/input/touchscreen/fusion_F0710A.c
@@ -16,6 +16,7 @@
#include <linux/delay.h>
#include <asm/irq.h>
#include <linux/gpio.h>
+#include <linux/input/fusion_F0710A.h>
#include "fusion_F0710A.h"
@@ -264,10 +265,52 @@ const static u8* g_ver_product[4] = {
static int fusion_F0710A_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
+ struct fusion_f0710a_init_data *pdata = i2c->dev.platform_data;
int ret;
u8 ver_product, ver_id;
u32 version;
+ if (pdata == NULL)
+ {
+ dev_err(&i2c->dev, "No platform data for Fusion driver\n");
+ return -ENODEV;
+ }
+
+ /* Request pinmuxing, if necessary */
+ if (pdata->pinmux_fusion_pins != NULL)
+ {
+ ret = pdata->pinmux_fusion_pins();
+ if (ret < 0) {
+ dev_err(&i2c->dev, "muxing GPIOs failed\n");
+ return -ENODEV;
+ }
+ }
+
+ if ((gpio_request(pdata->gpio_int, "SO-DIMM 28 (Iris X16-38 Pen)") == 0) &&
+ (gpio_direction_input(pdata->gpio_int) == 0)) {
+ gpio_export(pdata->gpio_int, 0);
+ } else {
+ printk(KERN_WARNING "Could not obtain GPIO for Fusion pen down\n");
+ return -ENODEV;
+ }
+
+ if ((gpio_request(pdata->gpio_reset, "SO-DIMM 30 (Iris X16-39 RST)") == 0) &&
+ (gpio_direction_output(pdata->gpio_reset, 1) == 0)) {
+
+ /* Generate a 0 => 1 edge explicitly... */
+ gpio_set_value(pdata->gpio_reset, 0);
+ mdelay(10);
+ gpio_set_value(pdata->gpio_reset, 1);
+
+ gpio_export(pdata->gpio_reset, 0);
+ } else {
+ printk(KERN_WARNING "Could not obtain GPIO for Fusion reset\n");
+ return -ENODEV;
+ }
+
+ /* Use Pen Down GPIO as sampling interrupt */
+ i2c->irq = gpio_to_irq(pdata->gpio_int);
+
if(!i2c->irq)
{
dev_err(&i2c->dev, "fusion_F0710A irq < 0 \n");
@@ -390,6 +433,10 @@ static int fusion_F0710A_resume(struct i2c_client *i2c)
static int fusion_F0710A_remove(struct i2c_client *i2c)
{
+ struct fusion_f0710a_init_data *pdata = i2c->dev.platform_data;
+
+ gpio_free(pdata->gpio_int);
+ gpio_free(pdata->gpio_reset);
destroy_workqueue(fusion_F0710A.workq);
free_irq(i2c->irq, &fusion_F0710A);
input_unregister_device(fusion_F0710A.input);
diff --git a/include/linux/input/fusion_F0710A.h b/include/linux/input/fusion_F0710A.h
new file mode 100644
index 000000000000..7d152cbdd06e
--- /dev/null
+++ b/include/linux/input/fusion_F0710A.h
@@ -0,0 +1,20 @@
+/* linux/input/fusion_F0710A.h
+ *
+ * Platform data for Fusion F0710A driver
+ *
+ * Copyright (c) 2013 Toradex AG (stefan.agner@toradex.ch)
+ *
+ * For licencing details see kernel-base/COPYING
+ */
+
+#ifndef __LINUX_I2C_FUSION_F0710A_H
+#define __LINUX_I2C_FUSION_F0710A_H
+
+/* Board specific touch screen initial values */
+struct fusion_f0710a_init_data {
+ int (*pinmux_fusion_pins)(void);
+ int gpio_int;
+ int gpio_reset;
+};
+
+#endif /* __LINUX_I2C_FUSION_F0710A_H */