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

Commit 43cd233e authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "input: touchscreen: st: toggle reset gpio during error on SVM"

parents 580b4428 f57ed929
Loading
Loading
Loading
Loading
+508 −156

File changed.

Preview size limit exceeded, changes collapsed.

+60 −5
Original line number Diff line number Diff line
@@ -217,9 +217,59 @@ enum trusted_touch_mode_config {
	TRUSTED_TOUCH_MODE_NONE
};

enum trusted_touch_pvm_states {
	TRUSTED_TOUCH_PVM_INIT,
	PVM_I2C_RESOURCE_ACQUIRED,
	PVM_INTERRUPT_DISABLED,
	PVM_IOMEM_LENT,
	PVM_IOMEM_LENT_NOTIFIED,
	PVM_IRQ_LENT,
	PVM_IRQ_LENT_NOTIFIED,
	PVM_IOMEM_RELEASE_NOTIFIED,
	PVM_IRQ_RELEASE_NOTIFIED,
	PVM_ALL_RESOURCES_RELEASE_NOTIFIED,
	PVM_IRQ_RECLAIMED,
	PVM_IOMEM_RECLAIMED,
	PVM_INTERRUPT_ENABLED,
	PVM_I2C_RESOURCE_RELEASED,
	TRUSTED_TOUCH_PVM_STATE_MAX
};

enum trusted_touch_tvm_states {
	TRUSTED_TOUCH_TVM_INIT,
	TVM_IOMEM_LENT_NOTIFIED,
	TVM_IRQ_LENT_NOTIFIED,
	TVM_ALL_RESOURCES_LENT_NOTIFIED,
	TVM_IOMEM_ACCEPTED,
	TVM_I2C_SESSION_ACQUIRED,
	TVM_IRQ_ACCEPTED,
	TVM_INTERRUPT_ENABLED,
	TVM_INTERRUPT_DISABLED,
	TVM_IRQ_RELEASED,
	TVM_IOMEM_RELEASED,
	TVM_I2C_SESSION_RELEASED,
	TRUSTED_TOUCH_TVM_STATE_MAX
};

#ifdef CONFIG_ST_TRUSTED_TOUCH
#define TRUSTED_TOUCH_MEM_LABEL 0x7

#define TOUCH_RESET_GPIO_BASE 0xF116000
#define TOUCH_RESET_GPIO_SIZE 0x1000
#define TOUCH_RESET_GPIO_OFFSET 0x4
#define TOUCH_INTR_GPIO_BASE 0xF117000
#define TOUCH_INTR_GPIO_SIZE 0x1000
#define TOUCH_INTR_GPIO_OFFSET 0x8

#define TRUSTED_TOUCH_EVENT_LEND_FAILURE -1
#define TRUSTED_TOUCH_EVENT_LEND_NOTIFICATION_FAILURE -2
#define TRUSTED_TOUCH_EVENT_ACCEPT_FAILURE -3
#define	TRUSTED_TOUCH_EVENT_FUNCTIONAL_FAILURE -4
#define	TRUSTED_TOUCH_EVENT_RELEASE_FAILURE -5
#define	TRUSTED_TOUCH_EVENT_RECLAIM_FAILURE -6
#define	TRUSTED_TOUCH_EVENT_I2C_FAILURE -7
#define	TRUSTED_TOUCH_EVENT_NOTIFICATIONS_PENDING 5

