Skip to contentSkip to conversation

crypto: add amlogic crypto offloader driver

PATCH Superseded Corentin Labbe 4 participants 9 messages Oct 14, 2019 – Oct 16, 2019

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Corentin Labbe

author maintainer
#0 lore raw

v2 cover crypto: add amlogic crypto offloader driver

Hello

This serie adds support for the crypto offloader present on amlogic GXL SoCs.

Tested on meson-gxl-s905x-khadas-vim and meson-gxl-s905x-libretech-cc

Regards

Changes since v1:
- renamed files and algo with gxl
- removed unused reset handlings
- splited the probe functions
- splited meson_cipher fallback in need_fallback() and do_fallback()

Corentin Labbe (4):
dt-bindings: crypto: Add DT bindings documentation for amlogic-crypto
MAINTAINERS: Add myself as maintainer of amlogic crypto
crypto: amlogic: Add crypto accelerator for amlogic GXL
ARM64: dts: amlogic: adds crypto hardware node

 .../bindings/crypto/amlogic,gxl-crypto.yaml   |  52 +++
 MAINTAINERS                                   |   7 +
 arch/arm64/boot/dts/amlogic/meson-gxl.dtsi    |  10 +
 drivers/crypto/Kconfig                        |   2 +
 drivers/crypto/Makefile                       |   1 +
 drivers/crypto/amlogic/Kconfig                |  24 ++
 drivers/crypto/amlogic/Makefile               |   2 +
 drivers/crypto/amlogic/amlogic-gxl-cipher.c   | 381 ++++++++++++++++++
 drivers/crypto/amlogic/amlogic-gxl-core.c     | 333 +++++++++++++++
 drivers/crypto/amlogic/amlogic-gxl.h          | 170 ++++++++
 10 files changed, 982 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml
 create mode 100644 drivers/crypto/amlogic/Kconfig
 create mode 100644 drivers/crypto/amlogic/Makefile
 create mode 100644 drivers/crypto/amlogic/amlogic-gxl-cipher.c
 create mode 100644 drivers/crypto/amlogic/amlogic-gxl-core.c
 create mode 100644 drivers/crypto/amlogic/amlogic-gxl.h
Signature · 1 line
2.21.0
author maintainer
#1 lore raw

PATCH v2 1/4 dt-bindings: crypto: Add DT bindings documentation for amlogic-crypto

This patch adds documentation for Device-Tree bindings for the Amlogic GXL cryptographic offloader driver.

---
 .../bindings/crypto/amlogic,gxl-crypto.yaml   | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml
Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml new file +52 -0
new file mode 100644
index 000000000000..5becc60a0e28
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/crypto/amlogic,gxl-crypto.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic GXL Cryptographic Offloader
+
+maintainers:
+  - Corentin Labbe <[email protected]>
+
+properties:
+  compatible:
+    items:
+    - const: amlogic,gxl-crypto
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: "Interrupt for flow 0"
+      - description: "Interrupt for flow 1"
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: blkmv
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/gxbb-clkc.h>
+
+    crypto: crypto@c883e000 {
+        compatible = "amlogic,gxl-crypto";
+        reg = <0x0 0xc883e000 0x0 0x36>;
+        interrupts = <GIC_SPI 188 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 189 IRQ_TYPE_EDGE_RISING>;
+        clocks = <&clkc CLKID_BLKMV>;
+        clock-names = "blkmv";
+    };
Signature · 1 line
2.21.0
maintainer Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] dt-bindings: crypto: Add DT bindings documentation for amlogic-crypto

Quoted 9 lines · Corentin Labbe

This patch adds documentation for Device-Tree bindings for the Amlogic GXL cryptographic offloader driver.

---
 .../bindings/crypto/amlogic,gxl-crypto.yaml   | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/amlogic,gxl-crypto.yaml
author maintainer
#3 lore raw

PATCH v2 2/4 MAINTAINERS: Add myself as maintainer of amlogic crypto

In reply to Corentin Labbe

