Skip to content

Commit f37fbd3

Browse files
lunnJason Cooper
authored andcommitted
Crypto: CESA: Add support for DT based instantiation.
Based on work by Michael Walle and Jason Cooper. Added support for getting the interrupt number and address of SRAM from DT. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Jason Cooper <jason@lakedaemon.net> Conflicts: arch/arm/mach-kirkwood/board-dt.c
1 parent 2eecb47 commit f37fbd3

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Marvell Cryptographic Engines And Security Accelerator
2+
3+
Required properties:
4+
- compatible : should be "marvell,orion-crypto"
5+
- reg : base physical address of the engine and length of memory mapped
6+
region, followed by base physical address of sram and its memory
7+
length
8+
- reg-names : "regs" , "sram";
9+
- interrupts : interrupt number
10+
11+
Examples:
12+
13+
crypto@30000 {
14+
compatible = "marvell,orion-crypto";
15+
reg = <0x30000 0x10000>,
16+
<0x4000000 0x800>;
17+
reg-names = "regs" , "sram";
18+
interrupts = <22>;
19+
status = "okay";
20+
};

arch/arm/boot/dts/kirkwood.dtsi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
ocp@f1000000 {
1616
compatible = "simple-bus";
17-
ranges = <0 0xf1000000 0x4000000>;
17+
ranges = <0x00000000 0xf1000000 0x4000000
18+
0xf5000000 0xf5000000 0x0000400>;
1819
#address-cells = <1>;
1920
#size-cells = <1>;
2021

@@ -105,5 +106,14 @@
105106
clock-frequency = <100000>;
106107
status = "disabled";
107108
};
109+
110+
crypto@30000 {
111+
compatible = "marvell,orion-crypto";
112+
reg = <0x30000 0x10000>,
113+
<0xf5000000 0x800>;
114+
reg-names = "regs", "sram";
115+
interrupts = <22>;
116+
status = "okay";
117+
};
108118
};
109119
};

arch/arm/mach-kirkwood/board-dt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = {
3333
OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL),
3434
OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL),
3535
OF_DEV_AUXDATA("marvell,orion-nand", 0xf4000000, "orion_nand", NULL),
36+
OF_DEV_AUXDATA("marvell,orion-crypto", 0xf1030000, "mv_crypto", NULL),
3637
{},
3738
};
3839

@@ -60,7 +61,6 @@ static void __init kirkwood_dt_init(void)
6061
/* internal devices that every board has */
6162
kirkwood_xor0_init();
6263
kirkwood_xor1_init();
63-
kirkwood_crypto_init();
6464

6565
#ifdef CONFIG_KEXEC
6666
kexec_reinit = kirkwood_enable_pcie;

drivers/crypto/mv_cesa.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <linux/clk.h>
2020
#include <crypto/internal/hash.h>
2121
#include <crypto/sha.h>
22+
#include <linux/of.h>
23+
#include <linux/of_platform.h>
24+
#include <linux/of_irq.h>
2225

2326
#include "mv_cesa.h"
2427

@@ -1062,7 +1065,10 @@ static int mv_probe(struct platform_device *pdev)
10621065
goto err_unmap_reg;
10631066
}
10641067

1065-
irq = platform_get_irq(pdev, 0);
1068+
if (pdev->dev.of_node)
1069+
irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
1070+
else
1071+
irq = platform_get_irq(pdev, 0);
10661072
if (irq < 0 || irq == NO_IRQ) {
10671073
ret = irq;
10681074
goto err_unmap_sram;
@@ -1170,12 +1176,19 @@ static int mv_remove(struct platform_device *pdev)
11701176
return 0;
11711177
}
11721178

1179+
static const struct of_device_id mv_cesa_of_match_table[] = {
1180+
{ .compatible = "marvell,orion-crypto", },
1181+
{}
1182+
};
1183+
MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table);
1184+
11731185
static struct platform_driver marvell_crypto = {
11741186
.probe = mv_probe,
1175-
.remove = mv_remove,
1187+
.remove = __devexit_p(mv_remove),
11761188
.driver = {
11771189
.owner = THIS_MODULE,
11781190
.name = "mv_crypto",
1191+
.of_match_table = of_match_ptr(mv_cesa_of_match_table),
11791192
},
11801193
};
11811194
MODULE_ALIAS("platform:mv_crypto");

0 commit comments

Comments
 (0)