struct trusted_touch_vm_info {
	enum hh_irq_label irq_label;
	enum hh_vm_names vm_name;
@@ -230,13 +280,17 @@ struct trusted_touch_vm_info {
	u32 iomem_list_size;
	void *mem_cookie;
#ifdef CONFIG_ARCH_QTI_VM
	atomic_t tvm_owns_iomem;
	atomic_t tvm_owns_irq;
	struct mutex tvm_state_mutex;
	atomic_t tvm_state;
#else
	atomic_t pvm_owns_iomem;
	atomic_t pvm_owns_irq;
	struct mutex pvm_state_mutex;
	atomic_t pvm_state;
#endif
};

#ifdef CONFIG_ARCH_QTI_VM
void fts_trusted_touch_tvm_i2c_failure_report(struct fts_ts_info *info);
#endif
#endif

/*
@@ -359,11 +413,12 @@ struct fts_ts_info {
	struct mutex fts_clk_io_ctrl_mutex;
	const char *touch_environment;
	struct completion trusted_touch_powerdown;
	struct completion resource_checkpoint;
	struct clk *core_clk;
	struct clk *iface_clk;
	atomic_t trusted_touch_initialized;
	atomic_t trusted_touch_enabled;
	atomic_t trusted_touch_event;
	atomic_t trusted_touch_abort_status;
	atomic_t delayed_vm_probe_pending;
	atomic_t trusted_touch_mode;
#endif
+45 −4
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
 *
 */

#include <linux/pm_runtime.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/platform_device.h>
@@ -141,13 +142,32 @@ int fts_readCmd(u8 *cmd, int cmdLength, u8 *outBuf, int byteToRead)
	while (retry < I2C_RETRY && ret < OK) {
		ret = i2c_transfer(client->adapter, I2CMsg, 2);
		retry++;
		if (ret < OK)
		if (ret < OK) {
#ifdef CONFIG_ST_TRUSTED_TOUCH
#ifdef CONFIG_ARCH_QTI_VM
			if (atomic_read(&info->trusted_touch_enabled) &&
					ret == -ECONNRESET){
				pr_err("failed i2c read reacquiring session\n");
				pm_runtime_put_sync(
					info->client->adapter->dev.parent);
				pm_runtime_get_sync(
					info->client->adapter->dev.parent);
			}
#endif
#endif
			msleep(I2C_WAIT_BEFORE_RETRY);
		}
	}
	if (ret < 0) {
#ifdef CONFIG_ST_TRUSTED_TOUCH
#ifdef CONFIG_ARCH_QTI_VM
		pr_err("initiating abort due to i2c xfer failure\n");
		fts_trusted_touch_tvm_i2c_failure_report(info);
#endif
#endif
		logError(1, "%s %s: ERROR %02X\n",
			tag, __func__, ERROR_I2C_R);
		return ERROR_I2C_R;
		return ret;
	}

	memcpy(outBuf, buf + cmdLength, byteToRead);
@@ -189,13 +209,34 @@ int fts_writeCmd(u8 *cmd, int cmdLength)
	while (retry < I2C_RETRY && ret < OK) {
		ret = i2c_transfer(client->adapter, I2CMsg, 1);
		retry++;
		if (ret < OK)
		if (ret < OK) {
#ifdef CONFIG_ST_TRUSTED_TOUCH
#ifdef CONFIG_ARCH_QTI_VM
			if (atomic_read(&info->trusted_touch_enabled) &&
					ret == -ECONNRESET){
				pr_err("failed i2c write reacquiring session\n");
				pm_runtime_put_sync(
					info->client->adapter->dev.parent);
				pm_runtime_get_sync(
					info->client->adapter->dev.parent);

			}
#endif
#endif
			msleep(I2C_WAIT_BEFORE_RETRY);
			logError(1, "ERROR: %d\n", ret);
		}
		//logError(1,"%s fts_writeCmd: attempt %d\n", tag, retry);
	}
	if (ret < 0) {
#ifdef CONFIG_ST_TRUSTED_TOUCH
#ifdef CONFIG_ARCH_QTI_VM
		pr_err("initiating abort due to i2c xfer failure\n");
		fts_trusted_touch_tvm_i2c_failure_report(info);
#endif
#endif
		logError(1, "%s %s: ERROR %02X\n", tag, __func__, ERROR_I2C_W);
		return ERROR_I2C_W;
		return ret;
	}
	return OK;
}
+5 −3
Original line number Diff line number Diff line
@@ -789,11 +789,13 @@ int fts_disableInterrupt(void)
int fts_enableInterrupt(void)
{
	u8 cmd[4] = { FTS_CMD_HW_REG_W, 0x00, 0x00, IER_ENABLE };
	int ret = 0;

	u16ToU8_be(IER_ADDR, &cmd[1]);
	if (fts_writeCmd(cmd, 4) < 0) {
		logError(1, "%s %s: ERROR %02X\n", tag, __func__, ERROR_I2C_W);
		return ERROR_I2C_W;
	ret = fts_writeCmd(cmd, 4);
	if (ret < 0) {
		logError(1, "%s %s: ERROR %d\n", tag, __func__, ret);
		return ret;
	}
	logError(0, "%s Interrupt Enabled!\n", tag);
	return OK;