Lines Matching +full:has +full:- +full:chip +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
9 * Sirrix AG - security technologies <tpmdd@sirrix.com> and
10 * Applied Data Security Group, Ruhr-University Bochum, Germany
11 * Project-Homepage: http://www.trust.rub.de/projects/linux-device-driver-infineon-tpm/
19 /* maximum number of WTX-packages */
21 /* msleep-Time for WTX-packages */
23 /* msleep-Time --> Interval to check status register */
25 /* gives number of max. msleep()-calls before throwing timeout */
150 static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo) in empty_fifo() argument
169 this has nothing to say, since the TPM will give its answer in empty_fifo()
182 return -EIO; in empty_fifo()
187 static int wait(struct tpm_chip *chip, int wait_for_bit) in wait() argument
193 /* check the status-register if wait_for_bit is set */ in wait()
200 dev_err(&chip->dev, "Timeout in wait(STAT_XFE)\n"); in wait()
202 dev_err(&chip->dev, "Timeout in wait(STAT_RDA)\n"); in wait()
203 return -EIO; in wait()
208 static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) in wait_and_send() argument
210 wait(chip, STAT_XFE); in wait_and_send()
214 /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more
215 calculation time, it sends a WTX-package, which has to be acknowledged
217 creation. Set the maximum number of WTX-packages in the definitions
218 above, if the number is reached, the waiting-time will be denied
219 and the TPM command has to be resend.
222 static void tpm_wtx(struct tpm_chip *chip) in tpm_wtx() argument
225 dev_info(&chip->dev, "Granting WTX (%02d / %02d)\n", in tpm_wtx()
227 wait_and_send(chip, TPM_VL_VER); in tpm_wtx()
228 wait_and_send(chip, TPM_CTRL_WTX); in tpm_wtx()
229 wait_and_send(chip, 0x00); in tpm_wtx()
230 wait_and_send(chip, 0x00); in tpm_wtx()
234 static void tpm_wtx_abort(struct tpm_chip *chip) in tpm_wtx_abort() argument
236 dev_info(&chip->dev, "Aborting WTX\n"); in tpm_wtx_abort()
237 wait_and_send(chip, TPM_VL_VER); in tpm_wtx_abort()
238 wait_and_send(chip, TPM_CTRL_WTX_ABORT); in tpm_wtx_abort()
239 wait_and_send(chip, 0x00); in tpm_wtx_abort()
240 wait_and_send(chip, 0x00); in tpm_wtx_abort()
245 static int tpm_inf_recv(struct tpm_chip *chip, u8 * buf, size_t count) in tpm_inf_recv() argument
255 ret = wait(chip, STAT_RDA); in tpm_inf_recv()
257 return -EIO; in tpm_inf_recv()
262 dev_err(&chip->dev, in tpm_inf_recv()
264 return -EIO; in tpm_inf_recv()
272 wait(chip, STAT_RDA); in tpm_inf_recv()
277 dev_err(&chip->dev, "Error handling on vendor layer!\n"); in tpm_inf_recv()
278 return -EIO; in tpm_inf_recv()
284 size = size - 6; in tpm_inf_recv()
289 dev_info(&chip->dev, "WTX-package received\n"); in tpm_inf_recv()
291 tpm_wtx(chip); in tpm_inf_recv()
294 tpm_wtx_abort(chip); in tpm_inf_recv()
300 dev_info(&chip->dev, "WTX-abort acknowledged\n"); in tpm_inf_recv()
305 dev_err(&chip->dev, "ERROR-package received:\n"); in tpm_inf_recv()
307 dev_err(&chip->dev, in tpm_inf_recv()
308 "-> Negative acknowledgement" in tpm_inf_recv()
309 " - retransmit command!\n"); in tpm_inf_recv()
310 return -EIO; in tpm_inf_recv()
312 return -EIO; in tpm_inf_recv()
315 static int tpm_inf_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, in tpm_inf_send() argument
325 ret = empty_fifo(chip, 1); in tpm_inf_send()
327 dev_err(&chip->dev, "Timeout while clearing FIFO\n"); in tpm_inf_send()
328 return -EIO; in tpm_inf_send()
331 ret = wait(chip, STAT_XFE); in tpm_inf_send()
333 return -EIO; in tpm_inf_send()
343 wait_and_send(chip, TPM_VL_VER); in tpm_inf_send()
344 wait_and_send(chip, TPM_CTRL_DATA); in tpm_inf_send()
345 wait_and_send(chip, count_high); in tpm_inf_send()
346 wait_and_send(chip, count_low); in tpm_inf_send()
349 wait_and_send(chip, TPM_VL_VER); in tpm_inf_send()
350 wait_and_send(chip, TPM_VL_CHANNEL_TPM); in tpm_inf_send()
351 wait_and_send(chip, count_4); in tpm_inf_send()
352 wait_and_send(chip, count_3); in tpm_inf_send()
353 wait_and_send(chip, count_2); in tpm_inf_send()
354 wait_and_send(chip, count_1); in tpm_inf_send()
358 wait_and_send(chip, buf[i]); in tpm_inf_send()
363 static void tpm_inf_cancel(struct tpm_chip *chip) in tpm_inf_cancel() argument
372 static u8 tpm_inf_status(struct tpm_chip *chip) in tpm_inf_status() argument
404 struct tpm_chip *chip; in tpm_inf_pnp_probe() local
406 /* read IO-ports through PnP */ in tpm_inf_pnp_probe()
417 rc = -EINVAL; in tpm_inf_pnp_probe()
420 dev_info(&dev->dev, "Found %s with ID %s\n", in tpm_inf_pnp_probe()
421 dev->name, dev_id->id); in tpm_inf_pnp_probe()
423 rc = -EINVAL; in tpm_inf_pnp_probe()
429 rc = -EINVAL; in tpm_inf_pnp_probe()
435 rc = -EINVAL; in tpm_inf_pnp_probe()
446 dev_info(&dev->dev, "Found %s with ID %s\n", in tpm_inf_pnp_probe()
447 dev->name, dev_id->id); in tpm_inf_pnp_probe()
452 rc = -EINVAL; in tpm_inf_pnp_probe()
459 rc = -EINVAL; in tpm_inf_pnp_probe()
473 rc = -EINVAL; in tpm_inf_pnp_probe()
477 /* query chip for its vendor, its version number a.s.o. */ in tpm_inf_pnp_probe()
500 chipname = " (unknown chip)"; in tpm_inf_pnp_probe()
506 /* configure TPM with IO-ports */ in tpm_inf_pnp_probe()
512 /* control if IO-ports are set correctly */ in tpm_inf_pnp_probe()
519 dev_err(&dev->dev, in tpm_inf_pnp_probe()
520 "Could not set IO-data registers to 0x%x\n", in tpm_inf_pnp_probe()
522 rc = -EIO; in tpm_inf_pnp_probe()
535 dev_info(&dev->dev, "TPM found: " in tpm_inf_pnp_probe()
538 "chip version 0x%02x%02x, " in tpm_inf_pnp_probe()
539 "vendor id 0x%x%x (Infineon), " in tpm_inf_pnp_probe()
540 "product id 0x%02x%02x" in tpm_inf_pnp_probe()
552 chip = tpmm_chip_alloc(&dev->dev, &tpm_inf); in tpm_inf_pnp_probe()
553 if (IS_ERR(chip)) { in tpm_inf_pnp_probe()
554 rc = PTR_ERR(chip); in tpm_inf_pnp_probe()
558 rc = tpm_chip_register(chip); in tpm_inf_pnp_probe()
564 rc = -ENODEV; in tpm_inf_pnp_probe()
583 struct tpm_chip *chip = pnp_get_drvdata(dev); in tpm_inf_pnp_remove() local
585 tpm_chip_unregister(chip); in tpm_inf_pnp_remove()
600 /* Re-configure TPM after suspending */ in tpm_inf_resume()