From patchwork Wed Mar 1 11:51:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 9598291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A73160453 for ; Wed, 1 Mar 2017 11:51:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40D2628138 for ; Wed, 1 Mar 2017 11:51:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34F4D284F9; Wed, 1 Mar 2017 11:51:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9972E28138 for ; Wed, 1 Mar 2017 11:51:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cj2n7-0003Dv-KH; Wed, 01 Mar 2017 11:51:33 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cj2n7-0003Dq-7V for tpmdd-devel@lists.sourceforge.net; Wed, 01 Mar 2017 11:51:33 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of collabora.com designates 46.235.227.227 as permitted sender) client-ip=46.235.227.227; envelope-from=enric.balletbo@collabora.com; helo=bhuna.collabora.co.uk; Received: from bhuna.collabora.co.uk ([46.235.227.227]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1cj2n5-0002cE-UV for tpmdd-devel@lists.sourceforge.net; Wed, 01 Mar 2017 11:51:33 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 4ACD7267FA5 From: Enric Balletbo i Serra To: Rob Herring , Peter Huewe Date: Wed, 1 Mar 2017 12:51:16 +0100 Message-Id: <20170301115116.19696-1-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.9.3 X-Headers-End: 1cj2n5-0002cE-UV Cc: Mark Rutland , tpmdd-devel@lists.sourceforge.net, Sonny Rao , linux-kernel@vger.kernel.org Subject: [tpmdd-devel] [PATCH] tpm: do not suspend/resume if power stays on X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP From: Sonny Rao The suspend/resume behavior of the TPM can be controlled by setting "powered-while-suspended" in the DTS. Signed-off-by: Sonny Rao Signed-off-by: Enric Balletbo i Serra --- Documentation/devicetree/bindings/tpm/tpm.txt | 25 +++++++++++++++++++++++++ drivers/char/tpm/tpm_i2c_infineon.c | 25 ++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/tpm/tpm.txt diff --git a/Documentation/devicetree/bindings/tpm/tpm.txt b/Documentation/devicetree/bindings/tpm/tpm.txt new file mode 100644 index 0000000..af4de0d --- /dev/null +++ b/Documentation/devicetree/bindings/tpm/tpm.txt @@ -0,0 +1,25 @@ +TPM (Trusted Platform Module) + +A TPM on the I2C bus is a child of the node for the bus. + +Required properties: +- compatible: should be "infineon," +- reg: the I2C address + +Optional properties: +- powered-while-suspended: present when the TPM is left powered on between + suspend and resume (makes the suspend/resume callbacks do nothing). + +Example: + i2c@12C90000 { + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; + gpios = <&gpa1 2 3 3 0>, + <&gpa1 3 3 3 0>; + + tpm { + compatible = "infineon,slb9635tt"; + reg = <0x20>; + powered-while-suspended; + }; + }; diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c index 62ee44e..19d9522 100644 --- a/drivers/char/tpm/tpm_i2c_infineon.c +++ b/drivers/char/tpm/tpm_i2c_infineon.c @@ -70,6 +70,7 @@ struct tpm_inf_dev { u8 buf[TPM_BUFSIZE + sizeof(u8)]; /* max. buffer size + addr */ struct tpm_chip *chip; enum i2c_chip_type chip_type; + bool powered_while_suspended; }; static struct tpm_inf_dev tpm_dev; @@ -599,6 +600,11 @@ static int tpm_tis_i2c_init(struct device *dev) goto out_err; } + if (dev->of_node && + of_get_property(dev->of_node, "powered-while-suspended", NULL)) { + tpm_dev.powered_while_suspended = true; + } + /* read four bytes from DID_VID register */ if (iic_tpm_read(TPM_DID_VID(0), (u8 *)&vendor, 4) < 0) { dev_err(dev, "could not read vendor id\n"); @@ -662,7 +668,24 @@ static const struct of_device_id tpm_tis_i2c_of_match[] = { MODULE_DEVICE_TABLE(of, tpm_tis_i2c_of_match); #endif -static SIMPLE_DEV_PM_OPS(tpm_tis_i2c_ops, tpm_pm_suspend, tpm_pm_resume); +static int __maybe_unused tpm_tis_i2c_suspend(struct device *dev) +{ + if (tpm_dev.powered_while_suspended) + return 0; + + return tpm_pm_suspend(dev); +} + +static int __maybe_unused tpm_tis_i2c_resume(struct device *dev) +{ + if (tpm_dev.powered_while_suspended) + return 0; + + return tpm_pm_resume(dev); +} + +static SIMPLE_DEV_PM_OPS(tpm_tis_i2c_ops, tpm_tis_i2c_suspend, + tpm_tis_i2c_resume); static int tpm_tis_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)