I will maintain the amlogic crypto driver.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 36c5d6ee01f9..a8487a0999ce 100644
@@ -1477,6 +1477,13 @@ F:	drivers/soc/amlogic/
 F:	drivers/rtc/rtc-meson*
 N:	meson
 
+ARM/Amlogic Meson SoC Crypto Drivers
+M:	Corentin Labbe <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/crypto/amlogic/
+F:	Documentation/devicetree/bindings/crypto/amlogic*
+
 ARM/Amlogic Meson SoC Sound Drivers
 M:	Jerome Brunet <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
Signature · 1 line
2.21.0
author maintainer
#4 lore raw

PATCH v2 3/4 crypto: amlogic: Add crypto accelerator for amlogic GXL

In reply to Corentin Labbe

This patch adds support for the amlogic GXL cryptographic offloader present on GXL SoCs.

This driver supports AES cipher in CBC/ECB mode.

---
 drivers/crypto/Kconfig                      |   2 +
 drivers/crypto/Makefile                     |   1 +
 drivers/crypto/amlogic/Kconfig              |  24 ++
 drivers/crypto/amlogic/Makefile             |   2 +
 drivers/crypto/amlogic/amlogic-gxl-cipher.c | 381 ++++++++++++++++++++
 drivers/crypto/amlogic/amlogic-gxl-core.c   | 333 +++++++++++++++++
 drivers/crypto/amlogic/amlogic-gxl.h        | 170 +++++++++
 7 files changed, 913 insertions(+)
 create mode 100644 drivers/crypto/amlogic/Kconfig
 create mode 100644 drivers/crypto/amlogic/Makefile
 create mode 100644 drivers/crypto/amlogic/amlogic-gxl-cipher.c
 create mode 100644 drivers/crypto/amlogic/amlogic-gxl-core.c
 create mode 100644 drivers/crypto/amlogic/amlogic-gxl.h
drivers/crypto/Kconfig +2 -0
index 9f08ed72eae8..04a2f53e66a3 100644
@@ -784,4 +784,6 @@ config CRYPTO_DEV_CCREE
 
 source "drivers/crypto/hisilicon/Kconfig"
 
+source "drivers/crypto/amlogic/Kconfig"
+
 endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
index 79e2da4a51e4..40229d499476 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_CRYPTO_DEV_BCM_SPU) += bcm/
 obj-$(CONFIG_CRYPTO_DEV_SAFEXCEL) += inside-secure/
 obj-$(CONFIG_CRYPTO_DEV_ARTPEC6) += axis/
 obj-y += hisilicon/
+obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/
drivers/crypto/amlogic/Kconfig new file +24 -0
new file mode 100644
index 000000000000..9c4bf96afeb3
@@ -0,0 +1,24 @@
+config CRYPTO_DEV_AMLOGIC_GXL
+	tristate "Support for amlogic cryptographic offloader"
+	default y if ARCH_MESON
+	select CRYPTO_BLKCIPHER
+	select CRYPTO_ENGINE
+	select CRYPTO_ECB
+	select CRYPTO_CBC
+	select CRYPTO_AES
+	help
+	  Select y here for having support for the cryptographic offloader
+	  availlable on Amlogic GXL SoC.
+	  This hardware handle AES ciphers in ECB/CBC mode.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called amlogic-crypto.
+
+config CRYPTO_DEV_AMLOGIC_GXL_DEBUG
+	bool "Enabled amlogic stats"
+	depends on CRYPTO_DEV_AMLOGIC_GXL
+	depends on DEBUG_FS
+	help
+	  Say y to enabled amlogic-crypto debug stats.
+	  This will create /sys/kernel/debug/gxl-crypto/stats for displaying
+	  the number of requests per flow and per algorithm.
drivers/crypto/amlogic/Makefile new file +2 -0
new file mode 100644
index 000000000000..39057e62c13e
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic-gxl-crypto.o
+amlogic-gxl-crypto-y := amlogic-gxl-core.o amlogic-gxl-cipher.o
drivers/crypto/amlogic/amlogic-gxl-cipher.c new file +381 -0

