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->work_space.context_buf); in tpm_dev_release()
271 kfree(chip->work_space.session_buf); in tpm_dev_release()
272 kfree(chip->allocated_banks); in tpm_dev_release()
277 * tpm_class_shutdown() - prepare the TPM device for loss of power.
281 * TPM 2.0 spec. Then, calls bus- and device- specific shutdown code.
289 down_write(&chip->ops_sem); in tpm_class_shutdown()
290 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_class_shutdown()
296 chip->ops = NULL; in tpm_class_shutdown()
297 up_write(&chip->ops_sem); in tpm_class_shutdown()
303 * tpm_chip_alloc() - allocate a new struct tpm_chip instance
310 * device number for it. Must be paired with put_device(&chip->dev).
320 return ERR_PTR(-ENOMEM); in tpm_chip_alloc()
322 mutex_init(&chip->tpm_mutex); in tpm_chip_alloc()
323 init_rwsem(&chip->ops_sem); in tpm_chip_alloc()
325 chip->ops = ops; in tpm_chip_alloc()
335 chip->dev_num = rc; in tpm_chip_alloc()
337 device_initialize(&chip->dev); in tpm_chip_alloc()
339 chip->dev.class = tpm_class; in tpm_chip_alloc()
340 chip->dev.class->shutdown_pre = tpm_class_shutdown; in tpm_chip_alloc()
341 chip->dev.release = tpm_dev_release; in tpm_chip_alloc()
342 chip->dev.parent = pdev; in tpm_chip_alloc()
343 chip->dev.groups = chip->groups; in tpm_chip_alloc()
345 if (chip->dev_num == 0) in tpm_chip_alloc()
346 chip->dev.devt = MKDEV(MISC_MAJOR, TPM_MINOR); in tpm_chip_alloc()
348 chip->dev.devt = MKDEV(MAJOR(tpm_devt), chip->dev_num); in tpm_chip_alloc()
350 rc = dev_set_name(&chip->dev, "tpm%d", chip->dev_num); in tpm_chip_alloc()
355 chip->flags |= TPM_CHIP_FLAG_VIRTUAL; in tpm_chip_alloc()
357 cdev_init(&chip->cdev, &tpm_fops); in tpm_chip_alloc()
358 chip->cdev.owner = THIS_MODULE; in tpm_chip_alloc()
360 rc = tpm2_init_space(&chip->work_space, TPM2_SPACE_BUFFER_SIZE); in tpm_chip_alloc()
362 rc = -ENOMEM; in tpm_chip_alloc()
366 chip->locality = -1; in tpm_chip_alloc()
370 put_device(&chip->dev); in tpm_chip_alloc()
376 * tpmm_chip_alloc() - allocate a new struct tpm_chip instance
394 &chip->dev); in tpmm_chip_alloc()
408 rc = cdev_device_add(&chip->cdev, &chip->dev); in tpm_add_char_device()
410 dev_err(&chip->dev, in tpm_add_char_device()
412 dev_name(&chip->dev), MAJOR(chip->dev.devt), in tpm_add_char_device()
413 MINOR(chip->dev.devt), rc); in tpm_add_char_device()
417 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_add_char_device()
425 idr_replace(&dev_nums_idr, chip, chip->dev_num); in tpm_add_char_device()
431 cdev_device_del(&chip->cdev, &chip->dev); in tpm_add_char_device()
437 cdev_device_del(&chip->cdev, &chip->dev); in tpm_del_char_device()
441 idr_replace(&dev_nums_idr, NULL, chip->dev_num); in tpm_del_char_device()
445 down_write(&chip->ops_sem); in tpm_del_char_device()
446 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_del_char_device()
452 chip->ops = NULL; in tpm_del_char_device()
453 up_write(&chip->ops_sem); in tpm_del_char_device()
460 if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) in tpm_del_legacy_sysfs()
463 sysfs_remove_link(&chip->dev.parent->kobj, "ppi"); in tpm_del_legacy_sysfs()
465 for (i = chip->groups[0]->attrs; *i != NULL; ++i) in tpm_del_legacy_sysfs()
466 sysfs_remove_link(&chip->dev.parent->kobj, (*i)->name); in tpm_del_legacy_sysfs()
478 if (chip->flags & (TPM_CHIP_FLAG_TPM2 | TPM_CHIP_FLAG_VIRTUAL)) in tpm_add_legacy_sysfs()
482 &chip->dev.parent->kobj, &chip->dev.kobj, "ppi", NULL); in tpm_add_legacy_sysfs()
483 if (rc && rc != -ENOENT) in tpm_add_legacy_sysfs()
486 /* All the names from tpm-sysfs */ in tpm_add_legacy_sysfs()
487 for (i = chip->groups[0]->attrs; *i != NULL; ++i) { in tpm_add_legacy_sysfs()
489 &chip->dev.parent->kobj, &chip->dev.kobj, (*i)->name, NULL); in tpm_add_legacy_sysfs()
511 snprintf(chip->hwrng_name, sizeof(chip->hwrng_name), in tpm_add_hwrng()
512 "tpm-rng-%d", chip->dev_num); in tpm_add_hwrng()
513 chip->hwrng.name = chip->hwrng_name; in tpm_add_hwrng()
514 chip->hwrng.read = tpm_hwrng_read; in tpm_add_hwrng()
515 return hwrng_register(&chip->hwrng); in tpm_add_hwrng()
522 rc = (chip->flags & TPM_CHIP_FLAG_TPM2) ? in tpm_get_pcr_allocation()
527 return -ENODEV; in tpm_get_pcr_allocation()
533 * tpm_chip_register() - create a character device for the TPM chip
538 * chips available for in-kernel use.
585 hwrng_unregister(&chip->hwrng); in tpm_chip_register()
594 * tpm_chip_unregister() - release the TPM driver
610 hwrng_unregister(&chip->hwrng); in tpm_chip_unregister()
612 if (chip->flags & TPM_CHIP_FLAG_TPM2) in tpm_chip_unregister()