summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2014-07-10 13:04:24 +0200
committerMax Krummenacher <max.krummenacher@toradex.com>2014-07-10 13:04:24 +0200
commit6b5ba243c21e60706806c4ea56124a0749b21c5b (patch)
treead515c8ae58b805babbbca1c73afe208765719f0 /drivers
parentdc26d6d33912cea5bc252c3a086314d6a99432f7 (diff)
input: touchscreen: fusion: add device tree integration
Add device tree integration and add the device to the dtb. i2c device, interrupt and reset GPIO can be specified in the dts as follows: Note that additionally you may have to set the pinmuxing for the pins to be GPIO. &i2c1 { status = "okay"; pcap@10 { /* TouchRevolution Fusion 7 and 10 multi-touch controller */ compatible = "touchrevolution,fusion-f0710a"; reg = <0x10>; gpios = <&gpio6 10 0 /* MXM-11, Pen down interrupt */ &gpio6 9 0 /* MXM-13, Reset interrupt */ >; };
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/touchscreen/fusion_F0710A.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/drivers/input/touchscreen/fusion_F0710A.c b/drivers/input/touchscreen/fusion_F0710A.c
index c5c0f1fc38ea..0c7598b3da6e 100644
--- a/drivers/input/touchscreen/fusion_F0710A.c
+++ b/drivers/input/touchscreen/fusion_F0710A.c
@@ -17,6 +17,9 @@
#include <asm/irq.h>
#include <linux/gpio.h>
#include <linux/input/fusion_F0710A.h>
+#include <linux/slab.h>
+#include <linux/of_gpio.h>
+
#include "fusion_F0710A.h"
@@ -285,22 +288,53 @@ const static u8* g_ver_product[4] = {
"10Z8", "70Z7", "43Z6", ""
};
+static int of_fusion_F0710A_get_pins(struct device_node *np,
+ unsigned int *int_pin, unsigned int *reset_pin)
+{
+ if (of_gpio_count(np) < 2)
+ return -ENODEV;
+
+ *int_pin = of_get_gpio(np, 0);
+ *reset_pin = of_get_gpio(np, 1);
+
+ if (!gpio_is_valid(*int_pin) || !gpio_is_valid(*reset_pin)) {
+ pr_err("%s: invalid GPIO pins, int=%d/reset=%d\n",
+ np->full_name, *int_pin, *reset_pin);
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
static int fusion_F0710A_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
+ struct device_node *np = i2c->dev.of_node;
struct fusion_f0710a_init_data *pdata = i2c->dev.platform_data;
int ret;
u8 ver_product, ver_id;
u32 version;
- if (pdata == NULL)
- {
+ if (np != NULL) {
+ pdata = i2c->dev.platform_data =
+ devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL);
+ if (pdata == NULL) {
+ dev_err(&i2c->dev, "No platform data for Fusion driver\n");
+ return -ENODEV;
+ }
+ /* the dtb did the pinmuxing for us */
+ pdata->pinmux_fusion_pins = NULL;
+ ret = of_fusion_F0710A_get_pins(i2c->dev.of_node,
+ &pdata->gpio_int, &pdata->gpio_reset);
+ if (ret)
+ return ret;
+ }
+ else 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)
- {
+ if (pdata->pinmux_fusion_pins != NULL) {
ret = pdata->pinmux_fusion_pins();
if (ret < 0) {
dev_err(&i2c->dev, "muxing GPIOs failed\n");
@@ -481,6 +515,16 @@ static struct i2c_device_id fusion_F0710A_id[] = {
{},
};
+
+static const struct of_device_id fusion_F0710A_dt_ids[] = {
+ {
+ .compatible = "touchrevolution,fusion-f0710a",
+ }, {
+ /* sentinel */
+ }
+};
+MODULE_DEVICE_TABLE(of, fusion_F0710A_dt_ids);
+
static const struct dev_pm_ops fusion_F0710A_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(fusion_F0710A_suspend, fusion_F0710A_resume)
};
@@ -490,6 +534,7 @@ static struct i2c_driver fusion_F0710A_i2c_drv = {
.owner = THIS_MODULE,
.name = DRV_NAME,
.pm = &fusion_F0710A_pm_ops,
+ .of_match_table = fusion_F0710A_dt_ids,
},
.probe = fusion_F0710A_probe,
.remove = fusion_F0710A_remove,