diff options
author | Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com> | 2011-01-17 23:47:31 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-01-17 23:49:16 -0500 |
commit | 81e78deafb21ba867eb244ab1117726c68d817f8 (patch) | |
tree | 49e1e773b8a740961881a54c5bce741a0766ea74 | |
parent | d2763b4f44e16f44cc4156c9591e74df9dcd88be (diff) |
Input: bu21013_ts - added regulator support
Add regulator support in ROHM BU21013 touch panel driver.
Signed-off-by: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/touchscreen/bu21013_ts.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 3c7e60b2f778..1507ce108d5b 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/input.h> | 12 | #include <linux/input.h> |
13 | #include <linux/input/bu21013.h> | 13 | #include <linux/input/bu21013.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/regulator/consumer.h> | ||
15 | 16 | ||
16 | #define PEN_DOWN_INTR 0 | 17 | #define PEN_DOWN_INTR 0 |
17 | #define MAX_FINGERS 2 | 18 | #define MAX_FINGERS 2 |
@@ -139,6 +140,7 @@ | |||
139 | * @chip: pointer to the touch panel controller | 140 | * @chip: pointer to the touch panel controller |
140 | * @in_dev: pointer to the input device structure | 141 | * @in_dev: pointer to the input device structure |
141 | * @intr_pin: interrupt pin value | 142 | * @intr_pin: interrupt pin value |
143 | * @regulator: pointer to the Regulator used for touch screen | ||
142 | * | 144 | * |
143 | * Touch panel device data structure | 145 | * Touch panel device data structure |
144 | */ | 146 | */ |
@@ -149,6 +151,7 @@ struct bu21013_ts_data { | |||
149 | const struct bu21013_platform_device *chip; | 151 | const struct bu21013_platform_device *chip; |
150 | struct input_dev *in_dev; | 152 | struct input_dev *in_dev; |
151 | unsigned int intr_pin; | 153 | unsigned int intr_pin; |
154 | struct regulator *regulator; | ||
152 | }; | 155 | }; |
153 | 156 | ||
154 | /** | 157 | /** |
@@ -456,6 +459,20 @@ static int __devinit bu21013_probe(struct i2c_client *client, | |||
456 | bu21013_data->in_dev = in_dev; | 459 | bu21013_data->in_dev = in_dev; |
457 | bu21013_data->chip = pdata; | 460 | bu21013_data->chip = pdata; |
458 | bu21013_data->client = client; | 461 | bu21013_data->client = client; |
462 | |||
463 | bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH"); | ||
464 | if (IS_ERR(bu21013_data->regulator)) { | ||
465 | dev_err(&client->dev, "regulator_get failed\n"); | ||
466 | error = PTR_ERR(bu21013_data->regulator); | ||
467 | goto err_free_mem; | ||
468 | } | ||
469 | |||
470 | error = regulator_enable(bu21013_data->regulator); | ||
471 | if (error < 0) { | ||
472 | dev_err(&client->dev, "regulator enable failed\n"); | ||
473 | goto err_put_regulator; | ||
474 | } | ||
475 | |||
459 | bu21013_data->touch_stopped = false; | 476 | bu21013_data->touch_stopped = false; |
460 | init_waitqueue_head(&bu21013_data->wait); | 477 | init_waitqueue_head(&bu21013_data->wait); |
461 | 478 | ||
@@ -464,7 +481,7 @@ static int __devinit bu21013_probe(struct i2c_client *client, | |||
464 | error = pdata->cs_en(pdata->cs_pin); | 481 | error = pdata->cs_en(pdata->cs_pin); |
465 | if (error < 0) { | 482 | if (error < 0) { |
466 | dev_err(&client->dev, "chip init failed\n"); | 483 | dev_err(&client->dev, "chip init failed\n"); |
467 | goto err_free_mem; | 484 | goto err_disable_regulator; |
468 | } | 485 | } |
469 | } | 486 | } |
470 | 487 | ||
@@ -513,6 +530,10 @@ err_free_irq: | |||
513 | bu21013_free_irq(bu21013_data); | 530 | bu21013_free_irq(bu21013_data); |
514 | err_cs_disable: | 531 | err_cs_disable: |
515 | pdata->cs_dis(pdata->cs_pin); | 532 | pdata->cs_dis(pdata->cs_pin); |
533 | err_disable_regulator: | ||
534 | regulator_disable(bu21013_data->regulator); | ||
535 | err_put_regulator: | ||
536 | regulator_put(bu21013_data->regulator); | ||
516 | err_free_mem: | 537 | err_free_mem: |
517 | input_free_device(in_dev); | 538 | input_free_device(in_dev); |
518 | kfree(bu21013_data); | 539 | kfree(bu21013_data); |
@@ -535,6 +556,10 @@ static int __devexit bu21013_remove(struct i2c_client *client) | |||
535 | bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin); | 556 | bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin); |
536 | 557 | ||
537 | input_unregister_device(bu21013_data->in_dev); | 558 | input_unregister_device(bu21013_data->in_dev); |
559 | |||
560 | regulator_disable(bu21013_data->regulator); | ||
561 | regulator_put(bu21013_data->regulator); | ||
562 | |||
538 | kfree(bu21013_data); | 563 | kfree(bu21013_data); |
539 | 564 | ||
540 | device_init_wakeup(&client->dev, false); | 565 | device_init_wakeup(&client->dev, false); |
@@ -561,6 +586,8 @@ static int bu21013_suspend(struct device *dev) | |||
561 | else | 586 | else |
562 | disable_irq(bu21013_data->chip->irq); | 587 | disable_irq(bu21013_data->chip->irq); |
563 | 588 | ||
589 | regulator_disable(bu21013_data->regulator); | ||
590 | |||
564 | return 0; | 591 | return 0; |
565 | } | 592 | } |
566 | 593 | ||
@@ -577,6 +604,12 @@ static int bu21013_resume(struct device *dev) | |||
577 | struct i2c_client *client = bu21013_data->client; | 604 | struct i2c_client *client = bu21013_data->client; |
578 | int retval; | 605 | int retval; |
579 | 606 | ||
607 | retval = regulator_enable(bu21013_data->regulator); | ||
608 | if (retval < 0) { | ||
609 | dev_err(&client->dev, "bu21013 regulator enable failed\n"); | ||
610 | return retval; | ||
611 | } | ||
612 | |||
580 | retval = bu21013_init_chip(bu21013_data); | 613 | retval = bu21013_init_chip(bu21013_data); |
581 | if (retval < 0) { | 614 | if (retval < 0) { |
582 | dev_err(&client->dev, "bu21013 controller config failed\n"); | 615 | dev_err(&client->dev, "bu21013 controller config failed\n"); |