public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Christophe Ricard <christophe.ricard@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 23/28] dm: tpm: Convert LPC driver to driver model
Date: Mon, 24 Aug 2015 22:23:04 +0200	[thread overview]
Message-ID: <55DB7D28.9030508@gmail.com> (raw)
In-Reply-To: <1440289904-31280-24-git-send-email-sjg@chromium.org>

Hi Simon,

Acked-by: Christophe Ricard<christophe-h.ricard@st.com>

Best Regards
Christophe

On 23/08/2015 02:31, Simon Glass wrote:
> Convert the tpm_tis_lpc driver to use driver model and update boards which
> use it.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Update driver for the new uclass interface
>
>   configs/chromebook_link_defconfig   |   2 +
>   configs/chromebox_panther_defconfig |   2 +
>   configs/coreboot-x86_defconfig      |   2 +
>   drivers/tpm/tpm_tis_lpc.c           | 286 +++++++++++++++++-------------------
>   4 files changed, 137 insertions(+), 155 deletions(-)
>
> diff --git a/configs/chromebook_link_defconfig b/configs/chromebook_link_defconfig
> index b0fc5ca..85752e4 100644
> --- a/configs/chromebook_link_defconfig
> +++ b/configs/chromebook_link_defconfig
> @@ -11,12 +11,14 @@ CONFIG_HAVE_VGA_BIOS=y
>   CONFIG_BOOTSTAGE=y
>   CONFIG_BOOTSTAGE_REPORT=y
>   CONFIG_CMD_BOOTSTAGE=y
> +CONFIG_CMD_TPM=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DM_PCI=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_CMD_CROS_EC=y
>   CONFIG_CROS_EC=y
>   CONFIG_CROS_EC_LPC=y
> +CONFIG_DM_TPM=y
>   CONFIG_TPM_TIS_LPC=y
>   CONFIG_VIDEO_VESA=y
>   CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
> diff --git a/configs/chromebox_panther_defconfig b/configs/chromebox_panther_defconfig
> index e7ef8fe..a6bafe3 100644
> --- a/configs/chromebox_panther_defconfig
> +++ b/configs/chromebox_panther_defconfig
> @@ -11,12 +11,14 @@ CONFIG_HAVE_VGA_BIOS=y
>   CONFIG_BOOTSTAGE=y
>   CONFIG_BOOTSTAGE_REPORT=y
>   CONFIG_CMD_BOOTSTAGE=y
> +CONFIG_CMD_TPM=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DM_PCI=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_CMD_CROS_EC=y
>   CONFIG_CROS_EC=y
>   CONFIG_CROS_EC_LPC=y
> +CONFIG_DM_TPM=y
>   CONFIG_TPM_TIS_LPC=y
>   CONFIG_VIDEO_VESA=y
>   CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
> diff --git a/configs/coreboot-x86_defconfig b/configs/coreboot-x86_defconfig
> index 66b8caa..fda2b7e 100644
> --- a/configs/coreboot-x86_defconfig
> +++ b/configs/coreboot-x86_defconfig
> @@ -9,11 +9,13 @@ CONFIG_TSC_CALIBRATION_BYPASS=y
>   CONFIG_BOOTSTAGE=y
>   CONFIG_BOOTSTAGE_REPORT=y
>   CONFIG_CMD_BOOTSTAGE=y
> +CONFIG_CMD_TPM=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DM_PCI=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_NETDEVICES=y
>   CONFIG_E1000=y
> +CONFIG_DM_TPM=y
>   CONFIG_TPM_TIS_LPC=y
>   CONFIG_USE_PRIVATE_LIBGCC=y
>   CONFIG_SYS_VSNPRINTF=y
> diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
> index 3109c50..b41c3ce 100644
> --- a/drivers/tpm/tpm_tis_lpc.c
> +++ b/drivers/tpm/tpm_tis_lpc.c
> @@ -14,9 +14,11 @@
>    */
>   
>   #include <common.h>
> -#include <asm/io.h>
> +#include <dm.h>
> +#include <mapmem.h>
>   #include <tis.h>
>   #include <tpm.h>
> +#include <asm/io.h>
>   
>   #define PREFIX "lpc_tpm: "
>   
> @@ -37,13 +39,15 @@ struct tpm_locality {
>   	u8 padding4[251];
>   };
>   
> +struct tpm_tis_lpc_priv {
> +	struct tpm_locality *regs;
> +};
> +
>   /*
>    * This pointer refers to the TPM chip, 5 of its localities are mapped as an
>    * array.
>    */
>   #define TPM_TOTAL_LOCALITIES	5
> -static struct tpm_locality *lpc_tpm_dev =
> -	(struct tpm_locality *)CONFIG_TPM_TIS_BASE_ADDRESS;
>   
>   /* Some registers' bit field definitions */
>   #define TIS_STS_VALID                  (1 << 7) /* 0x80 */
> @@ -64,85 +68,45 @@ static struct tpm_locality *lpc_tpm_dev =
>   #define TIS_STS_BURST_COUNT_MASK       (0xffff)
>   #define TIS_STS_BURST_COUNT_SHIFT      (8)
>   
> -/*
> - * Error value returned if a tpm register does not enter the expected state
> - * after continuous polling. No actual TPM register reading ever returns -1,
> - * so this value is a safe error indication to be mixed with possible status
> - * register values.
> - */
> -#define TPM_TIMEOUT_ERR			(-1)
> -
> -/* Error value returned on various TPM driver errors. */
> -#define TPM_DRIVER_ERR		(1)
> -
>    /* 1 second is plenty for anything TPM does. */
>   #define MAX_DELAY_US	(1000 * 1000)
>   
>   /* Retrieve burst count value out of the status register contents. */
>   static u16 burst_count(u32 status)
>   {
> -	return (status >> TIS_STS_BURST_COUNT_SHIFT) & TIS_STS_BURST_COUNT_MASK;
> +	return (status >> TIS_STS_BURST_COUNT_SHIFT) &
> +			TIS_STS_BURST_COUNT_MASK;
>   }
>   
> -/*
> - * Structures defined below allow creating descriptions of TPM vendor/device
> - * ID information for run time discovery. The only device the system knows
> - * about at this time is Infineon slb9635.
> - */
> -struct device_name {
> -	u16 dev_id;
> -	const char * const dev_name;
> -};
> -
> -struct vendor_name {
> -	u16 vendor_id;
> -	const char *vendor_name;
> -	const struct device_name *dev_names;
> -};
> -
> -static const struct device_name infineon_devices[] = {
> -	{0xb, "SLB9635 TT 1.2"},
> -	{0}
> -};
> -
> -static const struct vendor_name vendor_names[] = {
> -	{0x15d1, "Infineon", infineon_devices},
> -};
> -
> -/*
> - * Cached vendor/device ID pair to indicate that the device has been already
> - * discovered.
> - */
> -static u32 vendor_dev_id;
> -
>   /* TPM access wrappers to support tracing */
> -static u8 tpm_read_byte(const u8 *ptr)
> +static u8 tpm_read_byte(struct tpm_tis_lpc_priv *priv, const u8 *ptr)
>   {
>   	u8  ret = readb(ptr);
>   	debug(PREFIX "Read reg 0x%4.4x returns 0x%2.2x\n",
> -	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, ret);
> +	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, ret);
>   	return ret;
>   }
>   
> -static u32 tpm_read_word(const u32 *ptr)
> +static u32 tpm_read_word(struct tpm_tis_lpc_priv *priv, const u32 *ptr)
>   {
>   	u32  ret = readl(ptr);
>   	debug(PREFIX "Read reg 0x%4.4x returns 0x%8.8x\n",
> -	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, ret);
> +	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, ret);
>   	return ret;
>   }
>   
> -static void tpm_write_byte(u8 value, u8 *ptr)
> +static void tpm_write_byte(struct tpm_tis_lpc_priv *priv, u8 value, u8 *ptr)
>   {
>   	debug(PREFIX "Write reg 0x%4.4x with 0x%2.2x\n",
> -	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, value);
> +	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, value);
>   	writeb(value, ptr);
>   }
>   
> -static void tpm_write_word(u32 value, u32 *ptr)
> +static void tpm_write_word(struct tpm_tis_lpc_priv *priv, u32 value,
> +			   u32 *ptr)
>   {
>   	debug(PREFIX "Write reg 0x%4.4x with 0x%8.8x\n",
> -	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)lpc_tpm_dev, value);
> +	      (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, value);
>   	writel(value, ptr);
>   }
>   
> @@ -157,67 +121,51 @@ static void tpm_write_word(u32 value, u32 *ptr)
>    * @expected - value the field(s) are supposed to be set to
>    *
>    * Returns the register contents in case the expected value was found in the
> - * appropriate register bits, or TPM_TIMEOUT_ERR on timeout.
> + * appropriate register bits, or -ETIMEDOUT on timeout.
>    */
> -static u32 tis_wait_reg(u32 *reg, u8 mask, u8 expected)
> +static int tis_wait_reg(struct tpm_tis_lpc_priv *priv, u32 *reg, u8 mask,
> +			u8 expected)
>   {
>   	u32 time_us = MAX_DELAY_US;
>   
>   	while (time_us > 0) {
> -		u32 value = tpm_read_word(reg);
> +		u32 value = tpm_read_word(priv, reg);
>   		if ((value & mask) == expected)
>   			return value;
>   		udelay(1); /* 1 us */
>   		time_us--;
>   	}
> -	return TPM_TIMEOUT_ERR;
> +
> +	return -ETIMEDOUT;
>   }
>   
>   /*
>    * Probe the TPM device and try determining its manufacturer/device name.
>    *
> - * Returns 0 on success (the device is found or was found during an earlier
> - * invocation) or TPM_DRIVER_ERR if the device is not found.
> + * Returns 0 on success, -ve on error
>    */
> -int tis_init(void)
> +static int tpm_tis_lpc_probe(struct udevice *dev)
>   {
> -	u32 didvid = tpm_read_word(&lpc_tpm_dev[0].did_vid);
> -	int i;
> -	const char *device_name = "unknown";
> -	const char *vendor_name = device_name;
> -	u16 vid, did;
> -
> -	if (vendor_dev_id)
> -		return 0;  /* Already probed. */
> -
> -	if (!didvid || (didvid == 0xffffffff)) {
> -		printf("%s: No TPM device found\n", __func__);
> -		return TPM_DRIVER_ERR;
> -	}
> +	struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
> +	u32 vid, did;
> +	fdt_addr_t addr;
> +	u32 didvid;
>   
> -	vendor_dev_id = didvid;
> +	addr = dev_get_addr(dev);
> +	if (addr == FDT_ADDR_T_NONE)
> +		return -EINVAL;
> +	priv->regs = map_sysmem(addr, 0);
> +	didvid = tpm_read_word(priv, &priv->regs[0].did_vid);
>   
>   	vid = didvid & 0xffff;
>   	did = (didvid >> 16) & 0xffff;
> -	for (i = 0; i < ARRAY_SIZE(vendor_names); i++) {
> -		int j = 0;
> -		u16 known_did;
> -
> -		if (vid == vendor_names[i].vendor_id)
> -			vendor_name = vendor_names[i].vendor_name;
> -
> -		while ((known_did = vendor_names[i].dev_names[j].dev_id) != 0) {
> -			if (known_did == did) {
> -				device_name =
> -					vendor_names[i].dev_names[j].dev_name;
> -				break;
> -			}
> -			j++;
> -		}
> -		break;
> +	if (vid != 0x15d1 || did != 0xb) {
> +		debug("Invalid vendor/device ID %04x/%04x\n", vid, did);
> +		return -ENOSYS;
>   	}
>   
> -	printf("Found TPM %s by %s\n", device_name, vendor_name);
> +	debug("Found TPM %s by %s\n", "SLB9635 TT 1.2", "Infineon");
> +
>   	return 0;
>   }
>   
> @@ -229,23 +177,25 @@ int tis_init(void)
>    * @data - address of the data to send, byte by byte
>    * @len - length of the data to send
>    *
> - * Returns 0 on success, TPM_DRIVER_ERR on error (in case the device does
> - * not accept the entire command).
> + * Returns 0 on success, -ve on error (in case the device does not accept
> + * the entire command).
>    */
> -static u32 tis_senddata(const u8 * const data, u32 len)
> +static int tis_senddata(struct udevice *dev, const u8 *data, size_t len)
>   {
> +	struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
> +	struct tpm_locality *regs = priv->regs;
>   	u32 offset = 0;
>   	u16 burst = 0;
>   	u32 max_cycles = 0;
>   	u8 locality = 0;
>   	u32 value;
>   
> -	value = tis_wait_reg(&lpc_tpm_dev[locality].tpm_status,
> +	value = tis_wait_reg(priv, &regs[locality].tpm_status,
>   			     TIS_STS_COMMAND_READY, TIS_STS_COMMAND_READY);
> -	if (value == TPM_TIMEOUT_ERR) {
> +	if (value == -ETIMEDOUT) {
>   		printf("%s:%d - failed to get 'command_ready' status\n",
>   		       __FILE__, __LINE__);
> -		return TPM_DRIVER_ERR;
> +		return value;
>   	}
>   	burst = burst_count(value);
>   
> @@ -257,11 +207,11 @@ static u32 tis_senddata(const u8 * const data, u32 len)
>   			if (max_cycles++ == MAX_DELAY_US) {
>   				printf("%s:%d failed to feed %d bytes of %d\n",
>   				       __FILE__, __LINE__, len - offset, len);
> -				return TPM_DRIVER_ERR;
> +				return -ETIMEDOUT;
>   			}
>   			udelay(1);
> -			burst = burst_count(tpm_read_word(&lpc_tpm_dev
> -						     [locality].tpm_status));
> +			burst = burst_count(tpm_read_word(priv,
> +					&regs[locality].tpm_status));
>   		}
>   
>   		max_cycles = 0;
> @@ -277,16 +227,16 @@ static u32 tis_senddata(const u8 * const data, u32 len)
>   		 */
>   		count = min((u32)burst, len - offset - 1);
>   		while (count--)
> -			tpm_write_byte(data[offset++],
> -				  &lpc_tpm_dev[locality].data);
> +			tpm_write_byte(priv, data[offset++],
> +				       &regs[locality].data);
>   
> -		value = tis_wait_reg(&lpc_tpm_dev[locality].tpm_status,
> +		value = tis_wait_reg(priv, &regs[locality].tpm_status,
>   				     TIS_STS_VALID, TIS_STS_VALID);
>   
> -		if ((value == TPM_TIMEOUT_ERR) || !(value & TIS_STS_EXPECT)) {
> +		if ((value == -ETIMEDOUT) || !(value & TIS_STS_EXPECT)) {
>   			printf("%s:%d TPM command feed overflow\n",
>   			       __FILE__, __LINE__);
> -			return TPM_DRIVER_ERR;
> +			return value == -ETIMEDOUT ? value : -EIO;
>   		}
>   
>   		burst = burst_count(value);
> @@ -301,21 +251,21 @@ static u32 tis_senddata(const u8 * const data, u32 len)
>   	}
>   
>   	/* Send the last byte. */
> -	tpm_write_byte(data[offset++], &lpc_tpm_dev[locality].data);
> +	tpm_write_byte(priv, data[offset++], &regs[locality].data);
>   	/*
>   	 * Verify that TPM does not expect any more data as part of this
>   	 * command.
>   	 */
> -	value = tis_wait_reg(&lpc_tpm_dev[locality].tpm_status,
> +	value = tis_wait_reg(priv, &regs[locality].tpm_status,
>   			     TIS_STS_VALID, TIS_STS_VALID);
> -	if ((value == TPM_TIMEOUT_ERR) || (value & TIS_STS_EXPECT)) {
> +	if ((value == -ETIMEDOUT) || (value & TIS_STS_EXPECT)) {
>   		printf("%s:%d unexpected TPM status 0x%x\n",
>   		       __FILE__, __LINE__, value);
> -		return TPM_DRIVER_ERR;
> +		return value == -ETIMEDOUT ? value : -EIO;
>   	}
>   
>   	/* OK, sitting pretty, let's start the command execution. */
> -	tpm_write_word(TIS_STS_TPM_GO, &lpc_tpm_dev[locality].tpm_status);
> +	tpm_write_word(priv, TIS_STS_TPM_GO, &regs[locality].tpm_status);
>   	return 0;
>   }
>   
> @@ -329,25 +279,27 @@ static u32 tis_senddata(const u8 * const data, u32 len)
>    *
>    * On success stores the number of received bytes to len and returns 0. On
>    * errors (misformatted TPM data or synchronization problems) returns
> - * TPM_DRIVER_ERR.
> + * -ve value.
>    */
> -static u32 tis_readresponse(u8 *buffer, u32 *len)
> +static int tis_readresponse(struct udevice *dev, u8 *buffer, size_t len)
>   {
> +	struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
> +	struct tpm_locality *regs = priv->regs;
>   	u16 burst;
>   	u32 value;
>   	u32 offset = 0;
>   	u8 locality = 0;
>   	const u32 has_data = TIS_STS_DATA_AVAILABLE | TIS_STS_VALID;
> -	u32 expected_count = *len;
> +	u32 expected_count = len;
>   	int max_cycles = 0;
>   
>   	/* Wait for the TPM to process the command. */
> -	value = tis_wait_reg(&lpc_tpm_dev[locality].tpm_status,
> +	value = tis_wait_reg(priv, &regs[locality].tpm_status,
>   			      has_data, has_data);
> -	if (value == TPM_TIMEOUT_ERR) {
> +	if (value == -ETIMEDOUT) {
>   		printf("%s:%d failed processing command\n",
>   		       __FILE__, __LINE__);
> -		return TPM_DRIVER_ERR;
> +		return value;
>   	}
>   
>   	do {
> @@ -355,18 +307,17 @@ static u32 tis_readresponse(u8 *buffer, u32 *len)
>   			if (max_cycles++ == MAX_DELAY_US) {
>   				printf("%s:%d TPM stuck on read\n",
>   				       __FILE__, __LINE__);
> -				return TPM_DRIVER_ERR;
> +				return -EIO;
>   			}
>   			udelay(1);
> -			value = tpm_read_word(&lpc_tpm_dev
> -					      [locality].tpm_status);
> +			value = tpm_read_word(priv, &regs[locality].tpm_status);
>   		}
>   
>   		max_cycles = 0;
>   
>   		while (burst-- && (offset < expected_count)) {
> -			buffer[offset++] = tpm_read_byte(&lpc_tpm_dev
> -							 [locality].data);
> +			buffer[offset++] = tpm_read_byte(priv,
> +						&regs[locality].data);
>   
>   			if (offset == 6) {
>   				/*
> @@ -383,22 +334,22 @@ static u32 tis_readresponse(u8 *buffer, u32 *len)
>   				expected_count = be32_to_cpu(real_length);
>   
>   				if ((expected_count < offset) ||
> -				    (expected_count > *len)) {
> +				    (expected_count > len)) {
>   					printf("%s:%d bad response size %d\n",
>   					       __FILE__, __LINE__,
>   					       expected_count);
> -					return TPM_DRIVER_ERR;
> +					return -ENOSPC;
>   				}
>   			}
>   		}
>   
>   		/* Wait for the next portion. */
> -		value = tis_wait_reg(&lpc_tpm_dev[locality].tpm_status,
> +		value = tis_wait_reg(priv, &regs[locality].tpm_status,
>   				     TIS_STS_VALID, TIS_STS_VALID);
> -		if (value == TPM_TIMEOUT_ERR) {
> +		if (value == -ETIMEDOUT) {
>   			printf("%s:%d failed to read response\n",
>   			       __FILE__, __LINE__);
> -			return TPM_DRIVER_ERR;
> +			return value;
>   		}
>   
>   		if (offset == expected_count)
> @@ -413,65 +364,90 @@ static u32 tis_readresponse(u8 *buffer, u32 *len)
>   	if (value & TIS_STS_DATA_AVAILABLE) {
>   		printf("%s:%d wrong receive status %x\n",
>   		       __FILE__, __LINE__, value);
> -		return TPM_DRIVER_ERR;
> +		return -EBADMSG;
>   	}
>   
>   	/* Tell the TPM that we are done. */
> -	tpm_write_word(TIS_STS_COMMAND_READY, &lpc_tpm_dev
> -		  [locality].tpm_status);
> -	*len = offset;
> -	return 0;
> +	tpm_write_word(priv, TIS_STS_COMMAND_READY,
> +		       &regs[locality].tpm_status);
> +
> +	return offset;
>   }
>   
> -int tis_open(void)
> +static int tpm_tis_lpc_open(struct udevice *dev)
>   {
> +	struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
> +	struct tpm_locality *regs = priv->regs;
>   	u8 locality = 0; /* we use locality zero for everything. */
> +	int ret;
>   
>   	/* now request access to locality. */
> -	tpm_write_word(TIS_ACCESS_REQUEST_USE, &lpc_tpm_dev[locality].access);
> +	tpm_write_word(priv, TIS_ACCESS_REQUEST_USE, &regs[locality].access);
>   
>   	/* did we get a lock? */
> -	if (tis_wait_reg(&lpc_tpm_dev[locality].access,
> +	ret = tis_wait_reg(priv, &regs[locality].access,
>   			 TIS_ACCESS_ACTIVE_LOCALITY,
> -			 TIS_ACCESS_ACTIVE_LOCALITY) == TPM_TIMEOUT_ERR) {
> +			 TIS_ACCESS_ACTIVE_LOCALITY);
> +	if (ret == -ETIMEDOUT) {
>   		printf("%s:%d - failed to lock locality %d\n",
>   		       __FILE__, __LINE__, locality);
> -		return TPM_DRIVER_ERR;
> +		return ret;
>   	}
>   
> -	tpm_write_word(TIS_STS_COMMAND_READY,
> -		       &lpc_tpm_dev[locality].tpm_status);
> +	tpm_write_word(priv, TIS_STS_COMMAND_READY,
> +		       &regs[locality].tpm_status);
>   	return 0;
>   }
>   
> -int tis_close(void)
> +static int tpm_tis_lpc_close(struct udevice *dev)
>   {
> +	struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
> +	struct tpm_locality *regs = priv->regs;
>   	u8 locality = 0;
>   
> -	if (tpm_read_word(&lpc_tpm_dev[locality].access) &
> +	if (tpm_read_word(priv, &regs[locality].access) &
>   	    TIS_ACCESS_ACTIVE_LOCALITY) {
> -		tpm_write_word(TIS_ACCESS_ACTIVE_LOCALITY,
> -			       &lpc_tpm_dev[locality].access);
> +		tpm_write_word(priv, TIS_ACCESS_ACTIVE_LOCALITY,
> +			       &regs[locality].access);
>   
> -		if (tis_wait_reg(&lpc_tpm_dev[locality].access,
> -				 TIS_ACCESS_ACTIVE_LOCALITY, 0) ==
> -		    TPM_TIMEOUT_ERR) {
> +		if (tis_wait_reg(priv, &regs[locality].access,
> +				 TIS_ACCESS_ACTIVE_LOCALITY, 0) == -ETIMEDOUT) {
>   			printf("%s:%d - failed to release locality %d\n",
>   			       __FILE__, __LINE__, locality);
> -			return TPM_DRIVER_ERR;
> +			return -ETIMEDOUT;
>   		}
>   	}
>   	return 0;
>   }
>   
> -int tis_sendrecv(const u8 *sendbuf, size_t send_size,
> -		 u8 *recvbuf, size_t *recv_len)
> +static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size)
>   {
> -	if (tis_senddata(sendbuf, send_size)) {
> -		printf("%s:%d failed sending data to TPM\n",
> -		       __FILE__, __LINE__);
> -		return TPM_DRIVER_ERR;
> -	}
> +	if (size < 50)
> +		return -ENOSPC;
>   
> -	return tis_readresponse(recvbuf, (u32 *)recv_len);
> +	return snprintf(buf, size, "1.2 TPM (vendor %s, chip %s)",
> +			"Infineon", "SLB9635 TT 1.2");
>   }
> +
> +
> +static const struct tpm_ops tpm_tis_lpc_ops = {
> +	.open		= tpm_tis_lpc_open,
> +	.close		= tpm_tis_lpc_close,
> +	.get_desc	= tpm_tis_get_desc,
> +	.send		= tis_senddata,
> +	.recv		= tis_readresponse,
> +};
> +
> +static const struct udevice_id tpm_tis_lpc_ids[] = {
> +	{ .compatible = "infineon,slb9635lpc" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(tpm_tis_lpc) = {
> +	.name   = "tpm_tis_lpc",
> +	.id     = UCLASS_TPM,
> +	.of_match = tpm_tis_lpc_ids,
> +	.ops    = &tpm_tis_lpc_ops,
> +	.probe	= tpm_tis_lpc_probe,
> +	.priv_auto_alloc_size = sizeof(struct tpm_tis_lpc_priv),
> +};

  reply	other threads:[~2015-08-24 20:23 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-23  0:31 [U-Boot] [PATCH v2 00/28] dm: Convert TPM drivers to driver model Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 01/28] tpm: Remove old pre-driver-model I2C code Simon Glass
2015-08-24  4:50   ` Heiko Schocher
2015-08-24  4:52     ` Simon Glass
2015-08-24  5:15       ` Heiko Schocher
2015-08-30 22:42         ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 02/28] tpm: Drop two unused options Simon Glass
2015-08-30 22:42   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 03/28] tpm: Add Kconfig options for TPMs Simon Glass
2015-08-24 20:24   ` Christophe Ricard
2015-08-30 22:42     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 04/28] tpm: Convert board config TPM options to Kconfig Simon Glass
2015-08-24 20:20   ` Christophe Ricard
2015-08-30 22:43     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 05/28] tpm: Convert drivers to use SPDX Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 06/28] tpm: Move the I2C TPM code into one file Simon Glass
2015-08-24 20:24   ` Christophe Ricard
2015-08-25  4:13     ` Simon Glass
2015-08-25 18:38       ` Christophe Ricard
2015-08-30 22:43         ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 07/28] tpm: tpm_tis_i2c: Drop unnecessary methods Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 08/28] tpm: tpm_tis_i2c: Drop struct tpm_vendor_specific Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 09/28] tpm: tpm_tis_i2c: Merge struct tpm_dev into tpm_chip Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 10/28] tpm: tpm_tis_i2c: Merge struct tpm " Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 11/28] tpm: tpm_tis_i2c: Move definitions into the header file Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 12/28] tpm: tpm_tis_i2c: Simplify init code Simon Glass
2015-08-24 20:20   ` Christophe Ricard
2015-08-30 22:43     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 13/28] tpm: tpm_tis_i2c: Use a consistent tpm_tis_i2c_ prefix Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 14/28] tpm: tpm_tis_i2c: Tidy up delays Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 15/28] dm: tpm: Add a uclass for Trusted Platform Modules Simon Glass
2015-08-24 20:21   ` Christophe Ricard
2015-08-30 22:43     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 16/28] dm: tpm: Convert the TPM command and library to driver model Simon Glass
2015-08-24 20:21   ` Christophe Ricard
2015-08-30 22:43     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 17/28] dm: i2c: Add a command to adjust the offset length Simon Glass
2015-08-24 20:21   ` Christophe Ricard
2015-08-30 22:43     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 18/28] tpm: Report tpm errors on the command line Simon Glass
2015-08-24 20:21   ` Christophe Ricard
2015-08-30 22:43     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 19/28] dm: tpm: sandbox: Convert TPM driver to driver model Simon Glass
2015-08-30 22:43   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 20/28] tpm: Check that parse_byte_string() has data to parse Simon Glass
2015-08-24 20:22   ` Christophe Ricard
2015-08-25  4:13     ` Simon Glass
2015-08-25 18:40       ` Christophe Ricard
2015-08-30 22:43         ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 21/28] exynos: x86: dts: Add tpm nodes to the device tree for Chrome OS devices Simon Glass
2015-08-24 20:22   ` Christophe Ricard
2015-08-30 22:43     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 22/28] dm: tpm: Convert I2C driver to driver model Simon Glass
2015-08-24 20:22   ` Christophe Ricard
2015-08-30 22:44     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 23/28] dm: tpm: Convert LPC " Simon Glass
2015-08-24 20:23   ` Christophe Ricard [this message]
2015-08-30 22:44     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 24/28] tpm: Add a 'tpm info' command Simon Glass
2015-08-30 22:44   ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 25/28] tpm: Add functions to access flags and permissions Simon Glass
2015-08-24 20:23   ` Christophe Ricard
2015-08-30 22:44     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 26/28] dm: tpm: Add a 'tpmtest' command Simon Glass
2015-08-24 20:23   ` Christophe Ricard
2015-08-30 22:44     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 27/28] tpm: Enable 'tpmtest' command for Chrome OS boards with TPMs Simon Glass
2015-08-24 20:23   ` Christophe Ricard
2015-08-30 22:44     ` Simon Glass
2015-08-23  0:31 ` [U-Boot] [PATCH v2 28/28] tegra: nyan: Enable TPM command and driver Simon Glass
2015-08-30 22:44   ` Simon Glass
2015-08-24 20:20 ` [U-Boot] [PATCH v2 00/28] dm: Convert TPM drivers to driver model Christophe Ricard
2015-08-25  4:13   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55DB7D28.9030508@gmail.com \
    --to=christophe.ricard@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox