blob: 1b132a3413bff28bbd2247d62014b6c2c2db725e [file] [log] [blame]
developer870b85a2021-07-02 10:54:11 +08001From 6d4a858d6f7db2a86f6513a543feb8f7b8a8b4c1 Mon Sep 17 00:00:00 2001
2From: "Mingming.Su" <Mingming.Su@mediatek.com>
3Date: Wed, 30 Jun 2021 16:59:32 +0800
4Subject: [PATCH] mt7986: trng: add rng support
5
61. Add trng compatible name for MT7986
72. Fix mtk_rng_wait_ready() function
8
9Signed-off-by: Mingming.Su <Mingming.Su@mediatek.com>
10---
11 drivers/char/hw_random/mtk-rng.c | 5 +++--
12 1 file changed, 3 insertions(+), 2 deletions(-)
13
14diff --git a/drivers/char/hw_random/mtk-rng.c b/drivers/char/hw_random/mtk-rng.c
15index e649be5a5..496adb0a0 100644
16--- a/drivers/char/hw_random/mtk-rng.c
17+++ b/drivers/char/hw_random/mtk-rng.c
18@@ -22,7 +22,7 @@
19 #define RNG_AUTOSUSPEND_TIMEOUT 100
20
21 #define USEC_POLL 2
22-#define TIMEOUT_POLL 20
23+#define TIMEOUT_POLL 60
24
25 #define RNG_CTRL 0x00
26 #define RNG_EN BIT(0)
27@@ -77,7 +77,7 @@ static bool mtk_rng_wait_ready(struct hwrng *rng, bool wait)
28 readl_poll_timeout_atomic(priv->base + RNG_CTRL, ready,
29 ready & RNG_READY, USEC_POLL,
30 TIMEOUT_POLL);
31- return !!ready;
32+ return !!(ready & RNG_READY);
33 }
34
35 static int mtk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
36@@ -181,6 +181,7 @@ static UNIVERSAL_DEV_PM_OPS(mtk_rng_pm_ops, mtk_rng_runtime_suspend,
37 #endif /* CONFIG_PM */
38
39 static const struct of_device_id mtk_rng_match[] = {
40+ { .compatible = "mediatek,mt7986-rng" },
41 { .compatible = "mediatek,mt7623-rng" },
42 {},
43 };
44--
452.18.0
46