mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
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: 6298e94821
("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>
This commit is contained in:
parent
6b3413f30d
commit
1e02e6fbda
3 changed files with 34 additions and 2 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <crypto/scatterwalk.h>
|
#include <crypto/scatterwalk.h>
|
||||||
#include <linux/scatterlist.h>
|
#include <linux/scatterlist.h>
|
||||||
|
@ -22,6 +23,14 @@
|
||||||
|
|
||||||
#include "sun4i-ss.h"
|
#include "sun4i-ss.h"
|
||||||
|
|
||||||
|
static const struct ss_variant ss_a10_variant = {
|
||||||
|
.sha1_in_be = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct ss_variant ss_a33_variant = {
|
||||||
|
.sha1_in_be = true,
|
||||||
|
};
|
||||||
|
|
||||||
static struct sun4i_ss_alg_template ss_algs[] = {
|
static struct sun4i_ss_alg_template ss_algs[] = {
|
||||||
{ .type = CRYPTO_ALG_TYPE_AHASH,
|
{ .type = CRYPTO_ALG_TYPE_AHASH,
|
||||||
.mode = SS_OP_MD5,
|
.mode = SS_OP_MD5,
|
||||||
|
@ -323,6 +332,12 @@ static int sun4i_ss_probe(struct platform_device *pdev)
|
||||||
return PTR_ERR(ss->base);
|
return PTR_ERR(ss->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ss->variant = of_device_get_match_data(&pdev->dev);
|
||||||
|
if (!ss->variant) {
|
||||||
|
dev_err(&pdev->dev, "Missing Security System variant\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
ss->ssclk = devm_clk_get(&pdev->dev, "mod");
|
ss->ssclk = devm_clk_get(&pdev->dev, "mod");
|
||||||
if (IS_ERR(ss->ssclk)) {
|
if (IS_ERR(ss->ssclk)) {
|
||||||
err = PTR_ERR(ss->ssclk);
|
err = PTR_ERR(ss->ssclk);
|
||||||
|
@ -484,7 +499,12 @@ static int sun4i_ss_remove(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id a20ss_crypto_of_match_table[] = {
|
static const struct of_device_id a20ss_crypto_of_match_table[] = {
|
||||||
{ .compatible = "allwinner,sun4i-a10-crypto" },
|
{ .compatible = "allwinner,sun4i-a10-crypto",
|
||||||
|
.data = &ss_a10_variant
|
||||||
|
},
|
||||||
|
{ .compatible = "allwinner,sun8i-a33-crypto",
|
||||||
|
.data = &ss_a33_variant
|
||||||
|
},
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, a20ss_crypto_of_match_table);
|
MODULE_DEVICE_TABLE(of, a20ss_crypto_of_match_table);
|
||||||
|
|
|
@ -479,7 +479,10 @@ hash_final:
|
||||||
/* Get the hash from the device */
|
/* Get the hash from the device */
|
||||||
if (op->mode == SS_OP_SHA1) {
|
if (op->mode == SS_OP_SHA1) {
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
v = cpu_to_be32(readl(ss->base + SS_MD0 + i * 4));
|
if (ss->variant->sha1_in_be)
|
||||||
|
v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4));
|
||||||
|
else
|
||||||
|
v = cpu_to_be32(readl(ss->base + SS_MD0 + i * 4));
|
||||||
memcpy(areq->result + i * 4, &v, 4);
|
memcpy(areq->result + i * 4, &v, 4);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -131,7 +131,16 @@
|
||||||
#define SS_SEED_LEN 192
|
#define SS_SEED_LEN 192
|
||||||
#define SS_DATA_LEN 160
|
#define SS_DATA_LEN 160
|
||||||
|
|
||||||
|
/*
|
||||||
|
* struct ss_variant - Describe SS hardware variant
|
||||||
|
* @sha1_in_be: The SHA1 digest is given by SS in BE, and so need to be inverted.
|
||||||
|
*/
|
||||||
|
struct ss_variant {
|
||||||
|
bool sha1_in_be;
|
||||||
|
};
|
||||||
|
|
||||||
struct sun4i_ss_ctx {
|
struct sun4i_ss_ctx {
|
||||||
|
const struct ss_variant *variant;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
int irq;
|
int irq;
|
||||||
struct clk *busclk;
|
struct clk *busclk;
|
||||||
|
|
Loading…
Add table
Reference in a new issue