aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinidhi Kasagar <srinidhi.kasagar@stericsson.com>2010-05-19 01:49:13 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-05-20 18:51:07 -0400
commit1944cc894fd4d2ecce9bab6940e464afbde4fef0 (patch)
tree5d6c95a2f254ff6690149e18a0fc82a1769fb522
parentf72caf7e496465182eeda842ac66a5e75404ddf1 (diff)
ARM: 6137/1: nomadik hwrng: Add clock support
This adds the clock support to the Nomadik RNG driver Signed-off-by: srinidhi kasagar <srinidhi.kasagar@stericsson.com> Acked-by: Linus walleij <linus.walleij@stericsson.com> Acked-by: Alessandro Rubini <rubini@unipv.it> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-nomadik/clock.c1
-rw-r--r--drivers/char/hw_random/nomadik-rng.c17
2 files changed, 18 insertions, 0 deletions
diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c
index 60f5bee09f2e..2c471fc451d7 100644
--- a/arch/arm/mach-nomadik/clock.c
+++ b/arch/arm/mach-nomadik/clock.c
@@ -56,6 +56,7 @@ static struct clk_lookup lookups[] = {
56 CLK(&clk_default, "gpio.1"), 56 CLK(&clk_default, "gpio.1"),
57 CLK(&clk_default, "gpio.2"), 57 CLK(&clk_default, "gpio.2"),
58 CLK(&clk_default, "gpio.3"), 58 CLK(&clk_default, "gpio.3"),
59 CLK(&clk_default, "rng"),
59}; 60};
60 61
61static int __init clk_init(void) 62static int __init clk_init(void)
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
21static struct clk *rng_clk;
18 22
19static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) 23static 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);
58out_release: 71out_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