c7bf8f59e05513a98b6d85bc06dfd1d25cfff656 — Denis 'GNUtoo' Carikli 6 years ago c69ea32 x60-tpm
mb/lenovo/x60: Enable TPM

Enable the onboard TPM device in the devicetree, and select Kconfig
options to add the appropriate ASL code.

This is adapted from commit 3d02b9c7.
(mainboard/lenovo/{t430s,t420s,t520,t530,x220}: Add TPM 1.2 mainboard

Without this, coreboot doesn't touch the device and generates no ACPI
entry for it. Thus, in GNU/Linux, it is not detected automatically.

You can, however, force the Linux kernel to scan buses by running the
following commands:

	# modprobe -r tpm_tis
	# modprobe tpm_tis force=1

Running the commands above outputs some messages to dmesg, although the
actual messages vary between kernel versions. With Linux 4.9.235:

	tpm_tis tpm_tis: 1.2 TPM (device-id 0x3202, rev-id 5)
	tpm tpm0: Issuing TPM_STARTUP
	tpm tpm0: [Hardware Error]: Adjusting reported timeouts: A 10000->10000us B 10000->10000us C 0->750000us D 0->750000us
	tpm tpm0: [Hardware Error]: Adjusting reported timeouts: A 10000->10000us B 10000->10000us C 0->750000us D 0->750000us
	tpm tpm0: TPM is disabled/deactivated (0x6)

Then /dev/tpm0 is created. The content of /sys/class/tpm/tpm0/caps is:

	Manufacturer: 0x41544d4c
	TCG version: 1.2
	Firmware version: 11.5

With Linux 5.4.64:

	tpm_tis tpm_tis: 1.2 TPM (device-id 0xFFFF, rev-id 255)
	tpm tpm0: tpm_try_transmit: send(): error -5
	tpm tpm0: A TPM error (-5) occurred attempting to determine the timeouts
	tpm_tis tpm_tis: Could not get TPM timeouts and durations

In this case, tpm0 is not created.

Now, coreboot tries to initialize the device but fails to do so. From
the console log:

	lpc_tpm: Read reg 0xf00 returns 0xffffffff
	tis_probe: No TPM device found
	TPM: Can't initialize.

While coreboot provides an ACPI entry anyway, for some reasons, Linux
still does not scan the device automatically.

See also previous discussions on LKML [1].

[1]: https://lore.kernel.org/lkml/?q=Regression+between+Linux+3.16+and+4.8%2F4.9+on+Lenovo+X60+with+coreboot

Change-Id: I6e65b37507c111af1c0c56822327d5497f58f085
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
Signed-off-by: Masanori Ogino <mogino@acm.org>
2 files changed, 5 insertions(+), 1 deletions(-)

M src/mainboard/lenovo/x60/Kconfig
M src/mainboard/lenovo/x60/devicetree.cb
M src/mainboard/lenovo/x60/Kconfig => src/mainboard/lenovo/x60/Kconfig +2 -0
@@ 24,6 24,8 @@ config BOARD_SPECIFIC_OPTIONS
	select I945_LVDS

config VBOOT

M src/mainboard/lenovo/x60/devicetree.cb => src/mainboard/lenovo/x60/devicetree.cb +3 -1
@@ 157,7 157,6 @@ chip northbridge/intel/i945
						io 0x60 = 0x164c

				chip superio/nsc/pc87392
					device pnp 2e.0 off end #FDC

@@ 182,6 181,9 @@ chip northbridge/intel/i945

					device pnp 2e.a off end # WDT
				chip drivers/pc80/tpm
					device pnp 0c31.0 on end
			device pci 1f.1 on # IDE
				subsystemid 0x17aa 0x200c