Lines Matching refs:dev
46 static int st33zp24_i2c_write8_reg(struct udevice *dev, u8 tpm_register, in st33zp24_i2c_write8_reg() argument
49 struct tpm_chip_priv *chip_priv = dev_get_uclass_priv(dev); in st33zp24_i2c_write8_reg()
54 return dm_i2c_write(dev, 0, chip_priv->buf, tpm_size + 1); in st33zp24_i2c_write8_reg()
65 static int st33zp24_i2c_read8_reg(struct udevice *dev, u8 tpm_register, in st33zp24_i2c_read8_reg() argument
72 status = st33zp24_i2c_write8_reg(dev, tpm_register, &data, 1); in st33zp24_i2c_read8_reg()
76 return dm_i2c_read(dev, 0, tpm_data, tpm_size); in st33zp24_i2c_read8_reg()
88 static int st33zp24_i2c_write(struct udevice *dev, u8 tpm_register, in st33zp24_i2c_write() argument
91 return st33zp24_i2c_write8_reg(dev, tpm_register | TPM_WRITE_DIRECTION, in st33zp24_i2c_write()
104 static int st33zp24_i2c_read(struct udevice *dev, u8 tpm_register, in st33zp24_i2c_read() argument
107 return st33zp24_i2c_read8_reg(dev, tpm_register, tpm_data, tpm_size); in st33zp24_i2c_read()
114 static void st33zp24_i2c_release_locality(struct udevice *dev) in st33zp24_i2c_release_locality() argument
118 st33zp24_i2c_write(dev, TPM_ACCESS, &data, 1); in st33zp24_i2c_release_locality()
126 static int st33zp24_i2c_check_locality(struct udevice *dev) in st33zp24_i2c_check_locality() argument
128 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_check_locality()
132 status = st33zp24_i2c_read(dev, TPM_ACCESS, &data, 1); in st33zp24_i2c_check_locality()
146 static int st33zp24_i2c_request_locality(struct udevice *dev) in st33zp24_i2c_request_locality() argument
148 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_request_locality()
153 if (st33zp24_i2c_check_locality(dev) == chip->locality) in st33zp24_i2c_request_locality()
157 ret = st33zp24_i2c_write(dev, TPM_ACCESS, &data, 1); in st33zp24_i2c_request_locality()
165 if (st33zp24_i2c_check_locality(dev) >= 0) in st33zp24_i2c_request_locality()
178 static u8 st33zp24_i2c_status(struct udevice *dev) in st33zp24_i2c_status() argument
182 st33zp24_i2c_read(dev, TPM_STS, &data, 1); in st33zp24_i2c_status()
192 static int st33zp24_i2c_get_burstcount(struct udevice *dev) in st33zp24_i2c_get_burstcount() argument
194 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_get_burstcount()
204 status = st33zp24_i2c_read(dev, tpm_reg, &temp, 1); in st33zp24_i2c_get_burstcount()
210 status = st33zp24_i2c_read(dev, tpm_reg, &temp, 1); in st33zp24_i2c_get_burstcount()
228 static void st33zp24_i2c_cancel(struct udevice *dev) in st33zp24_i2c_cancel() argument
233 st33zp24_i2c_write(dev, TPM_STS, &data, 1); in st33zp24_i2c_cancel()
244 static int st33zp24_i2c_wait_for_stat(struct udevice *dev, u8 mask, in st33zp24_i2c_wait_for_stat() argument
250 *status = st33zp24_i2c_status(dev); in st33zp24_i2c_wait_for_stat()
258 *status = st33zp24_i2c_status(dev); in st33zp24_i2c_wait_for_stat()
273 static int st33zp24_i2c_recv_data(struct udevice *dev, u8 *buf, size_t count) in st33zp24_i2c_recv_data() argument
275 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_recv_data()
279 st33zp24_i2c_wait_for_stat(dev, TPM_STS_DATA_AVAIL | TPM_STS_VALID, in st33zp24_i2c_recv_data()
281 burstcnt = st33zp24_i2c_get_burstcount(dev); in st33zp24_i2c_recv_data()
285 ret = st33zp24_i2c_read(dev, TPM_DATA_FIFO, buf + size, len); in st33zp24_i2c_recv_data()
302 static int st33zp24_i2c_recv(struct udevice *dev, u8 *buf, size_t count) in st33zp24_i2c_recv() argument
304 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_recv()
316 size = st33zp24_i2c_recv_data(dev, buf, TPM_HEADER_SIZE); in st33zp24_i2c_recv()
328 size += st33zp24_i2c_recv_data(dev, &buf[TPM_HEADER_SIZE], in st33zp24_i2c_recv()
337 st33zp24_i2c_cancel(dev); in st33zp24_i2c_recv()
338 st33zp24_i2c_release_locality(dev); in st33zp24_i2c_recv()
350 static int st33zp24_i2c_send(struct udevice *dev, const u8 *buf, size_t len) in st33zp24_i2c_send() argument
352 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_send()
362 ret = st33zp24_i2c_request_locality(dev); in st33zp24_i2c_send()
366 tpm_stat = st33zp24_i2c_status(dev); in st33zp24_i2c_send()
368 st33zp24_i2c_cancel(dev); in st33zp24_i2c_send()
369 if (st33zp24_i2c_wait_for_stat(dev, TPM_STS_COMMAND_READY, in st33zp24_i2c_send()
377 burstcnt = st33zp24_i2c_get_burstcount(dev); in st33zp24_i2c_send()
382 ret = st33zp24_i2c_write(dev, TPM_DATA_FIFO, buf + i, size); in st33zp24_i2c_send()
389 tpm_stat = st33zp24_i2c_status(dev); in st33zp24_i2c_send()
395 ret = st33zp24_i2c_write(dev, TPM_DATA_FIFO, buf + len - 1, 1); in st33zp24_i2c_send()
399 tpm_stat = st33zp24_i2c_status(dev); in st33zp24_i2c_send()
406 ret = st33zp24_i2c_write(dev, TPM_STS, &data, 1); in st33zp24_i2c_send()
413 st33zp24_i2c_cancel(dev); in st33zp24_i2c_send()
414 st33zp24_i2c_release_locality(dev); in st33zp24_i2c_send()
419 static int st33zp24_i2c_cleanup(struct udevice *dev) in st33zp24_i2c_cleanup() argument
421 st33zp24_i2c_cancel(dev); in st33zp24_i2c_cleanup()
427 st33zp24_i2c_release_locality(dev); in st33zp24_i2c_cleanup()
432 static int st33zp24_i2c_init(struct udevice *dev) in st33zp24_i2c_init() argument
434 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_init()
454 static int st33zp24_i2c_open(struct udevice *dev) in st33zp24_i2c_open() argument
456 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_open()
463 rc = st33zp24_i2c_init(dev); in st33zp24_i2c_open()
470 static int st33zp24_i2c_close(struct udevice *dev) in st33zp24_i2c_close() argument
472 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_close()
475 st33zp24_i2c_release_locality(dev); in st33zp24_i2c_close()
483 static int st33zp24_i2c_get_desc(struct udevice *dev, char *buf, int size) in st33zp24_i2c_get_desc() argument
485 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_get_desc()
492 dev->name, in st33zp24_i2c_get_desc()
505 static int st33zp24_i2c_probe(struct udevice *dev) in st33zp24_i2c_probe() argument
507 struct tpm_chip *chip = dev_get_priv(dev); in st33zp24_i2c_probe()
517 i2c_set_chip_offset_len(dev, 0); in st33zp24_i2c_probe()
524 static int st33zp24_i2c_remove(struct udevice *dev) in st33zp24_i2c_remove() argument
526 st33zp24_i2c_release_locality(dev); in st33zp24_i2c_remove()