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

crypto: inside-secure - fix clock resource by adding a register clock

On Armada 7K/8K we need to explicitly enable the register clock. This
clock is optional because not all the SoCs using this IP need it but at
least for Armada 7K/8K it is actually mandatory.

The binding documentation is updated accordingly.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Gregory CLEMENT and committed by
Herbert Xu
1d17cbfb 5b376896

+31 -10
+5 -1
Documentation/devicetree/bindings/crypto/inside-secure-safexcel.txt
··· 8 8 - interrupt-names: Should be "ring0", "ring1", "ring2", "ring3", "eip", "mem". 9 9 10 10 Optional properties: 11 - - clocks: Reference to the crypto engine clock. 11 + - clocks: Reference to the crypto engine clocks, the second clock is 12 + needed for the Armada 7K/8K SoCs. 13 + - clock-names: mandatory if there is a second clock, in this case the 14 + name must be "core" for the first clock and "reg" for 15 + the second one. 12 16 13 17 Example: 14 18
+25 -9
drivers/crypto/inside-secure/safexcel.c
··· 895 895 } 896 896 } 897 897 898 + priv->reg_clk = devm_clk_get(&pdev->dev, "reg"); 899 + ret = PTR_ERR_OR_ZERO(priv->reg_clk); 900 + /* The clock isn't mandatory */ 901 + if (ret != -ENOENT) { 902 + if (ret) 903 + goto err_core_clk; 904 + 905 + ret = clk_prepare_enable(priv->reg_clk); 906 + if (ret) { 907 + dev_err(dev, "unable to enable reg clk (%d)\n", ret); 908 + goto err_core_clk; 909 + } 910 + } 911 + 898 912 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); 899 913 if (ret) 900 - goto err_clk; 914 + goto err_reg_clk; 901 915 902 916 priv->context_pool = dmam_pool_create("safexcel-context", dev, 903 917 sizeof(struct safexcel_context_record), 904 918 1, 0); 905 919 if (!priv->context_pool) { 906 920 ret = -ENOMEM; 907 - goto err_clk; 921 + goto err_reg_clk; 908 922 } 909 923 910 924 safexcel_configure(priv); ··· 933 919 &priv->ring[i].cdr, 934 920 &priv->ring[i].rdr); 935 921 if (ret) 936 - goto err_clk; 922 + goto err_reg_clk; 937 923 938 924 ring_irq = devm_kzalloc(dev, sizeof(*ring_irq), GFP_KERNEL); 939 925 if (!ring_irq) { 940 926 ret = -ENOMEM; 941 - goto err_clk; 927 + goto err_reg_clk; 942 928 } 943 929 944 930 ring_irq->priv = priv; ··· 950 936 ring_irq); 951 937 if (irq < 0) { 952 938 ret = irq; 953 - goto err_clk; 939 + goto err_reg_clk; 954 940 } 955 941 956 942 priv->ring[i].work_data.priv = priv; ··· 961 947 priv->ring[i].workqueue = create_singlethread_workqueue(wq_name); 962 948 if (!priv->ring[i].workqueue) { 963 949 ret = -ENOMEM; 964 - goto err_clk; 950 + goto err_reg_clk; 965 951 } 966 952 967 953 priv->ring[i].requests = 0; ··· 982 968 ret = safexcel_hw_init(priv); 983 969 if (ret) { 984 970 dev_err(dev, "EIP h/w init failed (%d)\n", ret); 985 - goto err_clk; 971 + goto err_reg_clk; 986 972 } 987 973 988 974 ret = safexcel_register_algorithms(priv); 989 975 if (ret) { 990 976 dev_err(dev, "Failed to register algorithms (%d)\n", ret); 991 - goto err_clk; 977 + goto err_reg_clk; 992 978 } 993 979 994 980 return 0; 995 981 996 - err_clk: 982 + err_reg_clk: 983 + clk_disable_unprepare(priv->reg_clk); 984 + err_core_clk: 997 985 clk_disable_unprepare(priv->clk); 998 986 return ret; 999 987 }
+1
drivers/crypto/inside-secure/safexcel.h
··· 525 525 void __iomem *base; 526 526 struct device *dev; 527 527 struct clk *clk; 528 + struct clk *reg_clk; 528 529 struct safexcel_config config; 529 530 530 531 enum safexcel_eip_version version;