Skip to contentSkip to conversation

Add support for Texas Instruments DTHE V2 crypto accelerator

PATCH Superseded T Pratham 4 participants 8 messages May 8, 2025 – Jun 3, 2025

Subsystems (3)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

T Pratham

author maintainer
#0 lore raw

v4 cover Add support for Texas Instruments DTHE V2 crypto accelerator

This series adds support for TI DTHE V2 crypto accelerator. DTHE V2 is a new crypto accelerator which contains multiple crypto IPs [1]. This series implements support for ECB and CBC modes of AES for the AES Engine of the DTHE, using skcipher APIs of the kernel.

Tested with:
CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y

and tcrypt,
sudo modprobe tcrypt mode=500 sec=1

---
[1]: Section 14.6.3 (DMA Control Registers -> DMASS_DTHE)

Change log:
v4:
- Corrected dt-bindings example indentation
- Simplified dt-bindings example, removing the node surrounding crypto
- Fixed typo in dthev2-common.h header guard
- Removed unused ctx field in dev_data struct
- Moved per-op data into request context
v3:
- Corrected dt-bindings reg length is too long error
- Converted AES driver code to use crypto_engine APIs for using internal crypto queue instead of mutex.
- Removed calls to skcipher_request_complete in paths not returning -EINPROGRESS before.
- Added missing KConfig import, which was accidentally removed in v2.

v2:
- Corrected dt-bindings syntax errors and other review comments in v1.
- Completely changed driver code structure, splitting code into multiple files

Link to previous versions:
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
---
T Pratham (2):
dt-bindings: crypto: Add binding for TI DTHE V2
crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)

 .../bindings/crypto/ti,am62l-dthev2.yaml      |  50 ++
 MAINTAINERS                                   |   7 +
 drivers/crypto/Kconfig                        |   1 +
 drivers/crypto/Makefile                       |   1 +
 drivers/crypto/ti/Kconfig                     |  13 +
 drivers/crypto/ti/Makefile                    |   3 +
 drivers/crypto/ti/dthev2-aes.c                | 428 ++++++++++++++++++
 drivers/crypto/ti/dthev2-common.c             | 220 +++++++++
 drivers/crypto/ti/dthev2-common.h             | 111 +++++
 9 files changed, 834 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml
 create mode 100644 drivers/crypto/ti/Kconfig
 create mode 100644 drivers/crypto/ti/Makefile
 create mode 100644 drivers/crypto/ti/dthev2-aes.c
 create mode 100644 drivers/crypto/ti/dthev2-common.c
 create mode 100644 drivers/crypto/ti/dthev2-common.h
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v4 1/2 dt-bindings: crypto: Add binding for TI DTHE V2

Add DT binding for Texas Instruments DTHE V2 crypto accelerator.

DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.

---
 .../bindings/crypto/ti,am62l-dthev2.yaml      | 50 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml
Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml new file +50 -0
new file mode 100644
index 000000000000..5486bfeb2fe8
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/crypto/ti,am62l-dthev2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: K3 SoC DTHE V2 crypto module
+
+maintainers:
+  - T Pratham <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - ti,am62l-dthev2
+
+  reg:
+    maxItems: 1
+
+  dmas:
+    items:
+      - description: AES Engine RX DMA Channel
+      - description: AES Engine TX DMA Channel
+      - description: SHA Engine TX DMA Channel
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx1
+      - const: tx2
+
+required:
+  - compatible
+  - reg
+  - dmas
+  - dma-names
+
+additionalProperties: false
+
+examples:
+  - |
+    crypto@40800000 {
+        compatible = "ti,am62l-dthev2";
+        reg = <0x40800000 0x10000>;
+
+        dmas = <&main_bcdma 0 0 0x4700 0>,
+               <&main_bcdma 0 0 0xc701 0>,
+               <&main_bcdma 0 0 0xc700 0>;
+        dma-names = "rx", "tx1", "tx2";
+    };
MAINTAINERS +6 -0
index b119ae6b5f14..b990850b4994 100644
@@ -24552,6 +24552,12 @@ S:	Odd Fixes
 F:	drivers/clk/ti/
 F:	include/linux/clk/ti.h
 
