0001
0002
0003
0004
0005
0006 #define pr_fmt(fmt) "pseries-rng: " fmt
0007
0008 #include <linux/kernel.h>
0009 #include <linux/of.h>
0010 #include <asm/archrandom.h>
0011 #include <asm/machdep.h>
0012 #include <asm/plpar_wrappers.h>
0013 #include "pseries.h"
0014
0015
0016 static int pseries_get_random_long(unsigned long *v)
0017 {
0018 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
0019
0020 if (plpar_hcall(H_RANDOM, retbuf) == H_SUCCESS) {
0021 *v = retbuf[0];
0022 return 1;
0023 }
0024
0025 return 0;
0026 }
0027
0028 void __init pseries_rng_init(void)
0029 {
0030 struct device_node *dn;
0031
0032 dn = of_find_compatible_node(NULL, NULL, "ibm,random");
0033 if (!dn)
0034 return;
0035 ppc_md.get_random_seed = pseries_get_random_long;
0036 of_node_put(dn);
0037 }