From bcbe3d157904d3dd4d6b18a81859db45a5da2678 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Sep 2015 23:32:01 -0600 Subject: dm: Rename dev_get_parentdata() to dev_get_parent_priv() The current name is inconsistent with other driver model data access functions. Rename it and fix up all users. Signed-off-by: Simon Glass Reviewed-by: Joe Hershberger --- drivers/core/device.c | 2 +- drivers/misc/cros_ec_spi.c | 4 ++-- drivers/mtd/spi/sf_dataflash.c | 2 +- drivers/mtd/spi/sf_probe.c | 2 +- drivers/spi/fsl_qspi.c | 2 +- drivers/spi/ich.c | 2 +- drivers/spi/soft_spi.c | 2 +- drivers/spi/spi-uclass.c | 8 ++++---- drivers/usb/eth/smsc95xx.c | 4 ++-- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/host/ehci-hcd.c | 6 +++--- drivers/usb/host/usb-uclass.c | 8 ++++---- drivers/usb/host/xhci.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 10 +++++----- 14 files changed, 29 insertions(+), 29 deletions(-) (limited to 'drivers') diff --git a/drivers/core/device.c b/drivers/core/device.c index a3dc2ca..758f390 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -395,7 +395,7 @@ void *dev_get_uclass_priv(struct udevice *dev) return dev->uclass_priv; } -void *dev_get_parentdata(struct udevice *dev) +void *dev_get_parent_priv(struct udevice *dev) { if (!dev) { dm_warn("%s: null device\n", __func__); diff --git a/drivers/misc/cros_ec_spi.c b/drivers/misc/cros_ec_spi.c index 0686925..253d91a 100644 --- a/drivers/misc/cros_ec_spi.c +++ b/drivers/misc/cros_ec_spi.c @@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR; int cros_ec_spi_packet(struct udevice *udev, int out_bytes, int in_bytes) { struct cros_ec_dev *dev = dev_get_uclass_priv(udev); - struct spi_slave *slave = dev_get_parentdata(dev->dev); + struct spi_slave *slave = dev_get_parent_priv(dev->dev); ulong start; uint8_t byte; int rv; @@ -84,7 +84,7 @@ int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, int cmd_version, uint8_t **dinp, int din_len) { struct cros_ec_dev *dev = dev_get_uclass_priv(udev); - struct spi_slave *slave = dev_get_parentdata(dev->dev); + struct spi_slave *slave = dev_get_parent_priv(dev->dev); int in_bytes = din_len + 4; /* status, length, checksum, trailer */ uint8_t *out; uint8_t *p; diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c index 3111f4f..b2a56da 100644 --- a/drivers/mtd/spi/sf_dataflash.c +++ b/drivers/mtd/spi/sf_dataflash.c @@ -577,7 +577,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id) */ static int spi_dataflash_probe(struct udevice *dev) { - struct spi_slave *spi = dev_get_parentdata(dev); + struct spi_slave *spi = dev_get_parent_priv(dev); struct spi_flash *spi_flash; struct flash_info *info; u8 idcode[5]; diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 954376d..3bf03f7 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -471,7 +471,7 @@ int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len) int spi_flash_std_probe(struct udevice *dev) { - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); struct spi_flash *flash; diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index 868df5f..02b557f 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -913,7 +913,7 @@ void spi_init(void) #else static int fsl_qspi_child_pre_probe(struct udevice *dev) { - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); slave->max_write_size = TX_BUFFER_SIZE; diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index be4c0a3..b974e84 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -740,7 +740,7 @@ static int ich_spi_child_pre_probe(struct udevice *dev) struct udevice *bus = dev_get_parent(dev); struct ich_spi_platdata *plat = dev_get_platdata(bus); struct ich_spi_priv *priv = dev_get_priv(bus); - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); /* * Yes this controller can only write a small number of bytes at diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c index 6ae45f5..aa4abcc 100644 --- a/drivers/spi/soft_spi.c +++ b/drivers/spi/soft_spi.c @@ -200,7 +200,7 @@ static int soft_spi_ofdata_to_platdata(struct udevice *dev) static int soft_spi_probe(struct udevice *dev) { - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); struct soft_spi_platdata *plat = dev->platdata; int cs_flags, clk_flags; diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index d666272..58388ef 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -124,7 +124,7 @@ static int spi_post_probe(struct udevice *bus) static int spi_child_pre_probe(struct udevice *dev) { struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); /* * This is needed because we pass struct spi_slave around the place @@ -282,7 +282,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, ret = device_probe(dev); if (ret) goto err; - slave = dev_get_parentdata(dev); + slave = dev_get_parent_priv(dev); slave->dev = dev; } @@ -291,7 +291,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, goto err; *busp = bus; - *devp = dev_get_parentdata(dev); + *devp = dev_get_parent_priv(dev); debug("%s: bus=%p, slave=%p\n", __func__, bus, *devp); return 0; @@ -320,7 +320,7 @@ struct spi_slave *spi_setup_slave_fdt(const void *blob, int node, ret = device_get_child_by_of_offset(bus, node, &dev); if (ret) return NULL; - return dev_get_parentdata(dev); + return dev_get_parent_priv(dev); } /* Compatibility function - to be removed */ diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c index dc8fa88..d4b5ff4 100644 --- a/drivers/usb/eth/smsc95xx.c +++ b/drivers/usb/eth/smsc95xx.c @@ -945,7 +945,7 @@ int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss, #ifdef CONFIG_DM_ETH static int smsc95xx_eth_start(struct udevice *dev) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct smsc95xx_private *priv = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); @@ -1029,7 +1029,7 @@ static int smsc95xx_free_pkt(struct udevice *dev, uchar *packet, int packet_len) int smsc95xx_write_hwaddr(struct udevice *dev) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); struct smsc95xx_private *priv = dev_get_priv(dev); diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 3c3e082..62d20f0 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -19,7 +19,7 @@ int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct usb_interface_descriptor *iface_desc; bool ep_in_found = false, ep_out_found = false; struct usb_interface *iface; diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 135ef72..c85dbce 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -303,7 +303,7 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev, ttdev = udev; parent = udev->dev; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent); while (uparent->speed != USB_SPEED_HIGH) { struct udevice *dev = parent; @@ -313,9 +313,9 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev, return; } - ttdev = dev_get_parentdata(dev); + ttdev = dev_get_parent_priv(dev); parent = dev->parent; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent); } parent_devnum = uparent->devnum; #else diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index c66ebb6..7f6a9a6 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -289,7 +289,7 @@ static struct usb_device *find_child_devnum(struct udevice *parent, int devnum) if (!device_active(parent)) return NULL; - udev = dev_get_parentdata(parent); + udev = dev_get_parent_priv(parent); if (udev->devnum == devnum) return udev; @@ -575,7 +575,7 @@ int usb_scan_device(struct udevice *parent, int port, udev->portnr = port; debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr); parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ? - dev_get_parentdata(parent) : NULL; + dev_get_parent_priv(parent) : NULL; ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev); debug("read_descriptor for '%s': ret=%d\n", parent->name, ret); if (ret) @@ -638,7 +638,7 @@ int usb_detect_change(void) if (!device_active(dev)) continue; - udev = dev_get_parentdata(dev); + udev = dev_get_parent_priv(dev); if (usb_get_port_status(udev, udev->portnr, &status) < 0) /* USB request failed */ @@ -694,7 +694,7 @@ struct udevice *usb_get_bus(struct udevice *dev) int usb_child_pre_probe(struct udevice *dev) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); int ret; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 307e1a6..ca598aa 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1119,7 +1119,7 @@ static struct usb_device *get_usb_device(struct udevice *dev) if (device_get_uclass_id(dev) == UCLASS_USB) udev = dev_get_uclass_priv(dev); else - udev = dev_get_parentdata(dev); + udev = dev_get_parent_priv(dev); return udev; } @@ -1150,7 +1150,7 @@ static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev, } else { while (!is_root_hub(hub->parent)) hub = hub->parent; - uhop = dev_get_parentdata(hub); + uhop = dev_get_parent_priv(hub); root_portnr = uhop->portnr; } } diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h index 53fe4ff..1c41e2a 100644 --- a/drivers/usb/musb-new/usb-compat.h +++ b/drivers/usb/musb-new/usb-compat.h @@ -82,7 +82,7 @@ static inline u16 find_tt(struct usb_device *udev) */ ttdev = udev; parent = udev->dev; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent); while (uparent->speed != USB_SPEED_HIGH) { struct udevice *dev = parent; @@ -92,9 +92,9 @@ static inline u16 find_tt(struct usb_device *udev) return 0; } - ttdev = dev_get_parentdata(dev); + ttdev = dev_get_parent_priv(dev); parent = dev->parent; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent); } return (uparent->devnum << 8) | (ttdev->portnr - 1); @@ -119,12 +119,12 @@ static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev) * If these 2 are not the same we are being called from * usb_scan_device() and udev itself is the parent. */ - if (dev_get_parentdata(udev->dev) != udev) + if (dev_get_parent_priv(udev->dev) != udev) return udev; /* We are being called normally, use the parent pointer */ if (device_get_uclass_id(parent) == UCLASS_USB_HUB) - return dev_get_parentdata(parent); + return dev_get_parent_priv(parent); return NULL; } -- cgit v1.1 From 0766ad2f7fdae6d7482b8e1e3f5a49b3d9a3810b Mon Sep 17 00:00:00 2001 From: Christophe Ricard Date: Tue, 6 Oct 2015 22:54:41 +0200 Subject: dm: tpm: Move tpm_tis_i2c to tpm_i2c_infineon As there is no TCG specification or recommendation for i2c TPM 1.2, move tpm_tis_i2c driver to tpm_i2c_infineon. Other tpm vendors like Atmel or STMicroelectronics may have a different transport protocol for i2c. Signed-off-by: Christophe Ricard Reviewed-by: Tom Rini Acked-by: Simon Glass --- drivers/tpm/Kconfig | 4 +- drivers/tpm/Makefile | 2 +- drivers/tpm/tpm_tis_i2c.c | 623 ----------------------------------------- drivers/tpm/tpm_tis_i2c.h | 146 ---------- drivers/tpm/tpm_tis_infineon.c | 623 +++++++++++++++++++++++++++++++++++++++++ drivers/tpm/tpm_tis_infineon.h | 146 ++++++++++ 6 files changed, 772 insertions(+), 772 deletions(-) delete mode 100644 drivers/tpm/tpm_tis_i2c.c delete mode 100644 drivers/tpm/tpm_tis_i2c.h create mode 100644 drivers/tpm/tpm_tis_infineon.c create mode 100644 drivers/tpm/tpm_tis_infineon.h (limited to 'drivers') diff --git a/drivers/tpm/Kconfig b/drivers/tpm/Kconfig index 6bc8fdd..dacb847 100644 --- a/drivers/tpm/Kconfig +++ b/drivers/tpm/Kconfig @@ -31,7 +31,7 @@ config TPM_ATMEL_TWI to the device using the standard TPM Interface Specification (TIS) protocol -config TPM_TIS_I2C +config TPM_TIS_INFINEON bool "Enable support for Infineon SLB9635/45 TPMs on I2C" depends on TPM && DM_I2C help @@ -42,7 +42,7 @@ config TPM_TIS_I2C config TPM_TIS_I2C_BURST_LIMITATION bool "Enable I2C burst length limitation" - depends on TPM_TIS_I2C + depends on TPM_TIS_INFINEON help Some broken TPMs have a limitation on the number of bytes they can receive in one message. Enable this option to allow you to set this diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index 0d328f8..5748145 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -6,6 +6,6 @@ obj-$(CONFIG_DM_TPM) += tpm-uclass.o obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o -obj-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o +obj-$(CONFIG_TPM_TIS_INFINEON) += tpm_tis_infineon.o obj-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o diff --git a/drivers/tpm/tpm_tis_i2c.c b/drivers/tpm/tpm_tis_i2c.c deleted file mode 100644 index 9afe46c..0000000 --- a/drivers/tpm/tpm_tis_i2c.c +++ /dev/null @@ -1,623 +0,0 @@ -/* - * Copyright (C) 2011 Infineon Technologies - * - * Authors: - * Peter Huewe - * - * Description: - * Device driver for TCG/TCPA TPM (trusted platform module). - * Specifications at www.trustedcomputinggroup.org - * - * This device driver implements the TPM interface as defined in - * the TCG TPM Interface Spec version 1.2, revision 1.0 and the - * Infineon I2C Protocol Stack Specification v0.20. - * - * It is based on the Linux kernel driver tpm.c from Leendert van - * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. - * - * Version: 2.1.1 - * - * SPDX-License-Identifier: GPL-2.0 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tpm_tis_i2c.h" -#include "tpm_internal.h" - -DECLARE_GLOBAL_DATA_PTR; - -static const char * const chip_name[] = { - [SLB9635] = "slb9635tt", - [SLB9645] = "slb9645tt", - [UNKNOWN] = "unknown/fallback to slb9635", -}; - -/* - * tpm_tis_i2c_read() - read from TPM register - * @addr: register address to read from - * @buffer: provided by caller - * @len: number of bytes to read - * - * Read len bytes from TPM register and put them into - * buffer (little-endian format, i.e. first byte is put into buffer[0]). - * - * NOTE: TPM is big-endian for multi-byte values. Multi-byte - * values have to be swapped. - * - * Return -EIO on error, 0 on success. - */ -static int tpm_tis_i2c_read(struct udevice *dev, u8 addr, u8 *buffer, - size_t len) -{ - struct tpm_chip *chip = dev_get_priv(dev); - int rc; - int count; - uint32_t addrbuf = addr; - - if ((chip->chip_type == SLB9635) || (chip->chip_type == UNKNOWN)) { - /* slb9635 protocol should work in both cases */ - for (count = 0; count < MAX_COUNT; count++) { - rc = dm_i2c_write(dev, 0, (uchar *)&addrbuf, 1); - if (rc == 0) - break; /* Success, break to skip sleep */ - udelay(SLEEP_DURATION_US); - } - if (rc) - return rc; - - /* After the TPM has successfully received the register address - * it needs some time, thus we're sleeping here again, before - * retrieving the data - */ - for (count = 0; count < MAX_COUNT; count++) { - udelay(SLEEP_DURATION_US); - rc = dm_i2c_read(dev, 0, buffer, len); - if (rc == 0) - break; /* success, break to skip sleep */ - } - } else { - /* - * Use a combined read for newer chips. - * Unfortunately the smbus functions are not suitable due to - * the 32 byte limit of the smbus. - * Retries should usually not be needed, but are kept just to - * be safe on the safe side. - */ - for (count = 0; count < MAX_COUNT; count++) { - rc = dm_i2c_read(dev, addr, buffer, len); - if (rc == 0) - break; /* break here to skip sleep */ - udelay(SLEEP_DURATION_US); - } - } - - /* Take care of 'guard time' */ - udelay(SLEEP_DURATION_US); - if (rc) - return rc; - - return 0; -} - -static int tpm_tis_i2c_write_generic(struct udevice *dev, u8 addr, - const u8 *buffer, size_t len, - unsigned int sleep_time_us, u8 max_count) -{ - struct tpm_chip_priv *priv = dev_get_uclass_priv(dev); - struct tpm_chip *chip = dev_get_priv(dev); - int rc = 0; - int count; - - if (chip->chip_type == SLB9635) { - /* Prepare send buffer to include the address */ - priv->buf[0] = addr; - memcpy(&(priv->buf[1]), buffer, len); - buffer = priv->buf; - len++; - addr = 0; - } - - for (count = 0; count < max_count; count++) { - rc = dm_i2c_write(dev, addr, buffer, len); - if (rc == 0) - break; /* Success, break to skip sleep */ - udelay(sleep_time_us); - } - - /* take care of 'guard time' */ - udelay(sleep_time_us); - if (rc) - return rc; - - return 0; -} - -/* - * tpm_tis_i2c_write() - write to TPM register - * @addr: register address to write to - * @buffer: containing data to be written - * @len: number of bytes to write - * - * Write len bytes from provided buffer to TPM register (little - * endian format, i.e. buffer[0] is written as first byte). - * - * NOTE: TPM is big-endian for multi-byte values. Multi-byte - * values have to be swapped. - * - * NOTE: use this function instead of the tpm_tis_i2c_write_generic function. - * - * Return -EIO on error, 0 on success - */ -static int tpm_tis_i2c_write(struct udevice *dev, u8 addr, const u8 *buffer, - size_t len) -{ - return tpm_tis_i2c_write_generic(dev, addr, buffer, len, - SLEEP_DURATION_US, MAX_COUNT); -} - -/* - * This function is needed especially for the cleanup situation after - * sending TPM_READY - */ -static int tpm_tis_i2c_write_long(struct udevice *dev, u8 addr, u8 *buffer, - size_t len) -{ - return tpm_tis_i2c_write_generic(dev, addr, buffer, len, - SLEEP_DURATION_LONG_US, - MAX_COUNT_LONG); -} - -static int tpm_tis_i2c_check_locality(struct udevice *dev, int loc) -{ - const u8 mask = TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID; - struct tpm_chip *chip = dev_get_priv(dev); - u8 buf; - int rc; - - rc = tpm_tis_i2c_read(dev, TPM_ACCESS(loc), &buf, 1); - if (rc < 0) - return rc; - - if ((buf & mask) == mask) { - chip->locality = loc; - return loc; - } - - return -ENOENT; -} - -static void tpm_tis_i2c_release_locality(struct udevice *dev, int loc, - int force) -{ - const u8 mask = TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID; - u8 buf; - - if (tpm_tis_i2c_read(dev, TPM_ACCESS(loc), &buf, 1) < 0) - return; - - if (force || (buf & mask) == mask) { - buf = TPM_ACCESS_ACTIVE_LOCALITY; - tpm_tis_i2c_write(dev, TPM_ACCESS(loc), &buf, 1); - } -} - -static int tpm_tis_i2c_request_locality(struct udevice *dev, int loc) -{ - struct tpm_chip *chip = dev_get_priv(dev); - unsigned long start, stop; - u8 buf = TPM_ACCESS_REQUEST_USE; - int rc; - - rc = tpm_tis_i2c_check_locality(dev, loc); - if (rc >= 0) { - debug("%s: Already have locality\n", __func__); - return loc; /* We already have the locality */ - } else if (rc != -ENOENT) { - debug("%s: Failed to get locality: %d\n", __func__, rc); - return rc; - } - - rc = tpm_tis_i2c_write(dev, TPM_ACCESS(loc), &buf, 1); - if (rc) { - debug("%s: Failed to write to TPM: %d\n", __func__, rc); - return rc; - } - - /* Wait for burstcount */ - start = get_timer(0); - stop = chip->timeout_a; - do { - rc = tpm_tis_i2c_check_locality(dev, loc); - if (rc >= 0) { - debug("%s: Have locality\n", __func__); - return loc; - } else if (rc != -ENOENT) { - debug("%s: Failed to get locality: %d\n", __func__, rc); - return rc; - } - mdelay(TPM_TIMEOUT_MS); - } while (get_timer(start) < stop); - debug("%s: Timeout getting locality: %d\n", __func__, rc); - - return rc; -} - -static u8 tpm_tis_i2c_status(struct udevice *dev) -{ - struct tpm_chip *chip = dev_get_priv(dev); - /* NOTE: Since i2c read may fail, return 0 in this case --> time-out */ - u8 buf; - - if (tpm_tis_i2c_read(dev, TPM_STS(chip->locality), &buf, 1) < 0) - return 0; - else - return buf; -} - -static int tpm_tis_i2c_ready(struct udevice *dev) -{ - struct tpm_chip *chip = dev_get_priv(dev); - int rc; - - /* This causes the current command to be aborted */ - u8 buf = TPM_STS_COMMAND_READY; - - debug("%s\n", __func__); - rc = tpm_tis_i2c_write_long(dev, TPM_STS(chip->locality), &buf, 1); - if (rc) - debug("%s: rc=%d\n", __func__, rc); - - return rc; -} - -static ssize_t tpm_tis_i2c_get_burstcount(struct udevice *dev) -{ - struct tpm_chip *chip = dev_get_priv(dev); - unsigned long start, stop; - ssize_t burstcnt; - u8 addr, buf[3]; - - /* Wait for burstcount */ - /* XXX: Which timeout value? Spec has 2 answers (c & d) */ - start = get_timer(0); - stop = chip->timeout_d; - do { - /* Note: STS is little endian */ - addr = TPM_STS(chip->locality) + 1; - if (tpm_tis_i2c_read(dev, addr, buf, 3) < 0) - burstcnt = 0; - else - burstcnt = (buf[2] << 16) + (buf[1] << 8) + buf[0]; - - if (burstcnt) - return burstcnt; - mdelay(TPM_TIMEOUT_MS); - } while (get_timer(start) < stop); - - return -EBUSY; -} - -static int tpm_tis_i2c_wait_for_stat(struct udevice *dev, u8 mask, - unsigned long timeout, int *status) -{ - unsigned long start, stop; - - /* Check current status */ - *status = tpm_tis_i2c_status(dev); - if ((*status & mask) == mask) - return 0; - - start = get_timer(0); - stop = timeout; - do { - mdelay(TPM_TIMEOUT_MS); - *status = tpm_tis_i2c_status(dev); - if ((*status & mask) == mask) - return 0; - } while (get_timer(start) < stop); - - return -ETIMEDOUT; -} - -static int tpm_tis_i2c_recv_data(struct udevice *dev, u8 *buf, size_t count) -{ - struct tpm_chip *chip = dev_get_priv(dev); - size_t size = 0; - ssize_t burstcnt; - int rc; - - while (size < count) { - burstcnt = tpm_tis_i2c_get_burstcount(dev); - - /* burstcount < 0 -> tpm is busy */ - if (burstcnt < 0) - return burstcnt; - - /* Limit received data to max left */ - if (burstcnt > (count - size)) - burstcnt = count - size; - - rc = tpm_tis_i2c_read(dev, TPM_DATA_FIFO(chip->locality), - &(buf[size]), burstcnt); - if (rc == 0) - size += burstcnt; - } - - return size; -} - -static int tpm_tis_i2c_recv(struct udevice *dev, u8 *buf, size_t count) -{ - struct tpm_chip *chip = dev_get_priv(dev); - int size = 0; - int expected, status; - int rc; - - status = tpm_tis_i2c_status(dev); - if (status == TPM_STS_COMMAND_READY) - return -EINTR; - if ((status & (TPM_STS_DATA_AVAIL | TPM_STS_VALID)) != - (TPM_STS_DATA_AVAIL | TPM_STS_VALID)) - return -EAGAIN; - - debug("...got it;\n"); - - /* Read first 10 bytes, including tag, paramsize, and result */ - size = tpm_tis_i2c_recv_data(dev, buf, TPM_HEADER_SIZE); - if (size < TPM_HEADER_SIZE) { - debug("Unable to read header\n"); - return size < 0 ? size : -EIO; - } - - expected = get_unaligned_be32(buf + TPM_RSP_SIZE_BYTE); - if ((size_t)expected > count) { - debug("Error size=%x, expected=%x, count=%x\n", size, expected, - count); - return -ENOSPC; - } - - size += tpm_tis_i2c_recv_data(dev, &buf[TPM_HEADER_SIZE], - expected - TPM_HEADER_SIZE); - if (size < expected) { - debug("Unable to read remainder of result\n"); - return -ETIMEDOUT; - } - - rc = tpm_tis_i2c_wait_for_stat(dev, TPM_STS_VALID, chip->timeout_c, - &status); - if (rc) - return rc; - if (status & TPM_STS_DATA_AVAIL) { /* Retry? */ - debug("Error left over data\n"); - return -EIO; - } - - return size; -} - -static int tpm_tis_i2c_send(struct udevice *dev, const u8 *buf, size_t len) -{ - struct tpm_chip *chip = dev_get_priv(dev); - int rc, status; - size_t burstcnt; - size_t count = 0; - int retry = 0; - u8 sts = TPM_STS_GO; - - debug("%s: len=%d\n", __func__, len); - if (len > TPM_DEV_BUFSIZE) - return -E2BIG; /* Command is too long for our tpm, sorry */ - - if (tpm_tis_i2c_request_locality(dev, 0) < 0) - return -EBUSY; - - status = tpm_tis_i2c_status(dev); - if ((status & TPM_STS_COMMAND_READY) == 0) { - rc = tpm_tis_i2c_ready(dev); - if (rc) - return rc; - rc = tpm_tis_i2c_wait_for_stat(dev, TPM_STS_COMMAND_READY, - chip->timeout_b, &status); - if (rc) - return rc; - } - - burstcnt = tpm_tis_i2c_get_burstcount(dev); - - /* burstcount < 0 -> tpm is busy */ - if (burstcnt < 0) - return burstcnt; - - while (count < len) { - udelay(300); - if (burstcnt > len - count) - burstcnt = len - count; - -#ifdef CONFIG_TPM_TIS_I2C_BURST_LIMITATION - if (retry && burstcnt > CONFIG_TPM_TIS_I2C_BURST_LIMITATION_LEN) - burstcnt = CONFIG_TPM_TIS_I2C_BURST_LIMITATION_LEN; -#endif /* CONFIG_TPM_TIS_I2C_BURST_LIMITATION */ - - rc = tpm_tis_i2c_write(dev, TPM_DATA_FIFO(chip->locality), - &(buf[count]), burstcnt); - if (rc == 0) - count += burstcnt; - else { - debug("%s: error\n", __func__); - if (retry++ > 10) - return -EIO; - rc = tpm_tis_i2c_wait_for_stat(dev, TPM_STS_VALID, - chip->timeout_c, - &status); - if (rc) - return rc; - - if ((status & TPM_STS_DATA_EXPECT) == 0) - return -EIO; - } - } - - /* Go and do it */ - rc = tpm_tis_i2c_write(dev, TPM_STS(chip->locality), &sts, 1); - if (rc < 0) - return rc; - debug("%s: done, rc=%d\n", __func__, rc); - - return len; -} - -static int tpm_tis_i2c_cleanup(struct udevice *dev) -{ - struct tpm_chip *chip = dev_get_priv(dev); - - tpm_tis_i2c_ready(dev); - /* - * The TPM needs some time to clean up here, - * so we sleep rather than keeping the bus busy - */ - mdelay(2); - tpm_tis_i2c_release_locality(dev, chip->locality, 0); - - return 0; -} - -static int tpm_tis_i2c_init(struct udevice *dev) -{ - struct tpm_chip *chip = dev_get_priv(dev); - u32 vendor; - u32 expected_did_vid; - int rc; - - chip->is_open = 1; - - /* Default timeouts - these could move to the device tree */ - chip->timeout_a = TIS_SHORT_TIMEOUT_MS; - chip->timeout_b = TIS_LONG_TIMEOUT_MS; - chip->timeout_c = TIS_SHORT_TIMEOUT_MS; - chip->timeout_d = TIS_SHORT_TIMEOUT_MS; - - rc = tpm_tis_i2c_request_locality(dev, 0); - if (rc < 0) - return rc; - - /* Read four bytes from DID_VID register */ - if (tpm_tis_i2c_read(dev, TPM_DID_VID(0), (uchar *)&vendor, 4) < 0) { - tpm_tis_i2c_release_locality(dev, 0, 1); - return -EIO; - } - - if (chip->chip_type == SLB9635) { - vendor = be32_to_cpu(vendor); - expected_did_vid = TPM_TIS_I2C_DID_VID_9635; - } else { - /* device id and byte order has changed for newer i2c tpms */ - expected_did_vid = TPM_TIS_I2C_DID_VID_9645; - } - - if (chip->chip_type != UNKNOWN && vendor != expected_did_vid) { - error("Vendor id did not match! ID was %08x\n", vendor); - return -ENODEV; - } - - chip->vend_dev = vendor; - debug("1.2 TPM (chip type %s device-id 0x%X)\n", - chip_name[chip->chip_type], vendor >> 16); - - /* - * A timeout query to TPM can be placed here. - * Standard timeout values are used so far - */ - - return 0; -} - -static int tpm_tis_i2c_open(struct udevice *dev) -{ - struct tpm_chip *chip = dev_get_priv(dev); - int rc; - - debug("%s: start\n", __func__); - if (chip->is_open) - return -EBUSY; - rc = tpm_tis_i2c_init(dev); - if (rc < 0) - chip->is_open = 0; - - return rc; -} - -static int tpm_tis_i2c_close(struct udevice *dev) -{ - struct tpm_chip *chip = dev_get_priv(dev); - - if (chip->is_open) { - tpm_tis_i2c_release_locality(dev, chip->locality, 1); - chip->is_open = 0; - chip->vend_dev = 0; - } - - return 0; -} - -static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size) -{ - struct tpm_chip *chip = dev_get_priv(dev); - - if (size < 50) - return -ENOSPC; - - return snprintf(buf, size, "1.2 TPM (%s, chip type %s device-id 0x%x)", - chip->is_open ? "open" : "closed", - chip_name[chip->chip_type], - chip->vend_dev >> 16); -} - -static int tpm_tis_i2c_probe(struct udevice *dev) -{ - struct tpm_chip_priv *uc_priv = dev_get_uclass_priv(dev); - struct tpm_chip *chip = dev_get_priv(dev); - - chip->chip_type = dev_get_driver_data(dev); - - /* TODO: These need to be checked and tuned */ - uc_priv->duration_ms[TPM_SHORT] = TIS_SHORT_TIMEOUT_MS; - uc_priv->duration_ms[TPM_MEDIUM] = TIS_LONG_TIMEOUT_MS; - uc_priv->duration_ms[TPM_LONG] = TIS_LONG_TIMEOUT_MS; - uc_priv->retry_time_ms = TPM_TIMEOUT_MS; - - return 0; -} - -static const struct tpm_ops tpm_tis_i2c_ops = { - .open = tpm_tis_i2c_open, - .close = tpm_tis_i2c_close, - .get_desc = tpm_tis_get_desc, - .send = tpm_tis_i2c_send, - .recv = tpm_tis_i2c_recv, - .cleanup = tpm_tis_i2c_cleanup, -}; - -static const struct udevice_id tpm_tis_i2c_ids[] = { - { .compatible = "infineon,slb9635tt", .data = SLB9635 }, - { .compatible = "infineon,slb9645tt", .data = SLB9645 }, - { } -}; - -U_BOOT_DRIVER(tpm_tis_i2c) = { - .name = "tpm_tis_i2c", - .id = UCLASS_TPM, - .of_match = tpm_tis_i2c_ids, - .ops = &tpm_tis_i2c_ops, - .probe = tpm_tis_i2c_probe, - .priv_auto_alloc_size = sizeof(struct tpm_chip), -}; diff --git a/drivers/tpm/tpm_tis_i2c.h b/drivers/tpm/tpm_tis_i2c.h deleted file mode 100644 index 3b510d1..0000000 --- a/drivers/tpm/tpm_tis_i2c.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2011 Infineon Technologies - * - * Authors: - * Peter Huewe - * - * Version: 2.1.1 - * - * Description: - * Device driver for TCG/TCPA TPM (trusted platform module). - * Specifications at www.trustedcomputinggroup.org - * - * It is based on the Linux kernel driver tpm.c from Leendert van - * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. - * - * SPDX-License-Identifier: GPL-2.0 - */ - -#ifndef _TPM_TIS_I2C_H -#define _TPM_TIS_I2C_H - -#include -#include - -enum tpm_timeout { - TPM_TIMEOUT_MS = 5, - TIS_SHORT_TIMEOUT_MS = 750, - TIS_LONG_TIMEOUT_MS = 2000, - SLEEP_DURATION_US = 60, - SLEEP_DURATION_LONG_US = 210, -}; - -/* Size of external transmit buffer (used in tpm_transmit)*/ -#define TPM_BUFSIZE 4096 - -/* Index of Count field in TPM response buffer */ -#define TPM_RSP_SIZE_BYTE 2 -#define TPM_RSP_RC_BYTE 6 - -enum i2c_chip_type { - SLB9635, - SLB9645, - UNKNOWN, -}; - -struct tpm_chip { - int is_open; - int locality; - u32 vend_dev; - unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */ - enum i2c_chip_type chip_type; -}; - -struct tpm_input_header { - __be16 tag; - __be32 length; - __be32 ordinal; -} __packed; - -struct tpm_output_header { - __be16 tag; - __be32 length; - __be32 return_code; -} __packed; - -struct timeout_t { - __be32 a; - __be32 b; - __be32 c; - __be32 d; -} __packed; - -struct duration_t { - __be32 tpm_short; - __be32 tpm_medium; - __be32 tpm_long; -} __packed; - -union cap_t { - struct timeout_t timeout; - struct duration_t duration; -}; - -struct tpm_getcap_params_in { - __be32 cap; - __be32 subcap_size; - __be32 subcap; -} __packed; - -struct tpm_getcap_params_out { - __be32 cap_size; - union cap_t cap; -} __packed; - -union tpm_cmd_header { - struct tpm_input_header in; - struct tpm_output_header out; -}; - -union tpm_cmd_params { - struct tpm_getcap_params_out getcap_out; - struct tpm_getcap_params_in getcap_in; -}; - -struct tpm_cmd_t { - union tpm_cmd_header header; - union tpm_cmd_params params; -} __packed; - -/* Max number of iterations after i2c NAK */ -#define MAX_COUNT 3 - -/* - * Max number of iterations after i2c NAK for 'long' commands - * - * We need this especially for sending TPM_READY, since the cleanup after the - * transtion to the ready state may take some time, but it is unpredictable - * how long it will take. - */ -#define MAX_COUNT_LONG 50 - -enum tis_access { - TPM_ACCESS_VALID = 0x80, - TPM_ACCESS_ACTIVE_LOCALITY = 0x20, - TPM_ACCESS_REQUEST_PENDING = 0x04, - TPM_ACCESS_REQUEST_USE = 0x02, -}; - -enum tis_status { - TPM_STS_VALID = 0x80, - TPM_STS_COMMAND_READY = 0x40, - TPM_STS_GO = 0x20, - TPM_STS_DATA_AVAIL = 0x10, - TPM_STS_DATA_EXPECT = 0x08, -}; - -/* expected value for DIDVID register */ -#define TPM_TIS_I2C_DID_VID_9635 0x000b15d1L -#define TPM_TIS_I2C_DID_VID_9645 0x001a15d1L - -#define TPM_ACCESS(l) (0x0000 | ((l) << 4)) -#define TPM_STS(l) (0x0001 | ((l) << 4)) -#define TPM_DATA_FIFO(l) (0x0005 | ((l) << 4)) -#define TPM_DID_VID(l) (0x0006 | ((l) << 4)) - -#endif diff --git a/drivers/tpm/tpm_tis_infineon.c b/drivers/tpm/tpm_tis_infineon.c new file mode 100644 index 0000000..88eb786 --- /dev/null +++ b/drivers/tpm/tpm_tis_infineon.c @@ -0,0 +1,623 @@ +/* + * Copyright (C) 2011 Infineon Technologies + * + * Authors: + * Peter Huewe + * + * Description: + * Device driver for TCG/TCPA TPM (trusted platform module). + * Specifications at www.trustedcomputinggroup.org + * + * This device driver implements the TPM interface as defined in + * the TCG TPM Interface Spec version 1.2, revision 1.0 and the + * Infineon I2C Protocol Stack Specification v0.20. + * + * It is based on the Linux kernel driver tpm.c from Leendert van + * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. + * + * Version: 2.1.1 + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tpm_tis_infineon.h" +#include "tpm_internal.h" + +DECLARE_GLOBAL_DATA_PTR; + +static const char * const chip_name[] = { + [SLB9635] = "slb9635tt", + [SLB9645] = "slb9645tt", + [UNKNOWN] = "unknown/fallback to slb9635", +}; + +/* + * tpm_tis_i2c_read() - read from TPM register + * @addr: register address to read from + * @buffer: provided by caller + * @len: number of bytes to read + * + * Read len bytes from TPM register and put them into + * buffer (little-endian format, i.e. first byte is put into buffer[0]). + * + * NOTE: TPM is big-endian for multi-byte values. Multi-byte + * values have to be swapped. + * + * Return -EIO on error, 0 on success. + */ +static int tpm_tis_i2c_read(struct udevice *dev, u8 addr, u8 *buffer, + size_t len) +{ + struct tpm_chip *chip = dev_get_priv(dev); + int rc; + int count; + uint32_t addrbuf = addr; + + if ((chip->chip_type == SLB9635) || (chip->chip_type == UNKNOWN)) { + /* slb9635 protocol should work in both cases */ + for (count = 0; count < MAX_COUNT; count++) { + rc = dm_i2c_write(dev, 0, (uchar *)&addrbuf, 1); + if (rc == 0) + break; /* Success, break to skip sleep */ + udelay(SLEEP_DURATION_US); + } + if (rc) + return rc; + + /* After the TPM has successfully received the register address + * it needs some time, thus we're sleeping here again, before + * retrieving the data + */ + for (count = 0; count < MAX_COUNT; count++) { + udelay(SLEEP_DURATION_US); + rc = dm_i2c_read(dev, 0, buffer, len); + if (rc == 0) + break; /* success, break to skip sleep */ + } + } else { + /* + * Use a combined read for newer chips. + * Unfortunately the smbus functions are not suitable due to + * the 32 byte limit of the smbus. + * Retries should usually not be needed, but are kept just to + * be safe on the safe side. + */ + for (count = 0; count < MAX_COUNT; count++) { + rc = dm_i2c_read(dev, addr, buffer, len); + if (rc == 0) + break; /* break here to skip sleep */ + udelay(SLEEP_DURATION_US); + } + } + + /* Take care of 'guard time' */ + udelay(SLEEP_DURATION_US); + if (rc) + return rc; + + return 0; +} + +static int tpm_tis_i2c_write_generic(struct udevice *dev, u8 addr, + const u8 *buffer, size_t len, + unsigned int sleep_time_us, u8 max_count) +{ + struct tpm_chip_priv *priv = dev_get_uclass_priv(dev); + struct tpm_chip *chip = dev_get_priv(dev); + int rc = 0; + int count; + + if (chip->chip_type == SLB9635) { + /* Prepare send buffer to include the address */ + priv->buf[0] = addr; + memcpy(&(priv->buf[1]), buffer, len); + buffer = priv->buf; + len++; + addr = 0; + } + + for (count = 0; count < max_count; count++) { + rc = dm_i2c_write(dev, addr, buffer, len); + if (rc == 0) + break; /* Success, break to skip sleep */ + udelay(sleep_time_us); + } + + /* take care of 'guard time' */ + udelay(sleep_time_us); + if (rc) + return rc; + + return 0; +} + +/* + * tpm_tis_i2c_write() - write to TPM register + * @addr: register address to write to + * @buffer: containing data to be written + * @len: number of bytes to write + * + * Write len bytes from provided buffer to TPM register (little + * endian format, i.e. buffer[0] is written as first byte). + * + * NOTE: TPM is big-endian for multi-byte values. Multi-byte + * values have to be swapped. + * + * NOTE: use this function instead of the tpm_tis_i2c_write_generic function. + * + * Return -EIO on error, 0 on success + */ +static int tpm_tis_i2c_write(struct udevice *dev, u8 addr, const u8 *buffer, + size_t len) +{ + return tpm_tis_i2c_write_generic(dev, addr, buffer, len, + SLEEP_DURATION_US, MAX_COUNT); +} + +/* + * This function is needed especially for the cleanup situation after + * sending TPM_READY + */ +static int tpm_tis_i2c_write_long(struct udevice *dev, u8 addr, u8 *buffer, + size_t len) +{ + return tpm_tis_i2c_write_generic(dev, addr, buffer, len, + SLEEP_DURATION_LONG_US, + MAX_COUNT_LONG); +} + +static int tpm_tis_i2c_check_locality(struct udevice *dev, int loc) +{ + const u8 mask = TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID; + struct tpm_chip *chip = dev_get_priv(dev); + u8 buf; + int rc; + + rc = tpm_tis_i2c_read(dev, TPM_ACCESS(loc), &buf, 1); + if (rc < 0) + return rc; + + if ((buf & mask) == mask) { + chip->locality = loc; + return loc; + } + + return -ENOENT; +} + +static void tpm_tis_i2c_release_locality(struct udevice *dev, int loc, + int force) +{ + const u8 mask = TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID; + u8 buf; + + if (tpm_tis_i2c_read(dev, TPM_ACCESS(loc), &buf, 1) < 0) + return; + + if (force || (buf & mask) == mask) { + buf = TPM_ACCESS_ACTIVE_LOCALITY; + tpm_tis_i2c_write(dev, TPM_ACCESS(loc), &buf, 1); + } +} + +static int tpm_tis_i2c_request_locality(struct udevice *dev, int loc) +{ + struct tpm_chip *chip = dev_get_priv(dev); + unsigned long start, stop; + u8 buf = TPM_ACCESS_REQUEST_USE; + int rc; + + rc = tpm_tis_i2c_check_locality(dev, loc); + if (rc >= 0) { + debug("%s: Already have locality\n", __func__); + return loc; /* We already have the locality */ + } else if (rc != -ENOENT) { + debug("%s: Failed to get locality: %d\n", __func__, rc); + return rc; + } + + rc = tpm_tis_i2c_write(dev, TPM_ACCESS(loc), &buf, 1); + if (rc) { + debug("%s: Failed to write to TPM: %d\n", __func__, rc); + return rc; + } + + /* Wait for burstcount */ + start = get_timer(0); + stop = chip->timeout_a; + do { + rc = tpm_tis_i2c_check_locality(dev, loc); + if (rc >= 0) { + debug("%s: Have locality\n", __func__); + return loc; + } else if (rc != -ENOENT) { + debug("%s: Failed to get locality: %d\n", __func__, rc); + return rc; + } + mdelay(TPM_TIMEOUT_MS); + } while (get_timer(start) < stop); + debug("%s: Timeout getting locality: %d\n", __func__, rc); + + return rc; +} + +static u8 tpm_tis_i2c_status(struct udevice *dev) +{ + struct tpm_chip *chip = dev_get_priv(dev); + /* NOTE: Since i2c read may fail, return 0 in this case --> time-out */ + u8 buf; + + if (tpm_tis_i2c_read(dev, TPM_STS(chip->locality), &buf, 1) < 0) + return 0; + else + return buf; +} + +static int tpm_tis_i2c_ready(struct udevice *dev) +{ + struct tpm_chip *chip = dev_get_priv(dev); + int rc; + + /* This causes the current command to be aborted */ + u8 buf = TPM_STS_COMMAND_READY; + + debug("%s\n", __func__); + rc = tpm_tis_i2c_write_long(dev, TPM_STS(chip->locality), &buf, 1); + if (rc) + debug("%s: rc=%d\n", __func__, rc); + + return rc; +} + +static ssize_t tpm_tis_i2c_get_burstcount(struct udevice *dev) +{ + struct tpm_chip *chip = dev_get_priv(dev); + unsigned long start, stop; + ssize_t burstcnt; + u8 addr, buf[3]; + + /* Wait for burstcount */ + /* XXX: Which timeout value? Spec has 2 answers (c & d) */ + start = get_timer(0); + stop = chip->timeout_d; + do { + /* Note: STS is little endian */ + addr = TPM_STS(chip->locality) + 1; + if (tpm_tis_i2c_read(dev, addr, buf, 3) < 0) + burstcnt = 0; + else + burstcnt = (buf[2] << 16) + (buf[1] << 8) + buf[0]; + + if (burstcnt) + return burstcnt; + mdelay(TPM_TIMEOUT_MS); + } while (get_timer(start) < stop); + + return -EBUSY; +} + +static int tpm_tis_i2c_wait_for_stat(struct udevice *dev, u8 mask, + unsigned long timeout, int *status) +{ + unsigned long start, stop; + + /* Check current status */ + *status = tpm_tis_i2c_status(dev); + if ((*status & mask) == mask) + return 0; + + start = get_timer(0); + stop = timeout; + do { + mdelay(TPM_TIMEOUT_MS); + *status = tpm_tis_i2c_status(dev); + if ((*status & mask) == mask) + return 0; + } while (get_timer(start) < stop); + + return -ETIMEDOUT; +} + +static int tpm_tis_i2c_recv_data(struct udevice *dev, u8 *buf, size_t count) +{ + struct tpm_chip *chip = dev_get_priv(dev); + size_t size = 0; + ssize_t burstcnt; + int rc; + + while (size < count) { + burstcnt = tpm_tis_i2c_get_burstcount(dev); + + /* burstcount < 0 -> tpm is busy */ + if (burstcnt < 0) + return burstcnt; + + /* Limit received data to max left */ + if (burstcnt > (count - size)) + burstcnt = count - size; + + rc = tpm_tis_i2c_read(dev, TPM_DATA_FIFO(chip->locality), + &(buf[size]), burstcnt); + if (rc == 0) + size += burstcnt; + } + + return size; +} + +static int tpm_tis_i2c_recv(struct udevice *dev, u8 *buf, size_t count) +{ + struct tpm_chip *chip = dev_get_priv(dev); + int size = 0; + int expected, status; + int rc; + + status = tpm_tis_i2c_status(dev); + if (status == TPM_STS_COMMAND_READY) + return -EINTR; + if ((status & (TPM_STS_DATA_AVAIL | TPM_STS_VALID)) != + (TPM_STS_DATA_AVAIL | TPM_STS_VALID)) + return -EAGAIN; + + debug("...got it;\n"); + + /* Read first 10 bytes, including tag, paramsize, and result */ + size = tpm_tis_i2c_recv_data(dev, buf, TPM_HEADER_SIZE); + if (size < TPM_HEADER_SIZE) { + debug("Unable to read header\n"); + return size < 0 ? size : -EIO; + } + + expected = get_unaligned_be32(buf + TPM_RSP_SIZE_BYTE); + if ((size_t)expected > count) { + debug("Error size=%x, expected=%x, count=%x\n", size, expected, + count); + return -ENOSPC; + } + + size += tpm_tis_i2c_recv_data(dev, &buf[TPM_HEADER_SIZE], + expected - TPM_HEADER_SIZE); + if (size < expected) { + debug("Unable to read remainder of result\n"); + return -ETIMEDOUT; + } + + rc = tpm_tis_i2c_wait_for_stat(dev, TPM_STS_VALID, chip->timeout_c, + &status); + if (rc) + return rc; + if (status & TPM_STS_DATA_AVAIL) { /* Retry? */ + debug("Error left over data\n"); + return -EIO; + } + + return size; +} + +static int tpm_tis_i2c_send(struct udevice *dev, const u8 *buf, size_t len) +{ + struct tpm_chip *chip = dev_get_priv(dev); + int rc, status; + size_t burstcnt; + size_t count = 0; + int retry = 0; + u8 sts = TPM_STS_GO; + + debug("%s: len=%d\n", __func__, len); + if (len > TPM_DEV_BUFSIZE) + return -E2BIG; /* Command is too long for our tpm, sorry */ + + if (tpm_tis_i2c_request_locality(dev, 0) < 0) + return -EBUSY; + + status = tpm_tis_i2c_status(dev); + if ((status & TPM_STS_COMMAND_READY) == 0) { + rc = tpm_tis_i2c_ready(dev); + if (rc) + return rc; + rc = tpm_tis_i2c_wait_for_stat(dev, TPM_STS_COMMAND_READY, + chip->timeout_b, &status); + if (rc) + return rc; + } + + burstcnt = tpm_tis_i2c_get_burstcount(dev); + + /* burstcount < 0 -> tpm is busy */ + if (burstcnt < 0) + return burstcnt; + + while (count < len) { + udelay(300); + if (burstcnt > len - count) + burstcnt = len - count; + +#ifdef CONFIG_TPM_TIS_I2C_BURST_LIMITATION + if (retry && burstcnt > CONFIG_TPM_TIS_I2C_BURST_LIMITATION_LEN) + burstcnt = CONFIG_TPM_TIS_I2C_BURST_LIMITATION_LEN; +#endif /* CONFIG_TPM_TIS_I2C_BURST_LIMITATION */ + + rc = tpm_tis_i2c_write(dev, TPM_DATA_FIFO(chip->locality), + &(buf[count]), burstcnt); + if (rc == 0) + count += burstcnt; + else { + debug("%s: error\n", __func__); + if (retry++ > 10) + return -EIO; + rc = tpm_tis_i2c_wait_for_stat(dev, TPM_STS_VALID, + chip->timeout_c, + &status); + if (rc) + return rc; + + if ((status & TPM_STS_DATA_EXPECT) == 0) + return -EIO; + } + } + + /* Go and do it */ + rc = tpm_tis_i2c_write(dev, TPM_STS(chip->locality), &sts, 1); + if (rc < 0) + return rc; + debug("%s: done, rc=%d\n", __func__, rc); + + return len; +} + +static int tpm_tis_i2c_cleanup(struct udevice *dev) +{ + struct tpm_chip *chip = dev_get_priv(dev); + + tpm_tis_i2c_ready(dev); + /* + * The TPM needs some time to clean up here, + * so we sleep rather than keeping the bus busy + */ + mdelay(2); + tpm_tis_i2c_release_locality(dev, chip->locality, 0); + + return 0; +} + +static int tpm_tis_i2c_init(struct udevice *dev) +{ + struct tpm_chip *chip = dev_get_priv(dev); + u32 vendor; + u32 expected_did_vid; + int rc; + + chip->is_open = 1; + + /* Default timeouts - these could move to the device tree */ + chip->timeout_a = TIS_SHORT_TIMEOUT_MS; + chip->timeout_b = TIS_LONG_TIMEOUT_MS; + chip->timeout_c = TIS_SHORT_TIMEOUT_MS; + chip->timeout_d = TIS_SHORT_TIMEOUT_MS; + + rc = tpm_tis_i2c_request_locality(dev, 0); + if (rc < 0) + return rc; + + /* Read four bytes from DID_VID register */ + if (tpm_tis_i2c_read(dev, TPM_DID_VID(0), (uchar *)&vendor, 4) < 0) { + tpm_tis_i2c_release_locality(dev, 0, 1); + return -EIO; + } + + if (chip->chip_type == SLB9635) { + vendor = be32_to_cpu(vendor); + expected_did_vid = TPM_TIS_I2C_DID_VID_9635; + } else { + /* device id and byte order has changed for newer i2c tpms */ + expected_did_vid = TPM_TIS_I2C_DID_VID_9645; + } + + if (chip->chip_type != UNKNOWN && vendor != expected_did_vid) { + error("Vendor id did not match! ID was %08x\n", vendor); + return -ENODEV; + } + + chip->vend_dev = vendor; + debug("1.2 TPM (chip type %s device-id 0x%X)\n", + chip_name[chip->chip_type], vendor >> 16); + + /* + * A timeout query to TPM can be placed here. + * Standard timeout values are used so far + */ + + return 0; +} + +static int tpm_tis_i2c_open(struct udevice *dev) +{ + struct tpm_chip *chip = dev_get_priv(dev); + int rc; + + debug("%s: start\n", __func__); + if (chip->is_open) + return -EBUSY; + rc = tpm_tis_i2c_init(dev); + if (rc < 0) + chip->is_open = 0; + + return rc; +} + +static int tpm_tis_i2c_close(struct udevice *dev) +{ + struct tpm_chip *chip = dev_get_priv(dev); + + if (chip->is_open) { + tpm_tis_i2c_release_locality(dev, chip->locality, 1); + chip->is_open = 0; + chip->vend_dev = 0; + } + + return 0; +} + +static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size) +{ + struct tpm_chip *chip = dev_get_priv(dev); + + if (size < 50) + return -ENOSPC; + + return snprintf(buf, size, "1.2 TPM (%s, chip type %s device-id 0x%x)", + chip->is_open ? "open" : "closed", + chip_name[chip->chip_type], + chip->vend_dev >> 16); +} + +static int tpm_tis_i2c_probe(struct udevice *dev) +{ + struct tpm_chip_priv *uc_priv = dev_get_uclass_priv(dev); + struct tpm_chip *chip = dev_get_priv(dev); + + chip->chip_type = dev_get_driver_data(dev); + + /* TODO: These need to be checked and tuned */ + uc_priv->duration_ms[TPM_SHORT] = TIS_SHORT_TIMEOUT_MS; + uc_priv->duration_ms[TPM_MEDIUM] = TIS_LONG_TIMEOUT_MS; + uc_priv->duration_ms[TPM_LONG] = TIS_LONG_TIMEOUT_MS; + uc_priv->retry_time_ms = TPM_TIMEOUT_MS; + + return 0; +} + +static const struct tpm_ops tpm_tis_i2c_ops = { + .open = tpm_tis_i2c_open, + .close = tpm_tis_i2c_close, + .get_desc = tpm_tis_get_desc, + .send = tpm_tis_i2c_send, + .recv = tpm_tis_i2c_recv, + .cleanup = tpm_tis_i2c_cleanup, +}; + +static const struct udevice_id tpm_tis_i2c_ids[] = { + { .compatible = "infineon,slb9635tt", .data = SLB9635 }, + { .compatible = "infineon,slb9645tt", .data = SLB9645 }, + { } +}; + +U_BOOT_DRIVER(tpm_tis_i2c) = { + .name = "tpm_tis_infineon", + .id = UCLASS_TPM, + .of_match = tpm_tis_i2c_ids, + .ops = &tpm_tis_i2c_ops, + .probe = tpm_tis_i2c_probe, + .priv_auto_alloc_size = sizeof(struct tpm_chip), +}; diff --git a/drivers/tpm/tpm_tis_infineon.h b/drivers/tpm/tpm_tis_infineon.h new file mode 100644 index 0000000..3b510d1 --- /dev/null +++ b/drivers/tpm/tpm_tis_infineon.h @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2011 Infineon Technologies + * + * Authors: + * Peter Huewe + * + * Version: 2.1.1 + * + * Description: + * Device driver for TCG/TCPA TPM (trusted platform module). + * Specifications at www.trustedcomputinggroup.org + * + * It is based on the Linux kernel driver tpm.c from Leendert van + * Dorn, Dave Safford, Reiner Sailer, and Kyleen Hall. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef _TPM_TIS_I2C_H +#define _TPM_TIS_I2C_H + +#include +#include + +enum tpm_timeout { + TPM_TIMEOUT_MS = 5, + TIS_SHORT_TIMEOUT_MS = 750, + TIS_LONG_TIMEOUT_MS = 2000, + SLEEP_DURATION_US = 60, + SLEEP_DURATION_LONG_US = 210, +}; + +/* Size of external transmit buffer (used in tpm_transmit)*/ +#define TPM_BUFSIZE 4096 + +/* Index of Count field in TPM response buffer */ +#define TPM_RSP_SIZE_BYTE 2 +#define TPM_RSP_RC_BYTE 6 + +enum i2c_chip_type { + SLB9635, + SLB9645, + UNKNOWN, +}; + +struct tpm_chip { + int is_open; + int locality; + u32 vend_dev; + unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* msec */ + enum i2c_chip_type chip_type; +}; + +struct tpm_input_header { + __be16 tag; + __be32 length; + __be32 ordinal; +} __packed; + +struct tpm_output_header { + __be16 tag; + __be32 length; + __be32 return_code; +} __packed; + +struct timeout_t { + __be32 a; + __be32 b; + __be32 c; + __be32 d; +} __packed; + +struct duration_t { + __be32 tpm_short; + __be32 tpm_medium; + __be32 tpm_long; +} __packed; + +union cap_t { + struct timeout_t timeout; + struct duration_t duration; +}; + +struct tpm_getcap_params_in { + __be32 cap; + __be32 subcap_size; + __be32 subcap; +} __packed; + +struct tpm_getcap_params_out { + __be32 cap_size; + union cap_t cap; +} __packed; + +union tpm_cmd_header { + struct tpm_input_header in; + struct tpm_output_header out; +}; + +union tpm_cmd_params { + struct tpm_getcap_params_out getcap_out; + struct tpm_getcap_params_in getcap_in; +}; + +struct tpm_cmd_t { + union tpm_cmd_header header; + union tpm_cmd_params params; +} __packed; + +/* Max number of iterations after i2c NAK */ +#define MAX_COUNT 3 + +/* + * Max number of iterations after i2c NAK for 'long' commands + * + * We need this especially for sending TPM_READY, since the cleanup after the + * transtion to the ready state may take some time, but it is unpredictable + * how long it will take. + */ +#define MAX_COUNT_LONG 50 + +enum tis_access { + TPM_ACCESS_VALID = 0x80, + TPM_ACCESS_ACTIVE_LOCALITY = 0x20, + TPM_ACCESS_REQUEST_PENDING = 0x04, + TPM_ACCESS_REQUEST_USE = 0x02, +}; + +enum tis_status { + TPM_STS_VALID = 0x80, + TPM_STS_COMMAND_READY = 0x40, + TPM_STS_GO = 0x20, + TPM_STS_DATA_AVAIL = 0x10, + TPM_STS_DATA_EXPECT = 0x08, +}; + +/* expected value for DIDVID register */ +#define TPM_TIS_I2C_DID_VID_9635 0x000b15d1L +#define TPM_TIS_I2C_DID_VID_9645 0x001a15d1L + +#define TPM_ACCESS(l) (0x0000 | ((l) << 4)) +#define TPM_STS(l) (0x0001 | ((l) << 4)) +#define TPM_DATA_FIFO(l) (0x0005 | ((l) << 4)) +#define TPM_DID_VID(l) (0x0006 | ((l) << 4)) + +#endif -- cgit v1.1 From 302c5dba0a6eeb5846b628d3d59978dc0751def9 Mon Sep 17 00:00:00 2001 From: Christophe Ricard Date: Tue, 6 Oct 2015 22:54:42 +0200 Subject: dm: tpm: Add Driver Model support for tpm_atmel_twi driver tpm_atmel_twi can fit perfectly to the new UCLASS_TPM class. Signed-off-by: Christophe Ricard Reviewed-by: Tom Rini Acked-by: Simon Glass --- drivers/tpm/Kconfig | 2 +- drivers/tpm/tpm_atmel_twi.c | 68 +++++++++++++++++++++++++++++++++------------ 2 files changed, 51 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/tpm/Kconfig b/drivers/tpm/Kconfig index dacb847..ff2cdbe 100644 --- a/drivers/tpm/Kconfig +++ b/drivers/tpm/Kconfig @@ -24,7 +24,7 @@ config TPM_TIS_SANDBOX config TPM_ATMEL_TWI bool "Enable Atmel TWI TPM device driver" - depends on TPM + depends on TPM && DM_I2C help This driver supports an Atmel TPM device connected on the I2C bus. The usual tpm operations and the 'tpm' command can be used to talk diff --git a/drivers/tpm/tpm_atmel_twi.c b/drivers/tpm/tpm_atmel_twi.c index 205d7a5..2aa9381 100644 --- a/drivers/tpm/tpm_atmel_twi.c +++ b/drivers/tpm/tpm_atmel_twi.c @@ -7,51 +7,56 @@ */ #include +#include #include #include #include +#include "tpm_internal.h" + #define ATMEL_TPM_TIMEOUT_MS 5000 /* sufficient for anything but generating/exporting keys */ /* - * tis_init() - * - * Initialize the TPM device. Returns 0 on success or -1 on - * failure (in case device probing did not succeed). - */ -int tis_init(void) -{ - return 0; -} - -/* - * tis_open() + * tpm_atmel_twi_open() * * Requests access to locality 0 for the caller. After all commands have been * completed the caller is supposed to call tis_close(). * * Returns 0 on success, -1 on failure. */ -int tis_open(void) +static int tpm_atmel_twi_open(struct udevice *dev) { return 0; } /* - * tis_close() + * tpm_atmel_twi_close() * * terminate the currect session with the TPM by releasing the locked * locality. Returns 0 on success of -1 on failure (in case lock * removal did not succeed). */ -int tis_close(void) +static int tpm_atmel_twi_close(struct udevice *dev) +{ + return 0; +} + +/* + * tpm_atmel_twi_get_desc() + * + * @dev: Device to check + * @buf: Buffer to put the string + * @size: Maximum size of buffer + * @return length of string, or -ENOSPC it no space + */ +static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size) { return 0; } /* - * tis_sendrecv() + * tpm_atmel_twi_xfer() * * Send the requested data to the TPM and then try to get its response * @@ -63,8 +68,9 @@ int tis_close(void) * Returns 0 on success (and places the number of response bytes at recv_len) * or -1 on failure. */ -int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf, - size_t *recv_len) +static int tpm_atmel_twi_xfer(struct udevice *dev, + const uint8_t *sendbuf, size_t send_size, + uint8_t *recvbuf, size_t *recv_len) { int res; unsigned long start; @@ -83,6 +89,7 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf, start = get_timer(0); while ((res = i2c_read(0x29, 0, 0, recvbuf, 10))) { + /* TODO Use TIS_TIMEOUT from tpm_tis_infineon.h */ if (get_timer(start) > ATMEL_TPM_TIMEOUT_MS) { puts("tpm timed out\n"); return -1; @@ -110,3 +117,28 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf, return res; } + +static int tpm_atmel_twi_probe(struct udevice *dev) +{ + return 0; +} + +static const struct udevice_id tpm_atmel_twi_ids[] = { + { .compatible = "atmel,at97sc3204t"}, + { } +}; + +static const struct tpm_ops tpm_atmel_twi_ops = { + .open = tpm_atmel_twi_open, + .close = tpm_atmel_twi_close, + .xfer = tpm_atmel_twi_xfer, + .get_desc = tpm_atmel_twi_get_desc, +}; + +U_BOOT_DRIVER(tpm_atmel_twi) = { + .name = "tpm_atmel_twi", + .id = UCLASS_TPM, + .of_match = tpm_atmel_twi_ids, + .ops = &tpm_atmel_twi_ops, + .probe = tpm_atmel_twi_probe, +}; -- cgit v1.1 From c2b0f600a1707450ef985e28363893987f36fd8a Mon Sep 17 00:00:00 2001 From: Christophe Ricard Date: Tue, 6 Oct 2015 22:54:43 +0200 Subject: dm: tpm: Remove every compilation switch for TPM driver model As every TPM drivers support UCLASS_TPM, we can only rely on DM_TPM functions. This simplify a bit the code. Signed-off-by: Christophe Ricard Reviewed-by: Tom Rini Acked-by: Simon Glass --- drivers/tpm/tpm_tis_infineon.c | 1 - drivers/tpm/tpm_tis_lpc.c | 1 - 2 files changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/tpm/tpm_tis_infineon.c b/drivers/tpm/tpm_tis_infineon.c index 88eb786..f57c328 100644 --- a/drivers/tpm/tpm_tis_infineon.c +++ b/drivers/tpm/tpm_tis_infineon.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c index b41c3ce..257d035 100644 --- a/drivers/tpm/tpm_tis_lpc.c +++ b/drivers/tpm/tpm_tis_lpc.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include -- cgit v1.1 From 3e7d940bb695fd8ba450dde7742a58a224efaee4 Mon Sep 17 00:00:00 2001 From: Christophe Ricard Date: Tue, 6 Oct 2015 22:54:44 +0200 Subject: dm: tpm: Every TPM drivers should depends on DM_TPM Every TPM drivers should now depends on DM_TPM and not only TPM. Signed-off-by: Christophe Ricard Reviewed-by: Tom Rini Acked-by: Simon Glass --- drivers/tpm/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tpm/Kconfig b/drivers/tpm/Kconfig index ff2cdbe..3ab652c 100644 --- a/drivers/tpm/Kconfig +++ b/drivers/tpm/Kconfig @@ -24,7 +24,7 @@ config TPM_TIS_SANDBOX config TPM_ATMEL_TWI bool "Enable Atmel TWI TPM device driver" - depends on TPM && DM_I2C + depends on DM_TPM && DM_I2C help This driver supports an Atmel TPM device connected on the I2C bus. The usual tpm operations and the 'tpm' command can be used to talk @@ -33,7 +33,7 @@ config TPM_ATMEL_TWI config TPM_TIS_INFINEON bool "Enable support for Infineon SLB9635/45 TPMs on I2C" - depends on TPM && DM_I2C + depends on DM_TPM && DM_I2C help This driver supports Infineon TPM devices connected on the I2C bus. The usual tpm operations and the 'tpm' command can be used to talk @@ -57,7 +57,7 @@ config TPM_TIS_I2C_BURST_LIMITATION_LEN config TPM_TIS_LPC bool "Enable support for Infineon SLB9635/45 TPMs on LPC" - depends on TPM && X86 + depends on DM_TPM && X86 help This driver supports Infineon TPM devices connected on the I2C bus. The usual tpm operations and the 'tpm' command can be used to talk -- cgit v1.1 From 2419cd16a1357a6d0f394b4631ea07b4f9e85ac7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 3 Oct 2015 06:39:36 -0600 Subject: dm: tpm: Drop CONFIG_DM_TPM Now that all TPM drivers use driver model, we can drop the special driver model CONFIG option. Signed-off-by: Simon Glass Acked-by: Christophe Ricard --- drivers/tpm/Kconfig | 15 +++------------ drivers/tpm/Makefile | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/tpm/Kconfig b/drivers/tpm/Kconfig index 3ab652c..31b35f7 100644 --- a/drivers/tpm/Kconfig +++ b/drivers/tpm/Kconfig @@ -4,15 +4,6 @@ menu "TPM support" -config DM_TPM - bool "Enable driver model for Trusted Platform Module drivers" - depends on DM && TPM - help - Enable driver model for TPMs. The TIS interface (tis_open(), - tis_sendrecv(), etc.) is then implemented by the TPM uclass. Note - that even with driver model only a single TPM is currently - supported, since the tpm library assumes this. - config TPM_TIS_SANDBOX bool "Enable sandbox TPM driver" depends on SANDBOX @@ -24,7 +15,7 @@ config TPM_TIS_SANDBOX config TPM_ATMEL_TWI bool "Enable Atmel TWI TPM device driver" - depends on DM_TPM && DM_I2C + depends on TPM && DM_I2C help This driver supports an Atmel TPM device connected on the I2C bus. The usual tpm operations and the 'tpm' command can be used to talk @@ -33,7 +24,7 @@ config TPM_ATMEL_TWI config TPM_TIS_INFINEON bool "Enable support for Infineon SLB9635/45 TPMs on I2C" - depends on DM_TPM && DM_I2C + depends on TPM && DM_I2C help This driver supports Infineon TPM devices connected on the I2C bus. The usual tpm operations and the 'tpm' command can be used to talk @@ -57,7 +48,7 @@ config TPM_TIS_I2C_BURST_LIMITATION_LEN config TPM_TIS_LPC bool "Enable support for Infineon SLB9635/45 TPMs on LPC" - depends on DM_TPM && X86 + depends on TPM && X86 help This driver supports Infineon TPM devices connected on the I2C bus. The usual tpm operations and the 'tpm' command can be used to talk diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index 5748145..1d49e95 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_DM_TPM) += tpm-uclass.o +obj-$(CONFIG_TPM) += tpm-uclass.o obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o obj-$(CONFIG_TPM_TIS_INFINEON) += tpm_tis_infineon.o -- cgit v1.1