Skip to contentSkip to conversation

TXx9: Add TX4939 RNG support

PATCH In review Atsushi Nemoto 2 participants 6 messages May 26, 2009 – Jun 2, 2009 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 TXx9: Add TX4939 RNG support

Add platform support for RNG of TX4939 SoC.

---
 arch/mips/include/asm/txx9/tx4939.h   |    1 +
 arch/mips/txx9/generic/setup_tx4939.c |   18 ++++++++++++++++++
 arch/mips/txx9/rbtx4939/setup.c       |    1 +
 3 files changed, 20 insertions(+), 0 deletions(-)
arch/mips/include/asm/txx9/tx4939.h +1 -0
index 050364d..3451499 100644
@@ -547,5 +547,6 @@ void tx4939_ndfmc_init(unsigned int hold, unsigned int spw,
 void tx4939_dmac_init(int memcpy_chan0, int memcpy_chan1);
 void tx4939_aclc_init(void);
 void tx4939_sramc_init(void);
+void tx4939_rng_init(void);
 
 #endif /* __ASM_TXX9_TX4939_H */
arch/mips/txx9/generic/setup_tx4939.c +18 -0
index df13a89..4b7293c 100644
@@ -500,6 +500,24 @@ void __init tx4939_sramc_init(void)
 		txx9_sramc_init(&tx4939_sram_resource);
 }
 
+#define TX4939_RNG_REG	((TX4939_CRYPTO_REG & 0xfffffffffULL) + 0xb0)
+void __init tx4939_rng_init(void)
+{
+	static struct resource res = {
+		.start = TX4939_RNG_REG,
+		.end = TX4939_RNG_REG + 0x30 - 1,
+		.flags = IORESOURCE_MEM,
+	};
+	static struct platform_device pdev = {
+		.name = "tx4939-rng",
+		.id = -1,
+		.num_resources = 1,
+		.resource = &res,
+	};
+
+	platform_device_register(&pdev);
+}
+
 static void __init tx4939_stop_unused_modules(void)
 {
 	__u64 pcfg, rst = 0, ckd = 0;
arch/mips/txx9/rbtx4939/setup.c +1 -0
index b919696..c033ffe 100644
@@ -502,6 +502,7 @@ static void __init rbtx4939_device_init(void)
 	tx4939_aclc_init();
 	platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
 	tx4939_sramc_init();
+	tx4939_rng_init();
 }
 
 static void __init rbtx4939_setup(void)
Signature · 1 line
1.5.6.5
#1 lore raw

: This is a reply for comments from Matt Mackall via mm-commit mail.

Quoted 8 lines · Matt Mackall

arch/mips/txx9/generic/setup_tx4939.c void __init tx4939_aclc_init(void) · line 497

Quoted 6 lines

+++ a/arch/mips/txx9/generic/setup_tx4939.c

arch/mips/txx9/generic/setup_tx4939.c +1 -0
@@ -494,6 +494,24 @@ void __init tx4939_aclc_init(void)
 			       TXX9_IRQ_BASE + TX4939_IR_ACLC, 1, 0, 1);
 }
 
+#define TX4939_RNG_REG	((TX4939_CRYPTO_REG & 0xfffffffffULL) + 0xb0)

This isn't the best place for this define?

Well, I can move it to include/asm/txx9/tx4939.h.

Quoted 11 lines

