* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
@ 2009-12-05 11:31 Alessandro Rubini
2009-12-05 11:31 ` [PATCH V2 2/2] arm nomadik: add platform device for rng in cpu-8815 Alessandro Rubini
2009-12-05 18:56 ` [PATCH V2 1/2] arm nomadik: add hardware RNG driver Matt Mackall
0 siblings, 2 replies; 9+ messages in thread
From: Alessandro Rubini @ 2009-12-05 11:31 UTC (permalink / raw)
To: linux-arm-kernel
From: Alessandro Rubini <rubini@unipv.it>
The hardware random number generator by ST is used in both the Nomadik
8815 SoC and the U8500. It returns 16 bits every 400ns with automatic
delay if a read is issued too early. It depends on PLAT_NOMADIK.
Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
This V2 uses the new interface, so it depends on this patch from
cryptodev-2.6.git:
commit 9996508b3353063f2d6c48c1a28a84543d72d70b
Author: Ian Molton <ian.molton@collabora.co.uk>
Date: Tue Dec 1 14:47:32 2009 +0800
With dd I can fetch 3 MB/s of random data where /dev/urandom gives
0.4 M/s and /dev/zero gives 60 MB/s.
drivers/char/hw_random/Kconfig | 12 ++++
drivers/char/hw_random/Makefile | 1 +
drivers/char/hw_random/nomadik-rng.c | 103 ++++++++++++++++++++++++++++++++++
3 files changed, 116 insertions(+), 0 deletions(-)
create mode 100644 drivers/char/hw_random/nomadik-rng.c
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 8706026..6ea1014 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -186,3 +186,15 @@ config HW_RANDOM_MXC_RNGA
module will be called mxc-rnga.
If unsure, say Y.
+
+config HW_RANDOM_NOMADIK
+ tristate "ST-Ericsson Nomadik Random Number Generator support"
+ depends on HW_RANDOM && PLAT_NOMADIK
+ ---help---
+ This driver provides kernel-side support for the Random Number
+ Generator hardware found on ST-Ericsson SoCs (8815 and 8500).
+
+ To compile this driver as a module, choose M here: the
+ module will be called nomadik-rng.
+
+ If unsure, say Y.
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index 5eeb130..4273308 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -18,3 +18,4 @@ obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o
obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o
obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o
obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o
+obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o
diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c
new file mode 100644
index 0000000..a8b4c40
--- /dev/null
+++ b/drivers/char/hw_random/nomadik-rng.c
@@ -0,0 +1,103 @@
+/*
+ * Nomadik RNG support
+ * Copyright 2009 Alessandro Rubini
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/amba/bus.h>
+#include <linux/hw_random.h>
+#include <linux/io.h>
+
+static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
+{
+ void __iomem *base = (void __iomem *)rng->priv;
+
+ /*
+ * The register is 32 bits and gives 16 random bits (low half).
+ * A subsequent read will delay the core for 400ns, so we just read
+ * once and accept the very unlikely very small delay, even if wait==0.
+ */
+ *(u16 *)data = __raw_readl(base + 8) & 0xffff;
+ return 2;
+}
+
+/* we have at most one RNG per machine, granted */
+static struct hwrng nmk_rng = {
+ .name = "nomadik",
+ .read = nmk_rng_read,
+};
+
+static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id)
+{
+ void __iomem *base;
+ int ret;
+
+ ret = amba_request_regions(dev, dev->dev.init_name);
+ if (ret)
+ return ret;
+ ret = -ENOMEM;
+ base = ioremap(dev->res.start, resource_size(&dev->res));
+ if (!base)
+ goto out_release;
+ nmk_rng.priv = (unsigned long)base;
+ ret = hwrng_register(&nmk_rng);
+ if (ret)
+ goto out_unmap;
+ return 0;
+
+out_unmap:
+ iounmap(base);
+out_release:
+ amba_release_regions(dev);
+ return ret;
+}
+
+static int nmk_rng_remove(struct amba_device *dev)
+{
+ void __iomem *base = (void __iomem *)nmk_rng.priv;
+ hwrng_unregister(&nmk_rng);
+ iounmap(base);
+ amba_release_regions(dev);
+ return 0;
+}
+
+static struct amba_id nmk_rng_ids[] = {
+ {
+ .id = 0x000805e1,
+ .mask = 0x000fffff, /* top bits are rev and cfg: accept all */
+ },
+ {0, 0},
+};
+
+static struct amba_driver nmk_rng_driver = {
+ .drv = {
+ .owner = THIS_MODULE,
+ .name = "rng",
+ },
+ .probe = nmk_rng_probe,
+ .remove = nmk_rng_remove,
+ .id_table = nmk_rng_ids,
+};
+
+static int __init nmk_rng_init(void)
+{
+ return amba_driver_register(&nmk_rng_driver);
+}
+
+static void __devexit nmk_rng_exit(void)
+{
+ amba_driver_unregister(&nmk_rng_driver);
+}
+
+module_init(nmk_rng_init);
+module_exit(nmk_rng_exit);
+
+MODULE_LICENSE("GPL");
--
1.6.0.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH V2 2/2] arm nomadik: add platform device for rng in cpu-8815
2009-12-05 11:31 [PATCH V2 1/2] arm nomadik: add hardware RNG driver Alessandro Rubini
@ 2009-12-05 11:31 ` Alessandro Rubini
2009-12-05 18:56 ` [PATCH V2 1/2] arm nomadik: add hardware RNG driver Matt Mackall
1 sibling, 0 replies; 9+ messages in thread
From: Alessandro Rubini @ 2009-12-05 11:31 UTC (permalink / raw)
To: linux-arm-kernel
From: Alessandro Rubini <rubini@unipv.it>
Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
arch/arm/mach-nomadik/cpu-8815.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c
index f93c596..9bf33b3 100644
--- a/arch/arm/mach-nomadik/cpu-8815.c
+++ b/arch/arm/mach-nomadik/cpu-8815.c
@@ -86,11 +86,19 @@ static struct amba_device cpu8815_amba_gpio[] = {
},
};
+static struct amba_device cpu8815_amba_rng = {
+ .dev = {
+ .init_name = "rng",
+ },
+ __MEM_4K_RESOURCE(NOMADIK_RNG_BASE),
+};
+
static struct amba_device *amba_devs[] __initdata = {
cpu8815_amba_gpio + 0,
cpu8815_amba_gpio + 1,
cpu8815_amba_gpio + 2,
cpu8815_amba_gpio + 3,
+ &cpu8815_amba_rng
};
static int __init cpu8815_init(void)
--
1.6.0.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
2009-12-05 11:31 [PATCH V2 1/2] arm nomadik: add hardware RNG driver Alessandro Rubini
2009-12-05 11:31 ` [PATCH V2 2/2] arm nomadik: add platform device for rng in cpu-8815 Alessandro Rubini
@ 2009-12-05 18:56 ` Matt Mackall
2009-12-11 6:15 ` Herbert Xu
2009-12-19 11:47 ` Herbert Xu
1 sibling, 2 replies; 9+ messages in thread
From: Matt Mackall @ 2009-12-05 18:56 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Dec 05, 2009 at 12:31:28PM +0100, Alessandro Rubini wrote:
> From: Alessandro Rubini <rubini@unipv.it>
>
> The hardware random number generator by ST is used in both the Nomadik
> 8815 SoC and the U8500. It returns 16 bits every 400ns with automatic
> delay if a read is issued too early. It depends on PLAT_NOMADIK.
>
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
Looks good to me.
Acked-by: Matt Mackall <mpm@selenic.com>
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
2009-12-05 18:56 ` [PATCH V2 1/2] arm nomadik: add hardware RNG driver Matt Mackall
@ 2009-12-11 6:15 ` Herbert Xu
2009-12-17 8:36 ` Alessandro Rubini
2009-12-19 11:47 ` Herbert Xu
1 sibling, 1 reply; 9+ messages in thread
From: Herbert Xu @ 2009-12-11 6:15 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Dec 05, 2009 at 12:56:46PM -0600, Matt Mackall wrote:
> On Sat, Dec 05, 2009 at 12:31:28PM +0100, Alessandro Rubini wrote:
> > From: Alessandro Rubini <rubini@unipv.it>
> >
> > The hardware random number generator by ST is used in both the Nomadik
> > 8815 SoC and the U8500. It returns 16 bits every 400ns with automatic
> > delay if a read is issued too early. It depends on PLAT_NOMADIK.
> >
> > Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> > Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
>
> Looks good to me.
>
> Acked-by: Matt Mackall <mpm@selenic.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
2009-12-11 6:15 ` Herbert Xu
@ 2009-12-17 8:36 ` Alessandro Rubini
2009-12-17 8:42 ` Herbert Xu
0 siblings, 1 reply; 9+ messages in thread
From: Alessandro Rubini @ 2009-12-17 8:36 UTC (permalink / raw)
To: linux-arm-kernel
>> Acked-by: Matt Mackall <mpm@selenic.com>
> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
So, what should my next step? I don't find the patch in any tree.
Russell, should I put those two in your patch system?
thanks
/alessandro
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
2009-12-17 8:36 ` Alessandro Rubini
@ 2009-12-17 8:42 ` Herbert Xu
2009-12-17 10:51 ` Russell King - ARM Linux
0 siblings, 1 reply; 9+ messages in thread
From: Herbert Xu @ 2009-12-17 8:42 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Dec 17, 2009 at 09:36:24AM +0100, Alessandro Rubini wrote:
> >> Acked-by: Matt Mackall <mpm@selenic.com>
> > Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> So, what should my next step? I don't find the patch in any tree.
> Russell, should I put those two in your patch system?
Well I'm happy to pick these up as long as Russell is OK with
them. I wanted to hear from him as the second patch touches
the ARM tree.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
2009-12-17 8:42 ` Herbert Xu
@ 2009-12-17 10:51 ` Russell King - ARM Linux
2009-12-17 12:13 ` Herbert Xu
0 siblings, 1 reply; 9+ messages in thread
From: Russell King - ARM Linux @ 2009-12-17 10:51 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Dec 17, 2009 at 04:42:56PM +0800, Herbert Xu wrote:
> On Thu, Dec 17, 2009 at 09:36:24AM +0100, Alessandro Rubini wrote:
> > >> Acked-by: Matt Mackall <mpm@selenic.com>
> > > Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
> >
> > So, what should my next step? I don't find the patch in any tree.
> > Russell, should I put those two in your patch system?
>
> Well I'm happy to pick these up as long as Russell is OK with
> them. I wanted to hear from him as the second patch touches
> the ARM tree.
It shouldn't be a problem unless there ends up being conflicting changes
in that file. Currently there are none.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
2009-12-17 10:51 ` Russell King - ARM Linux
@ 2009-12-17 12:13 ` Herbert Xu
0 siblings, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2009-12-17 12:13 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Dec 17, 2009 at 10:51:36AM +0000, Russell King - ARM Linux wrote:
>
> It shouldn't be a problem unless there ends up being conflicting changes
> in that file. Currently there are none.
OK, I'll throw them into my tree then.
Thanks!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] arm nomadik: add hardware RNG driver
2009-12-05 18:56 ` [PATCH V2 1/2] arm nomadik: add hardware RNG driver Matt Mackall
2009-12-11 6:15 ` Herbert Xu
@ 2009-12-19 11:47 ` Herbert Xu
1 sibling, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2009-12-19 11:47 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Dec 05, 2009 at 12:56:46PM -0600, Matt Mackall wrote:
> On Sat, Dec 05, 2009 at 12:31:28PM +0100, Alessandro Rubini wrote:
> > From: Alessandro Rubini <rubini@unipv.it>
> >
> > The hardware random number generator by ST is used in both the Nomadik
> > 8815 SoC and the U8500. It returns 16 bits every 400ns with automatic
> > delay if a read is issued too early. It depends on PLAT_NOMADIK.
> >
> > Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> > Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
>
> Looks good to me.
>
> Acked-by: Matt Mackall <mpm@selenic.com>
Both patches applied to cryptodev. Thanks a lot!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-12-19 11:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-05 11:31 [PATCH V2 1/2] arm nomadik: add hardware RNG driver Alessandro Rubini
2009-12-05 11:31 ` [PATCH V2 2/2] arm nomadik: add platform device for rng in cpu-8815 Alessandro Rubini
2009-12-05 18:56 ` [PATCH V2 1/2] arm nomadik: add hardware RNG driver Matt Mackall
2009-12-11 6:15 ` Herbert Xu
2009-12-17 8:36 ` Alessandro Rubini
2009-12-17 8:42 ` Herbert Xu
2009-12-17 10:51 ` Russell King - ARM Linux
2009-12-17 12:13 ` Herbert Xu
2009-12-19 11:47 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.