381 lines not on this page · raw message

drivers/crypto/amlogic/amlogic-gxl-core.c new file +333 -0

333 lines not on this page · raw message

drivers/crypto/amlogic/amlogic-gxl.h new file +170 -0

170 lines not on this page · raw message

Signature · 1 line
2.21.0
#5 lore raw

Re: [PATCH v2 3/4] crypto: amlogic: Add crypto accelerator for amlogic GXL

Hi,

Quoted 6 lines · Corentin Labbe
drivers/crypto/amlogic/Kconfig new file +0 -0
new file mode 100644
index 000000000000..9c4bf96afeb3

drivers/crypto/amlogic/Kconfig line 10

Quoted 10 lines
drivers/crypto/amlogic/Kconfig new file +10 -0
@@ -0,0 +1,24 @@
+config CRYPTO_DEV_AMLOGIC_GXL
+	tristate "Support for amlogic cryptographic offloader"
+	default y if ARCH_MESON
+	select CRYPTO_BLKCIPHER
+	select CRYPTO_ENGINE
+	select CRYPTO_ECB
+	select CRYPTO_CBC
+	select CRYPTO_AES
+	help
+	  Select y here for having support for the cryptographic offloader

to have support for

drivers/crypto/amlogic/Kconfig line 11

Quoted 1 line
drivers/crypto/amlogic/Kconfig new file +1 -0
+	  availlable on Amlogic GXL SoC.

available

drivers/crypto/amlogic/Kconfig line 12

Quoted 1 line
drivers/crypto/amlogic/Kconfig new file +1 -0
+	  This hardware handle AES ciphers in ECB/CBC mode.

handles

drivers/crypto/amlogic/Kconfig line 15

Quoted 3 lines
drivers/crypto/amlogic/Kconfig new file +3 -0
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called amlogic-crypto.

That module name does not match the Makefile's name.

drivers/crypto/amlogic/Kconfig line 18

Quoted 3 lines
drivers/crypto/amlogic/Kconfig new file +3 -0
+
+config CRYPTO_DEV_AMLOGIC_GXL_DEBUG
+	bool "Enabled amlogic stats"

Enable

drivers/crypto/amlogic/Kconfig line 22

Quoted 4 lines
drivers/crypto/amlogic/Kconfig new file +4 -0
+	depends on CRYPTO_DEV_AMLOGIC_GXL
+	depends on DEBUG_FS
+	help
+	  Say y to enabled amlogic-crypto debug stats.

enable

Quoted 10 lines
drivers/crypto/amlogic/Kconfig new file +2 -0
+	  This will create /sys/kernel/debug/gxl-crypto/stats for displaying
+	  the number of requests per flow and per algorithm.
drivers/crypto/amlogic/Makefile new file +2 -0
new file mode 100644
index 000000000000..39057e62c13e
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic-gxl-crypto.o
+amlogic-gxl-crypto-y := amlogic-gxl-core.o amlogic-gxl-cipher.o
Signature · 1 line
~Randy
author maintainer
#6 lore raw

Re: [PATCH v2 3/4] crypto: amlogic: Add crypto accelerator for amlogic GXL

Quoted 49 lines · Randy Dunlap

Hi,

Quoted 6 lines · Corentin Labbe
drivers/crypto/amlogic/Kconfig new file +0 -0
new file mode 100644
index 000000000000..9c4bf96afeb3

drivers/crypto/amlogic/Kconfig line 10

Quoted 10 lines
drivers/crypto/amlogic/Kconfig new file +10 -0
@@ -0,0 +1,24 @@
+config CRYPTO_DEV_AMLOGIC_GXL
+	tristate "Support for amlogic cryptographic offloader"
+	default y if ARCH_MESON
+	select CRYPTO_BLKCIPHER
+	select CRYPTO_ENGINE
+	select CRYPTO_ECB
+	select CRYPTO_CBC
+	select CRYPTO_AES
+	help
+	  Select y here for having support for the cryptographic offloader

