23 #include <linux/module.h>
24 #include <linux/kernel.h>
30 #include <linux/sched.h>
36 static void timeriomem_rng_trigger(
unsigned long);
37 static DEFINE_TIMER(timeriomem_rng_timer, timeriomem_rng_trigger, 0, 0);
42 static int timeriomem_rng_data_present(
struct hwrng *rng,
int wait)
47 if (!wait || timeriomem_rng_data->
present)
48 return timeriomem_rng_data->
present;
55 static int timeriomem_rng_data_read(
struct hwrng *rng,
u32 *
data)
65 delay = cur - timeriomem_rng_timer.expires;
66 delay = rng->
priv - (delay % rng->
priv);
68 timeriomem_rng_timer.expires = cur +
delay;
69 timeriomem_rng_data->
present = 0;
71 init_completion(&timeriomem_rng_data->
completion);
78 static void timeriomem_rng_trigger(
unsigned long dummy)
80 timeriomem_rng_data->
present = 1;
84 static struct hwrng timeriomem_rng_ops = {
86 .data_present = timeriomem_rng_data_present,
87 .data_read = timeriomem_rng_data_read,
101 timeriomem_rng_data = pdev->
dev.platform_data;
104 if (!timeriomem_rng_data->
address)
107 if (timeriomem_rng_data->
period != 0
109 timeriomem_rng_timer.expires =
jiffies;
112 timeriomem_rng_data->
period);
114 timeriomem_rng_data->
present = 1;
122 timeriomem_rng_data->
period);
145 .name =
"timeriomem_rng",
148 .probe = timeriomem_rng_probe,