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

Commit 07a572e0 authored by Amy Maloche's avatar Amy Maloche Committed by Sudhakar Manapati
Browse files

input: synaptics_i2c_rmi4: Enable turning off regulators in suspend



In order to save maximum power, turn regulators completely off
instead of just putting into low power mode.

This patch is propagated from msm-3.4 kernel.
(commit: c790dc84494b016ffe65f3bc18793ed6bc6d5ff2
input: synaptics_i2c_rmi4: Enable turning off regulators in suspend)
Also cleaned the checkpatch warnings on msm-3.18 kernel.

Change-Id: I43042283dc1e06a8c26fd7b14556180389869059
Signed-off-by: default avatarAmy Maloche <amaloche@codeaurora.org>
Signed-off-by: default avatarSudhakar Manapati <smanap@codeaurora.org>
parent b5ea150d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ Optional property:
 - synaptics,panel-x		: panel x dimension
 - synaptics,panel-y		: panel y dimension
 - synaptics,fw-image-name	: name of firmware .img file in /etc/firmware
 - synaptics,power-down		: fully power down regulators in suspend

Example:
	i2c@f9927000 { /* BLSP1 QUP5 */
+62 −6
Original line number Diff line number Diff line
@@ -1052,6 +1052,8 @@ static int synaptics_rmi4_parse_dt(struct device *dev,

	rmi4_pdata->i2c_pull_up = of_property_read_bool(np,
			"synaptics,i2c-pull-up");
	rmi4_pdata->power_down_enable = of_property_read_bool(np,
			"synaptics,power-down");
	rmi4_pdata->x_flip = of_property_read_bool(np, "synaptics,x-flip");
	rmi4_pdata->y_flip = of_property_read_bool(np, "synaptics,y-flip");

@@ -1978,7 +1980,7 @@ static int synaptics_rmi4_power_on(struct synaptics_rmi4_data *rmi4_data,

error_reg_en_vcc_i2c:
	if (rmi4_data->board->i2c_pull_up)
		reg_set_optimum_mode_check(rmi4_data->vdd, 0);
		reg_set_optimum_mode_check(rmi4_data->vcc_i2c, 0);
error_reg_opt_i2c:
	regulator_disable(rmi4_data->vdd);
error_reg_en_vdd:
@@ -2550,27 +2552,51 @@ static int synaptics_rmi4_regulator_lpm(struct synaptics_rmi4_data *rmi4_data,
						bool on)
{
	int retval;
	int load_ua;

	if (on == false)
		goto regulator_hpm;

	retval = reg_set_optimum_mode_check(rmi4_data->vdd, RMI4_LPM_LOAD_UA);
	load_ua = rmi4_data->board->power_down_enable ? 0 : RMI4_LPM_LOAD_UA;
	retval = reg_set_optimum_mode_check(rmi4_data->vdd, load_ua);
	if (retval < 0) {
		dev_err(&rmi4_data->i2c_client->dev,
			"Regulator vcc_ana set_opt failed rc=%d\n",
			"Regulator vdd_ana set_opt failed rc=%d\n",
			retval);
		goto fail_regulator_lpm;
	}

	if (rmi4_data->board->power_down_enable) {
		retval = regulator_disable(rmi4_data->vdd);
		if (retval) {
			dev_err(&rmi4_data->i2c_client->dev,
				"Regulator vdd disable failed rc=%d\n",
				retval);
			goto fail_regulator_lpm;
		}
	}

	if (rmi4_data->board->i2c_pull_up) {
		load_ua = rmi4_data->board->power_down_enable ?
			0 : RMI4_I2C_LPM_LOAD_UA;
		retval = reg_set_optimum_mode_check(rmi4_data->vcc_i2c,
			RMI4_I2C_LPM_LOAD_UA);
			load_ua);
		if (retval < 0) {
			dev_err(&rmi4_data->i2c_client->dev,
				"Regulator vcc_i2c set_opt failed rc=%d\n",
				retval);
				"Regulator vcc_i2c set_opt failed ",
				"rc=%d\n", retval);
			goto fail_regulator_lpm;
		}

		if (rmi4_data->board->power_down_enable) {
			retval = regulator_disable(rmi4_data->vcc_i2c);
			if (retval) {
				dev_err(&rmi4_data->i2c_client->dev,
					"Regulator vcc_i2c disable failed ",
					"rc=%d\n", retval);
				goto fail_regulator_lpm;
			}
		}
	}

	return 0;
@@ -2586,6 +2612,16 @@ regulator_hpm:
		goto fail_regulator_hpm;
	}

	if (rmi4_data->board->power_down_enable) {
		retval = regulator_enable(rmi4_data->vdd);
		if (retval) {
			dev_err(&rmi4_data->i2c_client->dev,
				"Regulator vdd enable failed rc=%d\n",
				retval);
			goto fail_regulator_hpm;
		}
	}

	if (rmi4_data->board->i2c_pull_up) {
		retval = reg_set_optimum_mode_check(rmi4_data->vcc_i2c,
			RMI4_I2C_LOAD_UA);
@@ -2595,6 +2631,26 @@ regulator_hpm:
				retval);
			goto fail_regulator_hpm;
		}

		if (rmi4_data->board->power_down_enable) {
			retval = regulator_enable(rmi4_data->vcc_i2c);
			if (retval) {
				dev_err(&rmi4_data->i2c_client->dev,
					"Regulator vcc_i2c enable failed ",
					"rc=%d\n", retval);
				goto fail_regulator_hpm;
			}
		}
	}

	if (rmi4_data->board->power_down_enable) {
		retval = synaptics_rmi4_reset_device(rmi4_data);
		if (retval < 0) {
			dev_err(&rmi4_data->i2c_client->dev,
				"%s: Failed to issue reset command, rc = %d\n",
					__func__, retval);
			return retval;
		}
	}

	return 0;
+4 −0
Original line number Diff line number Diff line
@@ -35,8 +35,11 @@ struct synaptics_rmi4_capacitance_button_map {
 * struct synaptics_rmi4_platform_data - rmi4 platform data
 * @x_flip: x flip flag
 * @y_flip: y flip flag
 * @i2c_pull_up: pull up i2c bus with regulator
 * @power_down_enable: enable complete regulator shutdown in suspend
 * @irq_gpio: attention interrupt gpio
 * @irq_flags: flags used by the irq
 * @reset_flags: flags used by reset line
 * @reset_gpio: reset gpio
 * @panel_x: panel maximum values on the x
 * @panel_y: panel maximum values on the y
@@ -47,6 +50,7 @@ struct synaptics_rmi4_platform_data {
	bool x_flip;
	bool y_flip;
	bool i2c_pull_up;
	bool power_down_enable;
	unsigned irq_gpio;
	u32 irq_flags;
	u32 reset_flags;