diff options
| author | Hui Wang <jason77.wang@gmail.com> | 2012-10-25 03:38:01 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-10-25 03:38:22 -0400 |
| commit | ae495e844a77344fdaedbb2ad97d925d096e9f0d (patch) | |
| tree | b30e1cd487225c3d3316d7b6853b0796e6ad43c3 | |
| parent | 0cc8d6a9d23d6662da91eeb6bb8e7d1c559850f0 (diff) | |
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>
| -rw-r--r-- | Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt | 19 | ||||
| -rw-r--r-- | drivers/input/touchscreen/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/input/touchscreen/egalax_ts.c | 23 |
3 files changed, 41 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt b/Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt new file mode 100644 index 000000000000..df70318a617f --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt | |||
| @@ -0,0 +1,19 @@ | |||
| 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 | }; | ||
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 1ba232cbc09d..f7668b24c378 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
| @@ -239,7 +239,7 @@ config TOUCHSCREEN_EETI | |||
| 239 | 239 | ||
| 240 | config TOUCHSCREEN_EGALAX | 240 | config TOUCHSCREEN_EGALAX |
| 241 | tristate "EETI eGalax multi-touch panel support" | 241 | tristate "EETI eGalax multi-touch panel support" |
| 242 | depends on I2C | 242 | depends on I2C && OF |
| 243 | help | 243 | help |
| 244 | Say Y here to enable support for I2C connected EETI | 244 | Say Y here to enable support for I2C connected EETI |
| 245 | eGalax multi-touch panels. | 245 | eGalax multi-touch panels. |
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index c1e3460f1195..13fa62fdfb0b 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/bitops.h> | 29 | #include <linux/bitops.h> |
| 30 | #include <linux/input/mt.h> | 30 | #include <linux/input/mt.h> |
| 31 | #include <linux/of_gpio.h> | ||
| 31 | 32 | ||
| 32 | /* | 33 | /* |
| 33 | * Mouse Mode: some panel may configure the controller to mouse mode, | 34 | * Mouse Mode: some panel may configure the controller to mouse mode, |
| @@ -122,9 +123,17 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) | |||
| 122 | /* wake up controller by an falling edge of interrupt gpio. */ | 123 | /* wake up controller by an falling edge of interrupt gpio. */ |
| 123 | static int egalax_wake_up_device(struct i2c_client *client) | 124 | static int egalax_wake_up_device(struct i2c_client *client) |
| 124 | { | 125 | { |
| 125 | int gpio = irq_to_gpio(client->irq); | 126 | struct device_node *np = client->dev.of_node; |
| 127 | int gpio; | ||
| 126 | int ret; | 128 | int ret; |
| 127 | 129 | ||
| 130 | if (!np) | ||
| 131 | return -ENODEV; | ||
| 132 | |||
| 133 | gpio = of_get_named_gpio(np, "wakeup-gpios", 0); | ||
| 134 | if (!gpio_is_valid(gpio)) | ||
| 135 | return -ENODEV; | ||
| 136 | |||
| 128 | ret = gpio_request(gpio, "egalax_irq"); | 137 | ret = gpio_request(gpio, "egalax_irq"); |
| 129 | if (ret < 0) { | 138 | if (ret < 0) { |
| 130 | dev_err(&client->dev, | 139 | dev_err(&client->dev, |
| @@ -181,7 +190,11 @@ static int __devinit egalax_ts_probe(struct i2c_client *client, | |||
| 181 | ts->input_dev = input_dev; | 190 | ts->input_dev = input_dev; |
| 182 | 191 | ||
| 183 | /* controller may be in sleep, wake it up. */ | 192 | /* controller may be in sleep, wake it up. */ |
| 184 | egalax_wake_up_device(client); | 193 | error = egalax_wake_up_device(client); |
| 194 | if (error) { | ||
| 195 | dev_err(&client->dev, "Failed to wake up the controller\n"); | ||
| 196 | goto err_free_dev; | ||
| 197 | } | ||
| 185 | 198 | ||
| 186 | ret = egalax_firmware_version(client); | 199 | ret = egalax_firmware_version(client); |
| 187 | if (ret < 0) { | 200 | if (ret < 0) { |
| @@ -274,11 +287,17 @@ static int egalax_ts_resume(struct device *dev) | |||
| 274 | 287 | ||
| 275 | static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume); | 288 | static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume); |
| 276 | 289 | ||
| 290 | static struct of_device_id egalax_ts_dt_ids[] = { | ||
| 291 | { .compatible = "eeti,egalax_ts" }, | ||
| 292 | { /* sentinel */ } | ||
| 293 | }; | ||
| 294 | |||
| 277 | static struct i2c_driver egalax_ts_driver = { | 295 | static struct i2c_driver egalax_ts_driver = { |
| 278 | .driver = { | 296 | .driver = { |
| 279 | .name = "egalax_ts", | 297 | .name = "egalax_ts", |
| 280 | .owner = THIS_MODULE, | 298 | .owner = THIS_MODULE, |
| 281 | .pm = &egalax_ts_pm_ops, | 299 | .pm = &egalax_ts_pm_ops, |
| 300 | .of_match_table = of_match_ptr(egalax_ts_dt_ids), | ||
| 282 | }, | 301 | }, |
| 283 | .id_table = egalax_ts_id, | 302 | .id_table = egalax_ts_id, |
| 284 | .probe = egalax_ts_probe, | 303 | .probe = egalax_ts_probe, |
