diff options
-rw-r--r-- | arch/arm/boot/dts/imx6q-apalis-eval.dts | 22 | ||||
-rw-r--r-- | drivers/input/touchscreen/fusion_F0710A.c | 53 |
2 files changed, 66 insertions, 9 deletions
diff --git a/arch/arm/boot/dts/imx6q-apalis-eval.dts b/arch/arm/boot/dts/imx6q-apalis-eval.dts index 3b82feaad787..e186571685b0 100644 --- a/arch/arm/boot/dts/imx6q-apalis-eval.dts +++ b/arch/arm/boot/dts/imx6q-apalis-eval.dts @@ -147,6 +147,15 @@ &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 */ + >; + }; + pcie-switch@58 { compatible = "plx,pex8605"; reg = <0x58>; @@ -179,10 +188,15 @@ }; &iomuxc { - /* Mux the Apalis GPIOs 1-6 & 8 */ + /* + * Mux the Apalis GPIOs, GPIO7 used for PCIe reset, + * GPIO5, 6 used by optional fusion_F0710A kernel module + */ pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_apalis_gpio1 &pinctrl_apalis_gpio2 &pinctrl_apalis_gpio3 &pinctrl_apalis_gpio4 - &pinctrl_apalis_gpio5 &pinctrl_apalis_gpio6 &pinctrl_apalis_gpio8>; + pinctrl-0 = <&pinctrl_apalis_gpio1 &pinctrl_apalis_gpio2 + &pinctrl_apalis_gpio3 &pinctrl_apalis_gpio4 + &pinctrl_apalis_gpio5 &pinctrl_apalis_gpio6 + &pinctrl_apalis_gpio7 &pinctrl_apalis_gpio8>; }; &lcd { @@ -206,8 +220,6 @@ }; &pcie { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_apalis_gpio7>; reset-gpio = <&gpio1 2 0>; status = "okay"; }; 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, |