Lines Matching +full:burst +full:- +full:read

1 // SPDX-License-Identifier: GPL-2.0+
18 #include <tpm-v1.h>
87 /* Retrieve burst count value out of the status register contents. */
98 debug(PREFIX "Read reg 0x%4.4x returns 0x%2.2x\n", in tpm_read_byte()
99 (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, ret); in tpm_read_byte()
106 debug(PREFIX "Read reg 0x%4.4x returns 0x%8.8x\n", in tpm_read_word()
107 (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, ret); in tpm_read_word()
114 (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, value); in tpm_write_byte()
122 (u32)(uintptr_t)ptr - (u32)(uintptr_t)priv->regs, value); in tpm_write_word()
132 * @reg - pointer to the TPM register
133 * @mask - bitmask for the bitfield(s) to watch
134 * @expected - value the field(s) are supposed to be set to
137 * appropriate register bits, or -ETIMEDOUT on timeout.
149 time_us--; in tis_wait_reg()
152 return -ETIMEDOUT; in tis_wait_reg()
158 * Returns 0 on success, -ve on error
169 return -EINVAL; in tpm_tis_lpc_probe()
170 priv->regs = map_sysmem(addr, 0); in tpm_tis_lpc_probe()
171 didvid = tpm_read_word(priv, &priv->regs[0].did_vid); in tpm_tis_lpc_probe()
178 return -ENODEV; in tpm_tis_lpc_probe()
191 * @data - address of the data to send, byte by byte
192 * @len - length of the data to send
194 * Returns 0 on success, -ve on error (in case the device does not accept
200 struct tpm_locality *regs = priv->regs; in tis_senddata()
202 u16 burst = 0; in tis_senddata() local
209 if (value == -ETIMEDOUT) { in tis_senddata()
210 printf("%s:%d - failed to get 'command_ready' status\n", in tis_senddata()
214 burst = burst_count(value); in tis_senddata()
220 while (!burst) { in tis_senddata()
223 __FILE__, __LINE__, len - offset, len); in tis_senddata()
224 return -ETIMEDOUT; in tis_senddata()
227 burst = burst_count(tpm_read_word(priv, in tis_senddata()
238 * the -1 below) to make sure that the 'expected' status bit in tis_senddata()
242 count = min((size_t)burst, len - offset - 1); in tis_senddata()
243 while (count--) in tis_senddata()
250 if ((value == -ETIMEDOUT) || !(value & TIS_STS_EXPECT)) { in tis_senddata()
253 return value == -ETIMEDOUT ? value : -EIO; in tis_senddata()
256 burst = burst_count(value); in tis_senddata()
257 if ((offset == (len - 1)) && burst) { in tis_senddata()
260 * device, so burst size must be nonzero before we in tis_senddata()
275 if ((value == -ETIMEDOUT) || (value & TIS_STS_EXPECT)) { in tis_senddata()
278 return value == -ETIMEDOUT ? value : -EIO; in tis_senddata()
289 * read the TPM device response after a command was issued.
291 * @buffer - address where to read the response, byte by byte.
292 * @len - pointer to the size of buffer
296 * -ve value.
301 struct tpm_locality *regs = priv->regs; in tis_readresponse()
302 u16 burst; in tis_readresponse() local
313 if (value == -ETIMEDOUT) { in tis_readresponse()
320 while ((burst = burst_count(value)) == 0) { in tis_readresponse()
322 printf("%s:%d TPM stuck on read\n", in tis_readresponse()
324 return -EIO; in tis_readresponse()
332 while (burst-- && (offset < expected_count)) { in tis_readresponse()
340 * total - it is stored as a 4 byte number in in tis_readresponse()
355 return -ENOSPC; in tis_readresponse()
363 if (value == -ETIMEDOUT) { in tis_readresponse()
364 printf("%s:%d failed to read response\n", in tis_readresponse()
375 * Make sure we indeed read all there was. The TIS_STS_VALID bit is in tis_readresponse()
381 return -EBADMSG; in tis_readresponse()
394 struct tpm_locality *regs = priv->regs; in tpm_tis_lpc_close()
403 TIS_ACCESS_ACTIVE_LOCALITY, 0) == -ETIMEDOUT) { in tpm_tis_lpc_close()
404 printf("%s:%d - failed to release locality %d\n", in tpm_tis_lpc_close()
406 return -ETIMEDOUT; in tpm_tis_lpc_close()
415 struct tpm_locality *regs = priv->regs; in tpm_tis_lpc_open()
432 if (ret == -ETIMEDOUT) { in tpm_tis_lpc_open()
433 printf("%s:%d - failed to lock locality %d\n", in tpm_tis_lpc_open()
449 return -ENOSPC; in tpm_tis_get_desc()