From cb82730b70f31af3b43041ac4e47de69c18016c9 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 24 Jan 2014 17:29:43 +0100 Subject: 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. --- drivers/input/touchscreen/fusion_F0710A.c | 47 +++++++++++++++++++++++++++++++ include/linux/input/fusion_F0710A.h | 20 +++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 include/linux/input/fusion_F0710A.h diff --git a/drivers/input/touchscreen/fusion_F0710A.c b/drivers/input/touchscreen/fusion_F0710A.c index 2cd2096c3b98..1546e6a18512 100644 --- a/drivers/input/touchscreen/fusion_F0710A.c +++ b/drivers/input/touchscreen/fusion_F0710A.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "fusion_F0710A.h" @@ -286,10 +287,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"); @@ -412,6 +455,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 */ -- cgit v1.2.3