diff mbox

[v4,1/4] tpm/tpm_i2c_stm_st33: Replace access to io_lpcpd from struct st33zp24_platform_data to tpm_stm_dev

Message ID 1422220293-21005-2-git-send-email-christophe-h.ricard@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christophe Ricard Jan. 25, 2015, 9:11 p.m. UTC
io_lpcpd is accessible from struct tpm_stm_dev.
struct st33zp24_platform_data is only valid when using static platform
configuration data, not when using dts.

Reviewed-by: Jason Gunthorpe <jason.gunthorpe@obsidianresearch.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
 drivers/char/tpm/tpm_i2c_stm_st33.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Peter Huewe Jan. 26, 2015, 10:15 p.m. UTC | #1
Hi Christophe,
Am Sonntag, 25. Januar 2015, 22:11:30 schrieb Christophe Ricard:
> io_lpcpd is accessible from struct tpm_stm_dev.
> struct st33zp24_platform_data is only valid when using static platform
> configuration data, not when using dts.
> 
> Reviewed-by: Jason Gunthorpe <jason.gunthorpe@obsidianresearch.com>
> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
> ---
>  drivers/char/tpm/tpm_i2c_stm_st33.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c
> b/drivers/char/tpm/tpm_i2c_stm_st33.c index 612845b..882c60a 100644
> --- a/drivers/char/tpm/tpm_i2c_stm_st33.c
> +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
> @@ -837,11 +837,14 @@ static int tpm_stm_i2c_remove(struct i2c_client
> *client) */
>  static int tpm_stm_i2c_pm_suspend(struct device *dev)
>  {
> -	struct st33zp24_platform_data *pin_infos = dev->platform_data;
> +	struct tpm_chip *chip = dev_get_drvdata(dev);
> +	struct tpm_stm_dev *tpm_dev;
>  	int ret = 0;
> 
> -	if (gpio_is_valid(pin_infos->io_lpcpd))
> -		gpio_set_value(pin_infos->io_lpcpd, 0);
> +	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
> +
> +	if (gpio_is_valid(tpm_dev->io_lpcpd))
> +		gpio_set_value(tpm_dev->io_lpcpd, 0);
>  	else
>  		ret = tpm_pm_suspend(dev);

I know this is not changed by this patch, but
don't you need to send a tpm savestate? or is this implicit by pulling 
io_lpcpd ?



> 
> @@ -856,12 +859,13 @@ static int tpm_stm_i2c_pm_suspend(struct device *dev)
>  static int tpm_stm_i2c_pm_resume(struct device *dev)
>  {
>  	struct tpm_chip *chip = dev_get_drvdata(dev);
> -	struct st33zp24_platform_data *pin_infos = dev->platform_data;
> -
> +	struct tpm_stm_dev *tpm_dev;
>  	int ret = 0;
> 
> -	if (gpio_is_valid(pin_infos->io_lpcpd)) {
> -		gpio_set_value(pin_infos->io_lpcpd, 1);
> +	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
> +
> +	if (gpio_is_valid(tpm_dev->io_lpcpd)) {
> +		gpio_set_value(tpm_dev->io_lpcpd, 1);
>  		ret = wait_for_stat(chip,
>  				TPM_STS_VALID, chip->vendor.timeout_b,
>  				&chip->vendor.read_queue, false);


Same applies to startup(STATE) on resume?

Peter

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
Christophe Ricard Jan. 26, 2015, 10:18 p.m. UTC | #2
Hi Peter,

The lpcpd pin allow the tpm to go in low power mode keeping the current 
context in RAM.
As mention in the dts documentation:
"If set, power must be present when the platform is going into 
sleep/hibernate mode."
The gpio state is enough to save and restore the context.
This allows for example saving some memory wear or quicker state changes...

Best Regards
Christophe
On 26/01/2015 23:15, Peter Hüwe wrote:
> Hi Christophe,
> Am Sonntag, 25. Januar 2015, 22:11:30 schrieb Christophe Ricard:
>> io_lpcpd is accessible from struct tpm_stm_dev.
>> struct st33zp24_platform_data is only valid when using static platform
>> configuration data, not when using dts.
>>
>> Reviewed-by: Jason Gunthorpe <jason.gunthorpe@obsidianresearch.com>
>> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
>> ---
>>   drivers/char/tpm/tpm_i2c_stm_st33.c | 18 +++++++++++-------
>>   1 file changed, 11 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c
>> b/drivers/char/tpm/tpm_i2c_stm_st33.c index 612845b..882c60a 100644
>> --- a/drivers/char/tpm/tpm_i2c_stm_st33.c
>> +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
>> @@ -837,11 +837,14 @@ static int tpm_stm_i2c_remove(struct i2c_client
>> *client) */
>>   static int tpm_stm_i2c_pm_suspend(struct device *dev)
>>   {
>> -	struct st33zp24_platform_data *pin_infos = dev->platform_data;
>> +	struct tpm_chip *chip = dev_get_drvdata(dev);
>> +	struct tpm_stm_dev *tpm_dev;
>>   	int ret = 0;
>>
>> -	if (gpio_is_valid(pin_infos->io_lpcpd))
>> -		gpio_set_value(pin_infos->io_lpcpd, 0);
>> +	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
>> +
>> +	if (gpio_is_valid(tpm_dev->io_lpcpd))
>> +		gpio_set_value(tpm_dev->io_lpcpd, 0);
>>   	else
>>   		ret = tpm_pm_suspend(dev);
> I know this is not changed by this patch, but
> don't you need to send a tpm savestate? or is this implicit by pulling
> io_lpcpd ?
>
>
>
>> @@ -856,12 +859,13 @@ static int tpm_stm_i2c_pm_suspend(struct device *dev)
>>   static int tpm_stm_i2c_pm_resume(struct device *dev)
>>   {
>>   	struct tpm_chip *chip = dev_get_drvdata(dev);
>> -	struct st33zp24_platform_data *pin_infos = dev->platform_data;
>> -
>> +	struct tpm_stm_dev *tpm_dev;
>>   	int ret = 0;
>>
>> -	if (gpio_is_valid(pin_infos->io_lpcpd)) {
>> -		gpio_set_value(pin_infos->io_lpcpd, 1);
>> +	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
>> +
>> +	if (gpio_is_valid(tpm_dev->io_lpcpd)) {
>> +		gpio_set_value(tpm_dev->io_lpcpd, 1);
>>   		ret = wait_for_stat(chip,
>>   				TPM_STS_VALID, chip->vendor.timeout_b,
>>   				&chip->vendor.read_queue, false);
>
> Same applies to startup(STATE) on resume?
>
> Peter


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
index 612845b..882c60a 100644
--- a/drivers/char/tpm/tpm_i2c_stm_st33.c
+++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
@@ -837,11 +837,14 @@  static int tpm_stm_i2c_remove(struct i2c_client *client)
  */
 static int tpm_stm_i2c_pm_suspend(struct device *dev)
 {
-	struct st33zp24_platform_data *pin_infos = dev->platform_data;
+	struct tpm_chip *chip = dev_get_drvdata(dev);
+	struct tpm_stm_dev *tpm_dev;
 	int ret = 0;
 
-	if (gpio_is_valid(pin_infos->io_lpcpd))
-		gpio_set_value(pin_infos->io_lpcpd, 0);
+	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
+
+	if (gpio_is_valid(tpm_dev->io_lpcpd))
+		gpio_set_value(tpm_dev->io_lpcpd, 0);
 	else
 		ret = tpm_pm_suspend(dev);
 
@@ -856,12 +859,13 @@  static int tpm_stm_i2c_pm_suspend(struct device *dev)
 static int tpm_stm_i2c_pm_resume(struct device *dev)
 {
 	struct tpm_chip *chip = dev_get_drvdata(dev);
-	struct st33zp24_platform_data *pin_infos = dev->platform_data;
-
+	struct tpm_stm_dev *tpm_dev;
 	int ret = 0;
 
-	if (gpio_is_valid(pin_infos->io_lpcpd)) {
-		gpio_set_value(pin_infos->io_lpcpd, 1);
+	tpm_dev = (struct tpm_stm_dev *)TPM_VPRIV(chip);
+
+	if (gpio_is_valid(tpm_dev->io_lpcpd)) {
+		gpio_set_value(tpm_dev->io_lpcpd, 1);
 		ret = wait_for_stat(chip,
 				TPM_STS_VALID, chip->vendor.timeout_b,
 				&chip->vendor.read_queue, false);