@@ -24,6 +24,7 @@
#include <linux/wait.h>
#include <linux/acpi.h>
#include <linux/freezer.h>
+#include <linux/gpio/consumer.h>
#include "tpm.h"
#include "tpm_tis_core.h"
@@ -919,6 +920,21 @@ static const struct tpm_class_ops tpm_tis = {
.clk_enable = tpm_tis_clkrun_enable,
};
+/*
+ * Retrieve the reset GPIO if it is defined.
+ */
+static int tpm_tis_get_reset_gpio(struct device *dev, struct tpm_tis_data *data)
+{
+ data->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR(data->reset_gpio))
+ return PTR_ERR(data->reset_gpio);
+
+ if (data->reset_gpio)
+ gpiod_set_consumer_name(data->reset_gpio, "TPM reset");
+
+ return 0;
+}
+
int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
const struct tpm_tis_phy_ops *phy_ops,
acpi_handle acpi_dev_handle)
@@ -952,6 +968,10 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
dev_set_drvdata(&chip->dev, priv);
+ rc = tpm_tis_get_reset_gpio(dev, priv);
+ if (rc)
+ return rc;
+
if (priv->phy_ops->unset_reset)
priv->phy_ops->unset_reset(priv);
@@ -94,6 +94,7 @@ struct tpm_tis_data {
int irq;
bool irq_tested;
unsigned long flags;
+ struct gpio_desc *reset_gpio;
void __iomem *ilb_base_addr;
u16 clkrun_enabled;
wait_queue_head_t int_queue;
Get the optionally specified reset gpio. This property can be set with the con-id "reset-gpios". Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de> --- drivers/char/tpm/tpm_tis_core.c | 20 ++++++++++++++++++++ drivers/char/tpm/tpm_tis_core.h | 1 + 2 files changed, 21 insertions(+)