summaryrefslogtreecommitdiff
path: root/drivers/char/tpm/tpm_tis.c
diff options
context:
space:
mode:
authorAzhar Shaikh <azhar.shaikh@intel.com>2017-12-22 12:13:44 -0800
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2018-01-08 12:58:38 +0200
commitb3e958ce4c585bf666de249dc794971ebc62d2d3 (patch)
treee7cbb652ff058c2e5841ddb42071c02dfc102901 /drivers/char/tpm/tpm_tis.c
parentc382babccba2c82fe57f9e647f290fb7bf4d130d (diff)
tpm: Keep CLKRUN enabled throughout the duration of transmit_cmd()
Commit 5e572cab92f0bb5 ("tpm: Enable CLKRUN protocol for Braswell systems") disabled CLKRUN protocol during TPM transactions and re-enabled once the transaction is completed. But there were still some corner cases observed where, reading of TPM header failed for savestate command while going to suspend, which resulted in suspend failure. To fix this issue keep the CLKRUN protocol disabled for the entire duration of a single TPM command and not disabling and re-enabling again for every TPM transaction. For the other TPM accesses outside TPM command flow, add a higher level of disabling and re-enabling the CLKRUN protocol, instead of doing for every TPM transaction. Fixes: 5e572cab92f0bb5 ("tpm: Enable CLKRUN protocol for Braswell systems") Signed-off-by: Azhar Shaikh <azhar.shaikh@intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char/tpm/tpm_tis.c')
-rw-r--r--drivers/char/tpm/tpm_tis.c92
1 files changed, 10 insertions, 82 deletions
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 923f8f2cbaca..c847fc69a2fc 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -133,79 +133,17 @@ static int check_acpi_tpm2(struct device *dev)
}
#endif
-#ifdef CONFIG_X86
-#define LPC_CNTRL_OFFSET 0x84
-#define LPC_CLKRUN_EN (1 << 2)
-
-/**
- * tpm_platform_begin_xfer() - clear LPC CLKRUN_EN i.e. clocks will be running
- */
-static void tpm_platform_begin_xfer(struct tpm_tis_data *data)
-{
- u32 clkrun_val;
-
- if (!is_bsw())
- return;
-
- clkrun_val = ioread32(data->ilb_base_addr + LPC_CNTRL_OFFSET);
-
- /* Disable LPC CLKRUN# */
- clkrun_val &= ~LPC_CLKRUN_EN;
- iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET);
-
- /*
- * Write any random value on port 0x80 which is on LPC, to make
- * sure LPC clock is running before sending any TPM command.
- */
- outb(0xCC, 0x80);
-
-}
-
-/**
- * tpm_platform_end_xfer() - set LPC CLKRUN_EN i.e. clocks can be turned off
- */
-static void tpm_platform_end_xfer(struct tpm_tis_data *data)
-{
- u32 clkrun_val;
-
- if (!is_bsw())
- return;
-
- clkrun_val = ioread32(data->ilb_base_addr + LPC_CNTRL_OFFSET);
-
- /* Enable LPC CLKRUN# */
- clkrun_val |= LPC_CLKRUN_EN;
- iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET);
-
- /*
- * Write any random value on port 0x80 which is on LPC, to make
- * sure LPC clock is running before sending any TPM command.
- */
- outb(0xCC, 0x80);
-
-}
-#else
-static void tpm_platform_begin_xfer(struct tpm_tis_data *data)
-{
-}
-
-static void tpm_platform_end_xfer(struct tpm_tis_data *data)
-{
-}
-#endif
-
static int tpm_tcg_read_bytes(struct tpm_tis_data *data, u32 addr, u16 len,
u8 *result)
{
struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
- tpm_platform_begin_xfer(data);
+ if (is_bsw() && !(data->flags & TPM_TIS_CLK_ENABLE))
+ WARN(1, "CLKRUN not enabled!\n");
while (len--)
*result++ = ioread8(phy->iobase + addr);
- tpm_platform_end_xfer(data);
-
return 0;
}
@@ -214,13 +152,12 @@ static int tpm_tcg_write_bytes(struct tpm_tis_data *data, u32 addr, u16 len,
{
struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
- tpm_platform_begin_xfer(data);
+ if (is_bsw() && !(data->flags & TPM_TIS_CLK_ENABLE))
+ WARN(1, "CLKRUN not enabled!\n");
while (len--)
iowrite8(*value++, phy->iobase + addr);
- tpm_platform_end_xfer(data);
-
return 0;
}
@@ -228,12 +165,11 @@ static int tpm_tcg_read16(struct tpm_tis_data *data, u32 addr, u16 *result)
{
struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
- tpm_platform_begin_xfer(data);
+ if (is_bsw() && !(data->flags & TPM_TIS_CLK_ENABLE))
+ WARN(1, "CLKRUN not enabled!\n");
*result = ioread16(phy->iobase + addr);
- tpm_platform_end_xfer(data);
-
return 0;
}
@@ -241,12 +177,11 @@ static int tpm_tcg_read32(struct tpm_tis_data *data, u32 addr, u32 *result)
{
struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
- tpm_platform_begin_xfer(data);
+ if (is_bsw() && !(data->flags & TPM_TIS_CLK_ENABLE))
+ WARN(1, "CLKRUN not enabled!\n");
*result = ioread32(phy->iobase + addr);
- tpm_platform_end_xfer(data);
-
return 0;
}
@@ -254,12 +189,11 @@ static int tpm_tcg_write32(struct tpm_tis_data *data, u32 addr, u32 value)
{
struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
- tpm_platform_begin_xfer(data);
+ if (is_bsw() && !(data->flags & TPM_TIS_CLK_ENABLE))
+ WARN(1, "CLKRUN not enabled!\n");
iowrite32(value, phy->iobase + addr);
- tpm_platform_end_xfer(data);
-
return 0;
}
@@ -341,9 +275,6 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev)
tpm_chip_unregister(chip);
tpm_tis_remove(chip);
- if (is_bsw())
- iounmap(priv->ilb_base_addr);
-
}
static struct pnp_driver tis_pnp_driver = {
@@ -395,9 +326,6 @@ static int tpm_tis_plat_remove(struct platform_device *pdev)
tpm_chip_unregister(chip);
tpm_tis_remove(chip);
- if (is_bsw())
- iounmap(priv->ilb_base_addr);
-
return 0;
}