[U-Boot] Issue enabling TPM 2.0 on RPI

Hello,
I am trying to enable the TPM 2.0 SLB9670 in U-Boot for a Raspberry Pi 3 B+. More precisely, the TPM is on an add-on board, the IRIDIUM SLB9670. The communication between the RPI and the TPM is ensured by SPI so I enabled the software spi driver (spi-gpio) in U-Boot because the bcm28x spi driver is not available in U-Boot.
CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_SOFT_SPI=y
Then, I enabled the TPM support in U-Boot.
CONFIG_CMD_TPM_V2=y CONFIG_CMD_TPM=y CONFIG_TPM_V2=y CONFIG_TPM2_TIS_SPI=y CONFIG_TPM=y
Finally, I updated my Device Tree. /dts-v1/ / { ... aliases { spi0 = &soft_spi; };
soft_spi: soft-spi { compatible = "spi-gpio"; pinctrl-names = "default"; pinctrl-0 = <&spi0_gpio7>; status = "okay"; gpio-sck = <&gpio 11 0>; gpio-mosi = <&gpio 10 0>; gpio-miso = <&gpio 9 0>; cs-gpios = <&gpio 7 1>; #address-cells = <1>; #size-cells = <0>;
slb9670: slb9670@0 { compatible = "tis,tpm2-spi"; reg = <1>; #address-cells = <1>; #size-cells = <0>; spi-max-frequency = <32000000>; status = "okay"; }; };
spio0_gpio7: spio0_gpio7 { brcm,pins = <7 8 9 10 11>; brcm,function = <4>; }; ... };
But, when I try to execute the following command : U-Boot> tpm2 init
I have the following response :
tpm_tis_spi_probe : missing reset GPIO tpm_tis_spi_request_locality : Timeout getting locality : -2 tpm_tis_spi_probe : could not request locality 0 Could not find TPM (ret=-2)
The Iridium board contains a reset circuit on board, which pulls the reset line of the TPM to GND after VCC becomes available, so the reset GPIO is not needed I think.
I don’t see what is wrong with my setup, a little help would be very appreciated.
Thank you in advance, Elena

Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Fri, 14 Jun 2019 09:43:46 +0200:
Hello,
I am trying to enable the TPM 2.0 SLB9670 in U-Boot for a Raspberry Pi 3 B+. More precisely, the TPM is on an add-on board, the IRIDIUM SLB9670. The communication between the RPI and the TPM is ensured by SPI so I enabled the software spi driver (spi-gpio) in U-Boot because the bcm28x spi driver is not available in U-Boot.
CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_SOFT_SPI=y
Are you sure the SPI bus is correctly driven? Can you connect anything else and ensure it works? You may also probe all the GPIO lines (using an oscilloscope) and check each of them is clocked correctly.
Then, I enabled the TPM support in U-Boot.
CONFIG_CMD_TPM_V2=y CONFIG_CMD_TPM=y
If you use TPM V2, CMD_TPM is not needed. But that's not your problem.
CONFIG_TPM_V2=y CONFIG_TPM2_TIS_SPI=y CONFIG_TPM=y
Looks fine.
Finally, I updated my Device Tree. /dts-v1/ / { ... aliases { spi0 = &soft_spi; };
soft_spi: soft-spi { compatible = "spi-gpio"; pinctrl-names = "default"; pinctrl-0 = <&spi0_gpio7>; status = "okay"; gpio-sck = <&gpio 11 0>; gpio-mosi = <&gpio 10 0>; gpio-miso = <&gpio 9 0>; cs-gpios = <&gpio 7 1>; #address-cells = <1>; #size-cells = <0>;
slb9670: slb9670@0 { compatible = "tis,tpm2-spi"; reg = <1>; #address-cells = <1>; #size-cells = <0>; spi-max-frequency = <32000000>;
You might want to slow down a bit this frequency, try it with 1MHz, just for testing (and see something meaningful with the scope).
status = "okay"; };
};
spio0_gpio7: spio0_gpio7 { brcm,pins = <7 8 9 10 11>; brcm,function = <4>;
If you bit-bang the SPI bus, I suppose you must use the GPIO function on each pin, is <4> the GPIO function or the SPI function?
}; ... };
But, when I try to execute the following command : U-Boot> tpm2 init
I have the following response :
tpm_tis_spi_probe : missing reset GPIO
This is indeed harmless, just a warning.
tpm_tis_spi_request_locality : Timeout getting locality : -2
This usually means you cannot talk to the chip.
tpm_tis_spi_probe : could not request locality 0 Could not find TPM (ret=-2)
The Iridium board contains a reset circuit on board, which pulls the reset line of the TPM to GND after VCC becomes available, so the reset GPIO is not needed I think.
I don’t see what is wrong with my setup, a little help would be very appreciated.
Thank you in advance, Elena ___________
Good luck, Miquèl

Hello,
Miquel Raynal miquel.raynal@bootlin.com wrote on Mon, 17 Jun 2019 10:44:52 +0200:
Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Fri, 14 Jun 2019 09:43:46 +0200:
Hello,
I am trying to enable the TPM 2.0 SLB9670 in U-Boot for a Raspberry Pi 3 B+. More precisely, the TPM is on an add-on board, the IRIDIUM SLB9670.
Please also mind the voltage levels on the Iridium board which might be different with the Raspberry Pi's.
Also try the latest U-Boot, with this patch applied [1]. If it solves your issue, please send a Tested-by on the ML!
[1] https://patchwork.ozlabs.org/patch/1100655/
Thanks, Miquèl

Hello Miquèl,
Miquel Raynal miquel.raynal@bootlin.com wrote on Mon, 17 Jun 2019 10:44:52 +0200 :
Hello,
Miquel Raynal miquel.raynal@bootlin.com wrote on Mon, 17 Jun 2019 10:44:52 +0200:
Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Fri, 14 Jun 2019 09:43:46 +0200:
Hello,
I am trying to enable the TPM 2.0 SLB9670 in U-Boot for a Raspberry Pi 3 B+. More precisely, the TPM is on an add-on board, the IRIDIUM SLB9670.
Please also mind the voltage levels on the Iridium board which might be different with the Raspberry Pi's.
Also try the latest U-Boot, with this patch applied [1]. If it solves your issue, please send a Tested-by on the ML!
[1] https://patchwork.ozlabs.org/patch/1100655/
Thanks, Miquèl
I checked the voltage levels, they seem compatible. I also tried the patch with no luck.
Thank you very much for your support, Elena

Hi Miquèl,
Thank you for your answer.
Miquel Raynal miquel.raynal@bootlin.com wrote on Mon, 17 Jun 2019 10:44:52 +0200:
Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Fri, 14 Jun 2019 09:43:46 +0200:
Hello,
I am trying to enable the TPM 2.0 SLB9670 in U-Boot for a Raspberry Pi 3 B+. More precisely, the TPM is on an add-on board, the IRIDIUM SLB9670. The communication between the RPI and the TPM is ensured by SPI so I enabled the software spi driver (spi-gpio) in U-Boot because the bcm28x spi driver is not available in U-Boot.
CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_SOFT_SPI=y
Are you sure the SPI bus is correctly driven? Can you connect anything else and ensure it works? You may also probe all the GPIO lines (using an oscilloscope) and check each of them is clocked correctly.
I simply checked by doing a loopback test, i.e connecting MISO and MOSI by a cable and it worked. I will test with an oscilloscope when I have one and keep you up to date.
Then, I enabled the TPM support in U-Boot.
CONFIG_CMD_TPM_V2=y CONFIG_CMD_TPM=y
If you use TPM V2, CMD_TPM is not needed. But that's not your problem.
CONFIG_TPM_V2=y CONFIG_TPM2_TIS_SPI=y CONFIG_TPM=y
Looks fine.
Finally, I updated my Device Tree. /dts-v1/ / { ... aliases { spi0 = &soft_spi; };
soft_spi: soft-spi { compatible = "spi-gpio"; pinctrl-names = "default"; pinctrl-0 = <&spi0_gpio7>; status = "okay"; gpio-sck = <&gpio 11 0>; gpio-mosi = <&gpio 10 0>; gpio-miso = <&gpio 9 0>; cs-gpios = <&gpio 7 1>; #address-cells = <1>; #size-cells = <0>;
slb9670: slb9670@0 { compatible = "tis,tpm2-spi"; reg = <1>; #address-cells = <1>; #size-cells = <0>; spi-max-frequency = <32000000>;
You might want to slow down a bit this frequency, try it with 1MHz, just for testing (and see something meaningful with the scope).
I tried to lower the frequency to 1MHZ but without success.
status = "okay"; };
};
spio0_gpio7: spio0_gpio7 { brcm,pins = <7 8 9 10 11>; brcm,function = <4>;
If you bit-bang the SPI bus, I suppose you must use the GPIO function on each pin, is <4> the GPIO function or the SPI function?
No the <4> function is the SPI function, thank you it was a mistake. I changed it to GPIO function but I have the same errors when executing tpm2 commands in U-Boot.
}; ... };
But, when I try to execute the following command : U-Boot> tpm2 init
I have the following response :
tpm_tis_spi_probe : missing reset GPIO
This is indeed harmless, just a warning.
tpm_tis_spi_request_locality : Timeout getting locality : -2
This usually means you cannot talk to the chip.
tpm_tis_spi_probe : could not request locality 0 Could not find TPM (ret=-2)
The Iridium board contains a reset circuit on board, which pulls the reset line of the TPM to GND after VCC becomes available, so the reset GPIO is not needed I think.
I don’t see what is wrong with my setup, a little help would be very appreciated.
Thank you in advance, Elena ___________
Good luck, Miquèl
Moreover, I commented out the tpm_tis_spi_request_locality() function in the TPM driver just to perform a test by executing the U-Boot> tpm2 init I then had the following response : tpm_tis_spi_probe() SPI TPMv2.0 found (vid:15d1, did:001b, rid:10)
The identifiers are good so the communication with the TPM seems almost working ?
Thank you again, Elena

Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Mon, 17 Jun 2019 15:46:29 +0200:
Hi Miquèl,
Thank you for your answer.
Miquel Raynal miquel.raynal@bootlin.com wrote on Mon, 17 Jun 2019 10:44:52 +0200:
Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Fri, 14 Jun 2019 09:43:46 +0200:
Hello,
I am trying to enable the TPM 2.0 SLB9670 in U-Boot for a Raspberry Pi 3 B+. More precisely, the TPM is on an add-on board, the IRIDIUM SLB9670. The communication between the RPI and the TPM is ensured by SPI so I enabled the software spi driver (spi-gpio) in U-Boot because the bcm28x spi driver is not available in U-Boot.
CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_SOFT_SPI=y
Are you sure the SPI bus is correctly driven? Can you connect anything else and ensure it works? You may also probe all the GPIO lines (using an oscilloscope) and check each of them is clocked correctly.
I simply checked by doing a loopback test, i.e connecting MISO and MOSI by a cable and it worked. I will test with an oscilloscope when I have one and keep you up to date.
Then, I enabled the TPM support in U-Boot.
CONFIG_CMD_TPM_V2=y CONFIG_CMD_TPM=y
If you use TPM V2, CMD_TPM is not needed. But that's not your problem.
CONFIG_TPM_V2=y CONFIG_TPM2_TIS_SPI=y CONFIG_TPM=y
Looks fine.
Finally, I updated my Device Tree. /dts-v1/ / { ... aliases { spi0 = &soft_spi; };
soft_spi: soft-spi { compatible = "spi-gpio"; pinctrl-names = "default"; pinctrl-0 = <&spi0_gpio7>; status = "okay"; gpio-sck = <&gpio 11 0>; gpio-mosi = <&gpio 10 0>; gpio-miso = <&gpio 9 0>; cs-gpios = <&gpio 7 1>; #address-cells = <1>; #size-cells = <0>;
slb9670: slb9670@0 { compatible = "tis,tpm2-spi"; reg = <1>; #address-cells = <1>; #size-cells = <0>; spi-max-frequency = <32000000>;
You might want to slow down a bit this frequency, try it with 1MHz, just for testing (and see something meaningful with the scope).
I tried to lower the frequency to 1MHZ but without success.
status = "okay"; };
};
spio0_gpio7: spio0_gpio7 { brcm,pins = <7 8 9 10 11>; brcm,function = <4>;
If you bit-bang the SPI bus, I suppose you must use the GPIO function on each pin, is <4> the GPIO function or the SPI function?
No the <4> function is the SPI function, thank you it was a mistake. I changed it to GPIO function but I have the same errors when executing tpm2 commands in U-Boot.
}; ... };
But, when I try to execute the following command : U-Boot> tpm2 init
I have the following response :
tpm_tis_spi_probe : missing reset GPIO
This is indeed harmless, just a warning.
tpm_tis_spi_request_locality : Timeout getting locality : -2
This usually means you cannot talk to the chip.
tpm_tis_spi_probe : could not request locality 0 Could not find TPM (ret=-2)
The Iridium board contains a reset circuit on board, which pulls the reset line of the TPM to GND after VCC becomes available, so the reset GPIO is not needed I think.
I don’t see what is wrong with my setup, a little help would be very appreciated.
Thank you in advance, Elena ___________
Good luck, Miquèl
Moreover, I commented out the tpm_tis_spi_request_locality() function in the TPM driver just to perform a test by executing the U-Boot> tpm2 init I then had the following response : tpm_tis_spi_probe() SPI TPMv2.0 found (vid:15d1, did:001b, rid:10)
Right, so it seems that the communication works.
Back to debugging then, you may dump the bytes read/written in your SPI driver's read/write callbacks. Once you'll have a working solution, it would be very appreciated if you could contribute it back. Good luck!
Thanks, Miquèl

Hi Elena, Miquel,
I'm busy on SLB9670 again after a longer interruption. I'm using Xilinx Zynq/ZynqMP and SLB960/SLM9670/SLI9670 and u-boot 2019.06-rc2.
Out of the box the driver can access on the TPM after patching the Cadence SPI driver what I use on Zynq/ZynqMP. So you should be able to discover the TPM while using the setup you mentioned below but slow down the speed. Eventually 1MHz is too fast for Soft-SPI too.
I recommend to select a SPI speed between 10MHz to 25MHz when using a hard SPI like me. Why are you trying to use soft-spi instead of the hard-spi?
Also please try the command tpm info before trying tpm init. tpm info doesn't require to open the driver really but it reads out the vendor id.
Nevertheless I see an issue how the tpm driver controls the CS#. It seems CS# does not remain low long enough. Probably the TPMs of several vendors behave slightly different on CS#.
But firstly check tpm init please.
Dipl. Inform. Martin Hecht Senior Embedded Specialist / Functional Safety Engineer TA1130871952
Avnet SILICA Englische Straße 27 10587 Berlin
martin.hecht@avnet.eu O +49 (0) 30 214 88 227 M +49 (0) 172 890 60 19 avnet-silica.com ________________________________________ Von: U-Boot u-boot-bounces@lists.denx.de im Auftrag von Miquel Raynal miquel.raynal@bootlin.com Gesendet: Montag, 17. Juni 2019 16:28 An: Elena Unix Cc: u-boot@lists.denx.de Betreff: Re: [U-Boot] Issue enabling TPM 2.0 on RPI
Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Mon, 17 Jun 2019 15:46:29 +0200:
Hi Miquèl,
Thank you for your answer.
Miquel Raynal miquel.raynal@bootlin.com wrote on Mon, 17 Jun 2019 10:44:52 +0200:
Hi Elena,
Elena Unix elenaunix01@gmail.com wrote on Fri, 14 Jun 2019 09:43:46 +0200:
Hello,
I am trying to enable the TPM 2.0 SLB9670 in U-Boot for a Raspberry Pi 3 B+. More precisely, the TPM is on an add-on board, the IRIDIUM SLB9670. The communication between the RPI and the TPM is ensured by SPI so I enabled the software spi driver (spi-gpio) in U-Boot because the bcm28x spi driver is not available in U-Boot.
CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_SOFT_SPI=y
Are you sure the SPI bus is correctly driven? Can you connect anything else and ensure it works? You may also probe all the GPIO lines (using an oscilloscope) and check each of them is clocked correctly.
I simply checked by doing a loopback test, i.e connecting MISO and MOSI by a cable and it worked. I will test with an oscilloscope when I have one and keep you up to date.
Then, I enabled the TPM support in U-Boot.
CONFIG_CMD_TPM_V2=y CONFIG_CMD_TPM=y
If you use TPM V2, CMD_TPM is not needed. But that's not your problem.
CONFIG_TPM_V2=y CONFIG_TPM2_TIS_SPI=y CONFIG_TPM=y
Looks fine.
Finally, I updated my Device Tree. /dts-v1/ / { ... aliases { spi0 = &soft_spi; };
soft_spi: soft-spi { compatible = "spi-gpio"; pinctrl-names = "default"; pinctrl-0 = <&spi0_gpio7>; status = "okay"; gpio-sck = <&gpio 11 0>; gpio-mosi = <&gpio 10 0>; gpio-miso = <&gpio 9 0>; cs-gpios = <&gpio 7 1>; #address-cells = <1>; #size-cells = <0>;
slb9670: slb9670@0 { compatible = "tis,tpm2-spi"; reg = <1>; #address-cells = <1>; #size-cells = <0>; spi-max-frequency = <32000000>;
You might want to slow down a bit this frequency, try it with 1MHz, just for testing (and see something meaningful with the scope).
I tried to lower the frequency to 1MHZ but without success.
status = "okay"; };
};
spio0_gpio7: spio0_gpio7 { brcm,pins = <7 8 9 10 11>; brcm,function = <4>;
If you bit-bang the SPI bus, I suppose you must use the GPIO function on each pin, is <4> the GPIO function or the SPI function?
No the <4> function is the SPI function, thank you it was a mistake. I changed it to GPIO function but I have the same errors when executing tpm2 commands in U-Boot.
}; ... };
But, when I try to execute the following command : U-Boot> tpm2 init
I have the following response :
tpm_tis_spi_probe : missing reset GPIO
This is indeed harmless, just a warning.
tpm_tis_spi_request_locality : Timeout getting locality : -2
This usually means you cannot talk to the chip.
tpm_tis_spi_probe : could not request locality 0 Could not find TPM (ret=-2)
The Iridium board contains a reset circuit on board, which pulls the reset line of the TPM to GND after VCC becomes available, so the reset GPIO is not needed I think.
I don’t see what is wrong with my setup, a little help would be very appreciated.
Thank you in advance, Elena ___________
Good luck, Miquèl
Moreover, I commented out the tpm_tis_spi_request_locality() function in the TPM driver just to perform a test by executing the U-Boot> tpm2 init I then had the following response : tpm_tis_spi_probe() SPI TPMv2.0 found (vid:15d1, did:001b, rid:10)
Right, so it seems that the communication works.
Back to debugging then, you may dump the bytes read/written in your SPI driver's read/write callbacks. Once you'll have a working solution, it would be very appreciated if you could contribute it back. Good luck!
Thanks, Miquèl _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot We continuously commit to comply with the applicable data protection laws and ensure fair and transparent processing of your personal data. Please read our privacy statement including an information notice and data protection policy for detailed information on our website.
participants (3)
-
Elena Unix
-
Hecht, Martin (Avnet Silica)
-
Miquel Raynal