+TI DATA TRANSFORM AND HASHING ENGINE (DTHE) V2 CRYPTO ACCELERATOR DRIVER
+M:	T Pratham <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml
+
 TI DAVINCI MACHINE SUPPORT
 M:	Bartosz Golaszewski <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH v4 1/2] dt-bindings: crypto: Add binding for TI DTHE V2

In reply to T Pratham
Quoted 5 lines · T Pratham

Add DT binding for Texas Instruments DTHE V2 crypto accelerator.

DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.

Quoted 7 lines
---
 .../bindings/crypto/ti,am62l-dthev2.yaml      | 50 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

author maintainer
#4 lore raw

Re: [PATCH v4 1/2] dt-bindings: crypto: Add binding for TI DTHE V2

Quoted 17 lines · Rob Herring (Arm)
Quoted 5 lines · T Pratham

Add DT binding for Texas Instruments DTHE V2 crypto accelerator.

DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.

Quoted 7 lines
---
 .../bindings/crypto/ti,am62l-dthev2.yaml      | 50 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml

My bot found errors running 'make dt_binding_check' on your patch:

Quoted 9 lines

yamllint warnings/errors:

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

Hi, the error logs here are empty. What does this mean (error, no error)?

Also, I ran make dt_binding_check locally and did not see any errors. Below dependencies are installed and up to date.

Quoted 7 lines

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

Quoted 6 lines

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

Regards
T Pratham <[email protected]>

#5 lore raw

Re: [PATCH v4 1/2] dt-bindings: crypto: Add binding for TI DTHE V2

Quoted 23 lines · T Pratham
Quoted 22 lines · Rob Herring (Arm)
Quoted 5 lines · T Pratham

Add DT binding for Texas Instruments DTHE V2 crypto accelerator.

DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.

Quoted 7 lines
---
 .../bindings/crypto/ti,am62l-dthev2.yaml      | 50 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:

Quoted 7 lines
Quoted 4 lines

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

Hi, the error logs here are empty. What does this mean (error, no error)?

Also, I ran make dt_binding_check locally and did not see any errors. Below dependencies are installed and up to date.

Probably false-positive. This happens sometimes, sorry for this. Service is provided as is, in good faith.

Best regards,
Krzysztof

author maintainer
#6 lore raw

PATCH v4 2/2 crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)

In reply to T Pratham

Add support for ECB and CBC modes in the AES Engine of the DTHE V2 hardware crypto accelerator.

---
 MAINTAINERS                       |   1 +
 drivers/crypto/Kconfig            |   1 +
 drivers/crypto/Makefile           |   1 +
 drivers/crypto/ti/Kconfig         |  13 +
 drivers/crypto/ti/Makefile        |   3 +
 drivers/crypto/ti/dthev2-aes.c    | 428 ++++++++++++++++++++++++++++++
 drivers/crypto/ti/dthev2-common.c | 220 +++++++++++++++
 drivers/crypto/ti/dthev2-common.h | 111 ++++++++
 8 files changed, 778 insertions(+)
 create mode 100644 drivers/crypto/ti/Kconfig
 create mode 100644 drivers/crypto/ti/Makefile
 create mode 100644 drivers/crypto/ti/dthev2-aes.c
 create mode 100644 drivers/crypto/ti/dthev2-common.c
 create mode 100644 drivers/crypto/ti/dthev2-common.h
MAINTAINERS +1 -0
index b990850b4994..25a42e0b19e4 100644
@@ -24557,6 +24557,7 @@ M:	T Pratham <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml
+F:	drivers/crypto/ti/
 
 TI DAVINCI MACHINE SUPPORT
 M:	Bartosz Golaszewski <[email protected]>
drivers/crypto/Kconfig +1 -0
index 5686369779be..c1407236f137 100644
@@ -849,5 +849,6 @@ config CRYPTO_DEV_SA2UL
 source "drivers/crypto/aspeed/Kconfig"
 source "drivers/crypto/starfive/Kconfig"
 source "drivers/crypto/inside-secure/eip93/Kconfig"
