Infineon TPM2.0 SLB9672 module with Jetson AGX Orin

Hi all,I’m trying to enable Infineon SLB9672 on my Orin. The TPM driver and SPI is work. but it didn’t appear any info from TPM. Any suggestion?
dmesg.txt (65.7 KB)

lsmod | grep spi
spidev                 28672  0
tpm_tis_spi            16384  0
tpm_tis_core           28672  1 tpm_tis_spi
tpm                    73728  3 tpm_infineon,tpm_tis_core,tpm_tis_spi
spi_tegra114           32768  0
lsmod | grep tpm
tpm_infineon           20480  0
tpm_tis_spi            16384  0
tpm_tis_core           28672  1 tpm_tis_spi
tpm                    73728  3 tpm_infineon,tpm_tis_core,tpm_tis_spi
rng_core               24576  1 tpm

I have been porting TPM SLB9670 successfully on Orin. if work should be appear device-id like below photo:
tpm_tis_spi spi0.1: 2.0 TPM (device-id -0x1B, rev-id 22)
image

Hi SamM11,

Are you using the devkit or custom board for AGX Orin?
What’s your Jetpack version in use?

Please check if the following thread could help for your SPI issue.
SPI TPM module support fail on jetpack 5.0.2/5.1 on jetson xavier agx - #25 by DaneLLL

Hi @KevinFFF ,
I’m using the custom board for AGX Orin. and my Jetpack version is 5.1.1.
This patch I already try on my Orin. but still can’t work.

It seems both your TPM and SPI work. What are you expecting to see the info from TPM?

Do you see any node for TPM under /dev/?

Hi @KevinFFF ,
The result I want to see is about TPM info have a node under the /dev/.
Even through the driver was mount and device tree was set up ,but dmesg doesn’t appear any error message.

Have you checked the probe of TPM driver finished w/o any errors or debug into it?
You could add some debug messages into the driver source and check if its probe successfully.

Hi @KevinFFF ,
Below is my test result and dmesg,I add debug messages in the tpm_tis_core.c file, and checked every step should be work.But the result didn’t execute prink(“TPM: device-id”); and I don’t know why any suggestion?
Because I have been porting TPM slb9670 it’s doesn’t need to change anything just mount driver then work successfully.
And the TPM slb9670 and slb9672 use the same driver.
dmesg.txt (65.7 KB)

