drivers: tpm2: update reset gpio semantics
PATCH v2 1/1 drivers: tpm2: update reset gpio semantics
Use the more generic reset-gpios propery name.
---
v2: kept gpio-reset as legacy
.../tpm2/tis-tpm2-spi.txt | 2 +- drivers/tpm/tpm2_tis_spi.c | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-)
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +1 -1
@@ -6,7 +6,7 @@ Required properties: - reg : SPI Chip select Optional properties: -- gpio-reset : Reset GPIO (if not connected to the SoC reset line) +- reset-gpios : Reset GPIO (if not connected to the SoC reset line) - spi-max-frequency : See spi-bus.txt Example:
drivers/tpm/tpm2_tis_spi.c +13 -8
@@ -589,18 +589,23 @@ static int tpm_tis_spi_probe(struct udevice *dev)if (CONFIG_IS_ENABLED (DM_GPIO )) {struct gpio_desc reset_gpio; - ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , &reset_gpio,GPIOD_IS_OUT );if (ret) { -log (LOGC_NONE ,LOGL_NOTICE ,"%s: missing reset GPIO\n" , - __func__); - }else { -dm_gpio_set_value (&reset_gpio,1 ); -mdelay (1 ); -dm_gpio_set_value (&reset_gpio,0 ); +/* legacy reset */ + ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + &reset_gpio,GPIOD_IS_OUT ); +if (ret) { +log (LOGC_NONE ,LOGL_NOTICE , +"%s: missing reset GPIO\n" , __func__); + goto init; + } } +dm_gpio_set_value (&reset_gpio,1 ); +mdelay (1 ); +dm_gpio_set_value (&reset_gpio,0 ); } - +init:/* Ensure a minimum amount of time elapsed since reset of the TPM */ mdelay (drv_data->time_before_first_cmd_ms);
Signature · 1 line
2.31.1
Quoted 15 lines · Jorge Ramirez-Ortiz
Use the more generic reset-gpios propery name.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>---
v2: kept gpio-reset as legacy.../tpm2/tis-tpm2-spi.txt | 2 +- drivers/tpm/tpm2_tis_spi.c | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-)doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-0
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt Required properties: · line 9
Quoted 4 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-1@@ -6,7 +6,7 @@ Required properties: - reg : SPI Chip select Optional properties: -- gpio-reset : Reset GPIO (if not connected to the SoC reset line)
As I said you shouldn't remove this. Just extend description that it is deprecated and reset-gpios should be used instead.
Quoted 20 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +1
-0+- reset-gpios : Reset GPIO (if not connected to the SoC reset line) - spi-max-frequency : See spi-bus.txt Example:drivers/tpm/tpm2_tis_spi.c +1
-5@@ -589,18 +589,23 @@ static int tpm_tis_spi_probe(struct udevice *dev)if (CONFIG_IS_ENABLED (DM_GPIO )) {struct gpio_desc reset_gpio; - ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , &reset_gpio,GPIOD_IS_OUT );if (ret) { -log (LOGC_NONE ,LOGL_NOTICE ,"%s: missing reset GPIO\n" , - __func__); - }else { -dm_gpio_set_value (&reset_gpio,1 );
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 602
Quoted 10 lines
drivers/tpm/tpm2_tis_spi.c +8
-2-mdelay (1 ); -dm_gpio_set_value (&reset_gpio,0 ); +/* legacy reset */ + ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + &reset_gpio,GPIOD_IS_OUT ); +if (ret) { +log (LOGC_NONE ,LOGL_NOTICE , +"%s: missing reset GPIO\n" , __func__); + goto init; + }
And here it is clear that gpio-reset is used which should deprecated that's why you should print message about it here.
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 607
Quoted 5 lines
drivers/tpm/tpm2_tis_spi.c +3
-0} +dm_gpio_set_value (&reset_gpio,1 ); +mdelay (1 ); +dm_gpio_set_value (&reset_gpio,0 ); }
What about this to remove that goto?
ret = gpio_request_by_name(dev, "reset-gpios", 0,
&reset_gpio, GPIOD_IS_OUT);
if (ret) {
/* trying legacy reset */
ret = gpio_request_by_name(dev, "gpio-reset", 0,
&reset_gpio, GPIOD_IS_OUT);
if (!ret)
log(LOGC_NONE, LOGL_NOTICE,
"%s: Using deprecated gpio-reset switch to reset-gpios\n", __func__);
}if (!ret) {
dm_gpio_set_value(&reset_gpio, 1);
mdelay(1);
dm_gpio_set_value(&reset_gpio, 0);
}drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 611
Quoted 6 lines
drivers/tpm/tpm2_tis_spi.c +1
-1- +init:/* Ensure a minimum amount of time elapsed since reset of the TPM */ mdelay (drv_data->time_before_first_cmd_ms);
M
Quoted 20 lines · Michal Simek
Quoted 17 lines · Jorge Ramirez-Ortiz
Use the more generic reset-gpios propery name.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>---
v2: kept gpio-reset as legacy.../tpm2/tis-tpm2-spi.txt | 2 +- drivers/tpm/tpm2_tis_spi.c | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-)doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-0@@ -6,7 +6,7 @@ Required properties: - reg : SPI Chip select
Quoted 5 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt Required properties: · line 9
Quoted 2 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-1Optional properties: -- gpio-reset : Reset GPIO (if not connected to the SoC reset line)As I said you shouldn't remove this. Just extend description that it is deprecated and reset-gpios should be used instead.
I dont really agree with that. IMO we should remove the documentation since it is obsolete after this commit and anyone reading it should not care about the gpio-reset property.
Quoted 26 lines
Quoted 26 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +1
-0+- reset-gpios : Reset GPIO (if not connected to the SoC reset line) - spi-max-frequency : See spi-bus.txt Example:drivers/tpm/tpm2_tis_spi.c +4
-7@@ -589,18 +589,23 @@ static int tpm_tis_spi_probe(struct udevice *dev)if (CONFIG_IS_ENABLED (DM_GPIO )) {struct gpio_desc reset_gpio; - ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , &reset_gpio,GPIOD_IS_OUT );if (ret) { -log (LOGC_NONE ,LOGL_NOTICE ,"%s: missing reset GPIO\n" , - __func__); - }else { -dm_gpio_set_value (&reset_gpio,1 ); -mdelay (1 ); -dm_gpio_set_value (&reset_gpio,0 ); +/* legacy reset */ + ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + &reset_gpio,GPIOD_IS_OUT );
Quoted 8 lines
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 602
Quoted 5 lines
drivers/tpm/tpm2_tis_spi.c +5
-0+if (ret) { +log (LOGC_NONE ,LOGL_NOTICE , +"%s: missing reset GPIO\n" , __func__); + goto init; + }And here it is clear that gpio-reset is used which should deprecated that's why you should print message about it here.
yes, I can do that. makes sense
Quoted 9 lines
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 607
Quoted 7 lines
drivers/tpm/tpm2_tis_spi.c +3
-0} +dm_gpio_set_value (&reset_gpio,1 ); +mdelay (1 ); +dm_gpio_set_value (&reset_gpio,0 ); }What about this to remove that goto?
um, what is the problem with the goto (IMO tidier than yet another conditional); it is not as if this goto is making the code obscure.
with the change below you just removed previous functionality (ie indicating that there is no GPIO reset provided, hence why at first sight might look cleaner than a goto)
Quoted 26 lines
ret = gpio_request_by_name(dev, "reset-gpios", 0,
&reset_gpio, GPIOD_IS_OUT); if (ret) { /* trying legacy reset */ ret = gpio_request_by_name(dev, "gpio-reset", 0, &reset_gpio, GPIOD_IS_OUT); if (!ret) log(LOGC_NONE, LOGL_NOTICE, "%s: Using deprecated gpio-reset switch to reset-gpios\n", __func__); }if (!ret) { dm_gpio_set_value(&reset_gpio, 1); mdelay(1); dm_gpio_set_value(&reset_gpio, 0); }drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 611
Quoted 6 lines
drivers/tpm/tpm2_tis_spi.c +1
-1- +init:/* Ensure a minimum amount of time elapsed since reset of the TPM */ mdelay (drv_data->time_before_first_cmd_ms);M
Quoted 27 lines · Foundries
Quoted 20 lines · Michal Simek
Quoted 17 lines · Jorge Ramirez-Ortiz
Use the more generic reset-gpios propery name.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>---
v2: kept gpio-reset as legacy.../tpm2/tis-tpm2-spi.txt | 2 +- drivers/tpm/tpm2_tis_spi.c | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-)doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-0@@ -6,7 +6,7 @@ Required properties: - reg : SPI Chip selectQuoted 5 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt Required properties: · line 9
Quoted 2 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-1Optional properties: -- gpio-reset : Reset GPIO (if not connected to the SoC reset line)As I said you shouldn't remove this. Just extend description that it is deprecated and reset-gpios should be used instead.
Quoted 3 lines
I dont really agree with that. IMO we should remove the documentation since it is obsolete after this commit and anyone reading it should not care about the gpio-reset property.
Run this on linux kernel and you will see that normal style is to keep it there.
git grep deprecated Documentation/devicetree/bindings
Quoted 48 lines
Quoted 27 lines
Quoted 27 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +1
-0+- reset-gpios : Reset GPIO (if not connected to the SoC reset line) - spi-max-frequency : See spi-bus.txt Example:drivers/tpm/tpm2_tis_spi.c +4
-7@@ -589,18 +589,23 @@ static int tpm_tis_spi_probe(struct udevice *dev)if (CONFIG_IS_ENABLED (DM_GPIO )) {struct gpio_desc reset_gpio; - ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , &reset_gpio,GPIOD_IS_OUT );if (ret) { -log (LOGC_NONE ,LOGL_NOTICE ,"%s: missing reset GPIO\n" , - __func__); - }else { -dm_gpio_set_value (&reset_gpio,1 ); -mdelay (1 ); -dm_gpio_set_value (&reset_gpio,0 ); +/* legacy reset */ + ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + &reset_gpio,GPIOD_IS_OUT );Quoted 8 lines
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 602
Quoted 5 lines
drivers/tpm/tpm2_tis_spi.c +5
-0+if (ret) { +log (LOGC_NONE ,LOGL_NOTICE , +"%s: missing reset GPIO\n" , __func__); + goto init; + }And here it is clear that gpio-reset is used which should deprecated that's why you should print message about it here.
yes, I can do that. makes sense
Quoted 9 lines
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 607
Quoted 7 lines
drivers/tpm/tpm2_tis_spi.c +3
-0} +dm_gpio_set_value (&reset_gpio,1 ); +mdelay (1 ); +dm_gpio_set_value (&reset_gpio,0 ); }What about this to remove that goto?
Quoted 6 lines
um, what is the problem with the goto (IMO tidier than yet another conditional); it is not as if this goto is making the code obscure.
with the change below you just removed previous functionality (ie indicating that there is no GPIO reset provided, hence why at first sight might look cleaner than a goto)
I tend to use goto unless there is no way around. But up2you.
M
Quoted 30 lines · Michal Simek
Quoted 27 lines · Foundries
Quoted 25 lines · Michal Simek
Quoted 15 lines · Jorge Ramirez-Ortiz
Use the more generic reset-gpios propery name.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>---
v2: kept gpio-reset as legacy.../tpm2/tis-tpm2-spi.txt | 2 +- drivers/tpm/tpm2_tis_spi.c | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-)doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-0doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt Required properties: · line 9
Quoted 4 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +0
-1@@ -6,7 +6,7 @@ Required properties: - reg : SPI Chip select Optional properties: -- gpio-reset : Reset GPIO (if not connected to the SoC reset line)As I said you shouldn't remove this. Just extend description that it is deprecated and reset-gpios should be used instead.
Quoted 7 lines
Quoted 3 lines
I dont really agree with that. IMO we should remove the documentation since it is obsolete after this commit and anyone reading it should not care about the gpio-reset property.
Run this on linux kernel and you will see that normal style is to keep it there.
git grep deprecatedDocumentation/devicetree/bindings
um, ok then (although IMO it only makes sense when we have the tools to parse such documents and apply them at build time)...if you have to read the docs you might just as well change the property.
will post later today (I am also adding an additional test to tpm2 to read the rng)
Quoted 60 lines
Quoted 49 lines
Quoted 28 lines
Quoted 28 lines
doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt +1
-0+- reset-gpios : Reset GPIO (if not connected to the SoC reset line) - spi-max-frequency : See spi-bus.txt Example:drivers/tpm/tpm2_tis_spi.c +4
-7@@ -589,18 +589,23 @@ static int tpm_tis_spi_probe(struct udevice *dev)if (CONFIG_IS_ENABLED (DM_GPIO )) {struct gpio_desc reset_gpio; - ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , &reset_gpio,GPIOD_IS_OUT );if (ret) { -log (LOGC_NONE ,LOGL_NOTICE ,"%s: missing reset GPIO\n" , - __func__); - }else { -dm_gpio_set_value (&reset_gpio,1 ); -mdelay (1 ); -dm_gpio_set_value (&reset_gpio,0 ); +/* legacy reset */ + ret =gpio_request_by_name (dev,"gpio-reset" ,0 , + &reset_gpio,GPIOD_IS_OUT );Quoted 8 lines
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 602
Quoted 5 lines
drivers/tpm/tpm2_tis_spi.c +5
-0+if (ret) { +log (LOGC_NONE ,LOGL_NOTICE , +"%s: missing reset GPIO\n" , __func__); + goto init; + }And here it is clear that gpio-reset is used which should deprecated that's why you should print message about it here.
yes, I can do that. makes sense
Quoted 9 lines
drivers/tpm/tpm2_tis_spi.c static int tpm_tis_spi_probe(struct udevice *dev) · line 607
Quoted 7 lines
drivers/tpm/tpm2_tis_spi.c +3
-0} +dm_gpio_set_value (&reset_gpio,1 ); +mdelay (1 ); +dm_gpio_set_value (&reset_gpio,0 ); }What about this to remove that goto?
Quoted 6 lines
um, what is the problem with the goto (IMO tidier than yet another conditional); it is not as if this goto is making the code obscure.
with the change below you just removed previous functionality (ie indicating that there is no GPIO reset provided, hence why at first sight might look cleaner than a goto)
I tend to use goto unless there is no way around. But up2you.
M