arch/mips/txx9/rbtx4939/setup.c static void __init rbtx4939_device_init( · line 507

Quoted 9 lines
arch/mips/txx9/rbtx4939/setup.c +2 -0
+++ a/arch/mips/txx9/rbtx4939/setup.c
@@ -501,6 +501,7 @@ static void __init rbtx4939_device_init(
 	tx4939_dmac_init(0, 2);
 	tx4939_aclc_init();
 	platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
+	tx4939_rng_init();
 }
 
 static void __init rbtx4939_setup(void)

Not clear to me how this works when this is a module?

This patch add a registration of a platform device for RNG to vmlinux. And the other patch add a driver module for the RNG. This strategy is fairly common for SoCs or embedded platforms.

---
Atsushi Nemoto

#2 lore raw
Quoted 22 lines · Atsushi Nemoto

: This is a reply for comments from Matt Mackall via mm-commit mail.

Quoted 8 lines · Matt Mackall

arch/mips/txx9/generic/setup_tx4939.c void __init tx4939_aclc_init(void) · line 497

Quoted 6 lines

+++ a/arch/mips/txx9/generic/setup_tx4939.c

arch/mips/txx9/generic/setup_tx4939.c +1 -0
@@ -494,6 +494,24 @@ void __init tx4939_aclc_init(void)
 			       TXX9_IRQ_BASE + TX4939_IR_ACLC, 1, 0, 1);
 }
 
+#define TX4939_RNG_REG	((TX4939_CRYPTO_REG & 0xfffffffffULL) + 0xb0)

This isn't the best place for this define?

Well, I can move it to include/asm/txx9/tx4939.h.

Quoted 8 lines
Quoted 8 lines
arch/mips/txx9/rbtx4939/setup.c +2 -0
+++ a/arch/mips/txx9/rbtx4939/setup.c
@@ -501,6 +501,7 @@ static void __init rbtx4939_device_init(
 	tx4939_dmac_init(0, 2);
 	tx4939_aclc_init();
 	platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
+	tx4939_rng_init();
 }
 
Quoted 7 lines
Quoted 3 lines

arch/mips/txx9/rbtx4939/setup.c static void __init rbtx4939_device_init(void) · line 508

Quoted 1 line
arch/mips/txx9/rbtx4939/setup.c +0 -0
 static void __init rbtx4939_setup(void)

Not clear to me how this works when this is a module?

This patch add a registration of a platform device for RNG to vmlinux. And the other patch add a driver module for the RNG. This strategy is fairly common for SoCs or embedded platforms.

If your driver is built as a module (which your patch allows), the above won't work, right?

Signature · 1 line
http://selenic.com : development and support for Mercurial and Linux
#3 lore raw
Quoted 8 lines · Matt Mackall
Quoted 5 lines
Quoted 1 line

Not clear to me how this works when this is a module?

This patch add a registration of a platform device for RNG to vmlinux. And the other patch add a driver module for the RNG. This strategy is fairly common for SoCs or embedded platforms.

If your driver is built as a module (which your patch allows), the above won't work, right?

No, the rng driver can be used regardless of module or built-in, as like as other platform drivers. Any special issue for hw_rng?

---
Atsushi Nemoto

#4 lore raw
Quoted 7 lines · Atsushi Nemoto
Quoted 6 lines · Matt Mackall
Quoted 5 lines
Quoted 1 line

Not clear to me how this works when this is a module?

This patch add a registration of a platform device for RNG to vmlinux. And the other patch add a driver module for the RNG. This strategy is fairly common for SoCs or embedded platforms.

Quoted 5 lines
Quoted 2 lines

If your driver is built as a module (which your patch allows), the above won't work, right?

No, the rng driver can be used regardless of module or built-in, as like as other platform drivers. Any special issue for hw_rng?

I found the source of my confusion: you've given the init function in both files exactly the same name. So when I saw .._init at the bottom of the second patch, I assumed it was referring to the possibly not loaded driver's init code.

Signature · 1 line
http://selenic.com : development and support for Mercurial and Linux
#5 lore raw
Quoted 7 lines · Matt Mackall
Quoted 2 lines

No, the rng driver can be used regardless of module or built-in, as like as other platform drivers. Any special issue for hw_rng?

I found the source of my confusion: you've given the init function in both files exactly the same name. So when I saw .._init at the bottom of the second patch, I assumed it was referring to the possibly not loaded driver's init code.

OK, I see. I will rename one of them to avoid such a confusion. Thanks.

---
Atsushi Nemoto