to have support for

drivers/crypto/amlogic/Kconfig line 11

Quoted 1 line
drivers/crypto/amlogic/Kconfig new file +1 -0
+	  availlable on Amlogic GXL SoC.

available

drivers/crypto/amlogic/Kconfig line 12

Quoted 1 line
drivers/crypto/amlogic/Kconfig new file +1 -0
+	  This hardware handle AES ciphers in ECB/CBC mode.

handles

drivers/crypto/amlogic/Kconfig line 15

Quoted 3 lines
drivers/crypto/amlogic/Kconfig new file +3 -0
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called amlogic-crypto.

That module name does not match the Makefile's name.

drivers/crypto/amlogic/Kconfig line 18

Quoted 3 lines
drivers/crypto/amlogic/Kconfig new file +3 -0
+
+config CRYPTO_DEV_AMLOGIC_GXL_DEBUG
+	bool "Enabled amlogic stats"

Enable

drivers/crypto/amlogic/Kconfig line 22

Quoted 4 lines
drivers/crypto/amlogic/Kconfig new file +4 -0
+	depends on CRYPTO_DEV_AMLOGIC_GXL
+	depends on DEBUG_FS
+	help
+	  Say y to enabled amlogic-crypto debug stats.

enable

Quoted 11 lines

drivers/crypto/amlogic/Makefile line 2

Quoted 10 lines
drivers/crypto/amlogic/Kconfig new file +2 -0
+	  This will create /sys/kernel/debug/gxl-crypto/stats for displaying
+	  the number of requests per flow and per algorithm.
drivers/crypto/amlogic/Makefile new file +2 -0
new file mode 100644
index 000000000000..39057e62c13e
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic-gxl-crypto.o
+amlogic-gxl-crypto-y := amlogic-gxl-core.o amlogic-gxl-cipher.o

Thanks, I fixed it

Regards

author maintainer
#7 lore raw

PATCH v2 4/4 ARM64: dts: amlogic: adds crypto hardware node

In reply to Corentin Labbe

This patch adds the GXL crypto hardware node for all GXL SoCs.

---
 arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi +10 -0
index 49ff0a7d0210..ed33d8efaf62 100644
@@ -36,6 +36,16 @@
 				phys = <&usb3_phy>, <&usb2_phy0>, <&usb2_phy1>;
 			};
 		};
+
+		crypto: crypto@c883e000 {
+			compatible = "amlogic,gxl-crypto";
+			reg = <0x0 0xc883e000 0x0 0x36>;
+			interrupts = <GIC_SPI 188 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 189 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc CLKID_BLKMV>;
+			clock-names = "blkmv";
+			status = "okay";
+		};
 	};
 };
 
Signature · 1 line
2.21.0
maintainer Reviewed-by on v2 4/4
#8 lore raw

Re: [PATCH v2 4/4] ARM64: dts: amlogic: adds crypto hardware node

Quoted 15 lines · Corentin Labbe

This patch adds the GXL crypto hardware node for all GXL SoCs.

---
 arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi +0 -0
index 49ff0a7d0210..ed33d8efaf62 100644
@@ -36,6 +36,16 @@
 				phys = <&usb3_phy>, <&usb2_phy0>, <&usb2_phy1>;
 			};
 		};

arch/arm64/boot/dts/amlogic/meson-gxl.dtsi line 48

Quoted 10 lines
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi +10 -0
+
+		crypto: crypto@c883e000 {
+			compatible = "amlogic,gxl-crypto";
+			reg = <0x0 0xc883e000 0x0 0x36>;
+			interrupts = <GIC_SPI 188 IRQ_TYPE_EDGE_RISING>,
+				     <GIC_SPI 189 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&clkc CLKID_BLKMV>;
+			clock-names = "blkmv";
+			status = "okay";
+		};

Looks good.

I'll apply this via the amlogic tree as soon as Herbet applies the driver part.

Kevin