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 */
144 static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo) in empty_fifo() argument
163 this has nothing to say, since the TPM will give its answer in empty_fifo()
176 return -EIO; in empty_fifo()
181 static int wait(struct tpm_chip *chip, int wait_for_bit) in wait() argument
187 /* check the status-register if wait_for_bit is set */ in wait()
194 dev_err(&chip->dev, "Timeout in wait(STAT_XFE)\n"); in wait()
196 dev_err(&chip->dev, "Timeout in wait(STAT_RDA)\n"); in wait()
197 return -EIO; in wait()
202 static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) in wait_and_send() argument
204 wait(chip, STAT_XFE); in wait_and_send()
208 /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more
209 calculation time, it sends a WTX-package, which has to be acknowledged
211 creation. Set the maximum number of WTX-packages in the definitions
212 above, if the number is reached, the waiting-time will be denied
213 and the TPM command has to be resend.
216 static void tpm_wtx(struct tpm_chip *chip) in tpm_wtx() argument
219 dev_info(&chip->dev, "Granting WTX (%02d / %02d)\n", in tpm_wtx()
221 wait_and_send(chip, TPM_VL_VER); in tpm_wtx()
222 wait_and_send(chip, TPM_CTRL_WTX); in tpm_wtx()
223 wait_and_send(chip, 0x00); in tpm_wtx()
224 wait_and_send(chip, 0x00); in tpm_wtx()
228 static void tpm_wtx_abort(struct tpm_chip *chip) in tpm_wtx_abort() argument
230 dev_info(&chip->dev, "Aborting WTX\n"); in tpm_wtx_abort()
231 wait_and_send(chip, TPM_VL_VER); in tpm_wtx_abort()
232 wait_and_send(chip, TPM_CTRL_WTX_ABORT); in tpm_wtx_abort()
233 wait_and_send(chip, 0x00); in tpm_wtx_abort()
234 wait_and_send(chip, 0x00); in tpm_wtx_abort()
239 static int tpm_inf_recv(struct tpm_chip *chip, u8 * buf, size_t count) in tpm_inf_recv() argument
249 ret = wait(chip, STAT_RDA); in tpm_inf_recv()
251 return -EIO; in tpm_inf_recv()
256 dev_err(&chip->dev, in tpm_inf_recv()
258 return -EIO; in tpm_inf_recv()
266 wait(chip, STAT_RDA); in tpm_inf_recv()
271 dev_err(&chip->dev, "Error handling on vendor layer!\n"); in tpm_inf_recv()
272 return -EIO; in tpm_inf_recv()
278 size = size - 6; in tpm_inf_recv()
283 dev_info(&chip->dev, "WTX-package received\n"); in tpm_inf_recv()
285 tpm_wtx(chip); in tpm_inf_recv()
288 tpm_wtx_abort(chip); in tpm_inf_recv()
294 dev_info(&chip->dev, "WTX-abort acknowledged\n"); in tpm_inf_recv()
299 dev_err(&chip->dev, "ERROR-package received:\n"); in tpm_inf_recv()
301 dev_err(&chip->dev, in tpm_inf_recv()
302 "-> Negative acknowledgement" in tpm_inf_recv()
303 " - retransmit command!\n"); in tpm_inf_recv()
304 return -EIO; in tpm_inf_recv()
306 return -EIO; in tpm_inf_recv()
309 static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count) in tpm_inf_send() argument
318 ret = empty_fifo(chip, 1); in tpm_inf_send()
320 dev_err(&chip->dev, "Timeout while clearing FIFO\n"); in tpm_inf_send()
321 return -EIO; in tpm_inf_send()
324 ret = wait(chip, STAT_XFE); in tpm_inf_send()
326 return -EIO; in tpm_inf_send()
336 wait_and_send(chip, TPM_VL_VER); in tpm_inf_send()
337 wait_and_send(chip, TPM_CTRL_DATA); in tpm_inf_send()
338 wait_and_send(chip, count_high); in tpm_inf_send()
339 wait_and_send(chip, count_low); in tpm_inf_send()
342 wait_and_send(chip, TPM_VL_VER); in tpm_inf_send()
343 wait_and_send(chip, TPM_VL_CHANNEL_TPM); in tpm_inf_send()
344 wait_and_send(chip, count_4); in tpm_inf_send()
345 wait_and_send(chip, count_3); in tpm_inf_send()
346 wait_and_send(chip, count_2); in tpm_inf_send()
347 wait_and_send(chip, count_1); in tpm_inf_send()
351 wait_and_send(chip, buf[i]); in tpm_inf_send()
356 static void tpm_inf_cancel(struct tpm_chip *chip) in tpm_inf_cancel() argument
365 static u8 tpm_inf_status(struct tpm_chip *chip) in tpm_inf_status() argument
397 struct tpm_chip *chip; in tpm_inf_pnp_probe() local
399 /* read IO-ports through PnP */ in tpm_inf_pnp_probe()
410 rc = -EINVAL; in tpm_inf_pnp_probe()
413 dev_info(&dev->dev, "Found %s with ID %s\n", in tpm_inf_pnp_probe()
414 dev->name, dev_id->id); in tpm_inf_pnp_probe()
416 rc = -EINVAL; in tpm_inf_pnp_probe()
422 rc = -EINVAL; in tpm_inf_pnp_probe()
428 rc = -EINVAL; in tpm_inf_pnp_probe()
439 dev_info(&dev->dev, "Found %s with ID %s\n", in tpm_inf_pnp_probe()
440 dev->name, dev_id->id); in tpm_inf_pnp_probe()
445 rc = -EINVAL; in tpm_inf_pnp_probe()
452 rc = -EINVAL; in tpm_inf_pnp_probe()
466 rc = -EINVAL; in tpm_inf_pnp_probe()
470 /* query chip for its vendor, its version number a.s.o. */ in tpm_inf_pnp_probe()
493 chipname = " (unknown chip)"; in tpm_inf_pnp_probe()
499 /* configure TPM with IO-ports */ in tpm_inf_pnp_probe()
505 /* control if IO-ports are set correctly */ in tpm_inf_pnp_probe()
512 dev_err(&dev->dev, in tpm_inf_pnp_probe()
513 "Could not set IO-data registers to 0x%x\n", in tpm_inf_pnp_probe()
515 rc = -EIO; in tpm_inf_pnp_probe()
528 dev_info(&dev->dev, "TPM found: " in tpm_inf_pnp_probe()
531 "chip version 0x%02x%02x, " in tpm_inf_pnp_probe()
532 "vendor id 0x%x%x (Infineon), " in tpm_inf_pnp_probe()
533 "product id 0x%02x%02x" in tpm_inf_pnp_probe()
545 chip = tpmm_chip_alloc(&dev->dev, &tpm_inf); in tpm_inf_pnp_probe()
546 if (IS_ERR(chip)) { in tpm_inf_pnp_probe()
547 rc = PTR_ERR(chip); in tpm_inf_pnp_probe()
551 rc = tpm_chip_register(chip); in tpm_inf_pnp_probe()
557 rc = -ENODEV; in tpm_inf_pnp_probe()
576 struct tpm_chip *chip = pnp_get_drvdata(dev); in tpm_inf_pnp_remove() local
578 tpm_chip_unregister(chip); in tpm_inf_pnp_remove()
593 /* Re-configure TPM after suspending */ in tpm_inf_resume()