Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752426AbdCAMBC convert rfc822-to-8bit (ORCPT ); Wed, 1 Mar 2017 07:01:02 -0500 Received: from mout.gmx.net ([212.227.17.22]:50910 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbdCAMA6 (ORCPT ); Wed, 1 Mar 2017 07:00:58 -0500 Date: Wed, 01 Mar 2017 13:00:16 +0100 User-Agent: K-9 Mail for Android In-Reply-To: <20170301115116.19696-1-enric.balletbo@collabora.com> References: <20170301115116.19696-1-enric.balletbo@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH] tpm: do not suspend/resume if power stays on To: Enric Balletbo i Serra , Rob Herring CC: linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, Mark Rutland , Jarkko Sakkinen , Sonny Rao From: Peter Huewe Message-ID: X-Provags-ID: V03:K0:nOzZWDtfOPYrqyRbd6E/4N756Mdm12dy/NiZ8I02/fnPsT4BH2o PIFLavS532oHB2Vo4giu6gGOSgchREkQz09ywA0Znkh6Z8CA444Pv4b7mV0uBpViJkSf5c4 oz3utVRPYrUKVf7VS9xThZRmg8ZMZkDs7FJOZs14MvpvlM3R/J5RPqLjL91OoihHEY04nrN ify6zSnDXTrUirX3H4PsQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:7XsbOl5Ijb8=:prOz4f7/rABvyehf0rNqZS b8ODEUri9SN56BQ3EHND+btorkobDUNh2Av1ZDUiGg6VFCQjB8wx5l/f2CaLl7g/pH30fOWEe D73178xb5WCqCjgxcM8lR51Zh/ROgksau/8HymnGETwL2L9bZ+11ZybN7s0V46bmjSGPRwiMy 87DDkJInApo7htEl3zcpbdKfVTDi9vtrNb2HLwZitcJldl3C1rdJu2t/xuoZGe6PvRybmAO4p Y8GA9xx1bmIaJqZtH8eppET136K+SEW5fWw3PVsYXSS2pI+zflL6pmkJIpFWwtSBzeLKrSh9e /wCDFaCjjzwPEg7FJhZwzbug/z/yLfVMSZbDbxBEjVIMRBFvbbsC67duLwQ1lvPOyybVJ42CY kDgODvDWu8jRB00I4Mtjf13SN9zNNYAsQsgUZVtNAXLV0AapIizoqyBEu91H9C06YXKwNXMyM yq7Iac2+Ain/a/NTfeg4D4yGpF4bXl47gJxmbsxh/+hjFTPccWFZ0DXQi8NWV+Sk3zPcGs81J 4o5LU/wIKHahU92Fi6+wM6dguhQLLyAYUEItnYpeRfXvlG3ecPnszKlAGITNpf4QvgoqIF5Ux 9x6LPVLmErE7TVYLQzhUX42WwAslC42+QlljiiVI1Y9taMrhxgDXC+0I6bltf3ybBQLffH2cP 2PzVhaC7IvQi7mPw0Y4O6bIabVj1XmyB0ZjLBsf8NE2BO7YRuuu+6djfKPR1ohROKDtuDGIcS CcCIvXCROQ2HbiV1kbDsZ+jiJFBnipM7S2N9wMzgzjdkJG0r4M+8aHtQV9E1rZKyz9Iy/oJux DaZ2AdrBI1b+WCga3reUq1hJkzoP63JvNeUXkA1Znt8VbnFvuBwE2HEcq+3eaZI1Z+rAiAkwc LPz9HqewrKy2KCq2zB0Mw+cFYe0biqP3pYeKzvk4kN7nvTfTPGWiA1s+ep7TPjBpIw/PAhi7i Z8Ds/qxwO/J9eIWT24vxO+8YYZv2s3iWUYc07VSE7HC33/i9+U/sEkSZnlMhsFgdpjXaeiKkE +pA0A3HATzdnvI6E6Ui56r0= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3372 Lines: 113 Am 1. März 2017 12:51:16 MEZ schrieb Enric Balletbo i Serra : >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 Hi, for this device there exists a binding in the i2c subfolder https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/i2c/trivial-devices.txt?id=refs/tags/v4.10 Peter >@@ -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) -- Sent from my mobile