Lines Matching +full:locality +full:- +full:specific
1 // SPDX-License-Identifier: GPL-2.0-only
13 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
39 if (!chip->ops->request_locality) in tpm_request_locality()
42 rc = chip->ops->request_locality(chip, 0); in tpm_request_locality()
46 chip->locality = rc; in tpm_request_locality()
54 if (!chip->ops->relinquish_locality) in tpm_relinquish_locality()
57 rc = chip->ops->relinquish_locality(chip, chip->locality); in tpm_relinquish_locality()
59 dev_err(&chip->dev, "%s: : error %d\n", __func__, rc); in tpm_relinquish_locality()
61 chip->locality = -1; in tpm_relinquish_locality()
66 if (!chip->ops->cmd_ready) in tpm_cmd_ready()
69 return chip->ops->cmd_ready(chip); in tpm_cmd_ready()
74 if (!chip->ops->go_idle) in tpm_go_idle()
77 return chip->ops->go_idle(chip); in tpm_go_idle()
82 if (chip->ops->clk_enable) in tpm_clk_enable()
83 chip->ops->clk_enable(chip, true); in tpm_clk_enable()
88 if (chip->ops->clk_enable) in tpm_clk_disable()
89 chip->ops->clk_enable(chip, false); in tpm_clk_disable()
93 * tpm_chip_start() - power on the TPM
97 * * The response length - OK
98 * * -errno - A system error
106 if (chip->locality == -1) { in tpm_chip_start()
126 * tpm_chip_stop() - power off the TPM
130 * * The response length - OK
131 * * -errno - A system error
142 * tpm_try_get_ops() - Get a ref to the tpm_chip
150 * Returns -ERRNO if the chip could not be got.
154 int rc = -EIO; in tpm_try_get_ops()
156 get_device(&chip->dev); in tpm_try_get_ops()
158 down_read(&chip->ops_sem); in tpm_try_get_ops()
159 if (!chip->ops) in tpm_try_get_ops()
162 mutex_lock(&chip->tpm_mutex); in tpm_try_get_ops()
169 mutex_unlock(&chip->tpm_mutex); in tpm_try_get_ops()
171 up_read(&chip->ops_sem); in tpm_try_get_ops()
172 put_device(&chip->dev); in tpm_try_get_ops()
178 * tpm_put_ops() - Release a ref to the tpm_chip
187 mutex_unlock(&chip->tpm_mutex); in tpm_put_ops()
188 up_read(&chip->ops_sem); in tpm_put_ops()
189 put_device(&chip->dev); in tpm_put_ops()
194 * tpm_default_chip() - find a TPM chip and get a reference to it
208 get_device(&chip->dev); in tpm_default_chip()
221 * tpm_find_get_ops() - find and reserve a TPM chip
250 put_device(&chip->dev); in tpm_find_get_ops()
257 * tpm_dev_release() - free chip memory and the device number
267 idr_remove(&dev_nums_idr, chip->dev_num); in tpm_dev_release()
270 kfree(chip->log.bios_event_log); in tpm_dev_release()
271 kfree(chip->work_space.context_buf); in tpm_dev_release()
272 kfree(chip->work_space.session_buf); in tpm_dev_release()
273 kfree(chip->allocated_banks); in tpm_dev_release()
278 * tpm_class_shutdown() - prepare the TPM device for loss of power.
282 * TPM 2.0 spec. Then, calls bus- and device- specific shutdown code.
290 down_write(&chip->ops_sem); in tpm_class_shutdown()
291 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_class_shutdown()
297 chip->ops = NULL; in tpm_class_shutdown()
298 up_write(&chip->ops_sem); in tpm_class_shutdown()
304 * tpm_chip_alloc() - allocate a new struct tpm_chip instance
311 * device number for it. Must be paired with put_device(&chip->dev).
321 return ERR_PTR(-ENOMEM); in tpm_chip_alloc()
323 mutex_init(&chip->tpm_mutex); in tpm_chip_alloc()
324 init_rwsem(&chip->ops_sem); in tpm_chip_alloc()
326 chip->ops = ops; in tpm_chip_alloc()
336 chip->dev_num = rc; in tpm_chip_alloc()
338 device_initialize(&chip->dev); in tpm_chip_alloc()
340 chip->dev.class = tpm_class; in tpm_chip_alloc()
341 chip->dev.class->shutdown_pre = tpm_class_shutdown; in tpm_chip_alloc()
342 chip->dev.release = tpm_dev_release; in tpm_chip_alloc()
343 chip->dev.parent = pdev; in tpm_chip_alloc()
344 chip->dev.groups = chip->groups; in tpm_chip_alloc()
346 if (chip->dev_num == 0) in tpm_chip_alloc()
347 chip->dev.devt = MKDEV(MISC_MAJOR, TPM_MINOR); in tpm_chip_alloc()
349 chip->dev.devt = MKDEV(MAJOR(tpm_devt), chip->dev_num); in tpm_chip_alloc()
351 rc = dev_set_name(&chip->dev, "tpm%d", chip->dev_num); in tpm_chip_alloc()
356 chip->flags |= TPM_CHIP_FLAG_VIRTUAL; in tpm_chip_alloc()
358 cdev_init(&chip->cdev, &tpm_fops); in tpm_chip_alloc()
359 chip->cdev.owner = THIS_MODULE; in tpm_chip_alloc()
361 rc = tpm2_init_space(&chip->work_space, TPM2_SPACE_BUFFER_SIZE); in tpm_chip_alloc()
363 rc = -ENOMEM; in tpm_chip_alloc()
367 chip->locality = -1; in tpm_chip_alloc()
371 put_device(&chip->dev); in tpm_chip_alloc()
377 * tpmm_chip_alloc() - allocate a new struct tpm_chip instance
395 &chip->dev); in tpmm_chip_alloc()
409 rc = cdev_device_add(&chip->cdev, &chip->dev); in tpm_add_char_device()
411 dev_err(&chip->dev, in tpm_add_char_device()
413 dev_name(&chip->dev), MAJOR(chip->dev.devt), in tpm_add_char_device()
414 MINOR(chip->dev.devt), rc); in tpm_add_char_device()
418 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_add_char_device()
426 idr_replace(&dev_nums_idr, chip, chip->dev_num); in tpm_add_char_device()
432 cdev_device_del(&chip->cdev, &chip->dev); in tpm_add_char_device()
438 cdev_device_del(&chip->cdev, &chip->dev); in tpm_del_char_device()
442 idr_replace(&dev_nums_idr, NULL, chip->dev_num); in tpm_del_char_device()
446 down_write(&chip->ops_sem); in tpm_del_char_device()
447 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_del_char_device()
453 chip->ops = NULL; in tpm_del_char_device()
454 up_write(&chip->ops_sem); in tpm_del_char_device()
461 if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) in tpm_del_legacy_sysfs()
464 sysfs_remove_link(&chip->dev.parent->kobj, "ppi"); in tpm_del_legacy_sysfs()
466 for (i = chip->groups[0]->attrs; *i != NULL; ++i) in tpm_del_legacy_sysfs()
467 sysfs_remove_link(&chip->dev.parent->kobj, (*i)->name); in tpm_del_legacy_sysfs()
479 if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) in tpm_add_legacy_sysfs()
483 &chip->dev.parent->kobj, &chip->dev.kobj, "ppi", NULL); in tpm_add_legacy_sysfs()
484 if (rc && rc != -ENOENT) in tpm_add_legacy_sysfs()
487 /* All the names from tpm-sysfs */ in tpm_add_legacy_sysfs()
488 for (i = chip->groups[0]->attrs; *i != NULL; ++i) { in tpm_add_legacy_sysfs()
490 &chip->dev.parent->kobj, &chip->dev.kobj, (*i)->name, NULL); in tpm_add_legacy_sysfs()
512 snprintf(chip->hwrng_name, sizeof(chip->hwrng_name), in tpm_add_hwrng()
513 "tpm-rng-%d", chip->dev_num); in tpm_add_hwrng()
514 chip->hwrng.name = chip->hwrng_name; in tpm_add_hwrng()
515 chip->hwrng.read = tpm_hwrng_read; in tpm_add_hwrng()
516 return hwrng_register(&chip->hwrng); in tpm_add_hwrng()
523 rc = (chip->flags & TPM_CHIP_FLAG_TPM2) ? in tpm_get_pcr_allocation()
528 return -ENODEV; in tpm_get_pcr_allocation()
534 * tpm_chip_register() - create a character device for the TPM chip
539 * chips available for in-kernel use.
586 hwrng_unregister(&chip->hwrng); in tpm_chip_register()
595 * tpm_chip_unregister() - release the TPM driver
611 hwrng_unregister(&chip->hwrng); in tpm_chip_unregister()
613 if (chip->flags & TPM_CHIP_FLAG_TPM2) in tpm_chip_unregister()