blob: 87e26f5647e63dd3e2ca1b98fe617bb6a400813a [file] [log] [blame]
Sughosh Ganu90592ed2019-12-28 23:58:27 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2019, Linaro Limited
4 */
5
6#if !defined _RNG_H_
7#define _RNG_H_
8
Heinrich Schuchardt10a45cc2024-02-13 00:44:47 +01009#include <linux/types.h>
10
Sughosh Ganu90592ed2019-12-28 23:58:27 +053011struct udevice;
12
13/**
14 * dm_rng_read() - read a random number seed from the rng device
Sughosh Ganu90592ed2019-12-28 23:58:27 +053015 *
Heinrich Schuchardt40bb4e72020-06-13 12:29:52 +020016 * The function blocks until the requested number of bytes is read.
17 *
18 * @dev: random number generator device
19 * @buffer: input buffer to put the read random seed into
20 * @size: number of random bytes to read
21 * Return: 0 if OK, -ve on error
Sughosh Ganu90592ed2019-12-28 23:58:27 +053022 */
23int dm_rng_read(struct udevice *dev, void *buffer, size_t size);
24
Heinrich Schuchardt40bb4e72020-06-13 12:29:52 +020025/**
26 * struct dm_rng_ops - operations for the hwrng uclass
27 *
28 * This structures contains the function implemented by a hardware random
29 * number generation device.
30 */
Sughosh Ganu90592ed2019-12-28 23:58:27 +053031struct dm_rng_ops {
32 /**
Heinrich Schuchardt40bb4e72020-06-13 12:29:52 +020033 * @read: read a random bytes
Sughosh Ganu90592ed2019-12-28 23:58:27 +053034 *
Heinrich Schuchardt40bb4e72020-06-13 12:29:52 +020035 * The function blocks until the requested number of bytes is read.
Sughosh Ganu90592ed2019-12-28 23:58:27 +053036 *
Heinrich Schuchardt40bb4e72020-06-13 12:29:52 +020037 * @read.dev: random number generator device
38 * @read.data: input buffer to read the random seed into
39 * @read.max: number of random bytes to read
40 * @read.Return: 0 if OK, -ve on error
Sughosh Ganu90592ed2019-12-28 23:58:27 +053041 */
42 int (*read)(struct udevice *dev, void *data, size_t max);
43};
44
45#endif /* _RNG_H_ */