Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39740370 authored by Heiko Stuebner's avatar Heiko Stuebner Committed by Dmitry Torokhov
Browse files

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: default avatarHeiko Stuebner <heiko.stuebner@bq.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 09c8fb63
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -9,6 +9,9 @@ Required properties:
- x-size: horizontal resolution of touchscreen
- x-size: horizontal resolution of touchscreen
- y-size: vertical resolution of touchscreen
- y-size: vertical resolution of touchscreen


Optional properties:
- vdd-supply: Regulator controlling the controller supply

Example:
Example:


	i2c@00000000 {
	i2c@00000000 {
@@ -18,6 +21,7 @@ Example:
			compatible = "neonode,zforce";
			compatible = "neonode,zforce";
			reg = <0x50>;
			reg = <0x50>;
			interrupts = <2 0>;
			interrupts = <2 0>;
			vdd-supply = <&reg_zforce_vdd>;


			gpios = <&gpio5 6 0>, /* INT */
			gpios = <&gpio5 6 0>, /* INT */
				<&gpio5 9 0>; /* RST */
				<&gpio5 9 0>; /* RST */
+31 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,8 @@
#include <linux/sysfs.h>
#include <linux/sysfs.h>
#include <linux/input/mt.h>
#include <linux/input/mt.h>
#include <linux/platform_data/zforce_ts.h>
#include <linux/platform_data/zforce_ts.h>
#include <linux/regulator/consumer.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_gpio.h>


@@ -117,6 +119,8 @@ struct zforce_ts {
	const struct zforce_ts_platdata *pdata;
	const struct zforce_ts_platdata *pdata;
	char			phys[32];
	char			phys[32];


	struct regulator	*reg_vdd;

	bool			suspending;
	bool			suspending;
	bool			suspended;
	bool			suspended;
	bool			boot_complete;
	bool			boot_complete;
@@ -690,6 +694,11 @@ static void zforce_reset(void *data)
	struct zforce_ts *ts = data;
	struct zforce_ts *ts = data;


	gpio_set_value(ts->pdata->gpio_rst, 0);
	gpio_set_value(ts->pdata->gpio_rst, 0);

	udelay(10);

	if (!IS_ERR(ts->reg_vdd))
		regulator_disable(ts->reg_vdd);
}
}


static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
@@ -765,10 +774,32 @@ static int zforce_probe(struct i2c_client *client,
		return ret;
		return ret;
	}
	}


	ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd");
	if (IS_ERR(ts->reg_vdd)) {
		ret = PTR_ERR(ts->reg_vdd);
		if (ret == -EPROBE_DEFER)
			return ret;
	} else {
		ret = regulator_enable(ts->reg_vdd);
		if (ret)
			return ret;

		/*
		 * according to datasheet add 100us grace time after regular
		 * regulator enable delay.
		 */
		udelay(100);
	}

	ret = devm_add_action(&client->dev, zforce_reset, ts);
	ret = devm_add_action(&client->dev, zforce_reset, ts);
	if (ret) {
	if (ret) {
		dev_err(&client->dev, "failed to register reset action, %d\n",
		dev_err(&client->dev, "failed to register reset action, %d\n",
			ret);
			ret);

		/* hereafter the regulator will be disabled by the action */
		if (!IS_ERR(ts->reg_vdd))
			regulator_disable(ts->reg_vdd);

		return ret;
		return ret;
	}
	}