Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: picoxcell - support for device tree matching

Allow the crypto engines to be matched from device tree bindings.

Cc: devicetree-discuss@lists.ozlabs.org
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Jamie Iles and committed by
Herbert Xu
30343ef1 4efae8c9

+53 -6
+23
Documentation/devicetree/bindings/crypto/picochip-spacc.txt
··· 1 + Picochip picoXcell SPAcc (Security Protocol Accelerator) bindings 2 + 3 + Picochip picoXcell devices contain crypto offload engines that may be used for 4 + IPSEC and femtocell layer 2 ciphering. 5 + 6 + Required properties: 7 + - compatible : "picochip,spacc-ipsec" for the IPSEC offload engine 8 + "picochip,spacc-l2" for the femtocell layer 2 ciphering engine. 9 + - reg : Offset and length of the register set for this device 10 + - interrupt-parent : The interrupt controller that controls the SPAcc 11 + interrupt. 12 + - interrupts : The interrupt line from the SPAcc. 13 + - ref-clock : The input clock that drives the SPAcc. 14 + 15 + Example SPAcc node: 16 + 17 + spacc@10000 { 18 + compatible = "picochip,spacc-ipsec"; 19 + reg = <0x100000 0x10000>; 20 + interrupt-parent = <&vic0>; 21 + interrupts = <24>; 22 + ref-clock = <&ipsec_clk>, "ref"; 23 + };
+30 -6
drivers/crypto/picoxcell_crypto.c
··· 34 34 #include <linux/io.h> 35 35 #include <linux/list.h> 36 36 #include <linux/module.h> 37 + #include <linux/of.h> 37 38 #include <linux/platform_device.h> 38 39 #include <linux/pm.h> 39 40 #include <linux/rtnetlink.h> ··· 1658 1657 }, 1659 1658 }; 1660 1659 1660 + #ifdef CONFIG_OF 1661 + static const struct of_device_id spacc_of_id_table[] = { 1662 + { .compatible = "picochip,spacc-ipsec" }, 1663 + { .compatible = "picochip,spacc-l2" }, 1664 + {} 1665 + }; 1666 + #else /* CONFIG_OF */ 1667 + #define spacc_of_id_table NULL 1668 + #endif /* CONFIG_OF */ 1669 + 1670 + static bool spacc_is_compatible(struct platform_device *pdev, 1671 + const char *spacc_type) 1672 + { 1673 + const struct platform_device_id *platid = platform_get_device_id(pdev); 1674 + 1675 + if (platid && !strcmp(platid->name, spacc_type)) 1676 + return true; 1677 + 1678 + #ifdef CONFIG_OF 1679 + if (of_device_is_compatible(pdev->dev.of_node, spacc_type)) 1680 + return true; 1681 + #endif /* CONFIG_OF */ 1682 + 1683 + return false; 1684 + } 1685 + 1661 1686 static int __devinit spacc_probe(struct platform_device *pdev) 1662 1687 { 1663 1688 int i, err, ret = -EINVAL; 1664 1689 struct resource *mem, *irq; 1665 - const struct platform_device_id *platid = platform_get_device_id(pdev); 1666 1690 struct spacc_engine *engine = devm_kzalloc(&pdev->dev, sizeof(*engine), 1667 1691 GFP_KERNEL); 1668 1692 if (!engine) 1669 1693 return -ENOMEM; 1670 1694 1671 - if (!platid) 1672 - return -EINVAL; 1673 - 1674 - if (!strcmp(platid->name, "picoxcell-ipsec")) { 1695 + if (spacc_is_compatible(pdev, "picochip,spacc-ipsec")) { 1675 1696 engine->max_ctxs = SPACC_CRYPTO_IPSEC_MAX_CTXS; 1676 1697 engine->cipher_pg_sz = SPACC_CRYPTO_IPSEC_CIPHER_PG_SZ; 1677 1698 engine->hash_pg_sz = SPACC_CRYPTO_IPSEC_HASH_PG_SZ; 1678 1699 engine->fifo_sz = SPACC_CRYPTO_IPSEC_FIFO_SZ; 1679 1700 engine->algs = ipsec_engine_algs; 1680 1701 engine->num_algs = ARRAY_SIZE(ipsec_engine_algs); 1681 - } else if (!strcmp(platid->name, "picoxcell-l2")) { 1702 + } else if (spacc_is_compatible(pdev, "picochip,spacc-l2")) { 1682 1703 engine->max_ctxs = SPACC_CRYPTO_L2_MAX_CTXS; 1683 1704 engine->cipher_pg_sz = SPACC_CRYPTO_L2_CIPHER_PG_SZ; 1684 1705 engine->hash_pg_sz = SPACC_CRYPTO_L2_HASH_PG_SZ; ··· 1849 1826 #ifdef CONFIG_PM 1850 1827 .pm = &spacc_pm_ops, 1851 1828 #endif /* CONFIG_PM */ 1829 + .of_match_table = spacc_of_id_table, 1852 1830 }, 1853 1831 .id_table = spacc_id_table, 1854 1832 };