summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2014-01-24 17:29:43 +0100
committerMax Krummenacher <max.krummenacher@toradex.com>2016-06-28 11:05:26 +0200
commitb0c045aef6b33205bffc1489a2887a88eae8809e (patch)
treebce1d25bcfda6f026a832d6cbc4d6cf156532c58
parent8caf6069de4f9bf34a1a8e89ac242a9801261ae0 (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. (cherry picked from commit cb82730b70f31af3b43041ac4e47de69c18016c9)
-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 */