Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-riscv
[platform/kernel/u-boot.git] / drivers / rng / tpm_rng.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2022, Linaro Limited
4  */
5
6 #include <dm.h>
7 #include <rng.h>
8 #include <tpm_api.h>
9
10 static int rng_tpm_random_read(struct udevice *dev, void *data, size_t count)
11 {
12         return tpm_get_random(dev_get_parent(dev), data, count);
13 }
14
15 static const struct dm_rng_ops tpm_rng_ops = {
16         .read = rng_tpm_random_read,
17 };
18
19 U_BOOT_DRIVER(tpm_rng) = {
20         .name   = "tpm-rng",
21         .id     = UCLASS_RNG,
22         .ops    = &tpm_rng_ops,
23 };