23 #include <linux/kernel.h>
24 #include <linux/module.h>
32 #define EXYNOS_PRNG_STATUS_OFFSET 0x10
33 #define EXYNOS_PRNG_SEED_OFFSET 0x140
34 #define EXYNOS_PRNG_OUT1_OFFSET 0x160
35 #define SEED_SETTING_DONE BIT(1)
36 #define PRNG_START 0x18
37 #define PRNG_DONE BIT(5)
38 #define EXYNOS_AUTOSUSPEND_DELAY 100
57 static int exynos_init(
struct hwrng *rng)
60 struct exynos_rng, rng);
64 pm_runtime_get_sync(exynos_rng->
dev);
66 for (i = 0 ; i < 5 ; i++)
67 exynos_rng_writel(exynos_rng, jiffies,
74 pm_runtime_put_noidle(exynos_rng->
dev);
79 static int exynos_read(
struct hwrng *rng,
void *
buf,
83 struct exynos_rng, rng);
86 pm_runtime_get_sync(exynos_rng->
dev);
90 while (!(exynos_rng_readl(exynos_rng,
98 pm_runtime_mark_last_busy(exynos_rng->
dev);
99 pm_runtime_autosuspend(exynos_rng->
dev);
106 struct exynos_rng *exynos_rng;
113 exynos_rng->
dev = &pdev->
dev;
114 exynos_rng->
rng.name =
"exynos";
115 exynos_rng->
rng.init = exynos_init;
116 exynos_rng->
rng.read = exynos_read;
118 if (IS_ERR(exynos_rng->
clk)) {
125 if (!exynos_rng->
mem)
128 platform_set_drvdata(pdev, exynos_rng);
131 pm_runtime_use_autosuspend(&pdev->
dev);
139 struct exynos_rng *exynos_rng = platform_get_drvdata(pdev);
146 static int exynos_rng_runtime_suspend(
struct device *
dev)
149 struct exynos_rng *exynos_rng = platform_get_drvdata(pdev);
151 clk_disable_unprepare(exynos_rng->
clk);
156 static int exynos_rng_runtime_resume(
struct device *
dev)
159 struct exynos_rng *exynos_rng = platform_get_drvdata(pdev);
161 return clk_prepare_enable(exynos_rng->
clk);
166 exynos_rng_runtime_resume,
NULL);
170 .name =
"exynos-rng",
172 .pm = &exynos_rng_pm_ops,
174 .probe = exynos_rng_probe,