summaryrefslogtreecommitdiff
path: root/syna_tcm2.c
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2021-09-29 14:29:19 +0800
committerDavid Chen <davidycchen@google.com>2021-10-05 09:32:20 +0000
commit4b9e3a62a26612758b67fa70ca123b84ae1f4b34 (patch)
treef2531f813bc18702a31f473908ddd8d87d7432f4 /syna_tcm2.c
parent1ae7a213d8728bba95c797919cae0daf7f168f04 (diff)
downloadsynaptics_touch-4b9e3a62a26612758b67fa70ca123b84ae1f4b34.tar.gz
synaptics: support pinctrl configuration
Support pinctrl configuration to modify the pin states when the touch suspend and resume. Bug: 199104450 Signed-off-by: davidycchen <davidycchen@google.com> Change-Id: Idb809e28d1239e88f47cd39621292aa9609d0cc2
Diffstat (limited to 'syna_tcm2.c')
-rw-r--r--syna_tcm2.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/syna_tcm2.c b/syna_tcm2.c
index 11883c8..f43d6cd 100644
--- a/syna_tcm2.c
+++ b/syna_tcm2.c
@@ -1014,6 +1014,34 @@ static int syna_dev_enter_lowpwr_sensing(struct syna_tcm *tcm)
return 0;
}
+
+static int syna_pinctrl_configure(struct syna_tcm *tcm, bool enable)
+{
+ struct pinctrl_state *state;
+
+ if (IS_ERR_OR_NULL(tcm->pinctrl)) {
+ LOGE("Invalid pinctrl!\n");
+ return -EINVAL;
+ }
+
+ LOGD("%s\n", enable ? "ACTIVE" : "SUSPEND");
+
+ if (enable) {
+ state = pinctrl_lookup_state(tcm->pinctrl, "ts_active");
+ if (IS_ERR(state))
+ LOGE("Could not get ts_active pinstate!\n");
+ } else {
+ state = pinctrl_lookup_state(tcm->pinctrl, "ts_suspend");
+ if (IS_ERR(state))
+ LOGE("Could not get ts_suspend pinstate!\n");
+ }
+
+ if (!IS_ERR_OR_NULL(state))
+ return pinctrl_select_state(tcm->pinctrl, state);
+
+ return 0;
+}
+
/**
* syna_dev_resume()
*
@@ -1040,6 +1068,8 @@ static int syna_dev_resume(struct device *dev)
LOGI("Prepare to resume device\n");
+ syna_pinctrl_configure(tcm, true);
+
#ifdef RESET_ON_RESUME
syna_pal_sleep_ms(RESET_ON_RESUME_DELAY_MS);
@@ -1149,6 +1179,8 @@ static int syna_dev_suspend(struct device *dev)
if (irq_disabled && (hw_if->ops_enable_irq))
hw_if->ops_enable_irq(hw_if, false);
+ syna_pinctrl_configure(tcm, false);
+
LOGI("Device suspended (pwr_state:%d)\n", tcm->pwr_state);
return 0;
@@ -1699,6 +1731,13 @@ static int syna_dev_probe(struct platform_device *pdev)
return -ENOMEM;
}
+ tcm->pinctrl = devm_pinctrl_get(pdev->dev.parent);
+ if (IS_ERR_OR_NULL(tcm->pinctrl)) {
+ LOGE("Could not get pinctrl!\n");
+ } else {
+ syna_pinctrl_configure(tcm, true);
+ }
+
/* allocate the TouchCom device handle
* recommend to set polling mode here because isr is not registered yet
*/