instrumentalisation du driver tpm spi infineon

This commit is contained in:
2023-02-01 07:37:55 +00:00
parent cf419902d8
commit 6c83bce66e
3 changed files with 151 additions and 22 deletions
+24 -22
View File
@@ -69,23 +69,19 @@
spi0_pins: pinmux_spi0_pins {
pinctrl-single,pins = <
AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, PIN_OUTPUT, MUX_MODE0)
AM33XX_PADCONF(AM335X_PIN_SPI0_D0, PIN_OUTPUT, MUX_MODE0) /* spi0_d0_mosi, external pullup */
AM33XX_PADCONF(AM335X_PIN_SPI0_D1, PIN_INPUT, MUX_MODE0) /* spi0_d1_miso */
AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, PIN_INPUT_PULLUP, MUX_MODE0)
AM33XX_PADCONF(AM335X_PIN_SPI0_D0, PIN_INPUT, MUX_MODE0) /* spi0_d0_mosi, external pullup */
AM33XX_PADCONF(AM335X_PIN_SPI0_D1, PIN_INPUT_PULLUP, MUX_MODE0) /* spi0_d1_miso */
AM33XX_PADCONF(AM335X_PIN_SPI0_SCLK, PIN_INPUT, MUX_MODE0) /* external pullup */
>;
};
//AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, PIN_OUTPUT_PULLUP, MUX_MODE0)
//AM33XX_PADCONF(AM335X_PIN_SPI0_D0, PIN_OUTPUT, MUX_MODE0) /* spi0_d0_mosi */
//AM33XX_PADCONF(AM335X_PIN_SPI0_SCLK, PIN_INPUT, MUX_MODE0)
spi1_pins: pinmux_spi1_pins {
pinctrl-single,pins = <
AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_OUTPUT, MUX_MODE3) /* mcasp0_ahclkr, spi1_cs0 */
AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_OUTPUT, MUX_MODE3) /* mcasp0_fsx, spi1_d0_mosi */
AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_INPUT, MUX_MODE3) /* mcasp0_axr0, spi1_d1_miso */
AM33XX_PADCONF(AM335X_PIN_ECAP0_IN_PWM0_OUT, PIN_INPUT, MUX_MODE4) /* ecap0_in_pwm0_out, spi1_sclk */
AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_INPUT_PULLUP, MUX_MODE3) /* mcasp0_ahclkr, spi1_cs0 */
AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_INPUT_PULLUP, MUX_MODE3) /* mcasp0_fsx, spi1_d0_mosi */
AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_INPUT_PULLUP, MUX_MODE3) /* mcasp0_axr0, spi1_d1_miso */
AM33XX_PADCONF(AM335X_PIN_ECAP0_IN_PWM0_OUT, PIN_INPUT_PULLUP, MUX_MODE4) /* ecap0_in_pwm0_out, spi1_sclk */
>;
};
@@ -343,28 +339,28 @@
pinctrl-0 = <&spi0_pins>;
cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>; /* SPI0_CS0 */
status = "okay";
ti,pindir-do-out-d1-in;
//ti,pindir-do-out-d1-in;
/*
spidev@0 {
compatible = "rohm,dh2228fv";
spi-max-frequency = <5000000>;
reg = <1>;
};
*/
slb9670@1 {
slb9670@0 {
// number of cells required to define a chip select address on the SPI bus.
#address-cells = <1>;
//#address-cells = <1>;
// should be zero
#size-cells = <0>;
//#size-cells = <0>;
// name of SPI bus controller following generic names recommended practice
compatible = "infineon,slb9670";
spi-max-frequency = <32000000>;
reg = <0>;
num-cs = <1>;
//num-cs = <1>;
//gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
status = "okay";
//status = "okay";
};
*/
};
&spi1 {
@@ -372,18 +368,24 @@
pinctrl-0 = <&spi1_pins>;
cs-gpios = <&gpio3 17 GPIO_ACTIVE_LOW>; /* SPI1_CS0 */
status = "okay";
ti,pindir-do-out-d1-in;
//ti,pindir-do-out-d1-in;
slb9670@0 {
// number of cells required to define a chip select address on the SPI bus.
#address-cells = <1>;
//#address-cells = <1>;
// should be zero
#size-cells = <0>;
//#size-cells = <0>;
// name of SPI bus controller following generic names recommended practice
compatible = "infineon,slb9670";
spi-max-frequency = <32000000>;
spi-max-frequency = <33000000>;
reg = <0>;
};
spidev@1 {
compatible = "rohm,dh2228fv";
spi-max-frequency = <5000000>;
reg = <1>;
};
};
&elm {
@@ -0,0 +1,126 @@
--- 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;
}
@@ -861,7 +865,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 +898,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,6 +907,7 @@ 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)
@@ -912,6 +918,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
intmask &= ~TPM_GLOBAL_INT_ENABLE;
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 +927,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 +943,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 +977,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 +1003,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 +1016,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;
--- 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);
}
@@ -4,5 +4,6 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += " \
file://0001-dtc-lexer-extern-yylloc.patch \
file://0002-printk-tpm-spi.patch \
file://defconfig \
"