Skip to contentSkip to conversation

Add support for Texas Instruments DTHEv2 Crypto Engine

PATCH In review T Pratham 2 participants 6 messages Aug 20, 2025 – Sep 3, 2025

Subsystems (3)
lore
Share & tools
lore

T Pratham

author maintainer
#0 lore raw

v7 cover Add support for Texas Instruments DTHEv2 Crypto Engine

Data Transform and Hashing Engine (DTHE) v2 is a new cryptography engine introduced i TI AM62L SoC. DTHEv2 consists of multiple crypto IPs[1] (such as AES Engine, hashing engine, TRNG, etc.) which can be used for offloading cryptographic operations off of the CPU. The primary benefit of DTHEv2 is enhanced side-channel attack resistance, with AES and PKE engine being DPA and EMA resistant. These side-channel resistances are the underlying requirement for various certifications like SESIP, PSA, and IEC62443 (lvl 3+). Thus, DTHEv2 provides critical security benefits for embedded systems that require protection against passive physical attacks.

The AES Engine of DTHEv2 supports multiple AES modes (ECB, CBC, CTR, CFB, f8), several protocols (GCM, CCM, XTS) and authentication modes (CBC-MAC and f9). The hashing engine supports MD5, SHA1, and SHA2 (224, 256, 384, 512) algorithms along with HMAC. This patch series introduces basic driver support for DTHEv2 engine, beginning with suporting AES-ECB and AES-CBC algorithms. Other algorithms are planned to be added gradually in phases after initial suppport is added.

The driver is tested using full kernel crypto selftests (CRYPTO_SELFTESTS) which all pass successfully [2].

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

[2]: DTHEv2 AES-ECB and AES-CBC kernel self-tests logs

Change log:
v7:
- Dropped redundant crypto_engine_stop() calls.
- Corrected Reviewed-by tag.
v6:
- Reworded the cover letter and commit messages to name DTHEv2 as a crypto engine instead of crypto accelerator.
- Reworded the cover letter completely to emphasise more on the utility of DTHEv2 as better resistance against physical attacks
- Reworded DTHEv2 description (help text) in KConfig
- Added dma_terminate_sync calls to ensure DMA requests are removed in case when completion times-out.
- Some rearrangement of fields between dthe_tfm_ctx and dthe_aes_req_ctx struct, so that per tfm members are correctly placed in tfm_ctx and per request members are in req_ctx. Subsequently setkey, encrypt and decrypt functions are also changed.
- Removed exit_tfm function which was useless and not required.
- Removed unnecessary zeroing of tfm_ctx object in init_tfm.
- Corrected return value in dthe_aes_run function.
- Reduced cra_priority of DTHEv2 algorithms.
v5:
- Simplified tfm ctx struct
- Set cra_reqsize instead of using crypto_skcipher_set_reqsize()
- Move setting sysconfig and irqenable registers to dthe_aes_run
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:
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
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                     |  14 +
 drivers/crypto/ti/Makefile                    |   3 +
 drivers/crypto/ti/dthev2-aes.c                | 411 ++++++++++++++++++
 drivers/crypto/ti/dthev2-common.c             | 217 +++++++++
 drivers/crypto/ti/dthev2-common.h             | 101 +++++
 9 files changed, 805 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 v7 1/2 dt-bindings: crypto: Add binding for TI DTHE V2

Add DT binding for Texas Instruments DTHE V2 cryptography engine.

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 fe168477caa4..0f5bb8ad7653 100644
@@ -25169,6 +25169,12 @@ S:	Odd Fixes
 F:	drivers/clk/ti/
 F:	include/linux/clk/ti.h
 
+TI DATA TRANSFORM AND HASHING ENGINE (DTHE) V2 CRYPTO 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
author maintainer
#2 lore raw

PATCH v7 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 cryptography engine.

---
 MAINTAINERS                       |   1 +
 drivers/crypto/Kconfig            |   1 +
 drivers/crypto/Makefile           |   1 +
 drivers/crypto/ti/Kconfig         |  14 +
 drivers/crypto/ti/Makefile        |   3 +
 drivers/crypto/ti/dthev2-aes.c    | 411 ++++++++++++++++++++++++++++++
 drivers/crypto/ti/dthev2-common.c | 217 ++++++++++++++++
 drivers/crypto/ti/dthev2-common.h | 101 ++++++++
 8 files changed, 749 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 0f5bb8ad7653..ca728cc24169 100644
