Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=82.195.75.108 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263515; b=AKhIg8yR/iNWnHpbbiScmzBsqn64fx1Omq28gpnRTrRtml8x1dHqGiW4C0tXmikPtcSN og/NJNg7roPXecjWhSG6cGfFC7pp8iJkVjavYxzQLBt1rB4uXEzuZ1O2TIP7EcP5Gs3YI DDxNRvo0yvTCAgqg6u2APF5Ku91RKsyRaZ3GtLdKWnglK+z1F7fgSSmzTLcfA8yQzqJSg BLPYMHg/eprjvmpBsV/vMC3EWrpC/gyqPeKIox658GYp/m2lF/ePZqdi+BYrsYy726US8 ygx/bY72voaFoJ+lhNPfVAkuNAZBBtBTy21N9V4n4Hm7mg2fl8A/W3t82TpXUoGwMww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263515; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Debian-User; bh=Gxh0XixMzptCkBH75Ngsg+JVPD76hPTWZ+RDbpNTgDE=; b=2NI7kDIrfb3mwiBzEXWNZy0DZssPj5lz0v3/3t+Up6agoWqIZq9ap2ZUsMpwefe8eLKQ jfCjGi8KwDED5Ky0DuTu+KOfWLpO2F8TvXFlOMCMCdfztb/wYnB9CtF5ymp9u0LJOJEGb 7NDW6xah3oOX6nXOpUYnw84uselwP0LDDN3q8ib0mPwfixTwaN4bDMV9XQtbp5JrOWjlB v7qVq8Dkab3FMFKNMkYoKNLAXtxkqpzYIKhbwfHMtZHyKwVHzZoY7d1mv+lx9X9D1fo8q XgzR8OkHte8jtGsCfcDhmfjtcJHCJMpG8xyt3Z1Rt3wc54G2mqfc0SiVm6j2O2FQu7g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b="wIx2F/GL"; arc=none smtp.remote-ip=82.195.75.108 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E056606A322; Thu, 3 Dec 2026 02:05:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3E056606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=wIx2F/GL DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-Type:Content-ID:Content-Description; bh=Gxh0XixMzptCkBH75Ngsg+JVPD76hPTWZ+RDbpNTgDE=; b=wIx2F/GLRV8D6h8dFizYJPdJUE wuU7yJKu8j/qqcHBQoEHb6GlChvom7vGOhEHuFJeTLFmeh3j+rxhNsM38H6bLuU1OgpBMneSjO7CA 3jIyXkJCR8BWBQWODOuS/zz2NqngKCceCPtuFW6abn5gLSIXSjScYTlnxNH5rqw9kgcT7dTBSA9O9 p7azgEk7GZ0eY0aqKf6BIcHFKqTVPhvlT7KvMvP8NuvWdamvYe0Lt31A9b4F67FKLIKGRCG7FSgGw B0LOoHJmqsccTW7ZmWDeQPRBg4qidgJPwn+1eJZGodFj7Q7yLAokVxIRl0NXZVm38V8awv2Jayl9X SkzM5bdg==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1xYwC5-001xMg-2y; Thu, 03 Dec 2026 02:05:10 +0000 From: Emfox Zhou To: Even Xu , Xinpeng Sun , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 5/6] HID: intel-thc-hid: intel-ipts: handle system sleep Date: Thu, 3 Dec 2026 10:04:14 +0800 Message-ID: <20261203020433.2631656-5-emfox@debian.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Debian-User: emfox Take the port down before system sleep and bring it back up after resume. Signed-off-by: Emfox Zhou --- .../hid/intel-thc-hid/intel-ipts/pci-ipts.c | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c b/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c index 746ef27e2..5da8cbf78 100644 --- a/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c +++ b/drivers/hid/intel-thc-hid/intel-ipts/pci-ipts.c @@ -151,6 +151,57 @@ static void thc_ipts_remove(struct pci_dev *pci) pci_clear_master(pci); } +static int thc_ipts_suspend(struct device *dev) +{ + struct thc_ipts *idev = dev_get_drvdata(dev); + + thc_ipts_port_stop(idev); + + return 0; +} + +static int thc_ipts_resume(struct device *dev) +{ + struct thc_ipts *idev = dev_get_drvdata(dev); + int ret; + + /* + * A restore brings the global enable back while the port is down: mask + * before starting. + */ + thc_interrupt_enable(idev->thc, false); + + ret = thc_ipts_port_start(idev); + if (ret) + thc_ipts_port_stop(idev); + + return ret; +} + +/* + * Mask as soon as configuration space is back: the line may already be + * asserted. + */ +static int thc_ipts_resume_noirq(struct device *dev) +{ + struct thc_ipts *idev = dev_get_drvdata(dev); + + thc_interrupt_enable(idev->thc, false); + + return 0; +} + +static const struct dev_pm_ops thc_ipts_pm_ops = { + .suspend = thc_ipts_suspend, + .resume = thc_ipts_resume, + .freeze = thc_ipts_suspend, + .thaw = thc_ipts_resume, + .poweroff = thc_ipts_suspend, + .restore = thc_ipts_resume, + .resume_noirq = thc_ipts_resume_noirq, + .restore_noirq = thc_ipts_resume_noirq, +}; + static void thc_ipts_shutdown(struct pci_dev *pci) { struct thc_ipts *idev = pci_get_drvdata(pci); @@ -165,6 +216,7 @@ static struct pci_driver thc_ipts_driver = { .probe = thc_ipts_probe, .remove = thc_ipts_remove, .shutdown = thc_ipts_shutdown, + .driver.pm = pm_sleep_ptr(&thc_ipts_pm_ops), /* Bring-up waits for the controller, up to a few seconds. */ .driver.probe_type = PROBE_PREFER_ASYNCHRONOUS, };