]>
Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
a489043f ME |
2 | /* |
3 | * Copyright 2013, Michael Ellerman, IBM Corporation. | |
a489043f ME |
4 | */ |
5 | ||
6 | #define pr_fmt(fmt) "pseries-rng: " fmt | |
7 | ||
8 | #include <linux/kernel.h> | |
9 | #include <linux/of.h> | |
10 | #include <asm/archrandom.h> | |
11 | #include <asm/machdep.h> | |
148924f7 | 12 | #include <asm/plpar_wrappers.h> |
a489043f ME |
13 | |
14 | ||
15 | static int pseries_get_random_long(unsigned long *v) | |
16 | { | |
17 | unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; | |
18 | ||
19 | if (plpar_hcall(H_RANDOM, retbuf) == H_SUCCESS) { | |
20 | *v = retbuf[0]; | |
21 | return 1; | |
22 | } | |
23 | ||
24 | return 0; | |
25 | } | |
26 | ||
27 | static __init int rng_init(void) | |
28 | { | |
29 | struct device_node *dn; | |
30 | ||
31 | dn = of_find_compatible_node(NULL, NULL, "ibm,random"); | |
32 | if (!dn) | |
33 | return -ENODEV; | |
34 | ||
35 | pr_info("Registering arch random hook.\n"); | |
36 | ||
01c9348c | 37 | ppc_md.get_random_seed = pseries_get_random_long; |
a489043f ME |
38 | |
39 | return 0; | |
40 | } | |
8e83e905 | 41 | machine_subsys_initcall(pseries, rng_init); |