Lines Matching +full:locality +full:- +full:specific
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2014-2021 Nuvoton Technology corporation
4 * Copyright (C) 2019-2022 Infineon Technologies AG
14 #include <linux/crc-ccitt.h>
27 /* TIS-compatible register address to avoid clash with TPM_ACCESS (0x00) */
78 * Table 51 "I2C-TPM Register Overview".
80 * For most addresses this can be done by simply stripping off the locality
86 * Locality information is ignored, since this driver assumes exclusive access
87 * to the TPM and always uses locality 0.
115 if (msg->flags & I2C_M_RD) in tpm_tis_i2c_retry_transfer_until_ack()
116 guard_time = phy->guard_time_read; in tpm_tis_i2c_retry_transfer_until_ack()
118 guard_time = phy->guard_time_write; in tpm_tis_i2c_retry_transfer_until_ack()
121 ret = i2c_transfer(phy->i2c_client->adapter, msg, 1); in tpm_tis_i2c_retry_transfer_until_ack()
125 usleep_range(phy->guard_time_min, phy->guard_time_max); in tpm_tis_i2c_retry_transfer_until_ack()
176 return -EIO; in tpm_tis_i2c_sanity_check_read()
186 struct i2c_msg msg = { .addr = phy->i2c_client->addr }; in tpm_tis_i2c_read_bytes()
205 msg.len = len - read; in tpm_tis_i2c_read_bytes()
230 struct i2c_msg msg = { .addr = phy->i2c_client->addr }; in tpm_tis_i2c_write_bytes()
235 if (len > TPM_BUFSIZE - 1) in tpm_tis_i2c_write_bytes()
236 return -EIO; in tpm_tis_i2c_write_bytes()
238 phy->io_buf[0] = reg; in tpm_tis_i2c_write_bytes()
239 msg.buf = phy->io_buf; in tpm_tis_i2c_write_bytes()
242 msg.len = sizeof(reg) + len - wrote; in tpm_tis_i2c_write_bytes()
246 memcpy(phy->io_buf + sizeof(reg), value + wrote, in tpm_tis_i2c_write_bytes()
247 msg.len - sizeof(reg)); in tpm_tis_i2c_write_bytes()
252 wrote += msg.len - sizeof(reg); in tpm_tis_i2c_write_bytes()
271 return -EIO; in tpm_tis_i2c_verify_crc()
279 * The time period is vendor-specific and must be read from the
286 * - SR: <I2C read with repeated start> <guard time> <I2C read>
287 * - RR: <I2C read> <guard time> <I2C read>
288 * - RW: <I2C read> <guard time> <I2C write>
289 * - WR: <I2C write> <guard time> <I2C read>
290 * - WW: <I2C write> <guard time> <I2C write>
299 phy->guard_time_read = true; in tpm_tis_i2c_init_guard_time()
300 phy->guard_time_write = true; in tpm_tis_i2c_init_guard_time()
301 phy->guard_time_min = GUARD_TIME_DEFAULT_MIN; in tpm_tis_i2c_init_guard_time()
302 phy->guard_time_max = GUARD_TIME_DEFAULT_MAX; in tpm_tis_i2c_init_guard_time()
304 ret = tpm_tis_i2c_read_bytes(&phy->priv, TPM_I2C_INTERFACE_CAPABILITY, in tpm_tis_i2c_init_guard_time()
310 phy->guard_time_read = (i2c_caps & TPM_GUARD_TIME_RR_MASK) || in tpm_tis_i2c_init_guard_time()
312 phy->guard_time_write = (i2c_caps & TPM_GUARD_TIME_WR_MASK) || in tpm_tis_i2c_init_guard_time()
314 phy->guard_time_min = (i2c_caps & TPM_GUARD_TIME_MIN_MASK) >> in tpm_tis_i2c_init_guard_time()
317 phy->guard_time_max = phy->guard_time_min + phy->guard_time_min / 5; in tpm_tis_i2c_init_guard_time()
334 const u8 locality = 0; in tpm_tis_i2c_probe() local
337 phy = devm_kzalloc(&dev->dev, sizeof(struct tpm_tis_i2c_phy), in tpm_tis_i2c_probe()
340 return -ENOMEM; in tpm_tis_i2c_probe()
342 phy->io_buf = devm_kzalloc(&dev->dev, TPM_BUFSIZE, GFP_KERNEL); in tpm_tis_i2c_probe()
343 if (!phy->io_buf) in tpm_tis_i2c_probe()
344 return -ENOMEM; in tpm_tis_i2c_probe()
346 set_bit(TPM_TIS_DEFAULT_CANCELLATION, &phy->priv.flags); in tpm_tis_i2c_probe()
347 phy->i2c_client = dev; in tpm_tis_i2c_probe()
354 ret = tpm_tis_i2c_write_bytes(&phy->priv, TPM_LOC_SEL, sizeof(locality), in tpm_tis_i2c_probe()
355 &locality, TPM_TIS_PHYS_8); in tpm_tis_i2c_probe()
359 ret = tpm_tis_i2c_write_bytes(&phy->priv, TPM_I2C_DATA_CSUM_ENABLE, in tpm_tis_i2c_probe()
365 return tpm_tis_core_init(&dev->dev, &phy->priv, -1, &tpm_i2c_phy_ops, in tpm_tis_i2c_probe()
387 { .compatible = "tcg,tpm-tis-i2c", },