From 4b9e3a62a26612758b67fa70ca123b84ae1f4b34 Mon Sep 17 00:00:00 2001 From: davidycchen Date: Wed, 29 Sep 2021 14:29:19 +0800 Subject: synaptics: support pinctrl configuration Support pinctrl configuration to modify the pin states when the touch suspend and resume. Bug: 199104450 Signed-off-by: davidycchen Change-Id: Idb809e28d1239e88f47cd39621292aa9609d0cc2 --- syna_tcm2.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'syna_tcm2.c') 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 */ -- cgit v1.2.3