Skip to contentSkip to conversation

crypto: add sun8i-ss driver for Allwinner Security System

PATCH In review Corentin Labbe 5 participants 10 messages Oct 25, 2019 – Nov 1, 2019

Subsystems (4)
lore
Share & tools
lore

Corentin Labbe

author maintainer
#0 lore raw

v3 cover crypto: add sun8i-ss driver for Allwinner Security System

Hello

This patch serie adds support for the second version of Allwinner Security System. The first generation of the Security System is already handled by the sun4i-ss driver. Due to major change, the first driver cannot handle the second one.
This new Security System is present on A80 and A83T SoCs.

For the moment, the driver support only DES3/AES in ECB/CBC mode. Patchs for CTR/CTS, RSA and RNGs will came later.

This serie is tested with CRYPTO_MANAGER_EXTRA_TESTS and tested on:
sun8i-a83t-bananapi-m3
sun9i-a80-cubieboard4

This serie is based on top of the "crypto: add sun8i-ce driver for Allwinner crypto engine" serie.

Regards

Changes since v2:
- Made the reset mandatory
- Removed reset-names

Changes since v1:
- fixed uninitialized err in sun8i_ss_allocate_chanlist
- Added missing commit description on DT Documentation patch

Corentin Labbe (4):
crypto: Add Allwinner sun8i-ss cryptographic offloader
dt-bindings: crypto: Add DT bindings documentation for sun8i-ss
Security System
ARM: dts: sun8i: a83t: Add Security System node
ARM: dts: sun9i: a80: Add Security System node

 .../bindings/crypto/allwinner,sun8i-ss.yaml   |  61 ++
 arch/arm/boot/dts/sun8i-a83t.dtsi             |   9 +
 arch/arm/boot/dts/sun9i-a80.dtsi              |   9 +
 drivers/crypto/allwinner/Kconfig              |  28 +
 drivers/crypto/allwinner/Makefile             |   1 +
 drivers/crypto/allwinner/sun8i-ss/Makefile    |   2 +
 .../allwinner/sun8i-ss/sun8i-ss-cipher.c      | 438 ++++++++++++
 .../crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 642 ++++++++++++++++++
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h  | 218 ++++++
 9 files changed, 1408 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/allwinner,sun8i-ss.yaml
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/Makefile
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
Signature · 1 line
2.21.0
author maintainer
#1 lore raw

PATCH v3 1/4 crypto: Add Allwinner sun8i-ss cryptographic offloader

The Security System is an hardware cryptographic offloader present on Allwinner SoCs A80 and A83T.
It is different from the previous sun4i-ss.

This driver supports AES cipher in CBC and ECB mode.

---
 drivers/crypto/allwinner/Kconfig              |  28 +
 drivers/crypto/allwinner/Makefile             |   1 +
 drivers/crypto/allwinner/sun8i-ss/Makefile    |   2 +
 .../allwinner/sun8i-ss/sun8i-ss-cipher.c      | 438 ++++++++++++
 .../crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 642 ++++++++++++++++++
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h  | 218 ++++++
 6 files changed, 1329 insertions(+)
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/Makefile
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
drivers/crypto/allwinner/Kconfig +28 -0
index 9c445973ca08..5b522871ccc5 100644
@@ -58,3 +58,31 @@ config CRYPTO_DEV_SUN8I_CE_DEBUG
 	  Say y to enable sun8i-ce debug stats.
 	  This will create /sys/kernel/debug/sun8i-ce/stats for displaying
 	  the number of requests per flow and per algorithm.