@@ -25174,6 +25174,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 04b4c43b6bae..f056ec58c96e 100644
@@ -863,5 +863,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 +14 -0
new file mode 100644
index 000000000000..38d22cab05a9
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config CRYPTO_DEV_TI_DTHEV2
+	tristate "Support for TI DTHE V2 cryptography engine"
+	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 cryptography engine
+	  which can be found on TI K3 SOCs. Selecting this enables use
+	  of hardware offloading for cryptographic algorithms on
+	  these devices, providing enhanced resistance against side-channel
+	  attacks.
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 +411 -0

411 lines not on this page · raw message

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

217 lines not on this page · raw message

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

101 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#3 lore raw
In reply to T Pratham
Quoted 86 lines · T Pratham

Data Transform and Hashing Engine (DTHE) v2 is a new cryptography engine introduced i TI AM62L SoC. DTHEv2 consists of multiple crypto IPs[1] (such as AES Engine, hashing engine, TRNG, etc.) which can be used for offloading cryptographic operations off of the CPU. The primary benefit of DTHEv2 is enhanced side-channel attack resistance, with AES and PKE engine being DPA and EMA resistant. These side-channel resistances are the underlying requirement for various certifications like SESIP, PSA, and IEC62443 (lvl 3+). Thus, DTHEv2 provides critical security benefits for embedded systems that require protection against passive physical attacks.

The AES Engine of DTHEv2 supports multiple AES modes (ECB, CBC, CTR, CFB, f8), several protocols (GCM, CCM, XTS) and authentication modes (CBC-MAC and f9). The hashing engine supports MD5, SHA1, and SHA2 (224, 256, 384, 512) algorithms along with HMAC. This patch series introduces basic driver support for DTHEv2 engine, beginning with suporting AES-ECB and AES-CBC algorithms. Other algorithms are planned to be added gradually in phases after initial suppport is added.

The driver is tested using full kernel crypto selftests (CRYPTO_SELFTESTS) which all pass successfully [2].

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

[2]: DTHEv2 AES-ECB and AES-CBC kernel self-tests logs

Change log:
v7:
- Dropped redundant crypto_engine_stop() calls.
- Corrected Reviewed-by tag.
v6:
- Reworded the cover letter and commit messages to name DTHEv2 as a crypto engine instead of crypto accelerator.
- Reworded the cover letter completely to emphasise more on the utility of DTHEv2 as better resistance against physical attacks
- Reworded DTHEv2 description (help text) in KConfig
- Added dma_terminate_sync calls to ensure DMA requests are removed in case when completion times-out.
- Some rearrangement of fields between dthe_tfm_ctx and dthe_aes_req_ctx struct, so that per tfm members are correctly placed in tfm_ctx and per request members are in req_ctx. Subsequently setkey, encrypt and decrypt functions are also changed.
- Removed exit_tfm function which was useless and not required.
- Removed unnecessary zeroing of tfm_ctx object in init_tfm.
- Corrected return value in dthe_aes_run function.
- Reduced cra_priority of DTHEv2 algorithms.
v5:
- Simplified tfm ctx struct
- Set cra_reqsize instead of using crypto_skcipher_set_reqsize()
- Move setting sysconfig and irqenable registers to dthe_aes_run
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:
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
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)

Quoted 19 lines
 .../bindings/crypto/ti,am62l-dthev2.yaml      |  50 +++
 MAINTAINERS                                   |   7 +
 drivers/crypto/Kconfig                        |   1 +
 drivers/crypto/Makefile                       |   1 +
 drivers/crypto/ti/Kconfig                     |  14 +
 drivers/crypto/ti/Makefile                    |   3 +
 drivers/crypto/ti/dthev2-aes.c                | 411 ++++++++++++++++++
 drivers/crypto/ti/dthev2-common.c             | 217 +++++++++
 drivers/crypto/ti/dthev2-common.h             | 101 +++++
 9 files changed, 805 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

All applied. Thanks.

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
maintainer
#4 lore raw

PATCH 1/1 crypto: ti - Enable compile testing for dthev2

In reply to T Pratham

Allow ti dthev2 driver to be compile-tested.

drivers/crypto/Makefile +1 -1
index c0e8d4acc37c..170e10b18f9b 100644
@@ -48,4 +48,4 @@ obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/
 obj-y += intel/
 obj-y += starfive/
 obj-y += cavium/
-obj-$(CONFIG_ARCH_K3) += ti/
+obj-y += ti/
drivers/crypto/ti/Kconfig +1 -1
index 38d22cab05a9..d4f91c1e0cb5 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config CRYPTO_DEV_TI_DTHEV2
 	tristate "Support for TI DTHE V2 cryptography engine"
-	depends on CRYPTO && CRYPTO_HW && ARCH_K3
+	depends on ARCH_K3 || COMPILE_TEST
 	select CRYPTO_ENGINE
 	select CRYPTO_SKCIPHER
 	select CRYPTO_ECB
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