diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile
index 494aa5a..5172523 100644
--- a/drivers/tpm/Makefile
+++ b/drivers/tpm/Makefile
@@ -12,6 +12,6 @@
 
 obj-$(CONFIG_$(SPL_TPL_)TPM2_CR50_I2C) += cr50_i2c.o
 obj-$(CONFIG_TPM2_TIS_SANDBOX) += tpm2_tis_sandbox.o sandbox_common.o
-obj-$(CONFIG_TPM2_TIS_SPI) += tpm2_tis_spi.o
+obj-$(CONFIG_TPM2_TIS_SPI) += tpm2_tis_core.o tpm2_tis_spi.o
 obj-$(CONFIG_TPM2_FTPM_TEE) += tpm2_ftpm_tee.o
 obj-$(CONFIG_TPM2_MMIO) += tpm2_tis_core.o tpm2_tis_mmio.o
diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c
index 1d24d32..58b6f33 100644
--- a/drivers/tpm/tpm2_tis_spi.c
+++ b/drivers/tpm/tpm2_tis_spi.c
@@ -30,13 +30,6 @@
 #include "tpm_tis.h"
 #include "tpm_internal.h"
 
-#define TPM_ACCESS(l)			(0x0000 | ((l) << 12))
-#define TPM_INT_ENABLE(l)               (0x0008 | ((l) << 12))
-#define TPM_STS(l)			(0x0018 | ((l) << 12))
-#define TPM_DATA_FIFO(l)		(0x0024 | ((l) << 12))
-#define TPM_DID_VID(l)			(0x0F00 | ((l) << 12))
-#define TPM_RID(l)			(0x0F04 | ((l) << 12))
-
 #define MAX_SPI_FRAMESIZE 64
 
 /* Number of wait states to wait for */
@@ -165,7 +158,7 @@
 	return ret;
 }
 
-static int tpm_tis_spi_read(struct udevice *dev, u16 addr, u8 *in, u16 len)
+static int tpm_tis_spi_read(struct udevice *dev, u32 addr, u16 len, u8 *in)
 {
 	return tpm_tis_spi_xfer(dev, addr, NULL, in, len);
 }
@@ -175,382 +168,24 @@
 	__le32 result_le;
 	int ret;
 
-	ret = tpm_tis_spi_read(dev, addr, (u8 *)&result_le, sizeof(u32));
+	ret = tpm_tis_spi_read(dev, addr, sizeof(u32), (u8 *)&result_le);
 	if (!ret)
 		*result = le32_to_cpu(result_le);
 
 	return ret;
 }
 
-static int tpm_tis_spi_write(struct udevice *dev, u16 addr, const u8 *out,
-			     u16 len)
-{
-	return tpm_tis_spi_xfer(dev, addr, out, NULL, len);
-}
-
-static int tpm_tis_spi_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 ret;
-
-	ret = tpm_tis_spi_read(dev, TPM_ACCESS(loc), &buf, 1);
-	if (ret)
-		return ret;
-
-	if ((buf & mask) == mask) {
-		chip->locality = loc;
-		return 0;
-	}
-
-	return -ENOENT;
-}
-
-static void tpm_tis_spi_release_locality(struct udevice *dev, int loc,
-					 bool force)
-{
-	const u8 mask = TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID;
-	u8 buf;
-
-	if (tpm_tis_spi_read(dev, TPM_ACCESS(loc), &buf, 1) < 0)
-		return;
-
-	if (force || (buf & mask) == mask) {
-		buf = TPM_ACCESS_ACTIVE_LOCALITY;
-		tpm_tis_spi_write(dev, TPM_ACCESS(loc), &buf, 1);
-	}
-}
-
-static int tpm_tis_spi_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 ret;
-
-	ret = tpm_tis_spi_check_locality(dev, loc);
-	if (!ret)
-		return 0;
-
-	if (ret != -ENOENT) {
-		log(LOGC_NONE, LOGL_ERR, "%s: Failed to get locality: %d\n",
-		    __func__, ret);
-		return ret;
-	}
-
-	ret = tpm_tis_spi_write(dev, TPM_ACCESS(loc), &buf, 1);
-	if (ret) {
-		log(LOGC_NONE, LOGL_ERR, "%s: Failed to write to TPM: %d\n",
-		    __func__, ret);
-		return ret;
-	}
-
-	start = get_timer(0);
-	stop = chip->timeout_a;
-	do {
-		ret = tpm_tis_spi_check_locality(dev, loc);
-		if (!ret)
-			return 0;
-
-		if (ret != -ENOENT) {
-			log(LOGC_NONE, LOGL_ERR,
-			    "%s: Failed to get locality: %d\n", __func__, ret);
-			return ret;
-		}
-
-		mdelay(TPM_TIMEOUT_MS);
-	} while (get_timer(start) < stop);
-
-	log(LOGC_NONE, LOGL_ERR, "%s: Timeout getting locality: %d\n", __func__,
-	    ret);
-
-	return ret;
-}
-
-static u8 tpm_tis_spi_status(struct udevice *dev, u8 *status)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-
-	return tpm_tis_spi_read(dev, TPM_STS(chip->locality), status, 1);
-}
-
-static int tpm_tis_spi_wait_for_stat(struct udevice *dev, u8 mask,
-				     unsigned long timeout, u8 *status)
-{
-	unsigned long start = get_timer(0);
-	unsigned long stop = timeout;
-	int ret;
-
-	do {
-		mdelay(TPM_TIMEOUT_MS);
-		ret = tpm_tis_spi_status(dev, status);
-		if (ret)
-			return ret;
-
-		if ((*status & mask) == mask)
-			return 0;
-	} while (get_timer(start) < stop);
-
-	return -ETIMEDOUT;
-}
-
-static u8 tpm_tis_spi_valid_status(struct udevice *dev, u8 *status)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-
-	return tpm_tis_spi_wait_for_stat(dev, TPM_STS_VALID,
-		chip->timeout_c, status);
-}
 