tpm_tis_core.c:

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)
{
	u32 vendor;
	u32 intfcaps;
	u32 intmask;
	u32 clkrun_val;
	u8 rid;
	int rc, probe;
	struct tpm_chip *chip;

	chip = tpmm_chip_alloc(dev, &tpm_tis);
	if (IS_ERR(chip))
		return PTR_ERR(chip);
	printk("TPM: tpm_tis_core_init");
#ifdef CONFIG_ACPI
	chip->acpi_dev_handle = acpi_dev_handle;
#endif

	chip->hwrng.quality = priv->rng_quality;

	/* Maximum timeouts */
	chip->timeout_a = msecs_to_jiffies(TIS_TIMEOUT_A_MAX);
	chip->timeout_b = msecs_to_jiffies(TIS_TIMEOUT_B_MAX);
	chip->timeout_c = msecs_to_jiffies(TIS_TIMEOUT_C_MAX);
	chip->timeout_d = msecs_to_jiffies(TIS_TIMEOUT_D_MAX);
	priv->timeout_min = TPM_TIMEOUT_USECS_MIN;
	priv->timeout_max = TPM_TIMEOUT_USECS_MAX;
	priv->phy_ops = phy_ops;
	printk("TPM: Maximum timeouts");
	dev_set_drvdata(&chip->dev, priv);

	rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor);
	if (rc < 0)
		return rc;
  	printk("TPM: get vendor ID = %d\n",vendor);
	priv->manufacturer_id = vendor;

	if (priv->manufacturer_id == TPM_VID_ATML &&
		!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
		priv->timeout_min = TIS_TIMEOUT_MIN_ATML;
		priv->timeout_max = TIS_TIMEOUT_MAX_ATML;
	}

	if (is_bsw()) {
		priv->ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
					ILB_REMAP_SIZE);
		if (!priv->ilb_base_addr)
			return -ENOMEM;

		clkrun_val = ioread32(priv->ilb_base_addr + LPC_CNTRL_OFFSET);
		/* Check if CLKRUN# is already not enabled in the LPC bus */
		if (!(clkrun_val & LPC_CLKRUN_EN)) {
			iounmap(priv->ilb_base_addr);
			priv->ilb_base_addr = NULL;
		}
	}

	if (chip->ops->clk_enable != NULL)
		chip->ops->clk_enable(chip, true);

	if (wait_startup(chip, 0) != 0) {
		rc = -ENODEV;
		goto out_err;
	}

	/* 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;

	intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
		   TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
	intmask &= ~TPM_GLOBAL_INT_ENABLE;

	rc = request_locality(chip, 0);
	if (rc < 0) {
		rc = -ENODEV;
		goto out_err;
	}

	tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
	release_locality(chip, 0);

	rc = tpm_chip_start(chip);
	if (rc)
		goto out_err;
	rc = tpm2_probe(chip);
	tpm_chip_stop(chip);
	if (rc)
		goto out_err;

	rc = tpm_tis_read8(priv, TPM_RID(0), &rid);
	if (rc < 0)
		goto out_err;
        printk("TPM: device-id");
	dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
		 (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
		 vendor >> 16, rid);

	probe = probe_itpm(chip);
	if (probe < 0) {
		rc = -ENODEV;
		goto out_err;
	}

Could you help to add some debug message for rc?

Have you tried to connect slb9670 instead of slb9672 on current board and verify if it could work and probe as expected?

Hi @KevinFFF ,
Thank you for reply, I’m a complete beginner at this stuff.
Which place should I add some debug message for rc?

rc = tpm_tis_read8(priv, TPM_RID(0), &rid);
	if (rc < 0)
		goto out_err;
        printk("TPM: device-id");

Yes,I tried to connect slb9670 instead of slb9672 on current board and verify. and it can work and probe as expected.

Have you tried to connect slb9670 instead of slb9672 on current board and verify if it could work and probe as expected?

Just print rc value as following for both slb9670 and slb9672 and compare their difference.

rc = tpm_tis_read8(priv, TPM_RID(0), &rid);
printk("[DBG] rc = %d", rc);
	if (rc < 0)
		goto out_err;
        printk("TPM: device-id");

Hi @KevinFFF ,
Thank you for reply,
We found the which step stop the TPM work. we according to the dmesg to trace code and found the problem is stop at request_locality. So we add the debug message to the request_locality function.but still can’t get error message in dmesg.
tpm_tis_core.c.txt (29.5 KB)
dmesg for TPM :

sudo dmesg | grep TPM
[   15.617743] Probe TPM1,tpm_tis_driver_probe
[   15.617751] Probe TPM1,tpm_tis_spi_probe
[   15.622316] TPM: tpm_tis_core_init
[   15.630596] TPM: Maximum timeouts
[   15.636884] TPM: get vendor ID = 1906129
[   16.394988] TPM: ENODEV_2

tpm_tis_core.c(request_locality) part:

static int request_locality(struct tpm_chip *chip, int l)
{
	struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
	unsigned long stop, timeout;
	long rc;

	if (check_locality(chip, l))
		return l;

	rc = tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_REQUEST_USE);
	if (rc < 0)
		return rc;

	stop = jiffies + chip->timeout_a;

	if (chip->flags & TPM_CHIP_FLAG_IRQ) {
		printk("TPM: flags & TPM_CHIP_FLAG_IRQ\n");
again:
		timeout = stop - jiffies;
		if ((long)timeout <= 0)
			return -1;
		rc = wait_event_interruptible_timeout(priv->int_queue,
						      (check_locality
						       (chip, l)),
						      timeout);
		if (rc > 0)
			return l;
		if (rc == -ERESTARTSYS && freezing(current)) {
			clear_thread_flag(TIF_SIGPENDING);
			goto again;
		}
	} else {
		/* wait for burstcount */
		do {
			if (check_locality(chip, l))
				return l;
			tpm_msleep(TPM_TIMEOUT);
		} while (time_before(jiffies, stop));
	}
	return -1;
}

