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

Configure Feed

Select the types of activity you want to include in your feed.

crypto: sun4i-ss - add the A33 variant of SS

The A33 SS has a difference with all other SS, it give SHA1 digest
directly in BE.
So this patch adds variant support in sun4i-ss.

Fixes: 6298e948215f ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Corentin Labbe and committed by
Herbert Xu
1e02e6fb 6b3413f3

+34 -2
+21 -1
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c
··· 13 13 #include <linux/io.h> 14 14 #include <linux/module.h> 15 15 #include <linux/of.h> 16 + #include <linux/of_device.h> 16 17 #include <linux/platform_device.h> 17 18 #include <crypto/scatterwalk.h> 18 19 #include <linux/scatterlist.h> ··· 22 21 #include <linux/reset.h> 23 22 24 23 #include "sun4i-ss.h" 24 + 25 + static const struct ss_variant ss_a10_variant = { 26 + .sha1_in_be = false, 27 + }; 28 + 29 + static const struct ss_variant ss_a33_variant = { 30 + .sha1_in_be = true, 31 + }; 25 32 26 33 static struct sun4i_ss_alg_template ss_algs[] = { 27 34 { .type = CRYPTO_ALG_TYPE_AHASH, ··· 332 323 return PTR_ERR(ss->base); 333 324 } 334 325 326 + ss->variant = of_device_get_match_data(&pdev->dev); 327 + if (!ss->variant) { 328 + dev_err(&pdev->dev, "Missing Security System variant\n"); 329 + return -EINVAL; 330 + } 331 + 335 332 ss->ssclk = devm_clk_get(&pdev->dev, "mod"); 336 333 if (IS_ERR(ss->ssclk)) { 337 334 err = PTR_ERR(ss->ssclk); ··· 499 484 } 500 485 501 486 static const struct of_device_id a20ss_crypto_of_match_table[] = { 502 - { .compatible = "allwinner,sun4i-a10-crypto" }, 487 + { .compatible = "allwinner,sun4i-a10-crypto", 488 + .data = &ss_a10_variant 489 + }, 490 + { .compatible = "allwinner,sun8i-a33-crypto", 491 + .data = &ss_a33_variant 492 + }, 503 493 {} 504 494 }; 505 495 MODULE_DEVICE_TABLE(of, a20ss_crypto_of_match_table);
+4 -1
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c
··· 479 479 /* Get the hash from the device */ 480 480 if (op->mode == SS_OP_SHA1) { 481 481 for (i = 0; i < 5; i++) { 482 - v = cpu_to_be32(readl(ss->base + SS_MD0 + i * 4)); 482 + if (ss->variant->sha1_in_be) 483 + v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4)); 484 + else 485 + v = cpu_to_be32(readl(ss->base + SS_MD0 + i * 4)); 483 486 memcpy(areq->result + i * 4, &v, 4); 484 487 } 485 488 } else {
+9
drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h
··· 131 131 #define SS_SEED_LEN 192 132 132 #define SS_DATA_LEN 160 133 133 134 + /* 135 + * struct ss_variant - Describe SS hardware variant 136 + * @sha1_in_be: The SHA1 digest is given by SS in BE, and so need to be inverted. 137 + */ 138 + struct ss_variant { 139 + bool sha1_in_be; 140 + }; 141 + 134 142 struct sun4i_ss_ctx { 143 + const struct ss_variant *variant; 135 144 void __iomem *base; 136 145 int irq; 137 146 struct clk *busclk;