From: Michael Buesch <mb@bu3sch.de>
To: akpm@osdl.org
Cc: Deepak Saxena <dsaxena@plexity.net>,
mbuesch@freenet.de, bcm43xx-dev@lists.berlios.de,
linux-kernel@vger.kernel.org
Subject: [patch 6/6] New Generic HW RNG
Date: Sun, 07 May 2006 13:35:19 +0200 [thread overview]
Message-ID: <20060507113606.265064000@pc1> (raw)
In-Reply-To: 20060507113513.418451000@pc1
[-- Attachment #1: bcm43xx-hw-random.patch --]
[-- Type: text/plain, Size: 3458 bytes --]
Add bcm43xx H/W RNG support.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Index: hwrng/drivers/net/wireless/bcm43xx/Kconfig
===================================================================
--- hwrng.orig/drivers/net/wireless/bcm43xx/Kconfig 2006-05-07 01:53:13.000000000 +0200
+++ hwrng/drivers/net/wireless/bcm43xx/Kconfig 2006-05-07 01:58:41.000000000 +0200
@@ -2,6 +2,7 @@
tristate "Broadcom BCM43xx wireless support"
depends on PCI && IEEE80211 && IEEE80211_SOFTMAC && NET_RADIO && EXPERIMENTAL
select FW_LOADER
+ select HW_RANDOM
---help---
This is an experimental driver for the Broadcom 43xx wireless chip,
found in the Apple Airport Extreme and various other devices.
Index: hwrng/drivers/net/wireless/bcm43xx/bcm43xx.h
===================================================================
--- hwrng.orig/drivers/net/wireless/bcm43xx/bcm43xx.h 2006-05-07 01:53:13.000000000 +0200
+++ hwrng/drivers/net/wireless/bcm43xx/bcm43xx.h 2006-05-07 01:58:41.000000000 +0200
@@ -1,6 +1,7 @@
#ifndef BCM43xx_H_
#define BCM43xx_H_
+#include <linux/hw_random.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/spinlock.h>
@@ -82,6 +83,7 @@
#define BCM43xx_MMIO_TSF_1 0x634 /* core rev < 3 only */
#define BCM43xx_MMIO_TSF_2 0x636 /* core rev < 3 only */
#define BCM43xx_MMIO_TSF_3 0x638 /* core rev < 3 only */
+#define BCM43xx_MMIO_RNG 0x65A
#define BCM43xx_MMIO_POWERUP_DELAY 0x6A8
/* SPROM offsets. */
@@ -741,6 +743,9 @@
const struct firmware *initvals0;
const struct firmware *initvals1;
+ /* Random Number Generator. */
+ struct hwrng rng;
+
/* Debugging stuff follows. */
#ifdef CONFIG_BCM43XX_DEBUG
struct bcm43xx_dfsentry *dfsentry;
Index: hwrng/drivers/net/wireless/bcm43xx/bcm43xx_main.c
===================================================================
--- hwrng.orig/drivers/net/wireless/bcm43xx/bcm43xx_main.c 2006-05-07 01:53:13.000000000 +0200
+++ hwrng/drivers/net/wireless/bcm43xx/bcm43xx_main.c 2006-05-07 01:58:41.000000000 +0200
@@ -3144,6 +3144,37 @@
bcm43xx_clear_keys(bcm);
}
+static int bcm43xx_rng_read(struct hwrng *rng, u32 *data)
+{
+ struct bcm43xx_private *bcm = (struct bcm43xx_private *)rng->priv;
+ unsigned long flags;
+
+ bcm43xx_lock(bcm, flags);
+ *data = bcm43xx_read16(bcm, BCM43xx_MMIO_RNG);
+ bcm43xx_unlock(bcm, flags);
+
+ return (sizeof(u16));
+}
+
+static void bcm43xx_rng_exit(struct bcm43xx_private *bcm)
+{
+ hwrng_unregister(&bcm->rng);
+}
+
+static int bcm43xx_rng_init(struct bcm43xx_private *bcm)
+{
+ int err;
+
+ bcm->rng.name = KBUILD_MODNAME;
+ bcm->rng.data_read = bcm43xx_rng_read;
+ bcm->rng.priv = (unsigned long)bcm;
+ err = hwrng_register(&bcm->rng);
+ if (err)
+ printk(KERN_ERR PFX "RNG init failed\n");
+
+ return err;
+}
+
/* This is the opposite of bcm43xx_init_board() */
static void bcm43xx_free_board(struct bcm43xx_private *bcm)
{
@@ -3159,6 +3190,7 @@
bcm->shutting_down = 1;
bcm43xx_unlock(bcm, flags);
+ bcm43xx_rng_exit(bcm);
for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
if (!bcm->core_80211[i].available)
continue;
@@ -3240,6 +3272,9 @@
bcm43xx_switch_core(bcm, &bcm->core_80211[0]);
bcm43xx_mac_enable(bcm);
}
+ err = bcm43xx_rng_init(bcm);
+ if (err)
+ goto err_80211_unwind;
bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC);
bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr));
dprintk(KERN_INFO PFX "80211 cores initialized\n");
--
prev parent reply other threads:[~2006-05-07 12:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-07 11:35 [patch 0/6] New Generic HW RNG Michael Buesch
2006-05-07 11:35 ` [patch 1/6] " Michael Buesch
2006-05-07 11:35 ` [patch 2/6] " Michael Buesch
2006-05-07 13:03 ` Sergey Vlasov
2006-05-07 13:16 ` Michael Buesch
2006-05-07 13:27 ` Michael Buesch
2006-05-07 13:45 ` Sergey Vlasov
2006-05-07 13:56 ` Michael Buesch
2006-05-10 20:57 ` Greg KH
2006-05-10 21:18 ` Michael Buesch
2006-05-07 11:35 ` [patch 3/6] " Michael Buesch
2006-05-07 13:09 ` Sergey Vlasov
2006-05-07 14:51 ` Michael Buesch
2006-05-07 11:35 ` [patch 4/6] " Michael Buesch
2006-05-07 11:35 ` [patch 5/6] " Michael Buesch
2006-05-07 11:35 ` Michael Buesch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060507113606.265064000@pc1 \
--to=mb@bu3sch.de \
--cc=akpm@osdl.org \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=dsaxena@plexity.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mbuesch@freenet.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.