Skip to content

Commit 1944cc8

Browse files
Srinidhi KasagarRussell King
authored andcommitted
ARM: 6137/1: nomadik hwrng: Add clock support
This adds the clock support to the Nomadik RNG driver Signed-off-by: srinidhi kasagar <[email protected]> Acked-by: Linus walleij <[email protected]> Acked-by: Alessandro Rubini <[email protected]> Acked-by: Herbert Xu <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent f72caf7 commit 1944cc8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

arch/arm/mach-nomadik/clock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static struct clk_lookup lookups[] = {
5656
CLK(&clk_default, "gpio.1"),
5757
CLK(&clk_default, "gpio.2"),
5858
CLK(&clk_default, "gpio.3"),
59+
CLK(&clk_default, "rng"),
5960
};
6061

6162
static int __init clk_init(void)

drivers/char/hw_random/nomadik-rng.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include <linux/amba/bus.h>
1616
#include <linux/hw_random.h>
1717
#include <linux/io.h>
18+
#include <linux/clk.h>
19+
#include <linux/err.h>
20+
21+
static struct clk *rng_clk;
1822

1923
static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
2024
{
@@ -40,6 +44,15 @@ static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id)
4044
void __iomem *base;
4145
int ret;
4246

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+
4356
ret = amba_request_regions(dev, dev->dev.init_name);
4457
if (ret)
4558
return ret;
@@ -57,6 +70,8 @@ static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id)
5770
iounmap(base);
5871
out_release:
5972
amba_release_regions(dev);
73+
clk_disable(rng_clk);
74+
clk_put(rng_clk);
6075
return ret;
6176
}
6277

@@ -66,6 +81,8 @@ static int nmk_rng_remove(struct amba_device *dev)
6681
hwrng_unregister(&nmk_rng);
6782
iounmap(base);
6883
amba_release_regions(dev);
84+
clk_disable(rng_clk);
85+
clk_put(rng_clk);
6986
return 0;
7087
}
7188

0 commit comments

Comments
 (0)