diff options
Diffstat (limited to 'drivers/char/hw_random/nomadik-rng.c')
-rw-r--r-- | drivers/char/hw_random/nomadik-rng.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c index a8b4c4010144..a348c7e9aa0b 100644 --- a/drivers/char/hw_random/nomadik-rng.c +++ b/drivers/char/hw_random/nomadik-rng.c | |||
@@ -15,6 +15,10 @@ | |||
15 | #include <linux/amba/bus.h> | 15 | #include <linux/amba/bus.h> |
16 | #include <linux/hw_random.h> | 16 | #include <linux/hw_random.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/clk.h> | ||
19 | #include <linux/err.h> | ||
20 | |||
21 | static struct clk *rng_clk; | ||
18 | 22 | ||
19 | static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) | 23 | static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) |
20 | { | 24 | { |
@@ -40,6 +44,15 @@ static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id) | |||
40 | void __iomem *base; | 44 | void __iomem *base; |
41 | int ret; | 45 | int ret; |
42 | 46 | ||
47 | rng_clk = clk_get(&dev->dev, NULL); | ||
48 | if (IS_ERR(rng_clk)) { | ||
49 | dev_err(&dev->dev, "could not get rng clock\n"); | ||
50 | ret = PTR_ERR(rng_clk); | ||
51 | return ret; | ||
52 | } | ||
53 | |||
54 | clk_enable(rng_clk); | ||
55 | |||
43 | ret = amba_request_regions(dev, dev->dev.init_name); | 56 | ret = amba_request_regions(dev, dev->dev.init_name); |
44 | if (ret) | 57 | if (ret) |
45 | return ret; | 58 | return ret; |
@@ -57,6 +70,8 @@ out_unmap: | |||
57 | iounmap(base); | 70 | iounmap(base); |
58 | out_release: | 71 | out_release: |
59 | amba_release_regions(dev); | 72 | amba_release_regions(dev); |
73 | clk_disable(rng_clk); | ||
74 | clk_put(rng_clk); | ||
60 | return ret; | 75 | return ret; |
61 | } | 76 | } |
62 | 77 | ||
@@ -66,6 +81,8 @@ static int nmk_rng_remove(struct amba_device *dev) | |||
66 | hwrng_unregister(&nmk_rng); | 81 | hwrng_unregister(&nmk_rng); |
67 | iounmap(base); | 82 | iounmap(base); |
68 | amba_release_regions(dev); | 83 | amba_release_regions(dev); |
84 | clk_disable(rng_clk); | ||
85 | clk_put(rng_clk); | ||
69 | return 0; | 86 | return 0; |
70 | } | 87 | } |
71 | 88 | ||