Add MediaTek crypto acclelrator driver
Subsystems (3)
cover Add MediaTek crypto acclelrator driver
Hello,
This adds support for the MediaTek hardware accelerator on mt7623 SoC.
This driver currently implement:
- SHA1 and SHA2 family(HMAC) hash alogrithms.
- AES block cipher in CBC/ECB mode with 128/196/256 bits keys.
Changes since v1:
- remove EXPORT_SYMBOL
- remove unused PRNG setting
- sort headers in alphabetical order
- add a definition for IRQ unmber
- replace ambiguous definition
- add more annotation and function comment
- add COMPILE_TEST in Kconfig
Ryder Lee (2):
Add crypto driver support for some MediaTek chips
crypto: mediatek - add DT bindings documentation
.../devicetree/bindings/crypto/mediatek-crypto.txt | 32 + drivers/crypto/Kconfig | 17 + drivers/crypto/Makefile | 1 + drivers/crypto/mediatek/Makefile | 2 + drivers/crypto/mediatek/mtk-aes.c | 763 +++++++++++ drivers/crypto/mediatek/mtk-platform.c | 580 ++++++++ drivers/crypto/mediatek/mtk-platform.h | 235 ++++ drivers/crypto/mediatek/mtk-regs.h | 194 +++ drivers/crypto/mediatek/mtk-sha.c | 1423 ++++++++++++++++++++ 9 files changed, 3247 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt create mode 100644 drivers/crypto/mediatek/Makefile create mode 100644 drivers/crypto/mediatek/mtk-aes.c create mode 100644 drivers/crypto/mediatek/mtk-platform.c create mode 100644 drivers/crypto/mediatek/mtk-platform.h create mode 100644 drivers/crypto/mediatek/mtk-regs.h create mode 100644 drivers/crypto/mediatek/mtk-sha.c
Signature · 1 line
1.9.1
PATCH 1/2 Add crypto driver support for some MediaTek chips
This adds support for the MediaTek hardware accelerator on mt7623/mt2701/mt8521p SoC.
This driver currently implement:
- SHA1 and SHA2 family(HMAC) hash alogrithms.
- AES block cipher in CBC/ECB mode with 128/196/256 bits keys.
--- drivers/crypto/Kconfig | 17 + drivers/crypto/Makefile | 1 + drivers/crypto/mediatek/Makefile | 2 + drivers/crypto/mediatek/mtk-aes.c | 763 +++++++++++++++++ drivers/crypto/mediatek/mtk-platform.c | 580 +++++++++++++ drivers/crypto/mediatek/mtk-platform.h | 235 ++++++ drivers/crypto/mediatek/mtk-regs.h | 194 +++++ drivers/crypto/mediatek/mtk-sha.c | 1423 ++++++++++++++++++++++++++++++++ 8 files changed, 3215 insertions(+) create mode 100644 drivers/crypto/mediatek/Makefile create mode 100644 drivers/crypto/mediatek/mtk-aes.c create mode 100644 drivers/crypto/mediatek/mtk-platform.c create mode 100644 drivers/crypto/mediatek/mtk-platform.h create mode 100644 drivers/crypto/mediatek/mtk-regs.h create mode 100644 drivers/crypto/mediatek/mtk-sha.c
drivers/crypto/Kconfig +17 -0
@@ -553,6 +553,23 @@ config CRYPTO_DEV_ROCKCHIP This driver interfaces with the hardware crypto accelerator. Supporting cbc/ecb chainmode, and aes/des/des3_ede cipher mode. +config CRYPTO_DEV_MEDIATEK + tristate "MediaTek's Cryptographic Engine driver" + depends on ARM && (ARCH_MEDIATEK || COMPILE_TEST) + select NEON + select KERNEL_MODE_NEON + select ARM_CRYPTO + select CRYPTO_AES + select CRYPTO_BLKCIPHER + select CRYPTO_SHA1_ARM_NEON + select CRYPTO_SHA256_ARM + select CRYPTO_SHA512_ARM + select CRYPTO_HMAC + help + This driver allows you to utilize the hardware crypto accelerator + which can be found on the MT7623 MT2701, MT8521p, etc .... + Select this if you want to use it for AES/SHA1/SHA2 algorithms. + source "drivers/crypto/chelsio/Kconfig" endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_CRYPTO_DEV_IMGTEC_HASH) += img-hash.o obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o obj-$(CONFIG_CRYPTO_DEV_MV_CESA) += mv_cesa.o obj-$(CONFIG_CRYPTO_DEV_MARVELL_CESA) += marvell/ +obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mediatek/ obj-$(CONFIG_CRYPTO_DEV_MXS_DCP) += mxs-dcp.o obj-$(CONFIG_CRYPTO_DEV_NIAGARA2) += n2_crypto.o n2_crypto-y := n2_core.o n2_asm.o
drivers/crypto/mediatek/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mtk-crypto.o +mtk-crypto-objs:= mtk-platform.o mtk-aes.o mtk-sha.o
drivers/crypto/mediatek/mtk-aes.c new file +763 -0
763 lines not on this page · raw message
drivers/crypto/mediatek/mtk-platform.c new file +580 -0
580 lines not on this page · raw message
drivers/crypto/mediatek/mtk-platform.h new file +235 -0
235 lines not on this page · raw message
drivers/crypto/mediatek/mtk-regs.h new file +194 -0
194 lines not on this page · raw message
drivers/crypto/mediatek/mtk-sha.c new file +1423 -0
1,196 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v1 1/2] Add crypto driver support for some MediaTek chips
Hello
I have two minor comment.
Quoted 5 lines · Ryder Lee
This adds support for the MediaTek hardware accelerator on mt7623/mt2701/mt8521p SoC.
This driver currently implement:
- SHA1 and SHA2 family(HMAC) hash alogrithms.
There is a typo for algorithms.
[...]
Quoted 12 lines
drivers/crypto/mediatek/mtk-platform.h new file +12
-0+/** +* struct mtk_desc - DMA descriptor +* @hdr: the descriptor control header +* @buf: DMA address of input buffer segment +* @ct: DMA address of command token that control operation flow +* @ct_hdr: the command token control header +* @tag: the user-defined field +* @tfm: DMA address of transform state +* @bound: align descriptors offset boundary +* +* Structure passed to the crypto engine to describe where source +* data needs to be fetched and how it needs to be processed.
drivers/crypto/mediatek/mtk-platform.h line 71
Quoted 10 lines
drivers/crypto/mediatek/mtk-platform.h new file +10
-0+*/ +struct mtk_desc { +u32 hdr; +u32 buf; +u32 ct; +u32 ct_hdr; +u32 tag; +u32 tfm; +u32 bound[2 ]; +};
Do you have tested this descriptor with BE/LE kernel ?
Regards
Corentin Labbe
Re: [PATCH v1 1/2] Add crypto driver support for some MediaTek chips
Hello,
Quoted 30 lines · Corentin Labbe
Hello
I have two minor comment.
Quoted 5 lines · Ryder Lee
This adds support for the MediaTek hardware accelerator on mt7623/mt2701/mt8521p SoC.
This driver currently implement:
- SHA1 and SHA2 family(HMAC) hash alogrithms.There is a typo for algorithms.
[...]
Quoted 16 lines
drivers/crypto/mediatek/mtk-platform.h new file +16
-0+/** +* struct mtk_desc - DMA descriptor +* @hdr: the descriptor control header +* @buf: DMA address of input buffer segment +* @ct: DMA address of command token that control operation flow +* @ct_hdr: the command token control header +* @tag: the user-defined field +* @tfm: DMA address of transform state +* @bound: align descriptors offset boundary +* +* Structure passed to the crypto engine to describe where source +* data needs to be fetched and how it needs to be processed. +*/ +struct mtk_desc { +u32 hdr; +u32 buf;
Quoted 8 lines
drivers/crypto/mediatek/mtk-platform.h line 71
Quoted 6 lines
drivers/crypto/mediatek/mtk-platform.h new file +6
-0+u32 ct; +u32 ct_hdr; +u32 tag; +u32 tfm; +u32 bound[2 ]; +};Do you have tested this descriptor with BE/LE kernel ?
I did not test it with BE kernel, because both CPU and accelerator in our SoC just run on LE system.
Thanks for reminding me, i will use byteorder conversion macros and type identifiers.
Quoted 2 lines
Regards
Corentin Labbe
PATCH 2/2 crypto: mediatek - add DT bindings documentation
In reply to Ryder LeeAdd DT bindings documentation for the crypto driver
--- .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +32 -0
@@ -0,0 +1,32 @@ +MediaTek cryptographic accelerators + +Required properties: +- compatible: Should be "mediatek,mt7623-crypto" +- reg: Address and length of the register set for the device +- interrupts: Should contain the five crypto engines interrupts in numeric + order. These are global system and four descriptor rings. +- clocks: the clock used by the core +- clock-names: the names of the clock listed in the clocks property. These are + "ethif", "cryp" +- power-domains: Must contain a reference to the PM domain. + + +Optional properties: +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device + + +Example: + crypto: crypto at 1b240000 { + compatible = "mediatek,mt7623-crypto"; + reg = <0 0x1b240000 0 0x20000>; + interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 83 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_ETHIF_SEL>, + <ðsys CLK_ETHSYS_CRYPTO>; + clock-names = "ethif","cryp"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>; + };
Signature · 1 line
1.9.1
Matthias Brugger
maintainerRe: [PATCH v1 2/2] crypto: mediatek - add DT bindings documentation
Quoted 14 lines · Ryder Lee
Add DT bindings documentation for the crypto driver
Signed-off-by Ryder Lee <[email protected]>--- .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txtDocumentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +0
-0
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt line 4
Quoted 4 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +4
-0@@ -0,0 +1,32 @@ +MediaTek cryptographic accelerators + +Required properties: +- compatible: Should be "mediatek,mt7623-crypto"
Do you know how big the difference is between the crypto engine for mt7623/mt2701/mt8521p in comparison, let's say mt8173 or mt6797? Do this SoCs have a crypot engine? If so and they are quite similar, we might think of adding a mtk-crypto binding and add soc specific bindings.
Regards,
Matthias
Quoted 29 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +28
-0+- reg: Address and length of the register set for the device +- interrupts: Should contain the five crypto engines interrupts in numeric + order. These are global system and four descriptor rings. +- clocks: the clock used by the core +- clock-names: the names of the clock listed in the clocks property. These are + "ethif", "cryp" +- power-domains: Must contain a reference to the PM domain. + + +Optional properties: +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device + + +Example: + crypto: crypto at 1b240000 { + compatible = "mediatek,mt7623-crypto"; + reg = <0 0x1b240000 0 0x20000>; + interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 83 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_ETHIF_SEL>, + <ðsys CLK_ETHSYS_CRYPTO>; + clock-names = "ethif","cryp"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>; + };
Re: [PATCH v1 2/2] crypto: mediatek - add DT bindings documentation
Hello,
Quoted 10 lines · Matthias Brugger
Quoted 8 lines · Ryder Lee
Add DT bindings documentation for the crypto driver
Signed-off-by Ryder Lee <[email protected]>--- .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
Quoted 15 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt line 4
Quoted 10 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +4
-0@@ -0,0 +1,32 @@ +MediaTek cryptographic accelerators + +Required properties: +- compatible: Should be "mediatek,mt7623-crypto"Do you know how big the difference is between the crypto engine for mt7623/mt2701/mt8521p in comparison, let's say mt8173 or mt6797? Do this SoCs have a crypot engine? If so and they are quite similar, we might think of adding a mtk-crypto binding and add soc specific bindings.
This engine is just available in mt7623/mt2701/mt8521p series SoCs and they have no difference.
But there are still other crypto IPs in MTK, i think maybe we could use "mediatek,{IP name}-crypto? to distinguish them ?
Quoted 32 lines
Regards,
MatthiasQuoted 29 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +28
-0+- reg: Address and length of the register set for the device +- interrupts: Should contain the five crypto engines interrupts in numeric + order. These are global system and four descriptor rings. +- clocks: the clock used by the core +- clock-names: the names of the clock listed in the clocks property. These are + "ethif", "cryp" +- power-domains: Must contain a reference to the PM domain. + + +Optional properties: +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device + + +Example: + crypto: crypto at 1b240000 { + compatible = "mediatek,mt7623-crypto"; + reg = <0 0x1b240000 0 0x20000>; + interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 83 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_ETHIF_SEL>, + <ðsys CLK_ETHSYS_CRYPTO>; + clock-names = "ethif","cryp"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>; + };
Matthias Brugger
maintainerRe: [PATCH v1 2/2] crypto: mediatek - add DT bindings documentation
Quoted 29 lines · Ryder Lee
Hello,
Quoted 10 lines · Matthias Brugger
Quoted 8 lines · Ryder Lee
Add DT bindings documentation for the crypto driver
Signed-off-by Ryder Lee <[email protected]>--- .../devicetree/bindings/crypto/mediatek-crypto.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek-crypto.txtQuoted 15 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt line 4
Quoted 10 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +4
-0@@ -0,0 +1,32 @@ +MediaTek cryptographic accelerators + +Required properties: +- compatible: Should be "mediatek,mt7623-crypto"Do you know how big the difference is between the crypto engine for mt7623/mt2701/mt8521p in comparison, let's say mt8173 or mt6797? Do this SoCs have a crypot engine? If so and they are quite similar, we might think of adding a mtk-crypto binding and add soc specific bindings.
Quoted 6 lines
This engine is just available in mt7623/mt2701/mt8521p series SoCs and they have no difference.
But there are still other crypto IPs in MTK, i think maybe we could use "mediatek,{IP name}-crypto? to distinguish them ?
Sounds good, thanks for the clarification.
Matthias
Quoted 34 lines
Quoted 32 lines
Regards,
MatthiasQuoted 29 lines
Documentation/devicetree/bindings/crypto/mediatek-crypto.txt new file +28
-0+- reg: Address and length of the register set for the device +- interrupts: Should contain the five crypto engines interrupts in numeric + order. These are global system and four descriptor rings. +- clocks: the clock used by the core +- clock-names: the names of the clock listed in the clocks property. These are + "ethif", "cryp" +- power-domains: Must contain a reference to the PM domain. + + +Optional properties: +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device + + +Example: + crypto: crypto at 1b240000 { + compatible = "mediatek,mt7623-crypto"; + reg = <0 0x1b240000 0 0x20000>; + interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 83 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_ETHIF_SEL>, + <ðsys CLK_ETHSYS_CRYPTO>; + clock-names = "ethif","cryp"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>; + };