Since I don’t have this module, I couldn’t debug it locally on the devkit.

Could you try adding more debug message in request_locality() and check which line return error? and also compare the behavior with slb9670(which should work as expected you said).
Have you also tried to ask the vendor for their TPM driver?

Hi @KevinFFF ,
Thank you for reply,
I will try to ask the vendor for their TPM driver.

Hi @KevinFFF,
We use Infineon TPM SLB9670 on Orin through SPI
The result can work normal,but we use LA to test we found some weird phenomenon like below photo:
The CS should be slow then MISO,but it didn’t.
Does the pinmux setting error?Or occupied by other devices in the Device Tree?

SPI Pinmux setting:
sudo ./opt/nvidia/jetson.io/jetson-io.py to create a dtb file and use this dtb file.

pinmux@2430000 {
                pinctrl-0 = <0x516>;
                pinctrl-names = "default";
                compatible = "nvidia,tegra234-pinmux";
                reg = <0x00 0x2430000 0x00 0x19100 0x00 0xc300000 0x00 0x4000>;
                #gpio-range-cells = <0x03>;
                status = "okay";
                phandle = <0x2ce>;

                exp-header-pinmux {
                        phandle = <0x516>;

                        hdr40-pin26 {
                                nvidia,enable-input = <0x01>;
                                nvidia,tristate = <0x00>;
                                nvidia,function = "spi1";
                                nvidia,pins = "spi1_cs1_pz7";
                        };

                        hdr40-pin24 {
                                nvidia,enable-input = <0x01>;
                                nvidia,tristate = <0x00>;
                                nvidia,function = "spi1";
                                nvidia,pins = "spi1_cs0_pz6";
                        };

                        hdr40-pin23 {
                                nvidia,enable-input = <0x01>;
                                nvidia,tristate = <0x00>;
                                nvidia,function = "spi1";
                                nvidia,pins = "spi1_sck_pz3";
                        };

                        hdr40-pin21 {
                                nvidia,enable-input = <0x01>;
                                nvidia,tristate = <0x00>;
                                nvidia,function = "spi1";
                                nvidia,pins = "spi1_miso_pz4";
                        };

                        hdr40-pin19 {
                                nvidia,enable-input = <0x01>;
                                nvidia,tristate = <0x00>;
                                nvidia,function = "spi1";
                                nvidia,pins = "spi1_mosi_pz5";
                        };
                };

Add TPM device in spi@3210000:

spi@3210000 {
                compatible = "nvidia,tegra186-spi";
                reg = <0x00 0x3210000 0x00 0x10000>;
                interrupts = <0x00 0x24 0x04>;
                #address-cells = <0x01>;
                #size-cells = <0x00>;
                iommus = <0x02 0x04>;
                dma-coherent;
                dmas = <0x03 0x0f 0x03 0x0f>;
                dma-names = "rx\0tx";
                spi-max-frequency = <0x3dfd240>;
                nvidia,clk-parents = "pll_p\0clk_m";
                clocks = <0x04 0x87 0x04 0x66 0x04 0x0e>;
                clock-names = "spi\0pll_p\0clk_m";
                resets = <0x04 0x5b>;
                reset-names = "spi";
                status = "okay";
                phandle = <0x31e>;

                prod-settings {
                        #prod-cells = <0x04>;

                        prod {
                                prod = <0x00 0x194 0x80000000 0x00>;

                                board {
                                        prod = <0x00 0x04 0x3f 0x30>;
                                };
                        };
                };

                slb9670@0 {
                        compatible = "infineon,slb9670";
                        reg = <0x00>;
                        spi-max-frequency = <32000000>;

                        controller-data {
                                nvidia,enable-hw-based-cs;
                                nvidia,rx-clk-tap-delay = <0x11>;
                        };
                };

and I found the this post situation was similar to me(SPI infineon TPM 2.0 cs-gpios not correct work on Jetpack 5.0.2 and 5.1)

Do you have other SPI devices other than TPM SLB9670 on this SPI interface?

Could you help to use oscilloscope to check the waveform of these pins instead of LA?

The issue in the link you shared has been fixed with the patch I provided in 20/Jun.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.