Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: egalax_ts - get gpio from devicetree

The irq_to_gpio() is old, most platforms use GENERIC_GPIO framework
and don't support this API anymore.

The i.MX6q sabrelite platform equips an egalax touchscreen controller,
and this platform already transfered to GENERIC_GPIO framework, to
support this driver, we use a more generic way to get gpio.

Add a return value checking for waking up the controller in the probe
function, this guarantee only a workable device can pass init.

[dmitry.torokhov@gmail.com: Make driver depend on CONFIG_OF as it is
now required.]

Acked-by Zhang Jiejing <jiejing.zhang@freescale.com>
Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Hui Wang <jason77.wang@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Hui Wang and committed by
Dmitry Torokhov
ae495e84 0cc8d6a9

+41 -3
+19
Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt
··· 1 + * EETI eGalax Multiple Touch Controller 2 + 3 + Required properties: 4 + - compatible: must be "eeti,egalax_ts" 5 + - reg: i2c slave address 6 + - interrupt-parent: the phandle for the interrupt controller 7 + - interrupts: touch controller interrupt 8 + - wakeup-gpios: the gpio pin to be used for waking up the controller 9 + as well as uased as irq pin 10 + 11 + Example: 12 + 13 + egalax_ts@04 { 14 + compatible = "eeti,egalax_ts"; 15 + reg = <0x04>; 16 + interrupt-parent = <&gpio1>; 17 + interrupts = <9 2>; 18 + wakeup-gpios = <&gpio1 9 0>; 19 + };
+1 -1
drivers/input/touchscreen/Kconfig
··· 239 239 240 240 config TOUCHSCREEN_EGALAX 241 241 tristate "EETI eGalax multi-touch panel support" 242 - depends on I2C 242 + depends on I2C && OF 243 243 help 244 244 Say Y here to enable support for I2C connected EETI 245 245 eGalax multi-touch panels.
+21 -2
drivers/input/touchscreen/egalax_ts.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/bitops.h> 30 30 #include <linux/input/mt.h> 31 + #include <linux/of_gpio.h> 31 32 32 33 /* 33 34 * Mouse Mode: some panel may configure the controller to mouse mode, ··· 123 122 /* wake up controller by an falling edge of interrupt gpio. */ 124 123 static int egalax_wake_up_device(struct i2c_client *client) 125 124 { 126 - int gpio = irq_to_gpio(client->irq); 125 + struct device_node *np = client->dev.of_node; 126 + int gpio; 127 127 int ret; 128 + 129 + if (!np) 130 + return -ENODEV; 131 + 132 + gpio = of_get_named_gpio(np, "wakeup-gpios", 0); 133 + if (!gpio_is_valid(gpio)) 134 + return -ENODEV; 128 135 129 136 ret = gpio_request(gpio, "egalax_irq"); 130 137 if (ret < 0) { ··· 190 181 ts->input_dev = input_dev; 191 182 192 183 /* controller may be in sleep, wake it up. */ 193 - egalax_wake_up_device(client); 184 + error = egalax_wake_up_device(client); 185 + if (error) { 186 + dev_err(&client->dev, "Failed to wake up the controller\n"); 187 + goto err_free_dev; 188 + } 194 189 195 190 ret = egalax_firmware_version(client); 196 191 if (ret < 0) { ··· 287 274 288 275 static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume); 289 276 277 + static struct of_device_id egalax_ts_dt_ids[] = { 278 + { .compatible = "eeti,egalax_ts" }, 279 + { /* sentinel */ } 280 + }; 281 + 290 282 static struct i2c_driver egalax_ts_driver = { 291 283 .driver = { 292 284 .name = "egalax_ts", 293 285 .owner = THIS_MODULE, 294 286 .pm = &egalax_ts_pm_ops, 287 + .of_match_table = of_match_ptr(egalax_ts_dt_ids), 295 288 }, 296 289 .id_table = egalax_ts_id, 297 290 .probe = egalax_ts_probe,