-static int tpm_tis_spi_get_burstcount(struct udevice *dev)
+static int tpm_tis_spi_write(struct udevice *dev, u32 addr, u16 len, const u8 *out)
 {
-	struct tpm_chip *chip = dev_get_priv(dev);
-	unsigned long start, stop;
-	u32 burstcount, ret;
-
-	/* wait for burstcount */
-	start = get_timer(0);
-	stop = chip->timeout_d;
-	do {
-		ret = tpm_tis_spi_read32(dev, TPM_STS(chip->locality),
-					 &burstcount);
-		if (ret)
-			return -EBUSY;
-
-		burstcount = (burstcount >> 8) & 0xFFFF;
-		if (burstcount)
-			return burstcount;
-
-		mdelay(TPM_TIMEOUT_MS);
-	} while (get_timer(start) < stop);
-
-	return -EBUSY;
-}
-
-static int tpm_tis_spi_cancel(struct udevice *dev)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-	u8 data = TPM_STS_COMMAND_READY;
-
-	return tpm_tis_spi_write(dev, TPM_STS(chip->locality), &data, 1);
-}
-
-static int tpm_tis_spi_recv_data(struct udevice *dev, u8 *buf, size_t count)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-	int size = 0, burstcnt, len, ret;
-	u8 status;
-
-	while (size < count &&
-	       tpm_tis_spi_wait_for_stat(dev,
-					 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
-					 chip->timeout_c, &status) == 0) {
-		burstcnt = tpm_tis_spi_get_burstcount(dev);
-		if (burstcnt < 0)
-			return burstcnt;
-
-		len = min_t(int, burstcnt, count - size);
-		ret = tpm_tis_spi_read(dev, TPM_DATA_FIFO(chip->locality),
-				       buf + size, len);
-		if (ret < 0)
-			return ret;
-
-		size += len;
-	}
-
-	return size;
-}
-
-static int tpm_tis_spi_recv(struct udevice *dev, u8 *buf, size_t count)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-	int size, expected;
-
-	if (!chip)
-		return -ENODEV;
-
-	if (count < TPM_HEADER_SIZE) {
-		size = -EIO;
-		goto out;
-	}
-
-	size = tpm_tis_spi_recv_data(dev, buf, TPM_HEADER_SIZE);
-	if (size < TPM_HEADER_SIZE) {
-		log(LOGC_NONE, LOGL_ERR, "TPM error, unable to read header\n");
-		goto out;
-	}
-
-	expected = get_unaligned_be32(buf + 2);
-	if (expected > count) {
-		size = -EIO;
-		goto out;
-	}
-
-	size += tpm_tis_spi_recv_data(dev, &buf[TPM_HEADER_SIZE],
-				   expected - TPM_HEADER_SIZE);
-	if (size < expected) {
-		log(LOGC_NONE, LOGL_ERR,
-		    "TPM error, unable to read remaining bytes of result\n");
-		size = -EIO;
-		goto out;
-	}
-
-out:
-	tpm_tis_spi_cancel(dev);
-	tpm_tis_spi_release_locality(dev, chip->locality, false);
-
-	return size;
-}
-
-static int tpm_tis_spi_send(struct udevice *dev, const u8 *buf, size_t len)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-	u32 i, size;
-	u8 status;
-	int burstcnt, ret;
-	u8 data;
-
-	if (!chip)
-		return -ENODEV;
-
-	if (len > TPM_DEV_BUFSIZE)
-		return -E2BIG;  /* Command is too long for our tpm, sorry */
-
-	ret = tpm_tis_spi_request_locality(dev, 0);
-	if (ret < 0)
-		return -EBUSY;
-
-	/*
-	 * Check if the TPM is ready. If not, if not, cancel the pending command
-	 * and poll on the status to be finally ready.
-	 */
-	ret = tpm_tis_spi_status(dev, &status);
-	if (ret)
-		return ret;
-
-	if (!(status & TPM_STS_COMMAND_READY)) {
-		/* Force the transition, usually this will be done at startup */
-		ret = tpm_tis_spi_cancel(dev);
-		if (ret) {
-			log(LOGC_NONE, LOGL_ERR,
-			    "%s: Could not cancel previous operation\n",
-			    __func__);
-			goto out_err;
-		}
-
-		ret = tpm_tis_spi_wait_for_stat(dev, TPM_STS_COMMAND_READY,
-						chip->timeout_b, &status);
-		if (ret < 0 || !(status & TPM_STS_COMMAND_READY)) {
-			log(LOGC_NONE, LOGL_ERR,
-			    "status %d after wait for stat returned %d\n",
-			    status, ret);
-			goto out_err;
-		}
-	}
-
-	for (i = 0; i < len - 1;) {
-		burstcnt = tpm_tis_spi_get_burstcount(dev);
-		if (burstcnt < 0)
-			return burstcnt;
-
-		size = min_t(int, len - i - 1, burstcnt);
-		ret = tpm_tis_spi_write(dev, TPM_DATA_FIFO(chip->locality),
-					buf + i, size);
-		if (ret < 0)
-			goto out_err;
-
-		i += size;
-	}
-
-	ret = tpm_tis_spi_valid_status(dev, &status);
-	if (ret)
-		goto out_err;
-
-	if ((status & TPM_STS_DATA_EXPECT) == 0) {
-		ret = -EIO;
-		goto out_err;
-	}
-
-	ret = tpm_tis_spi_write(dev, TPM_DATA_FIFO(chip->locality),
-				buf + len - 1, 1);
-	if (ret)
-		goto out_err;
-
-	ret = tpm_tis_spi_valid_status(dev, &status);
-	if (ret)
-		goto out_err;
-
-	if ((status & TPM_STS_DATA_EXPECT) != 0) {
-		ret = -EIO;
-		goto out_err;
-	}
-
-	data = TPM_STS_GO;
-	ret = tpm_tis_spi_write(dev, TPM_STS(chip->locality), &data, 1);
-	if (ret)
-		goto out_err;
-
-	return len;
-
-out_err:
-	tpm_tis_spi_cancel(dev);
-	tpm_tis_spi_release_locality(dev, chip->locality, false);
-
-	return ret;
-}
-
-static int tpm_tis_spi_cleanup(struct udevice *dev)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-
-	tpm_tis_spi_cancel(dev);
-	/*
-	 * The TPM needs some time to clean up here,
-	 * so we sleep rather than keeping the bus busy
-	 */
-	mdelay(2);
-	tpm_tis_spi_release_locality(dev, chip->locality, false);
-
-	return 0;
-}
-
-static int tpm_tis_spi_open(struct udevice *dev)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-
-	if (chip->is_open)
-		return -EBUSY;
-
-	chip->is_open = 1;
-
-	return 0;
-}
-
-static int tpm_tis_spi_close(struct udevice *dev)
-{
-	struct tpm_chip *chip = dev_get_priv(dev);
-
-	if (chip->is_open) {
-		tpm_tis_spi_release_locality(dev, chip->locality, true);
-		chip->is_open = 0;
-	}
-
-	return 0;
+	return tpm_tis_spi_xfer(dev, addr, out, NULL, len);
 }
 
