Skip to content

Commit

Permalink
Crypto: CESA: Add support for DT based instantiation.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Andrew Lunn authored and Jason Cooper committed Sep 22, 2012
1 parent 2eecb47 commit f37fbd3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
20 changes: 20 additions & 0 deletions Documentation/devicetree/bindings/crypto/mv_cesa.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Marvell Cryptographic Engines And Security Accelerator

Required properties:
- compatible : should be "marvell,orion-crypto"
- reg : base physical address of the engine and length of memory mapped
region, followed by base physical address of sram and its memory
length
- reg-names : "regs" , "sram";
- interrupts : interrupt number

Examples:

crypto@30000 {
compatible = "marvell,orion-crypto";
reg = <0x30000 0x10000>,
<0x4000000 0x800>;
reg-names = "regs" , "sram";
interrupts = <22>;
status = "okay";
};
12 changes: 11 additions & 1 deletion arch/arm/boot/dts/kirkwood.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

ocp@f1000000 {
compatible = "simple-bus";
ranges = <0 0xf1000000 0x4000000>;
ranges = <0x00000000 0xf1000000 0x4000000
0xf5000000 0xf5000000 0x0000400>;
#address-cells = <1>;
#size-cells = <1>;

Expand Down Expand Up @@ -105,5 +106,14 @@
clock-frequency = <100000>;
status = "disabled";
};

crypto@30000 {
compatible = "marvell,orion-crypto";
reg = <0x30000 0x10000>,
<0xf5000000 0x800>;
reg-names = "regs", "sram";
interrupts = <22>;
status = "okay";
};
};
};
2 changes: 1 addition & 1 deletion arch/arm/mach-kirkwood/board-dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = {
OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL),
OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL),
OF_DEV_AUXDATA("marvell,orion-nand", 0xf4000000, "orion_nand", NULL),
OF_DEV_AUXDATA("marvell,orion-crypto", 0xf1030000, "mv_crypto", NULL),
{},
};

Expand Down Expand Up @@ -60,7 +61,6 @@ static void __init kirkwood_dt_init(void)
/* internal devices that every board has */
kirkwood_xor0_init();
kirkwood_xor1_init();
kirkwood_crypto_init();

#ifdef CONFIG_KEXEC
kexec_reinit = kirkwood_enable_pcie;
Expand Down
17 changes: 15 additions & 2 deletions drivers/crypto/mv_cesa.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <linux/clk.h>
#include <crypto/internal/hash.h>
#include <crypto/sha.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/of_irq.h>

#include "mv_cesa.h"

Expand Down Expand Up @@ -1062,7 +1065,10 @@ static int mv_probe(struct platform_device *pdev)
goto err_unmap_reg;
}

irq = platform_get_irq(pdev, 0);
if (pdev->dev.of_node)
irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
else
irq = platform_get_irq(pdev, 0);
if (irq < 0 || irq == NO_IRQ) {
ret = irq;
goto err_unmap_sram;
Expand Down Expand Up @@ -1170,12 +1176,19 @@ static int mv_remove(struct platform_device *pdev)
return 0;
}

static const struct of_device_id mv_cesa_of_match_table[] = {
{ .compatible = "marvell,orion-crypto", },
{}
};
MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table);

static struct platform_driver marvell_crypto = {
.probe = mv_probe,
.remove = mv_remove,
.remove = __devexit_p(mv_remove),
.driver = {
.owner = THIS_MODULE,
.name = "mv_crypto",
.of_match_table = of_match_ptr(mv_cesa_of_match_table),
},
};
MODULE_ALIAS("platform:mv_crypto");
Expand Down

0 comments on commit f37fbd3

Please sign in to comment.