+
+config CRYPTO_DEV_SUN8I_SS
+	tristate "Support for Allwinner Security System 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
+	depends on PM
+	help
+	  Select y here to have support for the Security System available on
+	  Allwinner SoC A80, A83T.
+	  The Security System handle AES/3DES ciphers in ECB/CBC mode.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called sun8i-ss.
+
+config CRYPTO_DEV_SUN8I_SS_DEBUG
+	bool "Enable sun8i-ss stats"
+	depends on CRYPTO_DEV_SUN8I_SS
+	depends on DEBUG_FS
+	help
+	  Say y to enable sun8i-ss debug stats.
+	  This will create /sys/kernel/debug/sun8i-ss/stats for displaying
+	  the number of requests per flow and per algorithm.
+
drivers/crypto/allwinner/Makefile +1 -0
index fdb720c5bcc7..6effe864d7ff 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_CRYPTO_DEV_SUN4I_SS) += sun4i-ss/
 obj-$(CONFIG_CRYPTO_DEV_SUN8I_CE) += sun8i-ce/
+obj-$(CONFIG_CRYPTO_DEV_SUN8I_SS) += sun8i-ss/
drivers/crypto/allwinner/sun8i-ss/Makefile new file +2 -0
new file mode 100644
index 000000000000..add7b0543fd5
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_SUN8I_SS) += sun8i-ss.o
+sun8i-ss-y += sun8i-ss-core.o sun8i-ss-cipher.o
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c new file +438 -0

438 lines not on this page · raw message

drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c new file +642 -0

642 lines not on this page · raw message

drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h new file +218 -0

218 lines not on this page · raw message

Signature · 1 line
2.21.0
#2 lore raw

Re: [PATCH v3 1/4] crypto: Add Allwinner sun8i-ss cryptographic offloader

Hi Corentin,

Quoted 9 lines · Corentin Labbe

The Security System is an hardware cryptographic offloader present on Allwinner SoCs A80 and A83T.
It is different from the previous sun4i-ss.

This driver supports AES cipher in CBC and ECB mode.

---

[...]

Quoted 9 lines
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c new file +9 -0
+static int sun8i_ss_probe(struct platform_device *pdev)
+{
+	struct sun8i_ss_dev *ss;
+	int err, irq;
+	u32 v;
+
+	ss = devm_kzalloc(&pdev->dev, sizeof(*ss), GFP_KERNEL);
+	if (!ss)
+		return -ENOMEM;

[...]

drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c line 545

Quoted 2 lines
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c new file +2 -0
+
+	ss->reset = devm_reset_control_get(&pdev->dev, NULL);

It looks like this driver could use devm_reset_control_get_shared() to get a (clk-like) refcounted reset control. Otherwise, please use devm_reset_control_get_exclusive() instead of devm_reset_control_get().

See the kerneldoc comment for reset_control_get_shared() for details.

regards
Philipp

author maintainer
#3 lore raw

PATCH v3 2/4 dt-bindings: crypto: Add DT bindings documentation for sun8i-ss Security System

In reply to Corentin Labbe

This patch adds documentation for Device-Tree bindings of the Security System cryptographic offloader driver.

---
 .../bindings/crypto/allwinner,sun8i-ss.yaml   | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/allwinner,sun8i-ss.yaml
Documentation/devicetree/bindings/crypto/allwinner,sun8i-ss.yaml new file +61 -0
new file mode 100644
index 000000000000..8e9894c9f1bf
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/crypto/allwinner,sun8i-ss.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner Security System v2 driver
+
+maintainers:
+  - Corentin Labbe <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun8i-a83t-crypto
+      - allwinner,sun9i-a80-crypto
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bus clock
+      - description: Module clock
+
+  clock-names:
+    items:
+      - const: bus
+      - const: mod
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/sun8i-a83t-ccu.h>
+    #include <dt-bindings/reset/sun8i-a83t-ccu.h>
+
+    crypto: crypto@1c15000 {
+      compatible = "allwinner,sun8i-a83t-crypto";
+      reg = <0x01c15000 0x1000>;
+      interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>;
+      resets = <&ccu RST_BUS_SS>;
+      clocks = <&ccu CLK_BUS_SS>, <&ccu CLK_SS>;
+      clock-names = "bus", "mod";
+    };
+
Signature · 1 line
2.21.0
Acked-by on v3 2/4
#4 lore raw

Re: [PATCH v3 2/4] dt-bindings: crypto: Add DT bindings documentation for sun8i-ss Security System

Hi,

Quoted 4 lines · Corentin Labbe

This patch adds documentation for Device-Tree bindings of the Security System cryptographic offloader driver.

This patch and the previous one are:

I'll apply the DT patches when Herbert will apply the first two.

Maxime

maintainer Reviewed-by on v3 2/4
#5 lore raw

Re: [PATCH v3 2/4] dt-bindings: crypto: Add DT bindings documentation for sun8i-ss Security System

In reply to Corentin Labbe
Quoted 9 lines · Corentin Labbe

This patch adds documentation for Device-Tree bindings of the Security System cryptographic offloader driver.

---
 .../bindings/crypto/allwinner,sun8i-ss.yaml   | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/allwinner,sun8i-ss.yaml
author maintainer
#6 lore raw

PATCH v3 3/4 ARM: dts: sun8i: a83t: Add Security System node

In reply to Corentin Labbe

The Security System is a hardware cryptographic accelerator that support AES/MD5/SHA1/DES/3DES/PRNG/RSA algorithms.
It could be found on Allwinner SoC A80 and A83T

This patch adds it on the Allwinner A83T SoC Device-tree.

---
 arch/arm/boot/dts/sun8i-a83t.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/sun8i-a83t.dtsi +9 -0
index 74bb053cf23c..53c38deb8a08 100644
@@ -583,6 +583,15 @@
 			reg = <0x1c14000 0x400>;
 		};
 
