Skip to content

Commit

Permalink
ARM: 6137/1: nomadik hwrng: Add clock support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Srinidhi Kasagar authored and Russell King committed May 20, 2010
1 parent f72caf7 commit 1944cc8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm/mach-nomadik/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static struct clk_lookup lookups[] = {
CLK(&clk_default, "gpio.1"),
CLK(&clk_default, "gpio.2"),
CLK(&clk_default, "gpio.3"),
CLK(&clk_default, "rng"),
};

static int __init clk_init(void)
Expand Down
17 changes: 17 additions & 0 deletions drivers/char/hw_random/nomadik-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <linux/amba/bus.h>
#include <linux/hw_random.h>
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/err.h>

static struct clk *rng_clk;

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

rng_clk = clk_get(&dev->dev, NULL);
if (IS_ERR(rng_clk)) {
dev_err(&dev->dev, "could not get rng clock\n");
ret = PTR_ERR(rng_clk);
return ret;
}

clk_enable(rng_clk);

ret = amba_request_regions(dev, dev->dev.init_name);
if (ret)
return ret;
Expand All @@ -57,6 +70,8 @@ static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id)
iounmap(base);
out_release:
amba_release_regions(dev);
clk_disable(rng_clk);
clk_put(rng_clk);
return ret;
}

Expand All @@ -66,6 +81,8 @@ static int nmk_rng_remove(struct amba_device *dev)
hwrng_unregister(&nmk_rng);
iounmap(base);
amba_release_regions(dev);
clk_disable(rng_clk);
clk_put(rng_clk);
return 0;
}

Expand Down

0 comments on commit 1944cc8

Please sign in to comment.