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

Commit 36205baa authored by Amy Maloche's avatar Amy Maloche Committed by Abinaya P
Browse files

input: synaptics_i2c_rmi4: Add GPIO configuration support



Add GPIO support to driver.  This includes setup and delays
required for gpio toggling during device bootup.

This patch is a propagated patch from 3.4 kernel
commit - 946da663e60245ceefae015b34274627ada5fb38,
input: synaptics_i2c_rmi4: Add GPIO configuration support

Change-Id: I7945ac26d3655902346a4969ac264311a96d3cbf
Signed-off-by: default avatarAmy Maloche <amaloche@codeaurora.org>
parent b93fd1d6
Loading
Loading
Loading
Loading
+66 −7
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@
#define RMI4_I2C_LOAD_UA	10000
#define RMI4_I2C_LPM_LOAD_UA	10

#define RMI4_GPIO_SLEEP_LOW_US 10000
#define RMI4_GPIO_WAIT_HIGH_MS 25

static int synaptics_rmi4_i2c_read(struct synaptics_rmi4_data *rmi4_data,
		unsigned short addr, unsigned char *data,
@@ -1845,15 +1847,60 @@ static int synaptics_rmi4_probe(struct i2c_client *client,
	retval = synaptics_rmi4_regulator_configure(rmi4_data, true);
	if (retval < 0) {
		dev_err(&client->dev, "Failed to configure regulators\n");
		goto err_input_device;
		goto err_reg_configure;
	}

	retval = synaptics_rmi4_power_on(rmi4_data, true);
	if (retval < 0) {
		dev_err(&client->dev, "Failed to power on\n");
		goto err_input_device;
		goto err_power_device;
	}

	if (gpio_is_valid(platform_data->irq_gpio)) {
		/* configure touchscreen irq gpio */
		retval = gpio_request(platform_data->irq_gpio, "rmi4_irq_gpio");
		if (retval) {
			dev_err(&client->dev, "unable to request gpio [%d]\n",
						platform_data->irq_gpio);
			goto err_query_device;
		}
		retval = gpio_direction_input(platform_data->irq_gpio);
		if (retval) {
			dev_err(&client->dev,
				"unable to set direction for gpio [%d]\n",
				platform_data->irq_gpio);
			goto err_irq_gpio_req;
		}
	} else {
		dev_err(&client->dev, "irq gpio not provided\n");
		goto err_query_device;
	}

	if (gpio_is_valid(platform_data->reset_gpio)) {
		/* configure touchscreen reset out gpio */
		retval = gpio_request(platform_data->reset_gpio,
				"rmi4_reset_gpio");
		if (retval) {
			dev_err(&client->dev, "unable to request gpio [%d]\n",
						platform_data->reset_gpio);
			goto err_irq_gpio_req;
		}

		retval = gpio_direction_output(platform_data->reset_gpio, 1);
		if (retval) {
			dev_err(&client->dev,
				"unable to set direction for gpio [%d]\n",
				platform_data->reset_gpio);
			goto err_reset_gpio_req;
		}

		gpio_set_value(platform_data->reset_gpio, 0);
		usleep(RMI4_GPIO_SLEEP_LOW_US);
		gpio_set_value(platform_data->reset_gpio, 1);
		msleep(RMI4_GPIO_WAIT_HIGH_MS);
	}


	init_waitqueue_head(&rmi4_data->wait);
	mutex_init(&(rmi4_data->rmi4_io_ctrl_mutex));

@@ -1862,7 +1909,7 @@ static int synaptics_rmi4_probe(struct i2c_client *client,
		dev_err(&client->dev,
				"%s: Failed to query device\n",
				__func__);
		goto err_query_device;
		goto err_reset_gpio_req;
	}

	i2c_set_clientdata(client, rmi4_data);
@@ -1946,9 +1993,6 @@ err_enable_irq:
	input_unregister_device(rmi4_data->input_dev);

err_register_input:
err_query_device:
	synaptics_rmi4_power_on(rmi4_data, false);
	synaptics_rmi4_regulator_configure(rmi4_data, false);
	if (!list_empty(&rmi->support_fn_list)) {
		list_for_each_entry(fhandler, &rmi->support_fn_list, link) {
			if (fhandler->fn_number == SYNAPTICS_RMI4_F1A)
@@ -1958,6 +2002,17 @@ err_query_device:
			kfree(fhandler);
		}
	}
err_reset_gpio_req:
	if (gpio_is_valid(platform_data->reset_gpio))
		gpio_free(platform_data->reset_gpio);
err_irq_gpio_req:
	if (gpio_is_valid(platform_data->irq_gpio))
		gpio_free(platform_data->irq_gpio);
err_query_device:
	synaptics_rmi4_power_on(rmi4_data, false);
err_power_device:
	synaptics_rmi4_regulator_configure(rmi4_data, false);
err_reg_configure:
	input_free_device(rmi4_data->input_dev);
	rmi4_data->input_dev = NULL;
err_input_device:
@@ -2010,7 +2065,11 @@ static int synaptics_rmi4_remove(struct i2c_client *client)
			kfree(fhandler);
		}
	}
	input_free_device(rmi4_data->input_dev);

	if (gpio_is_valid(rmi4_data->board->reset_gpio))
		gpio_free(rmi4_data->board->reset_gpio);
	if (gpio_is_valid(rmi4_data->board->irq_gpio))
		gpio_free(rmi4_data->board->irq_gpio);

	synaptics_rmi4_power_on(rmi4_data, false);
	synaptics_rmi4_regulator_configure(rmi4_data, false);