From patchwork Fri Sep 6 18:45:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135809 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AAB51398 for ; Fri, 6 Sep 2019 18:46:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C7C520838 for ; Fri, 6 Sep 2019 18:46:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VliEAdMq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395361AbfIFSqH (ORCPT ); Fri, 6 Sep 2019 14:46:07 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53010 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390567AbfIFSqG (ORCPT ); Fri, 6 Sep 2019 14:46:06 -0400 Received: by mail-wm1-f67.google.com with SMTP id t17so7513944wmi.2; Fri, 06 Sep 2019 11:46:04 -0700 (PDT) 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=UVVsUJ3cqxC7B0N9mD/oVG/ysz/2hMqLEdaltl6/SKo=; b=VliEAdMqXCZEuavCqjEh6OTr7ebBnxrMGNbDl2ershs4s/Nu3eg5EQbTh3IHq1RrYU 6sjfvjcrb8dH+OW8JTbCr0hZ4zVdMvWooEFD5JQBPoi3B5+8FyIkdGspxnf2/Y34eaJe wnT6Qj4WdcFJN1CKgrGjZQBghzuxkv/M5kPlNttWstId/gDVxTWjGtCwY2Pqjyi0fro4 1BtmmF4req7lbyPrLe/cjkdWNBaqTNUl/rTZZPIOX0vx/ssFR7CtsDgbN42TRjuKCqXH Msieu8Zh8UulkL+6NTZhiqPzAyauh7tIEkHGb4EeOOH2pw/3hIxzEjH823o38S/Psu4M jd8Q== 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=UVVsUJ3cqxC7B0N9mD/oVG/ysz/2hMqLEdaltl6/SKo=; b=TZ1VCnOpOyUhT2bBEONwZGKBmiRFFShuIPNO25YTFhlEDyjwvPblsGW43AEMT85fU9 Ffnz+KIb86lojLKLysJWd4kGOo3mUMbZf+FPPD9liS4d3I9hKE2TppCNNIZZ1FcLfj3e 2w4b62T6OGaBm4flL+kihL7MlxTgKM6AOM1jzSYyhXDnAgl1YtoUkj+icvQWntd7DXMV jh3m/wIEz10r9xGnTiSjwdJBywGTDvSFutyLrKFGgkh2RfK9Ze+Dx8qJ5GgoQ6O2U38H mDDRgB8CKlKSQ0SDcCVK7d5MK85c1QsA9S3cH7Sj10ScR/GvFuf8YQTnU11Z9vRU3ZcI yNGA== X-Gm-Message-State: APjAAAVauUCZJAXoEYIxAvCZ9pdY2/hzqQK/qISV1szYxrYFuyaO7lEl gSoP8PUXuZB6PNaQwTIye0E= X-Google-Smtp-Source: APXvYqyjrzRBxxj7tYzXaXaxio1nphXp3XWOYZgyMvwziBQzHIPj2h/NUODsCwcJ/4g0/R25PDbU+Q== X-Received: by 2002:a1c:9a46:: with SMTP id c67mr8434773wme.115.1567795564198; Fri, 06 Sep 2019 11:46:04 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:03 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 1/9] crypto: Add allwinner subdirectory Date: Fri, 6 Sep 2019 20:45:43 +0200 Message-Id: <20190906184551.17858-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Since a second Allwinner crypto driver will be added, it is better to create a dedicated subdirectory. Signed-off-by: Corentin Labbe --- MAINTAINERS | 6 ++++++ drivers/crypto/Kconfig | 2 ++ drivers/crypto/Makefile | 1 + drivers/crypto/allwinner/Kconfig | 6 ++++++ 4 files changed, 15 insertions(+) create mode 100644 drivers/crypto/allwinner/Kconfig diff --git a/MAINTAINERS b/MAINTAINERS index ee4e873c0f9a..d62ddf8ff262 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -681,6 +681,12 @@ L: linux-crypto@vger.kernel.org S: Maintained F: drivers/crypto/sunxi-ss/ +ALLWINNER CRYPTO ENGINE +M: Corentin Labbe +L: linux-crypto@vger.kernel.org +S: Maintained +F: drivers/crypto/allwinner/ + ALLWINNER VPU DRIVER M: Maxime Ripard M: Paul Kocialkowski diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 83271d944a96..fe90dd74797c 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig @@ -11,6 +11,8 @@ menuconfig CRYPTO_HW if CRYPTO_HW +source "drivers/crypto/allwinner/Kconfig" + config CRYPTO_DEV_PADLOCK tristate "Support for VIA PadLock ACE" depends on X86 && !UML diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index afc4753b5d28..90d60eff5ecc 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_CRYPTO_DEV_ALLWINNER) += allwinner/ obj-$(CONFIG_CRYPTO_DEV_ATMEL_AES) += atmel-aes.o obj-$(CONFIG_CRYPTO_DEV_ATMEL_SHA) += atmel-sha.o obj-$(CONFIG_CRYPTO_DEV_ATMEL_TDES) += atmel-tdes.o diff --git a/drivers/crypto/allwinner/Kconfig b/drivers/crypto/allwinner/Kconfig new file mode 100644 index 000000000000..0c8a99f7959d --- /dev/null +++ b/drivers/crypto/allwinner/Kconfig @@ -0,0 +1,6 @@ +config CRYPTO_DEV_ALLWINNER + bool "Support for Allwinner cryptographic offloader" + depends on ARCH_SUNXI || COMPILE_TEST + default y if ARCH_SUNXI + help + Say Y here to get to see options for Allwinner hardware crypto devices From patchwork Fri Sep 6 18:45:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135807 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 285861708 for ; Fri, 6 Sep 2019 18:46:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D94A6208C3 for ; Fri, 6 Sep 2019 18:46:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kKRpoEwr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436661AbfIFSqw (ORCPT ); Fri, 6 Sep 2019 14:46:52 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34011 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395368AbfIFSqL (ORCPT ); Fri, 6 Sep 2019 14:46:11 -0400 Received: by mail-wm1-f68.google.com with SMTP id y135so8012970wmc.1; Fri, 06 Sep 2019 11:46:07 -0700 (PDT) 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=gEQgUSBQCxuVE1wg76TJ7aomsqut3kVHgaiDJRHUfKg=; b=kKRpoEwrliVBBCH57DTvcRNglHxpwcwRhxKv/MWz4W2ZKW77NLluslz9vF3u/IzC4v VJueOo0iLDkrLq9vWAQK4GujbInid/r7guH1JbusfmaR1vmC0DNFQEAGorOj1YRrBM0j ZyIOTnsm9Vr5w995E73g+8mQIfIkxxTnTbkAeq9i3Dvc9FZEJ6j3yG9NcdK5OrtBqCz7 FiMzjXOGOir3XTXeST7YxH4q1mlN0SYRr9VyEla8Gv206Suig/rNEXAXtj+GKPpHhePT yHxWOrs4MewNec0REhiZndQJeUDIu8UgqZTBcsnRHAJ0WNg2mGDKTACfO0hBY4mc5ekZ SQ8w== 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=gEQgUSBQCxuVE1wg76TJ7aomsqut3kVHgaiDJRHUfKg=; b=bZlR0VBdxTl9xNCUGgBA+8AHsCzL+0OEAE6BIY9Cwig2bSx8F+YIU3KcDNQ2EnKPA/ v0hG5cIcOGawei0s5/1fVBRfvixbVqPZYQ+w6PcTf/UIgRhL/CSYJL7OZROHoi5kZI0a u3gKjs2NrLauwU0vmTXX5Zd/86LHe7DGVVDNWhwpdBfhIqBk8wQdAO3zcqoR9teksQQl ZcX+br6/ygL1xOvFmsG9O+3N8q6BDk0CUBE5nQwAr0V9SZ7LBgknm6N/s+awONFn+ijR azdkZSlMJJU/kAlBxGYi9sq4sRHYK9Ou6iNeIF4areFzU0DQ7aaSY9xZykFmhqMR37EV tspw== X-Gm-Message-State: APjAAAUfDbqVQcNhBKJsUCuPXrqdFnIWXpSc4BzdIdOTG9IOnpwSmia9 kMMFDwXWfZwsXw+++z2arEQ= X-Google-Smtp-Source: APXvYqy/j4C2YVSPqkQi1Za9BGBRBECm7mRvpRlnpa7SlPHT4wNraXnQsnwHrLzH7gWSEdZxbOsYMw== X-Received: by 2002:a1c:7c1a:: with SMTP id x26mr9264378wmc.115.1567795566441; Fri, 06 Sep 2019 11:46:06 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:05 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 2/9] crypto: Add Allwinner sun8i-ce Crypto Engine Date: Fri, 6 Sep 2019 20:45:44 +0200 Message-Id: <20190906184551.17858-3-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The Crypto Engine is an hardware cryptographic offloader present on all recent Allwinner SoCs H2+, H3, R40, A64, H5, H6 This driver supports AES cipher in CBC/ECB mode. Signed-off-by: Corentin Labbe --- drivers/crypto/allwinner/Kconfig | 26 + drivers/crypto/allwinner/Makefile | 1 + drivers/crypto/allwinner/sun8i-ce/Makefile | 2 + .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 390 +++++++++++ .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 630 ++++++++++++++++++ drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h | 256 +++++++ 6 files changed, 1305 insertions(+) create mode 100644 drivers/crypto/allwinner/Makefile create mode 100644 drivers/crypto/allwinner/sun8i-ce/Makefile create mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c create mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c create mode 100644 drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h diff --git a/drivers/crypto/allwinner/Kconfig b/drivers/crypto/allwinner/Kconfig index 0c8a99f7959d..742a08b64c90 100644 --- a/drivers/crypto/allwinner/Kconfig +++ b/drivers/crypto/allwinner/Kconfig @@ -4,3 +4,29 @@ config CRYPTO_DEV_ALLWINNER default y if ARCH_SUNXI help Say Y here to get to see options for Allwinner hardware crypto devices + +config CRYPTO_DEV_SUN8I_CE + tristate "Support for Allwinner Crypto Engine cryptographic offloader" + select CRYPTO_BLKCIPHER + select CRYPTO_ENGINE + select CRYPTO_ECB + select CRYPTO_CBC + select CRYPTO_AES + select CRYPTO_DES + depends on CRYPTO_DEV_ALLWINNER + help + Select y here for having support for the crypto Engine availlable on + Allwinner SoC H2+, H3, H5, H6, R40 and A64. + The Crypto Engine handle AES/3DES ciphers in ECB/CBC mode. + + To compile this driver as a module, choose M here: the module + will be called sun8i-ce. + +config CRYPTO_DEV_SUN8I_CE_DEBUG + bool "Enabled sun8i-ce stats" + depends on CRYPTO_DEV_SUN8I_CE + depends on DEBUG_FS + help + Say y to enabled sun8i-ce debug stats. + This will create /sys/kernel/debug/sun8i-ce/stats for displaying + the number of requests per flow and per algorithm. diff --git a/drivers/crypto/allwinner/Makefile b/drivers/crypto/allwinner/Makefile new file mode 100644 index 000000000000..11f02db9ee06 --- /dev/null +++ b/drivers/crypto/allwinner/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_CRYPTO_DEV_SUN8I_CE) += sun8i-ce/ diff --git a/drivers/crypto/allwinner/sun8i-ce/Makefile b/drivers/crypto/allwinner/sun8i-ce/Makefile new file mode 100644 index 000000000000..08b68c3c1ca9 --- /dev/null +++ b/drivers/crypto/allwinner/sun8i-ce/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_CRYPTO_DEV_SUN8I_CE) += sun8i-ce.o +sun8i-ce-y += sun8i-ce-core.o sun8i-ce-cipher.o diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c new file mode 100644 index 000000000000..c22f0592f168 --- /dev/null +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c @@ -0,0 +1,390 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * sun8i-ce-cipher.c - hardware cryptographic offloader for + * Allwinner H3/A64/H5/H2+/H6/R40 SoC + * + * Copyright (C) 2016-2019 Corentin LABBE + * + * This file add support for AES cipher with 128,192,256 bits keysize in + * CBC and ECB mode. + * + * You could find a link for the datasheet in Documentation/arm/sunxi/README + */ + +#include +#include +#include +#include +#include +#include +#include "sun8i-ce.h" + +static int sun8i_ce_cipher(struct skcipher_request *areq) +{ + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); + struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct sun8i_ce_dev *ce = op->ce; + struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); + struct skcipher_alg *alg = crypto_skcipher_alg(tfm); + struct sun8i_ce_alg_template *algt; + struct sun8i_ce_flow *chan; + struct ce_task *cet; + struct scatterlist *sg; + bool need_fallback = false; + unsigned int todo, len, offset, ivsize; + void *backup_iv = NULL; + int flow, i; + int nr_sgs = 0; + int nr_sgd = 0; + int err = 0; + + algt = container_of(alg, struct sun8i_ce_alg_template, alg.skcipher); + + dev_dbg(ce->dev, "%s %s %u %x IV(%p %u) key=%u\n", __func__, + crypto_tfm_alg_name(areq->base.tfm), + areq->cryptlen, + rctx->op_dir, areq->iv, crypto_skcipher_ivsize(tfm), + op->keylen); + + if (sg_nents(areq->src) > MAX_SG || sg_nents(areq->dst) > MAX_SG) + need_fallback = true; + + if (areq->cryptlen < crypto_skcipher_ivsize(tfm)) + need_fallback = true; + + if (areq->cryptlen == 0) + need_fallback = true; + if (areq->cryptlen % algt->alg.skcipher.base.cra_blocksize) + need_fallback = true; + + sg = areq->src; + while (sg && !need_fallback) { + if (sg->length % 4 || !IS_ALIGNED(sg->offset, sizeof(u32))) { + need_fallback = true; + break; + } + sg = sg_next(sg); + } + sg = areq->dst; + while (sg && !need_fallback) { + if (sg->length % 4 || !IS_ALIGNED(sg->offset, sizeof(u32))) { + need_fallback = true; + break; + } + sg = sg_next(sg); + } + +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + algt->stat_req++; +#endif + + if (need_fallback) { + SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, op->fallback_tfm); +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + algt->stat_fb++; +#endif + skcipher_request_set_sync_tfm(subreq, op->fallback_tfm); + skcipher_request_set_callback(subreq, areq->base.flags, NULL, + NULL); + skcipher_request_set_crypt(subreq, areq->src, areq->dst, + areq->cryptlen, areq->iv); + if (rctx->op_dir & CE_DECRYPTION) + err = crypto_skcipher_decrypt(subreq); + else + err = crypto_skcipher_encrypt(subreq); + skcipher_request_zero(subreq); + return err; + } + + flow = rctx->flow; + + chan = &ce->chanlist[flow]; + mutex_lock(&chan->lock); + + cet = chan->tl; + memset(cet, 0, sizeof(struct ce_task)); + + cet->t_id = flow; + cet->t_common_ctl = ce->variant->alg_cipher[algt->ce_algo_id]; + cet->t_common_ctl |= rctx->op_dir | CE_COMM_INT; + cet->t_dlen = areq->cryptlen / 4; + /* CTS and recent CE (H6) need length in bytes, in word otherwise */ + if (ce->variant->model == CE_v2) + cet->t_dlen = areq->cryptlen; + + cet->t_sym_ctl = ce->variant->op_mode[algt->ce_blockmode]; + len = op->keylen; + switch (len) { + case 128 / 8: + cet->t_sym_ctl |= CE_AES_128BITS; + break; + case 192 / 8: + cet->t_sym_ctl |= CE_AES_192BITS; + break; + case 256 / 8: + cet->t_sym_ctl |= CE_AES_256BITS; + break; + } + + cet->t_asym_ctl = 0; + + chan->op_mode = ce->variant->op_mode[algt->ce_blockmode]; + chan->op_dir = rctx->op_dir; + chan->method = ce->variant->alg_cipher[algt->ce_algo_id]; + chan->keylen = op->keylen; + + cet->t_key = dma_map_single(ce->dev, op->key, op->keylen, + DMA_TO_DEVICE); + if (dma_mapping_error(ce->dev, cet->t_key)) { + dev_err(ce->dev, "Cannot DMA MAP KEY\n"); + err = -EFAULT; + goto theend; + } + + ivsize = crypto_skcipher_ivsize(tfm); + if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) { + chan->ivlen = ivsize; + chan->bounce_iv = kzalloc(ivsize, GFP_KERNEL | GFP_DMA); + if (!chan->bounce_iv) { + err = -ENOMEM; + goto theend_key; + } + if (rctx->op_dir & CE_DECRYPTION) { + backup_iv = kzalloc(ivsize, GFP_KERNEL); + if (!backup_iv) { + err = -ENOMEM; + goto theend_key; + } + offset = areq->cryptlen - ivsize; + scatterwalk_map_and_copy(backup_iv, areq->src, offset, + ivsize, 0); + } + memcpy(chan->bounce_iv, areq->iv, ivsize); + } + + if (areq->src == areq->dst) { + nr_sgs = dma_map_sg(ce->dev, areq->src, sg_nents(areq->src), + DMA_BIDIRECTIONAL); + if (nr_sgs <= 0 || nr_sgs > MAX_SG) { + dev_err(ce->dev, "Invalid sg number %d\n", nr_sgs); + err = -EINVAL; + goto theend_iv; + } + nr_sgd = nr_sgs; + } else { + nr_sgs = dma_map_sg(ce->dev, areq->src, sg_nents(areq->src), + DMA_TO_DEVICE); + if (nr_sgs <= 0 || nr_sgs > MAX_SG) { + dev_err(ce->dev, "Invalid sg number %d\n", nr_sgs); + err = -EINVAL; + goto theend_iv; + } + nr_sgd = dma_map_sg(ce->dev, areq->dst, sg_nents(areq->dst), + DMA_FROM_DEVICE); + if (nr_sgd <= 0 || nr_sgd > MAX_SG) { + dev_err(ce->dev, "Invalid sg number %d\n", nr_sgd); + err = -EINVAL; + goto theend_sgs; + } + } + + len = areq->cryptlen; + for_each_sg(areq->src, sg, nr_sgs, i) { + cet->t_src[i].addr = sg_dma_address(sg); + todo = min(len, sg_dma_len(sg)); + cet->t_src[i].len = todo / 4; + dev_dbg(ce->dev, "%s total=%u SG(%d %u off=%d) todo=%u\n", __func__, + areq->cryptlen, i, cet->t_src[i].len, sg->offset, todo); + len -= todo; + } + if (len > 0) + dev_err(ce->dev, "remaining len %d\n", len); + + len = areq->cryptlen; + for_each_sg(areq->dst, sg, nr_sgd, i) { + cet->t_dst[i].addr = sg_dma_address(sg); + todo = min(len, sg_dma_len(sg)); + cet->t_dst[i].len = todo / 4; + dev_dbg(ce->dev, "%s total=%u SG(%d %u off=%d) todo=%u\n", __func__, + areq->cryptlen, i, cet->t_dst[i].len, sg->offset, todo); + len -= todo; + } + if (len > 0) + dev_err(ce->dev, "remaining len %d\n", len); + + chan->timeout = areq->cryptlen; + err = sun8i_ce_run_task(ce, flow, "cipher"); + if (err) + dev_err(ce->dev, "Error with len=%u\n", areq->cryptlen); + +theend_sgs: + if (areq->src == areq->dst) { + dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_BIDIRECTIONAL); + } else { + if (nr_sgs > 0) + dma_unmap_sg(ce->dev, areq->src, nr_sgs, DMA_TO_DEVICE); + dma_unmap_sg(ce->dev, areq->dst, nr_sgd, DMA_FROM_DEVICE); + } + +theend_iv: + if (areq->iv && ivsize > 0) { + offset = areq->cryptlen - ivsize; + if (rctx->op_dir & CE_DECRYPTION) { + memcpy(areq->iv, backup_iv, ivsize); + kzfree(backup_iv); + } else { + scatterwalk_map_and_copy(areq->iv, areq->dst, offset, + ivsize, 0); + } + kfree(chan->bounce_iv); + } + +theend_key: + dma_unmap_single(ce->dev, cet->t_key, op->keylen, DMA_TO_DEVICE); + +theend: + mutex_unlock(&chan->lock); + + return err; +} + +static int handle_cipher_request(struct crypto_engine *engine, void *areq) +{ + int err; + struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); + + err = sun8i_ce_cipher(breq); + crypto_finalize_skcipher_request(engine, breq, err); + + return 0; +} + +int sun8i_ce_skdecrypt(struct skcipher_request *areq) +{ + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); + struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); + int e = sun8i_ce_get_engine_number(op->ce); + struct crypto_engine *engine = op->ce->chanlist[e].engine; + + rctx->op_dir = CE_DECRYPTION; + rctx->flow = e; + + return crypto_transfer_skcipher_request_to_engine(engine, areq); +} + +int sun8i_ce_skencrypt(struct skcipher_request *areq) +{ + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq); + struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq); + int e = sun8i_ce_get_engine_number(op->ce); + struct crypto_engine *engine = op->ce->chanlist[e].engine; + + rctx->op_dir = CE_ENCRYPTION; + rctx->flow = e; + + return crypto_transfer_skcipher_request_to_engine(engine, areq); +} + +int sun8i_ce_cipher_init(struct crypto_tfm *tfm) +{ + struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm); + struct sun8i_ce_alg_template *algt; + const char *name = crypto_tfm_alg_name(tfm); + struct crypto_skcipher *sktfm = __crypto_skcipher_cast(tfm); + struct skcipher_alg *alg = crypto_skcipher_alg(sktfm); + + memset(op, 0, sizeof(struct sun8i_cipher_tfm_ctx)); + + algt = container_of(alg, struct sun8i_ce_alg_template, alg.skcipher); + op->ce = algt->ce; + + sktfm->reqsize = sizeof(struct sun8i_cipher_req_ctx); + + op->fallback_tfm = crypto_alloc_sync_skcipher(name, 0, CRYPTO_ALG_NEED_FALLBACK); + if (IS_ERR(op->fallback_tfm)) { + dev_err(op->ce->dev, "ERROR: Cannot allocate fallback for %s %ld\n", + name, PTR_ERR(op->fallback_tfm)); + return PTR_ERR(op->fallback_tfm); + } + + dev_info(op->ce->dev, "Fallback is %s\n", crypto_tfm_alg_driver_name(crypto_skcipher_tfm(&op->fallback_tfm->base))); + + op->enginectx.op.do_one_request = handle_cipher_request; + op->enginectx.op.prepare_request = NULL; + op->enginectx.op.unprepare_request = NULL; + + return 0; +} + +void sun8i_ce_cipher_exit(struct crypto_tfm *tfm) +{ + struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm); + + if (op->key) { + memzero_explicit(op->key, op->keylen); + kfree(op->key); + } + crypto_free_sync_skcipher(op->fallback_tfm); +} + +int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, + unsigned int keylen) +{ + struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + struct sun8i_ce_dev *ce = op->ce; + + switch (keylen) { + case 128 / 8: + break; + case 192 / 8: + break; + case 256 / 8: + break; + default: + dev_dbg(ce->dev, "ERROR: Invalid keylen %u\n", keylen); + crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + if (op->key) { + memzero_explicit(op->key, op->keylen); + kfree(op->key); + } + op->keylen = keylen; + op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA); + if (!op->key) + return -ENOMEM; + memcpy(op->key, key, keylen); + + crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK); + crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK); + + return crypto_sync_skcipher_setkey(op->fallback_tfm, key, keylen); +} + +int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, + unsigned int keylen) +{ + struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm); + int err; + + err = verify_skcipher_des3_key(tfm, key); + if (err) + return err; + + if (op->key) { + memzero_explicit(op->key, op->keylen); + kfree(op->key); + } + op->keylen = keylen; + op->key = kmalloc(keylen, GFP_KERNEL | GFP_DMA); + if (!op->key) + return -ENOMEM; + memcpy(op->key, key, keylen); + + crypto_sync_skcipher_clear_flags(op->fallback_tfm, CRYPTO_TFM_REQ_MASK); + crypto_sync_skcipher_set_flags(op->fallback_tfm, tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK); + + return crypto_sync_skcipher_setkey(op->fallback_tfm, key, keylen); +} diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c new file mode 100644 index 000000000000..c609b9943296 --- /dev/null +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c @@ -0,0 +1,630 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * sun8i-ce-core.c - hardware cryptographic offloader for + * Allwinner H3/A64/H5/H2+/H6/R40 SoC + * + * Copyright (C) 2015-2019 Corentin Labbe + * + * Core file which registers crypto algorithms supported by the CryptoEngine. + * + * You could find a link for the datasheet in Documentation/arm/sunxi/README + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sun8i-ce.h" + +static const struct ce_variant ce_h3_variant = { + .alg_cipher = { CE_ID_NOTSUPP, CE_ALG_AES, CE_ALG_DES, CE_ALG_3DES, + CE_ID_NOTSUPP, + }, + .op_mode = { CE_ID_NOTSUPP, CE_OP_ECB, CE_OP_CBC + }, + .intreg = CE_ISR, + .maxflow = 4, + .ce_clks = { + { "ahb", 200000000 }, + { "mod", 48000000 }, + } +}; + +static const struct ce_variant ce_h5_variant = { + .alg_cipher = { CE_ID_NOTSUPP, CE_ALG_AES, CE_ALG_DES, CE_ALG_3DES, + CE_ID_NOTSUPP, + }, + .op_mode = { CE_ID_NOTSUPP, CE_OP_ECB, CE_OP_CBC + }, + .intreg = CE_ISR, + .maxflow = 4, + .ce_clks = { + { "ahb", 200000000 }, + { "mod", 300000000 }, + } +}; + +static const struct ce_variant ce_h6_variant = { + .alg_cipher = { CE_ID_NOTSUPP, CE_ALG_AES, CE_ALG_DES, CE_ALG_3DES, + CE_ALG_RAES, + }, + .op_mode = { CE_ID_NOTSUPP, CE_OP_ECB, CE_OP_CBC + }, + .model = CE_v2, + .intreg = CE_ISR, + .maxflow = 4, + .ce_clks = { + { "ahb", 200000000 }, + { "mod", 300000000 }, + { "mbus", 400000000 }, + } +}; + +static const struct ce_variant ce_a64_variant = { + .alg_cipher = { CE_ID_NOTSUPP, CE_ALG_AES, CE_ALG_DES, CE_ALG_3DES, + CE_ID_NOTSUPP, + }, + .op_mode = { CE_ID_NOTSUPP, CE_OP_ECB, CE_OP_CBC + }, + .intreg = CE_ISR, + .maxflow = 4, + .ce_clks = { + { "ahb", 200000000 }, + { "mod", 300000000 }, + } +}; + +static const struct ce_variant ce_r40_variant = { + .alg_cipher = { CE_ID_NOTSUPP, CE_ALG_AES, CE_ALG_DES, CE_ALG_3DES, + CE_ID_NOTSUPP, + }, + .op_mode = { CE_ID_NOTSUPP, CE_OP_ECB, CE_OP_CBC + }, + .intreg = CE_ISR, + .maxflow = 4, + .ce_clks = { + { "ahb", 200000000 }, + { "mod", 300000000 }, + } +}; + +int sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce) +{ + return atomic_inc_return(&ce->flow) % ce->variant->maxflow; +} + +int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name) +{ + u32 v; + int err = 0; + struct ce_task *cet = ce->chanlist[flow].tl; + + if (ce->chanlist[flow].bounce_iv) { + cet->t_iv = dma_map_single(ce->dev, + ce->chanlist[flow].bounce_iv, + ce->chanlist[flow].ivlen, + DMA_TO_DEVICE); + if (dma_mapping_error(ce->dev, cet->t_iv)) { + dev_err(ce->dev, "Cannot DMA MAP IV\n"); + return -EFAULT; + } + } + +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + ce->chanlist[flow].stat_req++; +#endif + + mutex_lock(&ce->mlock); + + v = readl(ce->base + CE_ICR); + v |= 1 << flow; + writel(v, ce->base + CE_ICR); + + reinit_completion(&ce->chanlist[flow].complete); + writel(ce->chanlist[flow].t_phy, ce->base + CE_TDQ); + + ce->chanlist[flow].status = 0; + /* Be sure all data is written before enabling the task */ + wmb(); + + v = 1 | (ce->chanlist[flow].tl->t_common_ctl & 0x7F) << 8; + writel(v, ce->base + CE_TLR); + mutex_unlock(&ce->mlock); + + wait_for_completion_interruptible_timeout(&ce->chanlist[flow].complete, + msecs_to_jiffies(ce->chanlist[flow].timeout)); + + if (ce->chanlist[flow].status == 0) { + dev_err(ce->dev, "DMA timeout for %s\n", name); + err = -EFAULT; + } + /* No need to lock for this read, the channel is locked so + * nothing could modify the error value for this channel + */ + v = readl(ce->base + CE_ESR); + if (v) { + v >>= (flow * 4); + v &= 0xFF; + if (v) { + dev_err(ce->dev, "CE ERROR: %x for flow %x\n", v, flow); + err = -EFAULT; + } + if (v & CE_ERR_ALGO_NOTSUP) + dev_err(ce->dev, "CE ERROR: algorithm not supported\n"); + if (v & CE_ERR_DATALEN) + dev_err(ce->dev, "CE ERROR: data length error\n"); + if (v & CE_ERR_KEYSRAM) + dev_err(ce->dev, "CE ERROR: keysram access error for AES\n"); + if (v & CE_ERR_ADDR_INVALID) + dev_err(ce->dev, "CE ERROR: address invalid\n"); + } + + if (ce->chanlist[flow].bounce_iv) { + dma_unmap_single(ce->dev, cet->t_iv, + ce->chanlist[flow].ivlen, + DMA_TO_DEVICE); + } + + return err; +} + +static irqreturn_t ce_irq_handler(int irq, void *data) +{ + struct sun8i_ce_dev *ce = (struct sun8i_ce_dev *)data; + int flow = 0; + u32 p; + + p = readl(ce->base + ce->variant->intreg); + for (flow = 0; flow < ce->variant->maxflow; flow++) { + if (p & (BIT(flow))) { + writel(BIT(flow), ce->base + ce->variant->intreg); + ce->chanlist[flow].status = 1; + complete(&ce->chanlist[flow].complete); + } + } + + return IRQ_HANDLED; +} + +static struct sun8i_ce_alg_template ce_algs[] = { +{ + .type = CRYPTO_ALG_TYPE_SKCIPHER, + .ce_algo_id = CE_ID_CIPHER_AES, + .ce_blockmode = CE_ID_OP_CBC, + .alg.skcipher = { + .base = { + .cra_name = "cbc(aes)", + .cra_driver_name = "cbc-aes-sun8i-ce", + .cra_priority = 400, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, + .cra_ctxsize = sizeof(struct sun8i_cipher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0xf, + .cra_init = sun8i_ce_cipher_init, + .cra_exit = sun8i_ce_cipher_exit, + }, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .setkey = sun8i_ce_aes_setkey, + .encrypt = sun8i_ce_skencrypt, + .decrypt = sun8i_ce_skdecrypt, + } +}, +{ + .type = CRYPTO_ALG_TYPE_SKCIPHER, + .ce_algo_id = CE_ID_CIPHER_AES, + .ce_blockmode = CE_ID_OP_ECB, + .alg.skcipher = { + .base = { + .cra_name = "ecb(aes)", + .cra_driver_name = "ecb-aes-sun8i-ce", + .cra_priority = 400, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, + .cra_ctxsize = sizeof(struct sun8i_cipher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0xf, + .cra_init = sun8i_ce_cipher_init, + .cra_exit = sun8i_ce_cipher_exit, + }, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .setkey = sun8i_ce_aes_setkey, + .encrypt = sun8i_ce_skencrypt, + .decrypt = sun8i_ce_skdecrypt, + } +}, +{ + .type = CRYPTO_ALG_TYPE_SKCIPHER, + .ce_algo_id = CE_ID_CIPHER_DES3, + .ce_blockmode = CE_ID_OP_CBC, + .alg.skcipher = { + .base = { + .cra_name = "cbc(des3_ede)", + .cra_driver_name = "cbc-des3-sun8i-ce", + .cra_priority = 400, + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, + .cra_ctxsize = sizeof(struct sun8i_cipher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0xf, + .cra_init = sun8i_ce_cipher_init, + .cra_exit = sun8i_ce_cipher_exit, + }, + .min_keysize = DES3_EDE_KEY_SIZE, + .max_keysize = DES3_EDE_KEY_SIZE, + .ivsize = DES3_EDE_BLOCK_SIZE, + .setkey = sun8i_ce_des3_setkey, + .encrypt = sun8i_ce_skencrypt, + .decrypt = sun8i_ce_skdecrypt, + } +}, +{ + .type = CRYPTO_ALG_TYPE_SKCIPHER, + .ce_algo_id = CE_ID_CIPHER_DES3, + .ce_blockmode = CE_ID_OP_ECB, + .alg.skcipher = { + .base = { + .cra_name = "ecb(des3_ede)", + .cra_driver_name = "ecb-des3-sun8i-ce", + .cra_priority = 400, + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, + .cra_ctxsize = sizeof(struct sun8i_cipher_tfm_ctx), + .cra_module = THIS_MODULE, + .cra_alignmask = 0xf, + .cra_init = sun8i_ce_cipher_init, + .cra_exit = sun8i_ce_cipher_exit, + }, + .min_keysize = DES3_EDE_KEY_SIZE, + .max_keysize = DES3_EDE_KEY_SIZE, + .setkey = sun8i_ce_des3_setkey, + .encrypt = sun8i_ce_skencrypt, + .decrypt = sun8i_ce_skdecrypt, + } +}, +}; + +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG +static int sun8i_ce_dbgfs_read(struct seq_file *seq, void *v) +{ + struct sun8i_ce_dev *ce = seq->private; + int i; + + for (i = 0; i < ce->variant->maxflow; i++) + seq_printf(seq, "Channel %d: req %lu\n", i, ce->chanlist[i].stat_req); + + for (i = 0; i < ARRAY_SIZE(ce_algs); i++) { + if (!ce_algs[i].ce) + continue; + switch (ce_algs[i].type) { + case CRYPTO_ALG_TYPE_SKCIPHER: + seq_printf(seq, "%s %s %lu %lu\n", + ce_algs[i].alg.skcipher.base.cra_driver_name, + ce_algs[i].alg.skcipher.base.cra_name, + ce_algs[i].stat_req, ce_algs[i].stat_fb); + break; + } + } + return 0; +} + +static int sun8i_ce_dbgfs_open(struct inode *inode, struct file *file) +{ + return single_open(file, sun8i_ce_dbgfs_read, inode->i_private); +} + +static const struct file_operations sun8i_ce_debugfs_fops = { + .owner = THIS_MODULE, + .open = sun8i_ce_dbgfs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +#endif + +static int sun8i_ce_probe(struct platform_device *pdev) +{ + struct resource *res; + u32 v; + int err, i, ce_method, id, irq; + unsigned long cr; + struct sun8i_ce_dev *ce; + + if (!pdev->dev.of_node) + return -ENODEV; + + ce = devm_kzalloc(&pdev->dev, sizeof(*ce), GFP_KERNEL); + if (!ce) + return -ENOMEM; + + ce->variant = of_device_get_match_data(&pdev->dev); + if (!ce->variant) { + dev_err(&pdev->dev, "Missing Crypto Engine variant\n"); + return -EINVAL; + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ce->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(ce->base)) { + err = PTR_ERR(ce->base); + dev_err(&pdev->dev, "Cannot request MMIO err=%d\n", err); + return err; + } + + for (i = 0; i < CE_MAX_CLOCKS; i++) { + if (!ce->variant->ce_clks[i].name) + continue; + dev_info(&pdev->dev, "Get %s clock\n", ce->variant->ce_clks[i].name); + ce->ceclks[i] = devm_clk_get(&pdev->dev, ce->variant->ce_clks[i].name); + if (IS_ERR(ce->ceclks[i])) { + err = PTR_ERR(ce->ceclks[i]); + dev_err(&pdev->dev, "Cannot get %s CE clock err=%d\n", + ce->variant->ce_clks[i].name, err); + } + cr = clk_get_rate(ce->ceclks[i]); + if (ce->variant->ce_clks[i].freq) { + dev_info(&pdev->dev, "Set %s clock to %lu (%lu Mhz) from %lu (%lu Mhz)\n", + ce->variant->ce_clks[i].name, + ce->variant->ce_clks[i].freq, + ce->variant->ce_clks[i].freq / 1000000, + cr, + cr / 1000000); + err = clk_set_rate(ce->ceclks[i], ce->variant->ce_clks[i].freq); + if (err) + dev_err(&pdev->dev, "Fail to set %s clk speed to %lu\n", + ce->variant->ce_clks[i].name, + ce->variant->ce_clks[i].freq); + } else { + dev_info(&pdev->dev, "%s run at %lu\n", + ce->variant->ce_clks[i].name, cr); + } + err = clk_prepare_enable(ce->ceclks[i]); + if (err) { + dev_err(&pdev->dev, "Cannot prepare_enable %s\n", + ce->variant->ce_clks[i].name); + return err; + } + } + + /* Get Non Secure IRQ */ + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(ce->dev, "Cannot get NS IRQ\n"); + return irq; + } + + err = devm_request_irq(&pdev->dev, irq, ce_irq_handler, 0, + "sun8i-ce-ns", ce); + if (err < 0) { + dev_err(ce->dev, "Cannot request NS IRQ\n"); + return err; + } + + ce->reset = devm_reset_control_get_optional(&pdev->dev, "ahb"); + if (IS_ERR(ce->reset)) { + if (PTR_ERR(ce->reset) == -EPROBE_DEFER) + return PTR_ERR(ce->reset); + dev_info(&pdev->dev, "No reset control found\n"); + ce->reset = NULL; + } + + err = reset_control_deassert(ce->reset); + if (err) { + dev_err(&pdev->dev, "Cannot deassert reset control\n"); + goto error_clk; + } + + v = readl(ce->base + CE_CTR); + v >>= 16; + v &= 0x07; + dev_info(&pdev->dev, "CE_NS Die ID %x\n", v); + + ce->dev = &pdev->dev; + platform_set_drvdata(pdev, ce); + + mutex_init(&ce->mlock); + + ce->chanlist = devm_kcalloc(ce->dev, ce->variant->maxflow, + sizeof(struct sun8i_ce_flow), GFP_KERNEL); + if (!ce->chanlist) { + err = -ENOMEM; + goto error_flow; + } + + for (i = 0; i < ce->variant->maxflow; i++) { + init_completion(&ce->chanlist[i].complete); + mutex_init(&ce->chanlist[i].lock); + + ce->chanlist[i].engine = crypto_engine_alloc_init(ce->dev, true); + if (!ce->chanlist[i].engine) { + dev_err(ce->dev, "Cannot allocate engine\n"); + i--; + goto error_engine; + } + err = crypto_engine_start(ce->chanlist[i].engine); + if (err) { + dev_err(ce->dev, "Cannot start engine\n"); + goto error_engine; + } + ce->chanlist[i].tl = dma_alloc_coherent(ce->dev, + sizeof(struct ce_task), + &ce->chanlist[i].t_phy, + GFP_KERNEL); + if (!ce->chanlist[i].tl) { + dev_err(ce->dev, "Cannot get DMA memory for task %d\n", + i); + err = -ENOMEM; + goto error_engine; + } + } + +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + ce->dbgfs_dir = debugfs_create_dir("sun8i-ce", NULL); + if (IS_ERR_OR_NULL(ce->dbgfs_dir)) { + dev_err(ce->dev, "Fail to create debugfs dir"); + err = -ENOMEM; + goto error_engine; + } + ce->dbgfs_stats = debugfs_create_file("stats", 0444, + ce->dbgfs_dir, ce, + &sun8i_ce_debugfs_fops); + if (IS_ERR_OR_NULL(ce->dbgfs_stats)) { + dev_err(ce->dev, "Fail to create debugfs stat"); + err = -ENOMEM; + goto error_debugfs; + } +#endif + for (i = 0; i < ARRAY_SIZE(ce_algs); i++) { + ce_algs[i].ce = ce; + switch (ce_algs[i].type) { + case CRYPTO_ALG_TYPE_SKCIPHER: + id = ce_algs[i].ce_algo_id; + ce_method = ce->variant->alg_cipher[id]; + if (ce_method == CE_ID_NOTSUPP) { + dev_info(ce->dev, + "DEBUG: Algo of %s not supported\n", + ce_algs[i].alg.skcipher.base.cra_name); + ce_algs[i].ce = NULL; + break; + } + id = ce_algs[i].ce_blockmode; + ce_method = ce->variant->op_mode[id]; + if (ce_method == CE_ID_NOTSUPP) { + dev_info(ce->dev, "DEBUG: Blockmode of %s not supported\n", + ce_algs[i].alg.skcipher.base.cra_name); + ce_algs[i].ce = NULL; + break; + } + dev_info(ce->dev, "DEBUG: Register %s\n", + ce_algs[i].alg.skcipher.base.cra_name); + err = crypto_register_skcipher(&ce_algs[i].alg.skcipher); + if (err) { + dev_err(ce->dev, "Fail to register %s\n", + ce_algs[i].alg.skcipher.base.cra_name); + ce_algs[i].ce = NULL; + goto error_alg; + } + break; + default: + dev_err(ce->dev, "ERROR: tryed to register an unknown algo\n"); + } + } + + return 0; +error_alg: + i--; + for (; i >= 0; i--) { + switch (ce_algs[i].type) { + case CRYPTO_ALG_TYPE_SKCIPHER: + if (ce_algs[i].ce) + crypto_unregister_skcipher(&ce_algs[i].alg.skcipher); + break; + } + } +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG +error_debugfs: + debugfs_remove_recursive(ce->dbgfs_dir); +#endif + i = ce->variant->maxflow; +error_engine: + while (i >= 0) { + crypto_engine_exit(ce->chanlist[i].engine); + if (ce->chanlist[i].tl) + dma_free_coherent(ce->dev, sizeof(struct ce_task), + ce->chanlist[i].tl, + ce->chanlist[i].t_phy); + i--; + } +error_flow: + reset_control_assert(ce->reset); +error_clk: + for (i = 0; i < CE_MAX_CLOCKS; i++) + clk_disable_unprepare(ce->ceclks[i]); + return err; +} + +static int sun8i_ce_remove(struct platform_device *pdev) +{ + int i, timeout; + struct sun8i_ce_dev *ce = platform_get_drvdata(pdev); + + for (i = 0; i < ARRAY_SIZE(ce_algs); i++) { + switch (ce_algs[i].type) { + case CRYPTO_ALG_TYPE_SKCIPHER: + if (ce_algs[i].ce) { + dev_dbg(ce->dev, "Unregister %d %s\n", i, + ce_algs[i].alg.skcipher.base.cra_name); + crypto_unregister_skcipher(&ce_algs[i].alg.skcipher); + } + break; + } + } + +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + debugfs_remove_recursive(ce->dbgfs_dir); +#endif + + for (i = 0; i < ce->variant->maxflow; i++) { + crypto_engine_exit(ce->chanlist[i].engine); + timeout = 0; + while (mutex_is_locked(&ce->chanlist[i].lock) && timeout < 10) { + dev_info(ce->dev, "Wait for %d %d\n", i, timeout); + timeout++; + msleep(20); + } + dma_free_coherent(ce->dev, sizeof(struct ce_task), + ce->chanlist[i].tl, + ce->chanlist[i].t_phy); + } + + reset_control_assert(ce->reset); + for (i = 0; i < CE_MAX_CLOCKS; i++) + clk_disable_unprepare(ce->ceclks[i]); + return 0; +} + +static const struct of_device_id sun8i_ce_crypto_of_match_table[] = { + { .compatible = "allwinner,sun8i-h3-crypto", + .data = &ce_h3_variant }, + { .compatible = "allwinner,sun50i-h5-crypto", + .data = &ce_h5_variant }, + { .compatible = "allwinner,sun50i-h6-crypto", + .data = &ce_h6_variant }, + { .compatible = "allwinner,sun50i-a64-crypto", + .data = &ce_a64_variant }, + { .compatible = "allwinner,sun8i-r40-crypto", + .data = &ce_r40_variant }, + {} +}; +MODULE_DEVICE_TABLE(of, sun8i_ce_crypto_of_match_table); + +static struct platform_driver sun8i_ce_driver = { + .probe = sun8i_ce_probe, + .remove = sun8i_ce_remove, + .driver = { + .name = "sun8i-ce", + .of_match_table = sun8i_ce_crypto_of_match_table, + }, +}; + +module_platform_driver(sun8i_ce_driver); + +MODULE_DESCRIPTION("Allwinner Crypto Engine cryptographic offloader"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Corentin Labbe "); diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h new file mode 100644 index 000000000000..fe51f9569fa0 --- /dev/null +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h @@ -0,0 +1,256 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * sun8i-ce.h - hardware cryptographic offloader for + * Allwinner H3/A64/H5/H2+/H6 SoC + * + * Copyright (C) 2016-2019 Corentin LABBE + */ +#include +#include +#include +#include +#include +#include +#include + +#define MAX_SG 8 + +#define CE_STD 0 +#define CE_v2 1 + +#define CE_MAX_CLOCKS 3 + +/* CE Registers */ +#define CE_TDQ 0x00 +#define CE_CTR 0x04 +#define CE_ICR 0x08 +#define CE_ISR 0x0C +#define CE_TLR 0x10 +#define CE_TSR 0x14 +#define CE_ESR 0x18 +#define CE_CSSGR 0x1C +#define CE_CDSGR 0x20 +#define CE_CSAR 0x24 +#define CE_CDAR 0x28 +#define CE_TPR 0x2C + +/* Used in struct ce_task */ +/* ce_task common */ +#define CE_ENCRYPTION 0 +#define CE_DECRYPTION BIT(8) + +#define CE_COMM_INT BIT(31) + +/* ce_task symmetric */ +#define CE_AES_128BITS 0 +#define CE_AES_192BITS 1 +#define CE_AES_256BITS 2 + +#define CE_OP_ECB 0 +#define CE_OP_CBC (1 << 8) + +#define CE_ALG_AES 0 +#define CE_ALG_DES 1 +#define CE_ALG_3DES 2 +#define CE_ALG_RAES 48 + +/* Used in ce_variant */ +#define CE_ID_NOTSUPP 0xFF + +#define CE_ID_CIPHER_AES 1 +#define CE_ID_CIPHER_DES 2 +#define CE_ID_CIPHER_DES3 3 +#define CE_ID_CIPHER_RAES 4 +#define CE_ID_CIPHER_MAX 5 + +#define CE_ID_OP_ECB 1 +#define CE_ID_OP_CBC 2 +#define CE_ID_OP_MAX 3 + +/* Used in CE registers */ +#define CE_ERR_ALGO_NOTSUP BIT(0) +#define CE_ERR_DATALEN BIT(1) +#define CE_ERR_KEYSRAM BIT(2) +#define CE_ERR_ADDR_INVALID BIT(5) +#define CE_ERR_KEYLADDER BIT(6) + +/* + * struct ce_clock - Describe clocks used by sun8i-ce + * @name: Name of clock needed by this variant + * @freq: Maximum frequency for each clock + */ +struct ce_clock { + const char *name; + unsigned long freq; +}; + +/* + * struct ce_variant - Describe CE capability for each variant hardware + * @alg_cipher: list of supported ciphers. for each CE_ID_ this will give the + * coresponding CE_ALG_XXX/SS_ALG_XXX value + * @op_mode: list of supported block modes + * @model: The minor variant CE_STD/CE_SS/CE_v2 + * @intreg: reg offset for Interrupt register + * @maxflow: Numbers of flow for the current engine + */ +struct ce_variant { + char alg_cipher[CE_ID_CIPHER_MAX]; + u32 op_mode[CE_ID_OP_MAX]; + int model; + u32 intreg; + unsigned int maxflow; + struct ce_clock ce_clks[CE_MAX_CLOCKS]; +}; + +struct sginfo { + u32 addr; + u32 len; +} __packed; + +/* + * struct ce_task - CE Task descriptor + * The structure of this descriptor could be found in the datasheet + */ +struct ce_task { + u32 t_id; + u32 t_common_ctl; + u32 t_sym_ctl; + u32 t_asym_ctl; + u32 t_key; + u32 t_iv; + u32 t_ctr; + u32 t_dlen; + struct sginfo t_src[MAX_SG]; + struct sginfo t_dst[MAX_SG]; + u32 next; + u32 reserved[3]; +} __packed __aligned(8); + +/* + * struct sun8i_ce_flow - Information used by each flow + * @lock: lock protecting access of sun8i_ce_flow + * @engine: ptr to the crypto_engine for this flow + * @bounce_iv: buffer which contain the IV + * @ivlen: size of bounce_iv + * @keylen: keylen for this flow operation + * @complete: completion for the current task on this flow + * @status: set to 1 by interrupt if task is done + * @method: current method for flow + * @op_dir: direction (encrypt vs decrypt) of this flow + * @op_mode: op_mode for this flow + * @t_phy: Physical address of task + * @tl: pointer to the current ce_task for this flow + * @stat_req: number of request done by this flow + */ +struct sun8i_ce_flow { + struct mutex lock; + struct crypto_engine *engine; + void *bounce_iv; + unsigned int ivlen; + unsigned int keylen; + struct completion complete; + int status; + u32 method; + u32 op_dir; + u32 op_mode; + dma_addr_t t_phy; + int timeout; + struct ce_task *tl; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + unsigned long stat_req; +#endif +}; + +/* + * struct sun8i_ce_dev - main container for all this driver information + * @base: base address of SS/CE + * @ceclks: clocks used by SS/CE + * @reset: pointer to reset controller + * @dev: the platform device + * @mlock: Control access to device registers + * @chanlist: array of all flow + * @flow: flow to use in next request + * @variant: pointer to variant specific data + * @dbgfs_dir: Debugfs dentry for statistic directory + * @dbgfs_stats: Debugfs dentry for statistic counters + */ +struct sun8i_ce_dev { + void __iomem *base; + struct clk *ceclks[CE_MAX_CLOCKS]; + struct reset_control *reset; + struct device *dev; + struct mutex mlock; + struct sun8i_ce_flow *chanlist; + atomic_t flow; + const struct ce_variant *variant; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + struct dentry *dbgfs_dir; + struct dentry *dbgfs_stats; +#endif +}; + +/* + * struct sun8i_cipher_req_ctx - context for a skcipher request + * @op_dir: direction (encrypt vs decrypt) for this request + * @flow: the flow to use for this request + */ +struct sun8i_cipher_req_ctx { + u32 op_dir; + int flow; +}; + +/* + * struct sun8i_cipher_tfm_ctx - context for a skcipher TFM + * @enginectx: crypto_engine used by this TFM + * @key: pointer to key data + * @keylen: len of the key + * @ce: pointer to the private data of driver handling this TFM + * @fallback_tfm: pointer to the fallback TFM + */ +struct sun8i_cipher_tfm_ctx { + struct crypto_engine_ctx enginectx; + u32 *key; + u32 keylen; + struct sun8i_ce_dev *ce; + struct crypto_sync_skcipher *fallback_tfm; +}; + +/* + * struct sun8i_ce_alg_template - crypto_alg template + * @type: the CRYPTO_ALG_TYPE for this template + * @ce_algo_id: the CE_ID for this template + * @ce_blockmode: the type of block operation CE_ID + * @ce: pointer to the sun8i_ce_dev structure associated with + * this template + * @alg: one of sub struct must be used + * @stat_req: number of request done on this template + * @stat_fb: total of all data len done on this template + */ +struct sun8i_ce_alg_template { + u32 type; + u32 ce_algo_id; + u32 ce_blockmode; + struct sun8i_ce_dev *ce; + union { + struct skcipher_alg skcipher; + } alg; +#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG + unsigned long stat_req; + unsigned long stat_fb; +#endif +}; + +int sun8i_ce_enqueue(struct crypto_async_request *areq, u32 type); + +int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, + unsigned int keylen); +int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, + unsigned int keylen); +int sun8i_ce_cipher_init(struct crypto_tfm *tfm); +void sun8i_ce_cipher_exit(struct crypto_tfm *tfm); +int sun8i_ce_skdecrypt(struct skcipher_request *areq); +int sun8i_ce_skencrypt(struct skcipher_request *areq); + +int sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce); + +int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name); From patchwork Fri Sep 6 18:45:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135785 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B30E1398 for ; Fri, 6 Sep 2019 18:46:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D0A02173B for ; Fri, 6 Sep 2019 18:46:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BgPusha7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391458AbfIFSqL (ORCPT ); Fri, 6 Sep 2019 14:46:11 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54470 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395370AbfIFSqK (ORCPT ); Fri, 6 Sep 2019 14:46:10 -0400 Received: by mail-wm1-f66.google.com with SMTP id k2so7494917wmj.4; Fri, 06 Sep 2019 11:46:08 -0700 (PDT) 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=8335uoZd+LT0PenZntX1wYZZQovMh2HBfgED4ylV1H8=; b=BgPusha78ZW/cPNKiDFgfhvWxRZaVKbdmGqlpkN9MmEUQktGlSSLP85gzEKKdcG+xP R6H7X1DYibgG0M62pnrgldIQaGA9UJlmG1nHfiBS7ry8k+ilpUVzDFCKM7f5AIqVOuDy ZiZCX7vKtwcszA3pOF0unJtONhlGfLebCfAvwIj6+9rIhBgPhqLgg9W9LZFM/4Qg7lSg ytKiCyPelDioNz+j2NNhKt5opOQ2wDEY5m1A4sFOYfOgtBt0yRMq4mEmhha4Qai0b2Gh xoe+ogn4tPmcf7PZAc6KAg3InfAZuKTD5C2YmGU3Hpp3EMhFuZ4r/fCU8b9iL6RRjXfx Jxtw== 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=8335uoZd+LT0PenZntX1wYZZQovMh2HBfgED4ylV1H8=; b=AMyWvSPg4tWEN9QPPgpC+jdEqBQS+YD6UP8FeqW0QCZ0rdMeWftbeK/KPJtITKqeD0 NwpCLkcrDy7vHGwrzsKJw8cvXsUj68zdoN9hlF238ZpC16Ic4+78ejpq5pBQCcZ246A0 yNZDM15xhZIJJoEU9rMYa+yOd1O1RpXUXioqNkWIlr3K0Ljc5zafIVd9hD3jT+xmu37o 8hPZy6Cphjxg0rxqC7e7rll+IAU0LGsxMlSajoBxYAaGXo6mK8tOsrZ8wqm3pQAl2nIr xRZj5Ck5fQ+ct+YYgt+OzOxOrMKyX4qfuC7mOiBuHL37lk8y+zAABAq9H1aB5tvX4biK KSQg== X-Gm-Message-State: APjAAAWC7sjjq8EL/omPfjYECTe19mdXuvhHvquUqvmNgZ3hBWh5xYAc 7zumA49uNssbcsh4WChhGAA= X-Google-Smtp-Source: APXvYqwlofFwIAS7bR3rWQccQzImXsxRbREbRmVniVdJMI2PcVuPwBl+72P3N6n+EXqq318ogp/CYg== X-Received: by 2002:a7b:cb9a:: with SMTP id m26mr5027714wmi.57.1567795567864; Fri, 06 Sep 2019 11:46:07 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:07 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 3/9] dt-bindings: crypto: Add DT bindings documentation for sun8i-ce Crypto Engine Date: Fri, 6 Sep 2019 20:45:45 +0200 Message-Id: <20190906184551.17858-4-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch adds documentation for Device-Tree bindings for the Crypto Engine cryptographic accelerator driver. Signed-off-by: Corentin Labbe --- .../bindings/crypto/allwinner,sun8i-ce.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/allwinner,sun8i-ce.yaml diff --git a/Documentation/devicetree/bindings/crypto/allwinner,sun8i-ce.yaml b/Documentation/devicetree/bindings/crypto/allwinner,sun8i-ce.yaml new file mode 100644 index 000000000000..bd8ccedd6059 --- /dev/null +++ b/Documentation/devicetree/bindings/crypto/allwinner,sun8i-ce.yaml @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/allwinner,sun8i-ce.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner Crypto Engine driver + +maintainers: + - Corentin Labbe + +properties: + compatible: + oneOf: + - const: allwinner,sun8i-h3-crypto + - const: allwinner,sun8i-r40-crypto + - const: allwinner,sun50i-a64-crypto + - const: allwinner,sun50i-h5-crypto + - const: allwinner,sun50i-h6-crypto + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +if: + properties: + compatible: + contains: + const: allwinner,sun50i-h6-crypto +then: + clocks: + items: + - description: Bus clock + - description: Module clock + - description: MBus clock + + clock-names: + items: + - const: ahb + - const: mod + - const: mbus +else: + clocks: + items: + - description: Bus clock + - description: Module clock + + clock-names: + items: + - const: ahb + - const: mod + + resets: + maxItems: 1 + + reset-names: + const: ahb + + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + +examples: + - | + #include + #include + #include + + crypto: crypto@1c15000 { + compatible = "allwinner,sun8i-h3-crypto"; + reg = <0x01c15000 0x1000>; + interrupts = ; + clocks = <&ccu CLK_BUS_CE>, <&ccu CLK_CE>; + clock-names = "ahb", "mod"; + resets = <&ccu RST_BUS_CE>; + reset-names = "ahb"; + }; + From patchwork Fri Sep 6 18:45:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135803 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB6F91398 for ; Fri, 6 Sep 2019 18:46:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C007208C3 for ; Fri, 6 Sep 2019 18:46:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QL30LEzc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403809AbfIFSqr (ORCPT ); Fri, 6 Sep 2019 14:46:47 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46689 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395374AbfIFSqM (ORCPT ); Fri, 6 Sep 2019 14:46:12 -0400 Received: by mail-wr1-f65.google.com with SMTP id h7so7599796wrt.13; Fri, 06 Sep 2019 11:46:10 -0700 (PDT) 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=xU1lxAstjQUR72wZ/J0MWjQAlXMs9ML/BZPoCjnCEo0=; b=QL30LEzcYGE52tClH7qDSUb8rdbuplxJVHHskcftGAV0S6j3DeS2KHQNHuWtYJp5Sb hXGerX01T65u+PFpqv0CH6/t9MQpbNd1qCWZdD5PE3ir5Eoy6IcVgqs/KRa3cGbl5w5S xdLu216r67or4h0XUxQZuyEy38Gy9E9Hbu5d/8VSRGG6/aTUg5aVEiiheI8qhCmt7C6o VW0jsr2hgYyUEAAgk4Gm6RnWV47lWY9Tp9zVXQ4qet/NwZZskfp7HE4q2QzqXKT8/aDO 68ZZMMuhHYLzwJvDrJzggQzkJAeztA7oL5btV9AW0EbepEkzFfx+Df+6hj0sKcj3pk7n xuGw== 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=xU1lxAstjQUR72wZ/J0MWjQAlXMs9ML/BZPoCjnCEo0=; b=bCFw7vyuC2xbAPPCqkP9dEmlGRWZOhNXtcESPLGttIn1v2WwBiu9Gn1otxSRYC0i02 YsZ7hmb35EA5jmRtfWcQJCkfnCpXGciGvOHzCT7ZuWzafIhMSPVqWsMd0yKYVo/FFr/m 4x12Xmp/+wGIxydNHTTZiiyldId9qxoy8YIcABHN1yOIlKQVfEVZYQ/FKR3RvAgCQhTs y8KqVk0f7XYkBU2AiTMtTDiXhbIP1r2bFhVFPPdN14hfsZ8p+WLmZO7nRk2TY5CbaeuA BbnUy47/I4ALlSy4KgJzRJWpZueVAljCO8P34O64TVaWRy7PeCrkSG442OhIiJLVkDMb jBpQ== X-Gm-Message-State: APjAAAVFCGbue02SiaP0F3udC698ffoGH7KX2jokwW4JoP/iHZVS9Xay NsBuvnYqhH0zPz6RLKxtLKY= X-Google-Smtp-Source: APXvYqwDs4Nh97WeZFVLe8CNTzlwOhTt4GnK72gpsm66rGYD7SOIVos0xjrZSIonRTHM0uwsDW3Vdg== X-Received: by 2002:adf:dbce:: with SMTP id e14mr8938109wrj.56.1567795569299; Fri, 06 Sep 2019 11:46:09 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:08 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 4/9] ARM: dts: sun8i: r40: add crypto engine node Date: Fri, 6 Sep 2019 20:45:46 +0200 Message-Id: <20190906184551.17858-5-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The Crypto Engine is a hardware cryptographic offloader that supports many algorithms. It could be found on most Allwinner SoCs. This patch enables the Crypto Engine on the Allwinner R40 SoC Device-tree. Signed-off-by: Corentin Labbe --- arch/arm/boot/dts/sun8i-r40.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi index bde068111b85..7eb649cea163 100644 --- a/arch/arm/boot/dts/sun8i-r40.dtsi +++ b/arch/arm/boot/dts/sun8i-r40.dtsi @@ -266,6 +266,17 @@ #phy-cells = <1>; }; + crypto: crypto-engine@1c15000 { + compatible = "allwinner,sun8i-r40-crypto"; + reg = <0x01c15000 0x1000>; + interrupts = ; + clocks = <&ccu CLK_BUS_CE>, <&ccu CLK_CE>; + clock-names = "ahb", "mod"; + resets = <&ccu RST_BUS_CE>; + reset-names = "ahb"; + status = "okay"; + }; + ehci1: usb@1c19000 { compatible = "allwinner,sun8i-r40-ehci", "generic-ehci"; reg = <0x01c19000 0x100>; From patchwork Fri Sep 6 18:45:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135801 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 088C21398 for ; Fri, 6 Sep 2019 18:46:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9A70214E0 for ; Fri, 6 Sep 2019 18:46:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZhrFxoH/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395388AbfIFSqN (ORCPT ); Fri, 6 Sep 2019 14:46:13 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40341 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395376AbfIFSqM (ORCPT ); Fri, 6 Sep 2019 14:46:12 -0400 Received: by mail-wr1-f65.google.com with SMTP id w13so7597887wru.7; Fri, 06 Sep 2019 11:46:11 -0700 (PDT) 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=6gfPZRpIljPhV4Y76bqDwXphABtlmbrLYPaesl3pjCI=; b=ZhrFxoH/Go/p9mDemMia8OkzNhnhOPc3pjz+NcsRC2j4y/b2FxlHEx4JI6pFQy0591 5dKC6539twpYGEEBLEixpHsXoY3A9qmMkHplxGPCYrps8CgvQNI0OwcF8f9GdHF72+HS 4yDE06GGnbURNVBeChjpzi5N+D6lFsH4LobskCrGZ2NTTEXsELEuxBBeGPI5Um6IWuc/ YCbM76t3XLK0cDZcGgRKd2h1JxU038SSQKQBuJAceVR+tTAAvsXVfkRIczqqGy5HptOu 7RaTRWVYWuewASFlg3+W/7rRkSmk2Y5TcmjmddP2D3iO3Cl+H0S+GLhQYHWHAdPtn9lD G4wQ== 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=6gfPZRpIljPhV4Y76bqDwXphABtlmbrLYPaesl3pjCI=; b=msZj72w29CyeVmvABNQscxSJzsbXL2ZrS9DUR3jPiGtO4i/cDHljuimgntOJNsUcIj PIuJNW4XyNTWp+vkl04cqJ/IMHXZ6Tqvqg84Bemt5acw/dhz0qCdKhhb04ohBNAjzipa 9xQbb1FKgBBikwl+5rVGmX7Fcu6BcVd0VInik+Nbls46hcPa2boTCESOe9oQH60sbqIh 4B6B+w/DCT9HFoLK4oTXIIGOCfrmFmNnDv2f2mdf9PXp/NdamVBYxEFa/JvnOon1dGqX TR8D5OKFOm8BpiDyUbwAUNqNSaxdJ23/r8pQnr7wjY0/zTW4Xo4auQFJPHU6hs37himh eC1g== X-Gm-Message-State: APjAAAUXiRDC9zeNHm/suCRBvyRYg2qLeptvjl5x7k8m8gN10Gzui3Yi qsThtuWQc73GFMGc2gFu6P6G1Dr8 X-Google-Smtp-Source: APXvYqw3NjoNTVeM2qHMyiFQjvaRW2FdN8p50r5ozVUMwrqRJxmmaB+S5AyuSL/MHK/u6B6fQEleuA== X-Received: by 2002:adf:e30e:: with SMTP id b14mr8399491wrj.168.1567795570676; Fri, 06 Sep 2019 11:46:10 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:10 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 5/9] ARM: dts: sun8i: h3: Add Crypto Engine node Date: Fri, 6 Sep 2019 20:45:47 +0200 Message-Id: <20190906184551.17858-6-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The Crypto Engine is a hardware cryptographic accelerator that supports many algorithms. It could be found on most Allwinner SoCs. This patch enables the Crypto Engine on the Allwinner H3 SoC Device-tree. Signed-off-by: Corentin Labbe --- arch/arm/boot/dts/sun8i-h3.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi index e37c30e811d3..873abe1b279b 100644 --- a/arch/arm/boot/dts/sun8i-h3.dtsi +++ b/arch/arm/boot/dts/sun8i-h3.dtsi @@ -153,6 +153,17 @@ allwinner,sram = <&ve_sram 1>; }; + crypto: crypto@1c15000 { + compatible = "allwinner,sun8i-h3-crypto"; + reg = <0x01c15000 0x1000>; + interrupts = ; + interrupt-names = "ce_ns"; + resets = <&ccu RST_BUS_CE>; + reset-names = "ahb"; + clocks = <&ccu CLK_BUS_CE>, <&ccu CLK_CE>; + clock-names = "ahb", "mod"; + }; + mali: gpu@1c40000 { compatible = "allwinner,sun8i-h3-mali", "arm,mali-400"; reg = <0x01c40000 0x10000>; From patchwork Fri Sep 6 18:45:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135797 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA90B1398 for ; Fri, 6 Sep 2019 18:46:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C390C208C3 for ; Fri, 6 Sep 2019 18:46:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fXAj/oFn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395401AbfIFSqQ (ORCPT ); Fri, 6 Sep 2019 14:46:16 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35130 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395384AbfIFSqN (ORCPT ); Fri, 6 Sep 2019 14:46:13 -0400 Received: by mail-wr1-f66.google.com with SMTP id g7so7639429wrx.2; Fri, 06 Sep 2019 11:46:12 -0700 (PDT) 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=H7B3pdgueaTQoEx/oPVjB5PBvNleh5XGxboZw228Zx0=; b=fXAj/oFnSdb6IabmspTKjVarmJg8RHtLu3Ax/i7LLanXPSfUnht0o0jIOlQIkQNPvi hnKTdLMkqBNr3Kc8/50ClePJkB/Mdfe7bfoEVM0zoUEGcgpVUe0qLuWslAw32wGZoFoi ssQBgtefefxHpKJ7YypkI4UU2OHlU6J4HCF4F6pwvy6Ckft/tS4BmY0fxXlbkVrngXGe faiadrmAN43x0lessYdYqObgKhb5QoYZEDdXCYhdSo29kRPVveu1UEZxCDmVE9YzzvvW KELGFrgDBHtl4TcZCZniYtJz6wQ99NCSKb93+szw6Jv3an9pNddMt2usjMcZJIOwlSCV imUQ== 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=H7B3pdgueaTQoEx/oPVjB5PBvNleh5XGxboZw228Zx0=; b=RX3M3KwzjNunmhsKf0Miq3VDdJ/RIsELfJfRMmduxj4Rzvi3I9nZ77/tIWUS2ABHE7 2gU+UoEII11mpdBICtqHpuxBgoe2ovM45Kw7SkOCQjcVRCJya4BAF6ERmgpaBK702sf3 rdU4P9QU+jUy7eflixlMOLO4l3zPjI1aFzee7O+hrs6WrVRuNzKr1k2jrLIHSYpGH7E1 vEl5hcrb+9Z0ZntlgEqV5WQUTwWV60BxapUhzmSlYicIMnYHnAHS3oXDup+v3rrEsi4r CBIRf6h94eDgF5LjU0WPJhztPyVYzwvlPRR10pv/RV8suv8P+CcHW3gK7MZGsfgn4GOa uphA== X-Gm-Message-State: APjAAAVt5YefglvRtYvag39BlNFkhc/5D65sPf/OAEYEt3IOX1ihkIlw 4HEA9kc6+NVqjtqJVxnMrIA= X-Google-Smtp-Source: APXvYqyqzdUc2jNRTwd83hy+NRUGUlKAEAYXdsuFtAFSvYJ9Z0R/bbQ7sN+U0gRd1Os/fJyeLxpM5A== X-Received: by 2002:a5d:6504:: with SMTP id x4mr8443567wru.227.1567795572094; Fri, 06 Sep 2019 11:46:12 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:11 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 6/9] ARM64: dts: allwinner: sun50i: Add Crypto Engine node on A64 Date: Fri, 6 Sep 2019 20:45:48 +0200 Message-Id: <20190906184551.17858-7-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The Crypto Engine is a hardware cryptographic accelerator that supports many algorithms. It could be found on most Allwinner SoCs. This patch enables the Crypto Engine on the Allwinner A64 SoC Device-tree. Signed-off-by: Corentin Labbe --- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index 69128a6dfc46..c9e30d462ab1 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi @@ -487,6 +487,17 @@ reg = <0x1c14000 0x400>; }; + crypto: crypto@1c15000 { + compatible = "allwinner,sun50i-a64-crypto"; + reg = <0x01c15000 0x1000>; + interrupts = ; + interrupt-names = "ce_ns"; + resets = <&ccu RST_BUS_CE>; + reset-names = "ahb"; + clocks = <&ccu CLK_BUS_CE>, <&ccu CLK_CE>; + clock-names = "ahb", "mod"; + }; + usb_otg: usb@1c19000 { compatible = "allwinner,sun8i-a33-musb"; reg = <0x01c19000 0x0400>; From patchwork Fri Sep 6 18:45:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135793 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E42381398 for ; Fri, 6 Sep 2019 18:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1E8321848 for ; Fri, 6 Sep 2019 18:46:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ep9HDZiC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436586AbfIFSqR (ORCPT ); Fri, 6 Sep 2019 14:46:17 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39008 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395395AbfIFSqP (ORCPT ); Fri, 6 Sep 2019 14:46:15 -0400 Received: by mail-wr1-f65.google.com with SMTP id t16so7598389wra.6; Fri, 06 Sep 2019 11:46:14 -0700 (PDT) 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=8QtDLRptoE0CXvLgWwD97LTRuIDfzhWBaIHIlaUJgmo=; b=ep9HDZiCfuH8kRXERj63g91rhrUuOyjEtVhLHhk3QU7BOoV9SqhsZwanleSEly4oOJ w7Y3pMfAcOu2q5O1TSb6zwebqf/VygYEk0FnMQzBbayl/y+4F9NoAROZEWG9wYTzecab ILeNav7qAoyi8Jlr3+aGknSZpYk8aUkjUZkykfwVW9yawNu4C8/RAX9hVgKUn8OrniEM 2OTJYpZwtnU2xUlqymmZrxVpBu9NYIJz1BIM2mTokFhR0nMnFaT6/yT0ebWuINPczJO1 218A/xVTZ9dWS0qUzRQXYOO8cYk2BfhUhq6b/t8T/mvl1h/bRNy+5ecEIK13j8qkQ4c0 +s1Q== 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=8QtDLRptoE0CXvLgWwD97LTRuIDfzhWBaIHIlaUJgmo=; b=lPVVLGAL8agD4BHOlh4hgSCwQ7xSpKGnib8+8yTOcQMRSP8kFYOyqRT+wL82b5b6SN 0pztxlQ02QCM2882nf+6LiRByTdjatnRP3JVhohIXxuf7bs2rAUJBo/1n64nAAaoTvKf tu9NIvxig3N+J/J5Jwcli1XNXbH6ggbFkOmbLMVp+SbRymvjQwEIPN9MYA8jp5UbhfPQ CQ0Oh7sGg1VTNBwx2ekHLpS3HIqjtGx3GxBPg/dD+nB0OmnY39Ck447mcjORkn95qNWZ AQUL9iDBdGfV5YsqaAUhIV+Kc98yQeXFlAQTClo+w77CCV6Ne/TlltgPe48wTbxv7mU7 AXBg== X-Gm-Message-State: APjAAAVA1rA5N8q9FD8+p/tg/6dKoi1PqiV2h4OBF4xwsS64R7ORgY9o PAd+RJ1gIEHVRt+kIwUhSw4= X-Google-Smtp-Source: APXvYqx6NlZ/z+8VM/lYa3eo4+OsBuha3D3in2/3qbeTJ1A8BpcmX87Ghu+Ha7n2Ik0Ln+e88LowVA== X-Received: by 2002:adf:db8e:: with SMTP id u14mr1800226wri.50.1567795573543; Fri, 06 Sep 2019 11:46:13 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:12 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 7/9] ARM64: dts: allwinner: sun50i: Add crypto engine node on H5 Date: Fri, 6 Sep 2019 20:45:49 +0200 Message-Id: <20190906184551.17858-8-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The Crypto Engine is a hardware cryptographic accelerator that supports many algorithms. It could be found on most Allwinner SoCs. This patch enables the Crypto Engine on the Allwinner H5 SoC Device-tree. Signed-off-by: Corentin Labbe --- arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi index f002a496d7cb..174fb3dcb3f7 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi @@ -127,6 +127,17 @@ allwinner,sram = <&ve_sram 1>; }; + crypto: crypto@1c15000 { + compatible = "allwinner,sun50i-h5-crypto"; + reg = <0x01c15000 0x1000>; + interrupts = ; + interrupt-names = "ce_ns"; + resets = <&ccu RST_BUS_CE>; + reset-names = "ahb"; + clocks = <&ccu CLK_BUS_CE>, <&ccu CLK_CE>; + clock-names = "ahb", "mod"; + }; + mali: gpu@1e80000 { compatible = "allwinner,sun50i-h5-mali", "arm,mali-450"; reg = <0x01e80000 0x30000>; From patchwork Fri Sep 6 18:45:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135799 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49BC41398 for ; Fri, 6 Sep 2019 18:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2ADCE214E0 for ; Fri, 6 Sep 2019 18:46:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oqF++9+S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436641AbfIFSqj (ORCPT ); Fri, 6 Sep 2019 14:46:39 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46701 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395376AbfIFSqR (ORCPT ); Fri, 6 Sep 2019 14:46:17 -0400 Received: by mail-wr1-f67.google.com with SMTP id h7so7599990wrt.13; Fri, 06 Sep 2019 11:46:15 -0700 (PDT) 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=f5t3zhoR3RfkeeCxhIwf2rf3xgfwu01/OJcOf9PrEec=; b=oqF++9+SpbMo/KW24R+/jjUd2tj8D9lulEIyiUTjAaqRg9yH+SueSFntF23gdNjUeT CKRO/mKS4pkej7wwckSIO95TxZ71BMjA201QBlQFpIutN9WDYyRrdtSU1abY2rDEcSoa rpMmiggvRfxQcaG2tmvtxZJ9R4lbZsUFJqHUoH5CX0BR4gLTMKUh9qpo4wICvfPJdVd5 i5AfRQ58PxxuyiXuxq+WPpyMa688V5TbGoiNu1qwLj9AstCZGnNIDckKRTfJ7cIB62kG 33xPZ/sHi+NQ7Gn1EY6w5FzBwH1a2WmYJKohrVGuo8KFR6I8AduANY9gH8hfmG4myh3u 9A+w== 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=f5t3zhoR3RfkeeCxhIwf2rf3xgfwu01/OJcOf9PrEec=; b=GiGUMG/4Fc7CF7C7QTSc9JQh/hE4oNc+Bg71URckJ6RbcJFEoNwFIJ090OCQxIaHTG FFiL0+Ma3hu5op+S2ZwLcDL287Y7M5k/wBf0FT2AM7D1QZ9BO///D9WiBLnc9+1T9Nbs Y7lDtxq/FEebyMCK29LgJ3h/Zo6CyTlMoGhv1jcuaVSLwujuiqZVn8AAXVn2fkBAH/fU 6wQ8y7FH1VGyMgm8/2vOvjMth3m0KuADOhbAoLDL3mvvkM+zq6CQ/TKNdxsNMBYo3Bpf lXPVoFnQGm3qDruSuHCEvTWWeiJ1GQldokJAcdI00hnPQNVBRuX+zQFJ576Q36Nkm31w naAw== X-Gm-Message-State: APjAAAXltZfBAU9GQbii3ALyYez2Y6Bwmh0BsLqaxdc3MP2nx/sQ98Hl jhOYOq1QK5PDP4Gcu1b/DyY= X-Google-Smtp-Source: APXvYqxd5fVSBGAObcD5kqUHTqNYg4ew2h9AYvB8irXufaBYEpdRX5dLgjHGxv2PBsEVbxFIdoGj+A== X-Received: by 2002:a5d:4408:: with SMTP id z8mr8252982wrq.106.1567795574866; Fri, 06 Sep 2019 11:46:14 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:14 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 8/9] ARM64: dts: allwinner: sun50i: Add Crypto Engine node on H6 Date: Fri, 6 Sep 2019 20:45:50 +0200 Message-Id: <20190906184551.17858-9-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The Crypto Engine is a hardware cryptographic accelerator that supports many algorithms. This patch enables the Crypto Engine on the Allwinner H6 SoC Device-tree. Signed-off-by: Corentin Labbe --- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi index 0754f01fd731..51762499ed06 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi @@ -149,6 +149,16 @@ allwinner,sram = <&ve_sram 1>; }; + crypto: crypto@1904000 { + compatible = "allwinner,sun50i-h6-crypto"; + reg = <0x01904000 0x1000>; + clocks = <&ccu CLK_BUS_CE>, <&ccu CLK_CE>, <&ccu CLK_MBUS_CE>; + clock-names = "ahb", "mod", "mbus"; + resets = <&ccu RST_BUS_CE>; + reset-names = "ahb"; + interrupts = ; + }; + syscon: syscon@3000000 { compatible = "allwinner,sun50i-h6-system-control", "allwinner,sun50i-a64-system-control"; From patchwork Fri Sep 6 18:45:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 11135791 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E53771398 for ; Fri, 6 Sep 2019 18:46:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4861208C3 for ; Fri, 6 Sep 2019 18:46:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ltWL/0NI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392774AbfIFSqW (ORCPT ); Fri, 6 Sep 2019 14:46:22 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42901 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436555AbfIFSqS (ORCPT ); Fri, 6 Sep 2019 14:46:18 -0400 Received: by mail-wr1-f67.google.com with SMTP id q14so7580052wrm.9; Fri, 06 Sep 2019 11:46:16 -0700 (PDT) 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=mk9iiyM0WHriMjrKTK53bNyVyznn052YfKhoDOFj8+M=; b=ltWL/0NIoHGYNechlthfrItQ9BFEmloFHpTqEw3/M6HvdjFLXytt74OL7kTCA8j1Kt JHn+D+sUBJdHoDRjaVU1YaoFRb38IdxLNfKvEm3kAEKssc+XeChc/duhYWZT1SkRCORu m6U4l5HOC43ynNqIsNp6530iR3Pi9dAh4p9ZOTGjrk1YQE9D8dUsgEtiI3KiZ6wKdd4C M+uwyEpQ3Ouyt6jEaZwpOcoyqgAFr2rRSsungYDLbMAR5Zqe6lCfqZI7g4ZFDcCMhT5H JDNDLv/I8/CbVz6ePJWjHZDgJI6aVkrb2fJoz/1gnqpoLuKUNmpLfIpzNurmi1mCzdC/ vR9Q== 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=mk9iiyM0WHriMjrKTK53bNyVyznn052YfKhoDOFj8+M=; b=mKlcAwernL6r051jN/nR40NP5PaisRxy7rxbiI0cOkNykzHVRrLLzRGiASlqyfM6gi IGPADMwG+4HICJ11wpzA14LjiFVjLx+MI7sMc+J5t4Rtjj/CYGjXDfktSCtF4HSxnf+g Dtn6U8kZs30L4EqDopAgJjQqUJ6eWwxhCi6uQeLT/LjcVMt/YfF6w4NPXJBlXn6htsHH YJYpAType+c+8jhf7RJRNe1NmLNfrC0kCYwYF/2RMCHN+/sgJ1P5ErqEomjt8cRC3/8u bES+RNY+p5JNIeM7th4WzbHqomcuYl1ZGPnBbdEbH6+xCdmue/unVpaMbOG3tkexVH6Q 8cYA== X-Gm-Message-State: APjAAAW5Va3n+V/KXJXInQOhOOxu8e1fQpAR9ZIApaFnr5AYS0cKK7OS nCIcF1Y027j8baG4IGRoWD0= X-Google-Smtp-Source: APXvYqz0nobviNLqKZBy3ZK1oFqnw7zZh1G8l7RuxSpcJpXKnUegVQyaWqWl8zGGBhx++hogOT/Jdw== X-Received: by 2002:adf:e392:: with SMTP id e18mr9008949wrm.87.1567795576314; Fri, 06 Sep 2019 11:46:16 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id j1sm8677577wrg.24.2019.09.06.11.46.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 11:46:15 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, linux@armlinux.org.uk, 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 9/9] sunxi_defconfig: add new crypto options Date: Fri, 6 Sep 2019 20:45:51 +0200 Message-Id: <20190906184551.17858-10-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906184551.17858-1-clabbe.montjoie@gmail.com> References: <20190906184551.17858-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch adds the new allwinner crypto configs to sunxi_defconfig Signed-off-by: Corentin Labbe --- arch/arm/configs/sunxi_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig index df433abfcb02..d0ab8ba7710a 100644 --- a/arch/arm/configs/sunxi_defconfig +++ b/arch/arm/configs/sunxi_defconfig @@ -150,4 +150,6 @@ CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ISO8859_1=y CONFIG_PRINTK_TIME=y CONFIG_DEBUG_FS=y +CONFIG_CRYPTO_DEV_ALLWINNER=y +CONFIG_CRYPTO_DEV_SUN8I_CE=y CONFIG_CRYPTO_DEV_SUN4I_SS=y