From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 01/28] tpm: Remove old pre-driver-model I2C code
Date: Mon, 24 Aug 2015 06:50:39 +0200 [thread overview]
Message-ID: <55DAA29F.6020305@denx.de> (raw)
In-Reply-To: <1440289904-31280-2-git-send-email-sjg@chromium.org>
Hello Simon,
Am 23.08.2015 um 02:31 schrieb Simon Glass:
> This is not used anymore by any board so drop it.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Christophe Ricard <christophe-h.ricard@st.com>
> ---
>
> Changes in v2: None
>
> drivers/tpm/tpm.c | 108 ++--------------------------------------------
> drivers/tpm/tpm_private.h | 4 +-
> drivers/tpm/tpm_tis_i2c.c | 74 +------------------------------
> 3 files changed, 7 insertions(+), 179 deletions(-)
Thanks for your work! Nitpick ...
$ grep -lr CONFIG_TPM_TIS_I2C include/configs/
include/configs/exynos5-common.h
So I miss the removal of this define there and maybe
remove it in drivers/tpm/Makefile ...
Beside of this ...
Reviewed-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
> diff --git a/drivers/tpm/tpm.c b/drivers/tpm/tpm.c
> index a650892..24997f6 100644
> --- a/drivers/tpm/tpm.c
> +++ b/drivers/tpm/tpm.c
> @@ -49,13 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;
>
> /* TPM configuration */
> struct tpm {
> -#ifdef CONFIG_DM_I2C
> struct udevice *dev;
> -#else
> - int i2c_bus;
> - int slave_addr;
> - int old_bus;
> -#endif
> char inited;
> } tpm;
>
> @@ -441,7 +435,6 @@ out:
> return rc;
> }
>
> -#ifdef CONFIG_DM_I2C
> static int tpm_open_dev(struct udevice *dev)
> {
> int rc;
> @@ -449,24 +442,12 @@ static int tpm_open_dev(struct udevice *dev)
> debug("%s: start\n", __func__);
> if (g_chip.is_open)
> return -EBUSY;
> - rc = tpm_vendor_init_dev(dev);
> + rc = tpm_vendor_init(dev);
> if (rc < 0)
> g_chip.is_open = 0;
> return rc;
> }
> -#else
> -static int tpm_open(uint32_t dev_addr)
> -{
> - int rc;
>
> - if (g_chip.is_open)
> - return -EBUSY;
> - rc = tpm_vendor_init(dev_addr);
> - if (rc < 0)
> - g_chip.is_open = 0;
> - return rc;
> -}
> -#endif
> static void tpm_close(void)
> {
> if (g_chip.is_open) {
> @@ -475,42 +456,6 @@ static void tpm_close(void)
> }
> }
>
> -static int tpm_select(void)
> -{
> -#ifndef CONFIG_DM_I2C
> - int ret;
> -
> - tpm.old_bus = i2c_get_bus_num();
> - if (tpm.old_bus != tpm.i2c_bus) {
> - ret = i2c_set_bus_num(tpm.i2c_bus);
> - if (ret) {
> - debug("%s: Fail to set i2c bus %d\n", __func__,
> - tpm.i2c_bus);
> - return -1;
> - }
> - }
> -#endif
> - return 0;
> -}
> -
> -static int tpm_deselect(void)
> -{
> -#ifndef CONFIG_DM_I2C
> - int ret;
> -
> - if (tpm.old_bus != i2c_get_bus_num()) {
> - ret = i2c_set_bus_num(tpm.old_bus);
> - if (ret) {
> - debug("%s: Fail to restore i2c bus %d\n",
> - __func__, tpm.old_bus);
> - return -1;
> - }
> - }
> - tpm.old_bus = -1;
> -#endif
> - return 0;
> -}
> -
> /**
> * Decode TPM configuration.
> *
> @@ -520,8 +465,11 @@ static int tpm_deselect(void)
> static int tpm_decode_config(struct tpm *dev)
> {
> const void *blob = gd->fdt_blob;
> + struct udevice *bus;
> + int chip_addr;
> int parent;
> int node;
> + int ret;
>
> node = fdtdec_next_compatible(blob, 0, COMPAT_INFINEON_SLB9635_TPM);
> if (node < 0) {
> @@ -537,10 +485,6 @@ static int tpm_decode_config(struct tpm *dev)
> debug("%s: Cannot find node parent\n", __func__);
> return -1;
> }
> -#ifdef CONFIG_DM_I2C
> - struct udevice *bus;
> - int chip_addr;
> - int ret;
>
> /*
> * TODO(sjg at chromium.org): Remove this when driver model supports
> @@ -569,15 +513,6 @@ static int tpm_decode_config(struct tpm *dev)
> fdt_get_name(blob, node, NULL), ret);
> return ret;
> }
> -#else
> - int i2c_bus;
> -
> - i2c_bus = i2c_get_bus_num_fdt(parent);
> - if (i2c_bus < 0)
> - return -1;
> - dev->i2c_bus = i2c_bus;
> - dev->slave_addr = fdtdec_get_addr(blob, node, "reg");
> -#endif
>
> return 0;
> }
> @@ -602,22 +537,6 @@ int tis_init(void)
> if (tpm_decode_config(&tpm))
> return -1;
>
> - if (tpm_select())
> - return -1;
> -
> -#ifndef CONFIG_DM_I2C
> - /*
> - * Probe TPM twice; the first probing might fail because TPM is asleep,
> - * and the probing can wake up TPM.
> - */
> - if (i2c_probe(tpm.slave_addr) && i2c_probe(tpm.slave_addr)) {
> - debug("%s: fail to probe i2c addr 0x%x\n", __func__,
> - tpm.slave_addr);
> - return -1;
> - }
> -#endif
> -
> - tpm_deselect();
> debug("%s: done\n", __func__);
>
> tpm.inited = 1;
> @@ -632,16 +551,7 @@ int tis_open(void)
> if (!tpm.inited)
> return -1;
>
> - if (tpm_select())
> - return -1;
> -
> -#ifdef CONFIG_DM_I2C
> rc = tpm_open_dev(tpm.dev);
> -#else
> - rc = tpm_open(tpm.slave_addr);
> -#endif
> -
> - tpm_deselect();
>
> return rc;
> }
> @@ -651,13 +561,8 @@ int tis_close(void)
> if (!tpm.inited)
> return -1;
>
> - if (tpm_select())
> - return -1;
> -
> tpm_close();
>
> - tpm_deselect();
> -
> return 0;
> }
>
> @@ -675,13 +580,8 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
>
> memcpy(buf, sendbuf, sbuf_size);
>
> - if (tpm_select())
> - return -1;
> -
> len = tpm_transmit(buf, sbuf_size);
>
> - tpm_deselect();
> -
> if (len < 10) {
> *rbuf_len = 0;
> return -1;
> diff --git a/drivers/tpm/tpm_private.h b/drivers/tpm/tpm_private.h
> index 8894c98..daaf8b8 100644
> --- a/drivers/tpm/tpm_private.h
> +++ b/drivers/tpm/tpm_private.h
> @@ -129,10 +129,8 @@ struct tpm_cmd_t {
>
> struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *);
>
> -int tpm_vendor_init(uint32_t dev_addr);
> -
> struct udevice;
> -int tpm_vendor_init_dev(struct udevice *dev);
> +int tpm_vendor_init(struct udevice *dev);
>
> void tpm_vendor_cleanup(struct tpm_chip *chip);
>
> diff --git a/drivers/tpm/tpm_tis_i2c.c b/drivers/tpm/tpm_tis_i2c.c
> index cc740e9..b6eaef1 100644
> --- a/drivers/tpm/tpm_tis_i2c.c
> +++ b/drivers/tpm/tpm_tis_i2c.c
> @@ -50,9 +50,6 @@
>
> DECLARE_GLOBAL_DATA_PTR;
>
> -/* Address of the TPM on the I2C bus */
> -#define TPM_I2C_ADDR 0x20
> -
> /* Max buffer size supported by our tpm */
> #define TPM_DEV_BUFSIZE 1260
>
> @@ -73,13 +70,6 @@ DECLARE_GLOBAL_DATA_PTR;
>
> #define TPM_HEADER_SIZE 10
>
> -/*
> - * Expected value for DIDVID register
> - *
> - * The only device the system knows about at this moment is Infineon slb9635.
> - */
> -#define TPM_TIS_I2C_DID_VID 0x000b15d1L
> -
> enum tis_access {
> TPM_ACCESS_VALID = 0x80,
> TPM_ACCESS_ACTIVE_LOCALITY = 0x20,
> @@ -123,21 +113,11 @@ static const char * const chip_name[] = {
>
> /* Structure to store I2C TPM specific stuff */
> struct tpm_dev {
> -#ifdef CONFIG_DM_I2C
> struct udevice *dev;
> -#else
> - uint addr;
> -#endif
> u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)]; /* Max buffer size + addr */
> enum i2c_chip_type chip_type;
> };
>
> -static struct tpm_dev tpm_dev = {
> -#ifndef CONFIG_DM_I2C
> - .addr = TPM_I2C_ADDR
> -#endif
> -};
> -
> static struct tpm_dev tpm_dev;
>
> /*
> @@ -163,12 +143,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
> if ((tpm_dev.chip_type == SLB9635) || (tpm_dev.chip_type == UNKNOWN)) {
> /* slb9635 protocol should work in both cases */
> for (count = 0; count < MAX_COUNT; count++) {
> -#ifdef CONFIG_DM_I2C
> rc = dm_i2c_write(tpm_dev.dev, 0, (uchar *)&addrbuf, 1);
> -#else
> - rc = i2c_write(tpm_dev.addr, 0, 0,
> - (uchar *)&addrbuf, 1);
> -#endif
> if (rc == 0)
> break; /* Success, break to skip sleep */
> udelay(SLEEP_DURATION);
> @@ -182,11 +157,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
> */
> for (count = 0; count < MAX_COUNT; count++) {
> udelay(SLEEP_DURATION);
> -#ifdef CONFIG_DM_I2C
> rc = dm_i2c_read(tpm_dev.dev, 0, buffer, len);
> -#else
> - rc = i2c_read(tpm_dev.addr, 0, 0, buffer, len);
> -#endif
> if (rc == 0)
> break; /* success, break to skip sleep */
> }
> @@ -199,11 +170,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
> * be safe on the safe side.
> */
> for (count = 0; count < MAX_COUNT; count++) {
> -#ifdef CONFIG_DM_I2C
> rc = dm_i2c_read(tpm_dev.dev, addr, buffer, len);
> -#else
> - rc = i2c_read(tpm_dev.addr, addr, 1, buffer, len);
> -#endif
> if (rc == 0)
> break; /* break here to skip sleep */
> udelay(SLEEP_DURATION);
> @@ -224,20 +191,8 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
> int rc = 0;
> int count;
>
> - /* Prepare send buffer */
> -#ifndef CONFIG_DM_I2C
> - tpm_dev.buf[0] = addr;
> - memcpy(&(tpm_dev.buf[1]), buffer, len);
> - buffer = tpm_dev.buf;
> - len++;
> -#endif
> -
> for (count = 0; count < max_count; count++) {
> -#ifdef CONFIG_DM_I2C
> rc = dm_i2c_write(tpm_dev.dev, addr, buffer, len);
> -#else
> - rc = i2c_write(tpm_dev.addr, 0, 0, buffer, len);
> -#endif
> if (rc == 0)
> break; /* Success, break to skip sleep */
> udelay(sleep_time);
> @@ -597,12 +552,13 @@ static enum i2c_chip_type tpm_vendor_chip_type(void)
> return UNKNOWN;
> }
>
> -static int tpm_vendor_init_common(void)
> +int tpm_vendor_init(struct udevice *dev)
> {
> struct tpm_chip *chip;
> u32 vendor;
> u32 expected_did_vid;
>
> + tpm_dev.dev = dev;
> tpm_dev.chip_type = tpm_vendor_chip_type();
>
> chip = tpm_register_hardware(&tpm_tis_i2c);
> @@ -651,32 +607,6 @@ static int tpm_vendor_init_common(void)
> return 0;
> }
>
> -#ifdef CONFIG_DM_I2C
> -/* Initialisation of i2c tpm */
> -int tpm_vendor_init_dev(struct udevice *dev)
> -{
> - tpm_dev.dev = dev;
> - return tpm_vendor_init_common();
> -}
> -#else
> -/* Initialisation of i2c tpm */
> -int tpm_vendor_init(uint32_t dev_addr)
> -{
> - uint old_addr;
> - int rc = 0;
> -
> - old_addr = tpm_dev.addr;
> - if (dev_addr != 0)
> - tpm_dev.addr = dev_addr;
> -
> - rc = tpm_vendor_init_common();
> - if (rc)
> - tpm_dev.addr = old_addr;
> -
> - return rc;
> -}
> -#endif
> -
> void tpm_vendor_cleanup(struct tpm_chip *chip)
> {
> release_locality(chip, chip->vendor.locality, 1);
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2015-08-24 4:50 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 [this message]
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
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=55DAA29F.6020305@denx.de \
--to=hs@denx.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.