diff options
| author | Lee Jones <lee.jones@linaro.org> | 2012-09-28 05:29:07 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-11-28 02:05:11 -0500 |
| commit | 31fbcda71489d8cbe2b82819eaab4818524e3a49 (patch) | |
| tree | 0f19938312a79b229877e31dc728fba75c73a688 /drivers/input/touchscreen | |
| parent | 8c587f7709f7f6377842968562bcf51ee6f47f09 (diff) | |
Input: bu21013_ts - move GPIO init and exit functions into the driver
These GPIO init and exit functions have no place in platform data, they
should be part of the driver instead,
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/touchscreen')
| -rw-r--r-- | drivers/input/touchscreen/bu21013_ts.c | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 1e8cddd06c6..c6f6a04ec67 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
| 15 | #include <linux/regulator/consumer.h> | 15 | #include <linux/regulator/consumer.h> |
| 16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 17 | #include <linux/gpio.h> | ||
| 17 | 18 | ||
| 18 | #define PEN_DOWN_INTR 0 | 19 | #define PEN_DOWN_INTR 0 |
| 19 | #define MAX_FINGERS 2 | 20 | #define MAX_FINGERS 2 |
| @@ -148,11 +149,12 @@ | |||
| 148 | struct bu21013_ts_data { | 149 | struct bu21013_ts_data { |
| 149 | struct i2c_client *client; | 150 | struct i2c_client *client; |
| 150 | wait_queue_head_t wait; | 151 | wait_queue_head_t wait; |
| 151 | bool touch_stopped; | ||
| 152 | const struct bu21013_platform_device *chip; | 152 | const struct bu21013_platform_device *chip; |
| 153 | struct input_dev *in_dev; | 153 | struct input_dev *in_dev; |
| 154 | unsigned int intr_pin; | ||
| 155 | struct regulator *regulator; | 154 | struct regulator *regulator; |
| 155 | unsigned int irq; | ||
| 156 | unsigned int intr_pin; | ||
| 157 | bool touch_stopped; | ||
| 156 | }; | 158 | }; |
| 157 | 159 | ||
| 158 | /** | 160 | /** |
| @@ -262,7 +264,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) | |||
| 262 | return IRQ_NONE; | 264 | return IRQ_NONE; |
| 263 | } | 265 | } |
| 264 | 266 | ||
| 265 | data->intr_pin = data->chip->irq_read_val(); | 267 | data->intr_pin = gpio_get_value(data->chip->touch_pin); |
| 266 | if (data->intr_pin == PEN_DOWN_INTR) | 268 | if (data->intr_pin == PEN_DOWN_INTR) |
| 267 | wait_event_timeout(data->wait, data->touch_stopped, | 269 | wait_event_timeout(data->wait, data->touch_stopped, |
| 268 | msecs_to_jiffies(2)); | 270 | msecs_to_jiffies(2)); |
| @@ -418,10 +420,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) | |||
| 418 | { | 420 | { |
| 419 | bu21013_data->touch_stopped = true; | 421 | bu21013_data->touch_stopped = true; |
| 420 | wake_up(&bu21013_data->wait); | 422 | wake_up(&bu21013_data->wait); |
| 421 | free_irq(bu21013_data->chip->irq, bu21013_data); | 423 | free_irq(bu21013_data->irq, bu21013_data); |
| 422 | } | 424 | } |
| 423 | 425 | ||
| 424 | /** | 426 | /** |
| 427 | * bu21013_cs_disable() - deconfigures the touch panel controller | ||
| 428 | * @bu21013_data: device structure pointer | ||
| 429 | * | ||
| 430 | * This function is used to deconfigure the chip selection | ||
| 431 | * for touch panel controller. | ||
| 432 | */ | ||
| 433 | static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data) | ||
| 434 | { | ||
| 435 | int error; | ||
| 436 | |||
| 437 | error = gpio_direction_output(bu21013_data->chip->cs_pin, 0); | ||
| 438 | if (error < 0) | ||
| 439 | dev_warn(&bu21013_data->client->dev, | ||
| 440 | "%s: gpio direction failed, error: %d\n", | ||
| 441 | __func__, error); | ||
| 442 | else | ||
| 443 | gpio_set_value(bu21013_data->chip->cs_pin, 0); | ||
| 444 | |||
| 445 | gpio_free(bu21013_data->chip->cs_pin); | ||
| 446 | } | ||
| 447 | |||
| 448 | |||
| 449 | /** | ||
| 425 | * bu21013_probe() - initializes the i2c-client touchscreen driver | 450 | * bu21013_probe() - initializes the i2c-client touchscreen driver |
| 426 | * @client: i2c client structure pointer | 451 | * @client: i2c client structure pointer |
| 427 | * @id: i2c device id pointer | 452 | * @id: i2c device id pointer |
| @@ -430,7 +455,7 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) | |||
| 430 | * driver and returns integer. | 455 | * driver and returns integer. |
| 431 | */ | 456 | */ |
| 432 | static int bu21013_probe(struct i2c_client *client, | 457 | static int bu21013_probe(struct i2c_client *client, |
| 433 | const struct i2c_device_id *id) | 458 | const struct i2c_device_id *id) |
| 434 | { | 459 | { |
| 435 | struct bu21013_ts_data *bu21013_data; | 460 | struct bu21013_ts_data *bu21013_data; |
| 436 | struct input_dev *in_dev; | 461 | struct input_dev *in_dev; |
| @@ -449,6 +474,11 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 449 | return -EINVAL; | 474 | return -EINVAL; |
| 450 | } | 475 | } |
| 451 | 476 | ||
| 477 | if (!gpio_is_valid(pdata->touch_pin)) { | ||
| 478 | dev_err(&client->dev, "invalid touch_pin supplied\n"); | ||
| 479 | return -EINVAL; | ||
| 480 | } | ||
| 481 | |||
| 452 | bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); | 482 | bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); |
| 453 | in_dev = input_allocate_device(); | 483 | in_dev = input_allocate_device(); |
| 454 | if (!bu21013_data || !in_dev) { | 484 | if (!bu21013_data || !in_dev) { |
| @@ -460,6 +490,7 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 460 | bu21013_data->in_dev = in_dev; | 490 | bu21013_data->in_dev = in_dev; |
| 461 | bu21013_data->chip = pdata; | 491 | bu21013_data->chip = pdata; |
| 462 | bu21013_data->client = client; | 492 | bu21013_data->client = client; |
| 493 | bu21013_data->irq = gpio_to_irq(pdata->touch_pin); | ||
| 463 | 494 | ||
| 464 | bu21013_data->regulator = regulator_get(&client->dev, "avdd"); | 495 | bu21013_data->regulator = regulator_get(&client->dev, "avdd"); |
| 465 | if (IS_ERR(bu21013_data->regulator)) { | 496 | if (IS_ERR(bu21013_data->regulator)) { |
| @@ -478,12 +509,11 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 478 | init_waitqueue_head(&bu21013_data->wait); | 509 | init_waitqueue_head(&bu21013_data->wait); |
| 479 | 510 | ||
| 480 | /* configure the gpio pins */ | 511 | /* configure the gpio pins */ |
| 481 | if (pdata->cs_en) { | 512 | error = gpio_request_one(pdata->cs_pin, GPIOF_OUT_INIT_HIGH, |
| 482 | error = pdata->cs_en(pdata->cs_pin); | 513 | "touchp_reset"); |
| 483 | if (error < 0) { | 514 | if (error < 0) { |
| 484 | dev_err(&client->dev, "chip init failed\n"); | 515 | dev_err(&client->dev, "Unable to request gpio reset_pin\n"); |
| 485 | goto err_disable_regulator; | 516 | goto err_disable_regulator; |
| 486 | } | ||
| 487 | } | 517 | } |
| 488 | 518 | ||
| 489 | /* configure the touch panel controller */ | 519 | /* configure the touch panel controller */ |
| @@ -508,12 +538,13 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 508 | pdata->touch_y_max, 0, 0); | 538 | pdata->touch_y_max, 0, 0); |
| 509 | input_set_drvdata(in_dev, bu21013_data); | 539 | input_set_drvdata(in_dev, bu21013_data); |
| 510 | 540 | ||
| 511 | error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq, | 541 | error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq, |
| 512 | IRQF_TRIGGER_FALLING | IRQF_SHARED | | 542 | IRQF_TRIGGER_FALLING | IRQF_SHARED | |
| 513 | IRQF_ONESHOT, | 543 | IRQF_ONESHOT, |
| 514 | DRIVER_TP, bu21013_data); | 544 | DRIVER_TP, bu21013_data); |
| 515 | if (error) { | 545 | if (error) { |
| 516 | dev_err(&client->dev, "request irq %d failed\n", pdata->irq); | 546 | dev_err(&client->dev, "request irq %d failed\n", |
| 547 | bu21013_data->irq); | ||
| 517 | goto err_cs_disable; | 548 | goto err_cs_disable; |
| 518 | } | 549 | } |
| 519 | 550 | ||
| @@ -531,7 +562,7 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 531 | err_free_irq: | 562 | err_free_irq: |
| 532 | bu21013_free_irq(bu21013_data); | 563 | bu21013_free_irq(bu21013_data); |
| 533 | err_cs_disable: | 564 | err_cs_disable: |
| 534 | pdata->cs_dis(pdata->cs_pin); | 565 | bu21013_cs_disable(bu21013_data); |
| 535 | err_disable_regulator: | 566 | err_disable_regulator: |
| 536 | regulator_disable(bu21013_data->regulator); | 567 | regulator_disable(bu21013_data->regulator); |
| 537 | err_put_regulator: | 568 | err_put_regulator: |
| @@ -555,7 +586,7 @@ static int bu21013_remove(struct i2c_client *client) | |||
| 555 | 586 | ||
| 556 | bu21013_free_irq(bu21013_data); | 587 | bu21013_free_irq(bu21013_data); |
| 557 | 588 | ||
| 558 | bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin); | 589 | bu21013_cs_disable(bu21013_data); |
| 559 | 590 | ||
| 560 | input_unregister_device(bu21013_data->in_dev); | 591 | input_unregister_device(bu21013_data->in_dev); |
| 561 | 592 | ||
| @@ -584,9 +615,9 @@ static int bu21013_suspend(struct device *dev) | |||
| 584 | 615 | ||
| 585 | bu21013_data->touch_stopped = true; | 616 | bu21013_data->touch_stopped = true; |
| 586 | if (device_may_wakeup(&client->dev)) | 617 | if (device_may_wakeup(&client->dev)) |
| 587 | enable_irq_wake(bu21013_data->chip->irq); | 618 | enable_irq_wake(bu21013_data->irq); |
| 588 | else | 619 | else |
| 589 | disable_irq(bu21013_data->chip->irq); | 620 | disable_irq(bu21013_data->irq); |
| 590 | 621 | ||
| 591 | regulator_disable(bu21013_data->regulator); | 622 | regulator_disable(bu21013_data->regulator); |
| 592 | 623 | ||
| @@ -621,9 +652,9 @@ static int bu21013_resume(struct device *dev) | |||
