From patchwork Wed Nov 20 15:28:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 179857 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2255586ilf; Wed, 20 Nov 2019 07:28:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwm0VJwTcdmvAcX+YCAQF+zdA0o7N1H6rGdxeJxK9ETHh1HFgyVFEQBk+deYTqeLnMBg5Q9 X-Received: by 2002:a17:906:6552:: with SMTP id u18mr6115374ejn.36.1574263725241; Wed, 20 Nov 2019 07:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574263725; cv=none; d=google.com; s=arc-20160816; b=X2Wt+CgVpYJMYdCQ9mGvRqm4/WifkGxYelDrCFNsCzW0U0SKnYjgh1TcC6LzgNDqnK ssYhn/ikJJ+c73JTvEpmImdjASTaI/tIgiv5Qg+EmRAZ2MC2SenPLen07sVZ2LRPB3X0 kltTFlXl5SYnUe5buOaFQNf+y4CQcqdXdpu4aKT2WoEZ5PvsRbrRSNgifnLVYm9Un2t8 uB61NbNC1WuTWOKiugJ+f1R7QvJXom+P9yAlRyrAC1Zob6ptzfAsJMgJk31qgYmaM/p5 VcfTmyEM51T2w+BhTiqgaXDfIzK+KYEAgpVSgCC7e9tY2IgUhg0PIxU8EmYro5p+vXQf 3D7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mQbJHJ0ZZ045TuFFH0OpDkzJ7tdcb7RCVuOKVisaGsk=; b=aY65cFBKa7AFO7xNeEp/BuruhOEJ2umsO7SC47VxQUqCkMOZKPmhttIoDnRoLD4M1p j8mT1xT9cdmNEBMP1GSXM8+/jHEhh1YIUOuD0dghjACFYCPGMYYp8Bjh0QIeQMFUTVnS 0FlXJZdGTErf4iE88V20YqzZA8Xb3SmmXeZxSXWnWDJ6UN/rYFDcXi0hBMLE4JJ0e9mN JbmUIcxXB31qhQvr+xAEYbp4PdAr2L/ukLWELnyHgDL38pmBzN8SXBOiGrTTng0kijJ3 azLcFjiS9tntAxzydUAD/fO63zxMFlLvLy4wYLHBxmVcsDVsufBFaacLrEq8w0+alXlA Vu2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QnBKM8lF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si16283076ejk.81.2019.11.20.07.28.45; Wed, 20 Nov 2019 07:28:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QnBKM8lF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731199AbfKTP2m (ORCPT + 26 others); Wed, 20 Nov 2019 10:28:42 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45355 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728933AbfKTP2k (ORCPT ); Wed, 20 Nov 2019 10:28:40 -0500 Received: by mail-wr1-f65.google.com with SMTP id z10so224442wrs.12; Wed, 20 Nov 2019 07:28:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mQbJHJ0ZZ045TuFFH0OpDkzJ7tdcb7RCVuOKVisaGsk=; b=QnBKM8lFYAgiDp8LfIkxVzinvXpIuyW56oFqGpbPPZxnkZU6XH+vxyVCg4qx0klXcJ CYSM3C86zWGfP4zpnLTSfEEKpOJq5/aJG9FThkC1/W3Zd4ehndtC/i/Jq567GL1owuFb 6vucVz9yPAmXMzHNkZjRm0smO3K0bqeB2Y2ezetgaHphWqV969ZVtaf9L4SvENjkFfDz GLV7NMZSBi9CCjHgp0sz9NVftykvrK176B40j3lMgu22suhpXX1cjyGfVNw3Pb4xwgre UxM3g3jlZw7YWWFIF9AwhQEugdOL8xdWy+no+wLv4X2T6uXx5Nw5L1WUstUN9iBZ5Au+ LLgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mQbJHJ0ZZ045TuFFH0OpDkzJ7tdcb7RCVuOKVisaGsk=; b=JnHEPZkVhS0xFKrmxIzYh/KBtVi/v3RtGl/GwG4w19J2+LmY0zpqljVhlr6k13oTYm BuH4+6HUhCnDjY5o9mpo5fwdFhcl/MZq5r0svKX18w5j5cjY9Hu/GhwSvwimoEGXASnv K7BevgNSkFief3OMZxCeo1ObjcUSpGQwx3tlyiOg7gAnDrxS05YYjH9zY0PHQyREzbks zwqmDoIszwVgbh5D0NAJzS2zrT+bhjQvLfUf+JOsUIThTnCg2S+lXC/m4CB5AAJOMF01 8ZkJlpSqxPx7Nsmz5+OhV2ovmT5PiQXcli+FMgqQx1VdDHzRtl/BVExxyM/U7m4DLJUr jftQ== X-Gm-Message-State: APjAAAU/rx1qAiaBbnmb5e4tSV7I6LcROjeBxwoU37I0xfMcMZoCwh8p sJo9+vzi7cJMeoxebyz3aJY= X-Received: by 2002:a5d:6706:: with SMTP id o6mr4098747wru.54.1574263718682; Wed, 20 Nov 2019 07:28:38 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id w4sm31797881wrs.1.2019.11.20.07.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 07:28:38 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mark.rutland@arm.com, mripard@kernel.org, robh+dt@kernel.org, wens@csie.org Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH v2 1/3] dt-bindings: crypto: add new compatible for A33 SS Date: Wed, 20 Nov 2019 16:28:31 +0100 Message-Id: <20191120152833.20443-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191120152833.20443-1-clabbe.montjoie@gmail.com> References: <20191120152833.20443-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The A33 SS has a difference with all other SS, it give SHA1 digest directly in BE. This difference need to be handlded by the driver and so need a new compatible. Signed-off-by: Corentin Labbe --- .../devicetree/bindings/crypto/allwinner,sun4i-a10-crypto.yaml | 2 ++ 1 file changed, 2 insertions(+) -- 2.23.0 diff --git a/Documentation/devicetree/bindings/crypto/allwinner,sun4i-a10-crypto.yaml b/Documentation/devicetree/bindings/crypto/allwinner,sun4i-a10-crypto.yaml index 80b3e7350a73..5fc88fb3a91b 100644 --- a/Documentation/devicetree/bindings/crypto/allwinner,sun4i-a10-crypto.yaml +++ b/Documentation/devicetree/bindings/crypto/allwinner,sun4i-a10-crypto.yaml @@ -23,6 +23,8 @@ properties: - items: - const: allwinner,sun7i-a20-crypto - const: allwinner,sun4i-a10-crypto + - items: + - const: allwinner,sun8i-a33-crypto reg: maxItems: 1 From patchwork Wed Nov 20 15:28:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 179859 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2255618ilf; Wed, 20 Nov 2019 07:28:47 -0800 (PST) X-Google-Smtp-Source: APXvYqw+0Q4xuzFQm4s6zG1zliPKCF3EuGMBRZkyzuyh6xSTJTLrsZVyVaSwdxu9zdxhXIIFyZTL X-Received: by 2002:a17:906:4a43:: with SMTP id a3mr5897053ejv.311.1574263727492; Wed, 20 Nov 2019 07:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574263727; cv=none; d=google.com; s=arc-20160816; b=Acm4LVYffl5pqWdtt2cbGRH5uYanAu92EkN0nlV6TOHKMfA7f8YgeNY5vQS17iFv91 2huoL191vSo68v68an/y92IUCmLTKB0Tou0nBl/gdGWO2vV1sKbc47vjqPdZN0CdEf39 +uWMkmtmQYav6Quu3QsqQ8r3QkkB+MGT3V5dlc83w3sX+WhH2p0U9jgKwSZEYEgbX63n sghtQYgzG7onGs9fRr2eCOXUYXtCPaRuzKRKD6KPdG3ovGShR/zs11mK3q8ZF+YhZSFh 4bNKmBfH1rySokFkrttBjMSNPyS8uC+Igj02iwmqKmcoVwGayiILZJybd3MWMBf6vZLo W4+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VocVwERuj9CPUxI4LlG88AIMpkiR3wTIlIVCNMEfFWI=; b=nnuIXySyAsnajF+FgYELx1ulNwU0biL5zVIw6cHusO/XRuQLVPWW/1D93SxDfvYmVv ezNBhKTgf6euPWZld2Ny+IcqjoRHCqpTKeRUSyTWuw92Ii3G06sQhOP78fUWqPVixdmc pv0lEOqz39/YHRtQ66cTmaEptCCws85nV1fb6LrckBqDCkDFq5WqaUAKJucO9ojuqayR vYPE1+6L9TKKVX+K0sFxOd0icEcv2UYDN6tGpMSKGt5jp8bk1mSLpUAZVdXF1umq3P4i ddywIEdhpQAMfJiZhpCWOTYSBzWfllo/jawgmR9icftEWZhE10f0n48vny/AJIt6AYSb qsPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XGKqvA+f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si16283076ejk.81.2019.11.20.07.28.47; Wed, 20 Nov 2019 07:28:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XGKqvA+f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731258AbfKTP2p (ORCPT + 26 others); Wed, 20 Nov 2019 10:28:45 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:32834 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731187AbfKTP2n (ORCPT ); Wed, 20 Nov 2019 10:28:43 -0500 Received: by mail-wr1-f67.google.com with SMTP id w9so330952wrr.0; Wed, 20 Nov 2019 07:28:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VocVwERuj9CPUxI4LlG88AIMpkiR3wTIlIVCNMEfFWI=; b=XGKqvA+ftxeRIcTzRVR4iuKmoi0AoZftMzZznXbgI5lelIgfWtxFTXOkD40mmkJ0Yf 3F22LKumE86iAiZTdZP9sXgCKJowSPQEsszkhBRjtK2jKvfNZs3OcEhztgLYz9fCFYp7 FnRHXFhQTryMUWMHjF0jTxnuAMZ2bstdrHVNWQ3W5lOFj9A9vvJaoqPze3uXdJv0ZmY2 mVwxXHdA1kLLCy3FUnm+bNMrbOJ1Y8j0zdYzuYaQfcsoEF6V9j30lKqT3qf7x386q9pE uxwFmMwjNZKgba0UBhp6ZUEYCnk6EbEO2y9/cY8a//79YUOfCNXm2QqjQ3wj+jqWzPZt Q58g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VocVwERuj9CPUxI4LlG88AIMpkiR3wTIlIVCNMEfFWI=; b=lVU6/Gh4mAzBdN5p24+cARWJIpUG0mv25m7hwt6z86dKiTDhD7YvRSdQxPZeKn+Hae TSoxf6NI0elbnh/Q/CiyVRyySnidjFGVrooqn8qwRL7b8OdQuYUhgNtjHbZpyjUNugoF +V/5X3j891RlWoRBSydWAUQ8fOjtCJ6Nc7CFJ6DSnYv46EsyIZVNAVh3n3bcetWtJPTJ 5QGUpg+id9SHlv0Dglz0vKYpyIansPHqadO6se67dJzJPz0MWcUnoZEr3cqzN6LWm4yZ NTf9Vvmx9H27GCcSHLxGaE8GIadjQldqL6wZRiDbbgV5cO74gVded2uHgbnlQglNoGFD AcEQ== X-Gm-Message-State: APjAAAW8yVTTQhs7Fsb7BdFRVquXNtPWlJlkkieC6omI9NfruJfzBIX6 hPaHHjOP6Ub18/wpYoGKvnM5FTft X-Received: by 2002:a5d:4b82:: with SMTP id b2mr4032387wrt.335.1574263721112; Wed, 20 Nov 2019 07:28:41 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id w4sm31797881wrs.1.2019.11.20.07.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 07:28:40 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mark.rutland@arm.com, mripard@kernel.org, robh+dt@kernel.org, wens@csie.org Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH v2 3/3] crypto: sun4i-ss: add the A33 variant of SS Date: Wed, 20 Nov 2019 16:28:33 +0100 Message-Id: <20191120152833.20443-4-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191120152833.20443-1-clabbe.montjoie@gmail.com> References: <20191120152833.20443-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../crypto/allwinner/sun4i-ss/sun4i-ss-core.c | 22 ++++++++++++++++++- .../crypto/allwinner/sun4i-ss/sun4i-ss-hash.c | 5 ++++- drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h | 9 ++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) -- 2.23.0 diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c index 814cd12149a9..d35a05843c22 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,14 @@ #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[] = { { .type = CRYPTO_ALG_TYPE_AHASH, .mode = SS_OP_MD5, @@ -323,6 +332,12 @@ static int sun4i_ss_probe(struct platform_device *pdev) 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"); if (IS_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[] = { - { .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); diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c index 91cf58db3845..c791d6935c65 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c @@ -478,7 +478,10 @@ static int sun4i_hash(struct ahash_request *areq) /* Get the hash from the device */ if (op->mode == SS_OP_SHA1) { 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); } } else { diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h index 60425ac75d90..2b4c6333eb67 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h @@ -131,7 +131,16 @@ #define SS_SEED_LEN 192 #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 { + const struct ss_variant *variant; void __iomem *base; int irq; struct clk *busclk;