+source "drivers/crypto/ti/Kconfig"
 
 endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
index 22eadcc8f4a2..c0e8d4acc37c 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/
 obj-y += intel/
 obj-y += starfive/
 obj-y += cavium/
+obj-$(CONFIG_ARCH_K3) += ti/
drivers/crypto/ti/Kconfig new file +13 -0
new file mode 100644
index 000000000000..575e09fa7d96
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config CRYPTO_DEV_TI_DTHEV2
+	tristate "Support for TI DTHE V2 crypto accelerators"
+	depends on CRYPTO && CRYPTO_HW && ARCH_K3
+	select CRYPTO_ENGINE
+	select CRYPTO_SKCIPHER
+	select CRYPTO_ECB
+	select CRYPTO_CBC
+	help
+	  This enables support for the TI DTHE V2 hw crypto accelerator
+	  which can be found on TI K3 SOCs. Selecting this enables use
+	  of hardware acceleration for cryptographic algorithms on
+	  these devices.
drivers/crypto/ti/Makefile new file +3 -0
new file mode 100644
index 000000000000..b883078f203d
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_CRYPTO_DEV_TI_DTHEV2) += dthev2.o
+dthev2-objs := dthev2-common.o dthev2-aes.o
drivers/crypto/ti/dthev2-aes.c new file +428 -0

428 lines not on this page · raw message

drivers/crypto/ti/dthev2-common.c new file +220 -0

220 lines not on this page · raw message

drivers/crypto/ti/dthev2-common.h new file +111 -0

111 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#7 lore raw

Re: [PATCH v4 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)

Quoted 5 lines · T Pratham
drivers/crypto/ti/dthev2-aes.c new file +4 -0
+static int dthe_cipher_init_tfm(struct crypto_skcipher *tfm)
+{
+	struct dthe_tfm_ctx *ctx = crypto_skcipher_ctx(tfm);
+	struct dthe_data *dev_data = dthe_get_dev(ctx);

drivers/crypto/ti/dthev2-aes.c line 93

Quoted 10 lines
drivers/crypto/ti/dthev2-aes.c new file +10 -0
+
+	void __iomem *aes_base_reg = dev_data->regs + DTHE_P_AES_BASE;
+	u32 aes_irqenable_val = readl_relaxed(aes_base_reg + DTHE_P_AES_IRQENABLE);
+	u32 aes_sysconfig_val = readl_relaxed(aes_base_reg + DTHE_P_AES_SYSCONFIG);
+
+	memzero_explicit(ctx, sizeof(*ctx));
+	ctx->dev_data = dev_data;
+	ctx->ctx_info.aes_ctx = kzalloc(sizeof(*ctx->ctx_info.aes_ctx), GFP_KERNEL);
+	if (!ctx->ctx_info.aes_ctx)
+		return -ENOMEM;

The ctx_info union should just become part of ctx instead of a separate allocation.

drivers/crypto/ti/dthev2-aes.c line 95

Quoted 1 line
drivers/crypto/ti/dthev2-aes.c new file +1 -0
+	crypto_skcipher_set_reqsize(tfm, sizeof(struct dthe_aes_req_ctx));

Please set cra_reqsize instead in the algorithm.

drivers/crypto/ti/dthev2-aes.c line 101

Quoted 5 lines
drivers/crypto/ti/dthev2-aes.c new file +5 -0
+	aes_sysconfig_val |= DTHE_AES_SYSCONFIG_DMA_DATA_IN_OUT_EN;
+	writel_relaxed(aes_sysconfig_val, aes_base_reg + DTHE_P_AES_SYSCONFIG);
+
+	aes_irqenable_val |= DTHE_AES_IRQENABLE_EN_ALL;
+	writel_relaxed(aes_irqenable_val, aes_base_reg + DTHE_P_AES_IRQENABLE);

This does not look right. The tfm allocation happens once for each key, and they could be done concurrently. You should not be operating on the hardware in the init_tfm function.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt