15 #include <linux/kernel.h>
16 #include <linux/module.h>
19 #define DATA_REG_OFFSET 0x0200
20 #define CSR_REG_OFFSET 0x0278
21 #define CSR_OUT_EMPTY_MASK (1 << 24)
22 #define CSR_FAULT_MASK (1 << 1)
23 #define TRNG_BLOCK_RESET_MASK (1 << 0)
24 #define TAI_REG_OFFSET 0x0380
32 #define PICO_TRNG_TIMEOUT 20
35 static struct clk *rng_clk;
38 static inline u32 picoxcell_trng_read_csr(
void)
43 static inline bool picoxcell_trng_is_empty(
void)
54 static void picoxcell_trng_start(
void)
60 static void picoxcell_trng_reset(
void)
64 picoxcell_trng_start();
71 static int picoxcell_trng_read(
struct hwrng *rng,
void *
buf,
size_t max,
85 dev_err(rng_dev,
"fault detected, resetting TRNG\n");
86 picoxcell_trng_reset();
97 static struct hwrng picoxcell_trng = {
99 .read = picoxcell_trng_read,
114 dev_warn(&pdev->
dev,
"unable to request io mem\n");
125 if (IS_ERR(rng_clk)) {
127 return PTR_ERR(rng_clk);
136 picoxcell_trng_start();
141 rng_dev = &pdev->
dev;
142 dev_info(&pdev->
dev,
"pixoxcell random number generator active\n");
164 static int picoxcell_trng_suspend(
struct device *
dev)
171 static int picoxcell_trng_resume(
struct device *
dev)
176 static const struct dev_pm_ops picoxcell_trng_pm_ops = {
177 .
suspend = picoxcell_trng_suspend,
178 .resume = picoxcell_trng_resume,
183 .probe = picoxcell_trng_probe,
186 .name =
"picoxcell-trng",
189 .pm = &picoxcell_trng_pm_ops,