WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / platforms / pseries / rng.c
blob6268545947b8385a95459116132ec3b0163e6605
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright 2013, Michael Ellerman, IBM Corporation.
4 */
6 #define pr_fmt(fmt) "pseries-rng: " fmt
8 #include <linux/kernel.h>
9 #include <linux/of.h>
10 #include <asm/archrandom.h>
11 #include <asm/machdep.h>
12 #include <asm/plpar_wrappers.h>
15 static int pseries_get_random_long(unsigned long *v)
17 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
19 if (plpar_hcall(H_RANDOM, retbuf) == H_SUCCESS) {
20 *v = retbuf[0];
21 return 1;
24 return 0;
27 static __init int rng_init(void)
29 struct device_node *dn;
31 dn = of_find_compatible_node(NULL, NULL, "ibm,random");
32 if (!dn)
33 return -ENODEV;
35 pr_info("Registering arch random hook.\n");
37 ppc_md.get_random_seed = pseries_get_random_long;
39 of_node_put(dn);
40 return 0;
42 machine_subsys_initcall(pseries, rng_init);