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

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>

authored by

Heiko Stuebner and committed by
Dmitry Torokhov
39740370 09c8fb63

+35
+4
Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
··· 9 9 - x-size: horizontal resolution of touchscreen 10 10 - y-size: vertical resolution of touchscreen 11 11 12 + Optional properties: 13 + - vdd-supply: Regulator controlling the controller supply 14 + 12 15 Example: 13 16 14 17 i2c@00000000 { ··· 21 18 compatible = "neonode,zforce"; 22 19 reg = <0x50>; 23 20 interrupts = <2 0>; 21 + vdd-supply = <&reg_zforce_vdd>; 24 22 25 23 gpios = <&gpio5 6 0>, /* INT */ 26 24 <&gpio5 9 0>; /* RST */
+31
drivers/input/touchscreen/zforce_ts.c
··· 29 29 #include <linux/sysfs.h> 30 30 #include <linux/input/mt.h> 31 31 #include <linux/platform_data/zforce_ts.h> 32 + #include <linux/regulator/consumer.h> 33 + #include <linux/delay.h> 32 34 #include <linux/of.h> 33 35 #include <linux/of_gpio.h> 34 36 ··· 118 116 struct input_dev *input; 119 117 const struct zforce_ts_platdata *pdata; 120 118 char phys[32]; 119 + 120 + struct regulator *reg_vdd; 121 121 122 122 bool suspending; 123 123 bool suspended; ··· 694 690 struct zforce_ts *ts = data; 695 691 696 692 gpio_set_value(ts->pdata->gpio_rst, 0); 693 + 694 + udelay(10); 695 + 696 + if (!IS_ERR(ts->reg_vdd)) 697 + regulator_disable(ts->reg_vdd); 697 698 } 698 699 699 700 static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev) ··· 774 765 return ret; 775 766 } 776 767 768 + ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd"); 769 + if (IS_ERR(ts->reg_vdd)) { 770 + ret = PTR_ERR(ts->reg_vdd); 771 + if (ret == -EPROBE_DEFER) 772 + return ret; 773 + } else { 774 + ret = regulator_enable(ts->reg_vdd); 775 + if (ret) 776 + return ret; 777 + 778 + /* 779 + * according to datasheet add 100us grace time after regular 780 + * regulator enable delay. 781 + */ 782 + udelay(100); 783 + } 784 + 777 785 ret = devm_add_action(&client->dev, zforce_reset, ts); 778 786 if (ret) { 779 787 dev_err(&client->dev, "failed to register reset action, %d\n", 780 788 ret); 789 + 790 + /* hereafter the regulator will be disabled by the action */ 791 + if (!IS_ERR(ts->reg_vdd)) 792 + regulator_disable(ts->reg_vdd); 793 + 781 794 return ret; 782 795 } 783 796