diff options
| author | Heiko Stuebner <heiko.stuebner@bq.com> | 2014-07-21 13:02:11 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-07-21 13:28:53 -0400 |
| commit | 3974037039e925a9645e70e1dc91735d28faad95 (patch) | |
| tree | 7b2f7879d3b9463178643894b4bd69281ca5093b | |
| parent | 09c8fb63fb976f77af54f10a5ec2e3bb30dfc86f (diff) | |
Input: zforce - add regulator handling
It's possible that the controller has an individually switchable power supply.
Therefore add support to control a supplying regulator.
As this is not always the case, the regulator is requested as optional.
Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt | 4 | ||||
| -rw-r--r-- | drivers/input/touchscreen/zforce_ts.c | 31 |
2 files changed, 35 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt index 2faf1f1fa39e..80c37df940a7 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt | |||
| @@ -9,6 +9,9 @@ Required properties: | |||
| 9 | - x-size: horizontal resolution of touchscreen | 9 | - x-size: horizontal resolution of touchscreen |
| 10 | - y-size: vertical resolution of touchscreen | 10 | - y-size: vertical resolution of touchscreen |
| 11 | 11 | ||
| 12 | Optional properties: | ||
| 13 | - vdd-supply: Regulator controlling the controller supply | ||
| 14 | |||
| 12 | Example: | 15 | Example: |
| 13 | 16 | ||
| 14 | i2c@00000000 { | 17 | i2c@00000000 { |
| @@ -18,6 +21,7 @@ Example: | |||
| 18 | compatible = "neonode,zforce"; | 21 | compatible = "neonode,zforce"; |
| 19 | reg = <0x50>; | 22 | reg = <0x50>; |
| 20 | interrupts = <2 0>; | 23 | interrupts = <2 0>; |
| 24 | vdd-supply = <®_zforce_vdd>; | ||
| 21 | 25 | ||
| 22 | gpios = <&gpio5 6 0>, /* INT */ | 26 | gpios = <&gpio5 6 0>, /* INT */ |
| 23 | <&gpio5 9 0>; /* RST */ | 27 | <&gpio5 9 0>; /* RST */ |
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c index feea85b52fa8..8ba48f5eff7b 100644 --- a/drivers/input/touchscreen/zforce_ts.c +++ b/drivers/input/touchscreen/zforce_ts.c | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | #include <linux/sysfs.h> | 29 | #include <linux/sysfs.h> |
| 30 | #include <linux/input/mt.h> | 30 | #include <linux/input/mt.h> |
| 31 | #include <linux/platform_data/zforce_ts.h> | 31 | #include <linux/platform_data/zforce_ts.h> |
| 32 | #include <linux/regulator/consumer.h> | ||
| 33 | #include <linux/delay.h> | ||
| 32 | #include <linux/of.h> | 34 | #include <linux/of.h> |
| 33 | #include <linux/of_gpio.h> | 35 | #include <linux/of_gpio.h> |
| 34 | 36 | ||
| @@ -117,6 +119,8 @@ struct zforce_ts { | |||
| 117 | const struct zforce_ts_platdata *pdata; | 119 | const struct zforce_ts_platdata *pdata; |
| 118 | char phys[32]; | 120 | char phys[32]; |
| 119 | 121 | ||
| 122 | struct regulator *reg_vdd; | ||
| 123 | |||
| 120 | bool suspending; | 124 | bool suspending; |
| 121 | bool suspended; | 125 | bool suspended; |
| 122 | bool boot_complete; | 126 | bool boot_complete; |
| @@ -690,6 +694,11 @@ static void zforce_reset(void *data) | |||
| 690 | struct zforce_ts *ts = data; | 694 | struct zforce_ts *ts = data; |
| 691 | 695 | ||
| 692 | gpio_set_value(ts->pdata->gpio_rst, 0); | 696 | gpio_set_value(ts->pdata->gpio_rst, 0); |
| 697 | |||
| 698 | udelay(10); | ||
| 699 | |||
| 700 | if (!IS_ERR(ts->reg_vdd)) | ||
| 701 | regulator_disable(ts->reg_vdd); | ||
| 693 | } | 702 | } |
| 694 | 703 | ||
| 695 | static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev) | 704 | static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev) |
| @@ -765,10 +774,32 @@ static int zforce_probe(struct i2c_client *client, | |||
| 765 | return ret; | 774 | return ret; |
| 766 | } | 775 | } |
| 767 | 776 | ||
| 777 | ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd"); | ||
| 778 | if (IS_ERR(ts->reg_vdd)) { | ||
| 779 | ret = PTR_ERR(ts->reg_vdd); | ||
| 780 | if (ret == -EPROBE_DEFER) | ||
| 781 | return ret; | ||
| 782 | } else { | ||
| 783 | ret = regulator_enable(ts->reg_vdd); | ||
| 784 | if (ret) | ||
| 785 | return ret; | ||
| 786 | |||
| 787 | /* | ||
| 788 | * according to datasheet add 100us grace time after regular | ||
| 789 | * regulator enable delay. | ||
| 790 | */ | ||
| 791 | udelay(100); | ||
| 792 | } | ||
| 793 | |||
| 768 | ret = devm_add_action(&client->dev, zforce_reset, ts); | 794 | ret = devm_add_action(&client->dev, zforce_reset, ts); |
| 769 | if (ret) { | 795 | if (ret) { |
| 770 | dev_err(&client->dev, "failed to register reset action, %d\n", | 796 | dev_err(&client->dev, "failed to register reset action, %d\n", |
| 771 | ret); | 797 | ret); |
| 798 | |||
| 799 | /* hereafter the regulator will be disabled by the action */ | ||
| 800 | if (!IS_ERR(ts->reg_vdd)) | ||
| 801 | regulator_disable(ts->reg_vdd); | ||
| 802 | |||
| 772 | return ret; | 803 | return ret; |
| 773 | } | 804 | } |
| 774 | 805 | ||
