Skip to contentSkip to conversation

m68knommu: add DMA timer counter to entropy

PATCH New [email protected] 1 participant 1 message May 29, 2014 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68knommu: add DMA timer counter to entropy

From: Greg Ungerer <[email protected]>

The ColdFire DMA timer hardware module is a free running counter that is derived from the master system clock. It is effectively a cycle counter, so lets add it to the entropy pool.

---
 arch/m68k/platform/coldfire/dma_timer.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/m68k/platform/coldfire/dma_timer.c +7 -0
index 1f8d967..850463c 100644
@@ -9,6 +9,7 @@
 #include <linux/clocksource.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/timex.h>
 
 #include <asm/machdep.h>
 #include <asm/coldfire.h>
@@ -30,6 +31,11 @@
 #define DMA_DTMR_CLK_DIV_16	(2 << 1)
 #define DMA_DTMR_ENABLE		(1 << 0)
 
+static unsigned long cf_dt_random_get_entropy(void)
+{
+	return __raw_readl(DTCN0);
+}
+
 static cycle_t cf_dt_get_cycles(struct clocksource *cs)
 {
 	return __raw_readl(DTCN0);
@@ -56,6 +62,7 @@ static int __init  init_cf_dt_clocksource(void)
 	clk = clk_get(NULL, "mcftmr.0");
 	if (clk)
 		clk_enable(clk);
+	mach_random_get_entropy = cf_dt_random_get_entropy;
 
 	__raw_writeb(0x00, DTXMR0);
 	__raw_writeb(0x00, DTER0);
Signature · 1 line
1.8.1.4