+		crypto: crypto@1c15000 {
+			compatible = "allwinner,sun8i-a83t-crypto";
+			reg = <0x01c15000 0x1000>;
+			interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&ccu RST_BUS_SS>;
+			clocks = <&ccu CLK_BUS_SS>, <&ccu CLK_SS>;
+			clock-names = "bus", "mod";
+		};
+
 		usb_otg: usb@1c19000 {
 			compatible = "allwinner,sun8i-a83t-musb",
 				     "allwinner,sun8i-a33-musb";
Signature · 1 line
2.21.0
author maintainer
#7 lore raw

PATCH v3 4/4 ARM: dts: sun9i: a80: Add Security System node

In reply to Corentin Labbe

The Security System is a hardware cryptographic accelerator that support AES/MD5/SHA1/DES/3DES/PRNG/RSA algorithms.
It could be found on Allwinner SoC A80 and A83T

This patch adds it on the Allwinner A80 SoC Device-tree.

---
 arch/arm/boot/dts/sun9i-a80.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +9 -0
index b5c46934b5b1..1d900f591d5f 100644
@@ -457,6 +457,15 @@
 			reg = <0x01700000 0x100>;
 		};
 
+		crypto: crypto@1c02000 {
+			compatible = "allwinner,sun9i-a80-crypto";
+			reg = <0x01c02000 0x1000>;
+			interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&ccu RST_BUS_SS>;
+			clocks = <&ccu CLK_BUS_SS>, <&ccu CLK_SS>;
+			clock-names = "bus", "mod";
+		};
+
 		mmc0: mmc@1c0f000 {
 			compatible = "allwinner,sun9i-a80-mmc";
 			reg = <0x01c0f000 0x1000>;
Signature · 1 line
2.21.0
maintainer
#8 lore raw
In reply to Corentin Labbe
Quoted 35 lines · Corentin Labbe

Hello

This patch serie adds support for the second version of Allwinner Security System. The first generation of the Security System is already handled by the sun4i-ss driver. Due to major change, the first driver cannot handle the second one.
This new Security System is present on A80 and A83T SoCs.

For the moment, the driver support only DES3/AES in ECB/CBC mode. Patchs for CTR/CTS, RSA and RNGs will came later.

This serie is tested with CRYPTO_MANAGER_EXTRA_TESTS and tested on:
sun8i-a83t-bananapi-m3
sun9i-a80-cubieboard4

This serie is based on top of the "crypto: add sun8i-ce driver for Allwinner crypto engine" serie.

Regards

Changes since v2:
- Made the reset mandatory
- Removed reset-names

Changes since v1:
- fixed uninitialized err in sun8i_ss_allocate_chanlist
- Added missing commit description on DT Documentation patch

Corentin Labbe (4):
crypto: Add Allwinner sun8i-ss cryptographic offloader
dt-bindings: crypto: Add DT bindings documentation for sun8i-ss
Security System
ARM: dts: sun8i: a83t: Add Security System node
ARM: dts: sun9i: a80: Add Security System node

Quoted 15 lines
 .../bindings/crypto/allwinner,sun8i-ss.yaml   |  61 ++
 arch/arm/boot/dts/sun8i-a83t.dtsi             |   9 +
 arch/arm/boot/dts/sun9i-a80.dtsi              |   9 +
 drivers/crypto/allwinner/Kconfig              |  28 +
 drivers/crypto/allwinner/Makefile             |   1 +
 drivers/crypto/allwinner/sun8i-ss/Makefile    |   2 +
 .../allwinner/sun8i-ss/sun8i-ss-cipher.c      | 438 ++++++++++++
 .../crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 642 ++++++++++++++++++
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h  | 218 ++++++
 9 files changed, 1408 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/allwinner,sun8i-ss.yaml
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/Makefile
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h

Patches 1,2 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
#9 lore raw
Quoted 52 lines · Herbert Xu
Quoted 35 lines · Corentin Labbe

Hello

This patch serie adds support for the second version of Allwinner Security System. The first generation of the Security System is already handled by the sun4i-ss driver. Due to major change, the first driver cannot handle the second one.
This new Security System is present on A80 and A83T SoCs.

For the moment, the driver support only DES3/AES in ECB/CBC mode. Patchs for CTR/CTS, RSA and RNGs will came later.

This serie is tested with CRYPTO_MANAGER_EXTRA_TESTS and tested on:
sun8i-a83t-bananapi-m3
sun9i-a80-cubieboard4

This serie is based on top of the "crypto: add sun8i-ce driver for Allwinner crypto engine" serie.

Regards

Changes since v2:
- Made the reset mandatory
- Removed reset-names

Changes since v1:
- fixed uninitialized err in sun8i_ss_allocate_chanlist
- Added missing commit description on DT Documentation patch

Corentin Labbe (4):
crypto: Add Allwinner sun8i-ss cryptographic offloader
dt-bindings: crypto: Add DT bindings documentation for sun8i-ss
Security System
ARM: dts: sun8i: a83t: Add Security System node
ARM: dts: sun9i: a80: Add Security System node

Quoted 15 lines
 .../bindings/crypto/allwinner,sun8i-ss.yaml   |  61 ++
 arch/arm/boot/dts/sun8i-a83t.dtsi             |   9 +
 arch/arm/boot/dts/sun9i-a80.dtsi              |   9 +
 drivers/crypto/allwinner/Kconfig              |  28 +
 drivers/crypto/allwinner/Makefile             |   1 +
 drivers/crypto/allwinner/sun8i-ss/Makefile    |   2 +
 .../allwinner/sun8i-ss/sun8i-ss-cipher.c      | 438 ++++++++++++
 .../crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 642 ++++++++++++++++++
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h  | 218 ++++++
 9 files changed, 1408 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/allwinner,sun8i-ss.yaml
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/Makefile
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
 create mode 100644 drivers/crypto/allwinner/sun8i-ss/sun8i-ss.h
Quoted 1 line

Patches 1,2 applied. Thanks.

Applied 3 and 4, thanks!
Maxime