diff options
author | Oliver O'Halloran <oohall@gmail.com> | 2018-11-07 13:24:48 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.ibm.com> | 2018-11-08 20:50:36 -0600 |
commit | 324365f3aa9bcd55048f3ae7b77d5dff8658a8de (patch) | |
tree | d841f555649b56060321726a3c24143a2db62e91 /libstb | |
parent | d49bfeea7bf274efe2b8a3b0840181ec35ba60ca (diff) | |
download | skiboot-324365f3aa9bcd55048f3ae7b77d5dff8658a8de.zip skiboot-324365f3aa9bcd55048f3ae7b77d5dff8658a8de.tar.gz skiboot-324365f3aa9bcd55048f3ae7b77d5dff8658a8de.tar.bz2 |
libstb: Pass a tpm_dev to tpm_i2c_request_send()
Just pass the container structure rather than bus_id and xscom_base to
tpm_i2c_request_send(). Rename xscom_base to i2c_addr while we're here
since that's just plain wrong.
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'libstb')
-rw-r--r-- | libstb/drivers/tpm_i2c_interface.c | 7 | ||||
-rw-r--r-- | libstb/drivers/tpm_i2c_interface.h | 4 | ||||
-rw-r--r-- | libstb/drivers/tpm_i2c_nuvoton.c | 24 | ||||
-rw-r--r-- | libstb/tpm_chip.h | 2 |
4 files changed, 17 insertions, 20 deletions
diff --git a/libstb/drivers/tpm_i2c_interface.c b/libstb/drivers/tpm_i2c_interface.c index 8e5ba32..ea0dd66 100644 --- a/libstb/drivers/tpm_i2c_interface.c +++ b/libstb/drivers/tpm_i2c_interface.c @@ -39,7 +39,7 @@ * * Returns: Zero on success otherwise a negative error code */ -int tpm_i2c_request_send(int bus_id, int dev_addr, int read_write, +int tpm_i2c_request_send(struct tpm_dev *tpm_device, int read_write, uint32_t offset, uint32_t offset_bytes, void* buf, size_t buflen) { @@ -52,8 +52,9 @@ int tpm_i2c_request_send(int bus_id, int dev_addr, int read_write, */ timeout = (buflen + offset_bytes + 2) * I2C_BYTE_TIMEOUT_MS; - rc = i2c_request_send(bus_id, dev_addr, read_write, offset, - offset_bytes, buf, buflen, timeout); + rc = i2c_request_send(tpm_device->bus_id, tpm_device->i2c_addr, + read_write, offset, offset_bytes, buf, buflen, + timeout); if (rc == OPAL_PARAMETER) return STB_ARG_ERROR; else if (rc < 0) diff --git a/libstb/drivers/tpm_i2c_interface.h b/libstb/drivers/tpm_i2c_interface.h index d2acc1a..1134cd5 100644 --- a/libstb/drivers/tpm_i2c_interface.h +++ b/libstb/drivers/tpm_i2c_interface.h @@ -20,7 +20,9 @@ #include <i2c.h> #include <stdlib.h> -extern int tpm_i2c_request_send(int tpm_bus_id, int tpm_dev_addr, int read_write, +#include "../tpm_chip.h" + +extern int tpm_i2c_request_send(struct tpm_dev *tpm_device, int read_write, uint32_t offset, uint32_t offset_bytes, void* buf, size_t buflen); #endif /* __TPM_I2C_H */ diff --git a/libstb/drivers/tpm_i2c_nuvoton.c b/libstb/drivers/tpm_i2c_nuvoton.c index d18add9..7f29deb 100644 --- a/libstb/drivers/tpm_i2c_nuvoton.c +++ b/libstb/drivers/tpm_i2c_nuvoton.c @@ -61,15 +61,13 @@ static struct tpm_dev *tpm_device = NULL; static int tpm_status_write_byte(uint8_t byte) { uint8_t value = byte; - return tpm_i2c_request_send(tpm_device->bus_id, tpm_device->xscom_base, - SMBUS_WRITE, TPM_STS, 1, &value, + return tpm_i2c_request_send(tpm_device, SMBUS_WRITE, TPM_STS, 1, &value, sizeof(value)); } static int tpm_status_read_byte(uint8_t offset, uint8_t *byte) { - return tpm_i2c_request_send(tpm_device->bus_id, tpm_device->xscom_base, - SMBUS_READ, offset, 1, byte, + return tpm_i2c_request_send(tpm_device, SMBUS_READ, offset, 1, byte, sizeof(uint8_t)); } @@ -292,8 +290,7 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen) bytes = (count + burst_count > buflen - 1 ? (buflen - 1 - count) : burst_count); - rc = tpm_i2c_request_send(tpm_device->bus_id, - tpm_device->xscom_base, + rc = tpm_i2c_request_send(tpm_device, SMBUS_WRITE, TPM_DATA_FIFO_W, 1, &buf[count], bytes); count += bytes; @@ -335,8 +332,7 @@ static int tpm_write_fifo(uint8_t* buf, size_t buflen) if (burst_count < 0) return burst_count; - rc = tpm_i2c_request_send(tpm_device->bus_id, - tpm_device->xscom_base, + rc = tpm_i2c_request_send(tpm_device, SMBUS_WRITE, TPM_DATA_FIFO_W, 1, &buf[count], 1); @@ -401,8 +397,7 @@ static int tpm_read_fifo(uint8_t* buf, size_t* buflen) "bc=%d, bl=%zd\n", count, burst_count, *buflen); rc = STB_TPM_OVERFLOW; } - rc = tpm_i2c_request_send(tpm_device->bus_id, - tpm_device->xscom_base, + rc = tpm_i2c_request_send(tpm_device, SMBUS_READ, TPM_DATA_FIFO_R, 1, &buf[count], burst_count); @@ -452,7 +447,7 @@ static int tpm_transmit(struct tpm_dev *dev, uint8_t* buf, size_t cmdlen, tpm_device = dev; DBG("**** %s: dev %#x/%#x buf %016llx cmdlen %zu" " buflen %zu ****\n", - __func__, dev->bus_id, dev->xscom_base, *(uint64_t*) buf, + __func__, dev->bus_id, dev->i2c_addr, *(uint64_t *) buf, cmdlen, *buflen); DBG("step 1/5: set command ready\n"); @@ -518,7 +513,7 @@ static int nuvoton_tpm_quirk(void *data, struct i2c_request *req, int *rc) * in a nice world of pain. */ if (tpm_device->bus_id == req->bus->opal_id && - tpm_device->xscom_base == req->dev_addr && + tpm_device->i2c_addr == req->dev_addr && ((req->op == I2C_READ && req->rw_len == 1) || (req->op == I2C_WRITE && req->rw_len == 0))) { *rc = OPAL_I2C_TIMEOUT; @@ -545,9 +540,8 @@ void tpm_i2c_nuvoton_probe(void) * Read TPM device address and bus id. Make sure the properties * really exist if the default value is returned. */ - tpm_device->xscom_base = dt_prop_get_u32_def(node, "reg", 0); - if (!tpm_device->xscom_base && - !dt_find_property(node, "reg")) { + tpm_device->i2c_addr = dt_prop_get_u32_def(node, "reg", 0); + if (!tpm_device->i2c_addr && !dt_find_property(node, "reg")) { /* * @fwts-label NuvotonRegNotFound * @fwts-advice reg property not found. This indicates diff --git a/libstb/tpm_chip.h b/libstb/tpm_chip.h index fed5619..de7f8ed 100644 --- a/libstb/tpm_chip.h +++ b/libstb/tpm_chip.h @@ -28,7 +28,7 @@ struct tpm_dev { int bus_id; /* TPM address in the bus */ - int xscom_base; + int i2c_addr; }; struct tpm_driver { |