Files
meta-pengwyn/recipes-kernel/linux/files/0002-printk-tpm-spi.patch
T

241 lines
7.2 KiB
Diff

--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -36,12 +36,16 @@ static int tpm_request_locality(struct tpm_chip *chip)
{
int rc;
- if (!chip->ops->request_locality)
+ if (!chip->ops->request_locality) {
+ printk(KERN_INFO "[REQUEST LOCALITY] no function\n");
return 0;
+ }
rc = chip->ops->request_locality(chip, 0);
- if (rc < 0)
+ if (rc < 0) {
+ printk(KERN_INFO "[REQUEST LOCALITY] function error\n");
return rc;
+ }
chip->locality = rc;
return 0;
@@ -104,9 +108,11 @@ int tpm_chip_start(struct tpm_chip *chip)
tpm_clk_enable(chip);
if (chip->locality == -1) {
+ printk(KERN_INFO "[START] locality = -1\n");
ret = tpm_request_locality(chip);
if (ret) {
tpm_clk_disable(chip);
+ printk(KERN_INFO "[START] request locality error\n");
return ret;
}
}
@@ -115,6 +121,7 @@ int tpm_chip_start(struct tpm_chip *chip)
if (ret) {
tpm_relinquish_locality(chip);
tpm_clk_disable(chip);
+ printk(KERN_INFO "[START] cmd ready error\n");
return ret;
}
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -105,13 +105,17 @@ static int wait_startup(struct tpm_chip *chip, int l)
u8 access;
rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access);
- if (rc < 0)
+ if (rc < 0) {
+ printk(KERN_INFO "[WAIT_STARTUP] read byte error (addr: 0x%x, rc: %d)\n", TPM_ACCESS(l), rc);
return rc;
+ }
+ printk(KERN_INFO "[WAIT_STARTUP] access: %x\n", access);
if (access & TPM_ACCESS_VALID)
return 0;
tpm_msleep(TPM_TIMEOUT);
} while (time_before(jiffies, stop));
+ printk(KERN_INFO "[WAIT_STARTUP] timeout - return -1\n");
return -1;
}
@@ -122,12 +126,16 @@ static bool check_locality(struct tpm_chip *chip, int l)
u8 access;
rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access);
- if (rc < 0)
+ if (rc < 0) {
+ printk(KERN_INFO "[CHECK LOCALITY] read8 error\n");
return false;
+ }
+ printk(KERN_INFO "[CHECK LOCALITY] read8: 0x%x\n", access);
if ((access & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) {
priv->locality = l;
+ printk(KERN_INFO "[CHECK LOCALITY] access => TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID\n");
return true;
}
@@ -194,31 +202,42 @@ static int request_locality(struct tpm_chip *chip, int l)
unsigned long stop, timeout;
long rc;
- if (check_locality(chip, l))
+ if (check_locality(chip, l)) {
+ printk(KERN_INFO "[REQUEST_LOCALITY - CORE] error\n");
return l;
+ }
rc = tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_REQUEST_USE);
- if (rc < 0)
+ if (rc < 0) {
+ printk(KERN_INFO "[REQUEST_LOCALITY - CORE] write8 (0x%x) error\n", TPM_ACCESS_REQUEST_USE);
return rc;
+ }
stop = jiffies + chip->timeout_a;
+ printk(KERN_INFO "[REQUEST_LOCALITY - CORE] flags = 0x%x\n", chip->flags);
if (chip->flags & TPM_CHIP_FLAG_IRQ) {
+ printk(KERN_INFO "[REQUEST_LOCALITY - CORE] TPM_CHIP_FLAG_IRQ\n");
again:
timeout = stop - jiffies;
- if ((long)timeout <= 0)
+ if ((long)timeout <= 0) {
+ printk(KERN_INFO "[REQUEST_LOCALITY - CORE] timeout\n");
return -1;
+ }
rc = wait_event_interruptible_timeout(priv->int_queue,
(check_locality
(chip, l)),
timeout);
- if (rc > 0)
+ if (rc > 0){
+ printk(KERN_INFO "[REQUEST_LOCALITY - CORE] wait event : l = 0x%x\n", l);
return l;
+ }
if (rc == -ERESTARTSYS && freezing(current)) {
clear_thread_flag(TIF_SIGPENDING);
goto again;
}
} else {
+ printk(KERN_INFO "[REQUEST_LOCALITY - CORE] not TPM_CHIP_FLAG_IRQ\n");
/* wait for burstcount */
do {
if (check_locality(chip, l))
@@ -861,7 +880,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
u8 rid;
int rc, probe;
struct tpm_chip *chip;
-
+ printk(KERN_INFO "[INIT] start\n");
chip = tpmm_chip_alloc(dev, &tpm_tis);
if (IS_ERR(chip))
return PTR_ERR(chip);
@@ -894,6 +913,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
}
}
+ printk(KERN_INFO "[INIT] plop1\n");
if (chip->ops->clk_enable != NULL)
chip->ops->clk_enable(chip, true);
@@ -902,16 +922,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
goto out_err;
}
+ printk(KERN_INFO "[INIT] plop2\n");
/* Take control of the TPM's interrupt hardware and shut it off */
rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask);
if (rc < 0)
goto out_err;
+ printk(KERN_INFO "[INIT] intmask = 0x%x\n", intmask);
intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
+ printk(KERN_INFO "[INIT] intmask = 0x%x\n", intmask);
intmask &= ~TPM_GLOBAL_INT_ENABLE;
+ printk(KERN_INFO "[INIT] intmask = 0x%x\n", intmask);
tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
+ printk(KERN_INFO "[INIT] plop3\n");
rc = tpm_chip_start(chip);
if (rc)
goto out_err;
@@ -920,12 +945,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
if (rc)
goto out_err;
+ printk(KERN_INFO "[INIT] plop4\n");
rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor);
if (rc < 0)
goto out_err;
priv->manufacturer_id = vendor;
+ printk(KERN_INFO "[INIT] plop5\n");
rc = tpm_tis_read8(priv, TPM_RID(0), &rid);
if (rc < 0)
goto out_err;
@@ -934,12 +961,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
(chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
vendor >> 16, rid);
+ printk(KERN_INFO "[INIT] plop6\n");
probe = probe_itpm(chip);
if (probe < 0) {
rc = -ENODEV;
goto out_err;
}
+ printk(KERN_INFO "[INIT] plop7\n");
/* Figure out the capabilities */
rc = tpm_tis_read32(priv, TPM_INTF_CAPS(priv->locality), &intfcaps);
if (rc < 0)
@@ -966,6 +995,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
dev_dbg(dev, "\tData Avail Int Support\n");
+ printk(KERN_INFO "[INIT] plop8\n");
/* INTERRUPT Setup */
init_waitqueue_head(&priv->read_queue);
init_waitqueue_head(&priv->int_queue);
@@ -991,6 +1021,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
}
}
+ printk(KERN_INFO "[INIT] plop9\n");
rc = tpm_chip_register(chip);
if (rc)
goto out_err;
@@ -1003,6 +1034,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
if ((chip->ops != NULL) && (chip->ops->clk_enable != NULL))
chip->ops->clk_enable(chip, false);
+ printk(KERN_INFO "[INIT] out_err\n");
tpm_tis_remove(chip);
return rc;
diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
index 19513e622053..317aadb6973b 100644
--- a/drivers/char/tpm/tpm_tis_spi.c
+++ b/drivers/char/tpm/tpm_tis_spi.c
@@ -197,6 +197,7 @@ static int tpm_tis_spi_probe(struct spi_device *dev)
struct tpm_tis_spi_phy *phy;
int irq;
+ printk(KERN_INFO "[PROBE] start\n");
phy = devm_kzalloc(&dev->dev, sizeof(struct tpm_tis_spi_phy),
GFP_KERNEL);
if (!phy)
@@ -214,6 +215,7 @@ static int tpm_tis_spi_probe(struct spi_device *dev)
else
irq = -1;
+ printk(KERN_INFO "[PROBE] end\n");
return tpm_tis_core_init(&dev->dev, &phy->priv, irq, &tpm_spi_phy_ops,
NULL);
}