-static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size)
+static int tpm_tis_spi_write32(struct udevice *dev, u32 addr, u32 value)
 {
-	struct tpm_chip *chip = dev_get_priv(dev);
-
-	if (size < 80)
-		return -ENOSPC;
+	__le32 value_le = cpu_to_le32(value);
 
-	return snprintf(buf, size,
-			"%s v2.0: VendorID 0x%04x, DeviceID 0x%04x, RevisionID 0x%02x [%s]",
-			dev->name, chip->vend_dev & 0xFFFF,
-			chip->vend_dev >> 16, chip->rid,
-			(chip->is_open ? "open" : "closed"));
+	return tpm_tis_spi_write(dev, addr, sizeof(value), (u8 *)&value_le);
 }
 
 static int tpm_tis_wait_init(struct udevice *dev, int loc)
@@ -565,7 +200,7 @@
 	do {
 		mdelay(TPM_TIMEOUT_MS);
 
-		ret = tpm_tis_spi_read(dev, TPM_ACCESS(loc), &status, 1);
+		ret = tpm_tis_spi_read(dev, TPM_ACCESS(loc), 1, &status);
 		if (ret)
 			break;
 
@@ -576,6 +211,13 @@
 	return -EIO;
 }
 
+static struct tpm_tis_phy_ops phy_ops = {
+	.read_bytes = tpm_tis_spi_read,
+	.write_bytes = tpm_tis_spi_write,
+	.read32 = tpm_tis_spi_read32,
+	.write32 = tpm_tis_spi_write32,
+};
+
 static int tpm_tis_spi_probe(struct udevice *dev)
 {
 	struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(dev);
@@ -611,65 +253,38 @@
 	/* Ensure a minimum amount of time elapsed since reset of the TPM */
 	mdelay(drv_data->time_before_first_cmd_ms);
 
-	chip->locality = 0;
-	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;
-	priv->pcr_count = drv_data->pcr_count;
-	priv->pcr_select_min = drv_data->pcr_select_min;
-
 	ret = tpm_tis_wait_init(dev, chip->locality);
 	if (ret) {
 		log(LOGC_DM, LOGL_ERR, "%s: no device found\n", __func__);
 		return ret;
 	}
 
-	ret = tpm_tis_spi_request_locality(dev, chip->locality);
-	if (ret) {
-		log(LOGC_NONE, LOGL_ERR, "%s: could not request locality %d\n",
-		    __func__, chip->locality);
-		return ret;
-	}
-
-	ret = tpm_tis_spi_read32(dev, TPM_DID_VID(chip->locality),
-				 &chip->vend_dev);
-	if (ret) {
-		log(LOGC_NONE, LOGL_ERR,
-		    "%s: could not retrieve VendorID/DeviceID\n", __func__);
-		return ret;
-	}
-
-	ret = tpm_tis_spi_read(dev, TPM_RID(chip->locality), &chip->rid, 1);
-	if (ret) {
-		log(LOGC_NONE, LOGL_ERR, "%s: could not retrieve RevisionID\n",
-		    __func__);
-		return ret;
-	}
+	tpm_tis_ops_register(dev, &phy_ops);
+	ret = tpm_tis_init(dev);
+	if (ret)
+		goto err;
 
-	log(LOGC_NONE, LOGL_ERR,
-	    "SPI TPMv2.0 found (vid:%04x, did:%04x, rid:%02x)\n",
-	    chip->vend_dev & 0xFFFF, chip->vend_dev >> 16, chip->rid);
+	priv->pcr_count = drv_data->pcr_count;
+	priv->pcr_select_min = drv_data->pcr_select_min;
+	priv->version = TPM_V2;
 
 	return 0;
+err:
+	return -EINVAL;
 }
 
-static int tpm_tis_spi_remove(struct udevice *dev)
+static int tpm_tis_spi_remove(struct udevice *udev)
 {
-	struct tpm_chip *chip = dev_get_priv(dev);
-
-	tpm_tis_spi_release_locality(dev, chip->locality, true);
-
-	return 0;
+	return tpm_tis_cleanup(udev);
 }
 
 static const struct tpm_ops tpm_tis_spi_ops = {
-	.open		= tpm_tis_spi_open,
-	.close		= tpm_tis_spi_close,
+	.open		= tpm_tis_open,
+	.close		= tpm_tis_close,
 	.get_desc	= tpm_tis_get_desc,
-	.send		= tpm_tis_spi_send,
-	.recv		= tpm_tis_spi_recv,
-	.cleanup	= tpm_tis_spi_cleanup,
+	.send		= tpm_tis_send,
+	.recv		= tpm_tis_recv,
+	.cleanup	= tpm_tis_cleanup,
 };
 
 static const struct tpm_tis_chip_data tpm_tis_std_chip_data = {
