Skip to contentSkip to conversation

crypto: caam: Add support for i.MX8M Mini

PATCH Superseded Adam Ford 4 participants 11 messages Dec 13, 2019 – Dec 20, 2019

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH v2 1/3 crypto: caam: Add support for i.MX8M Mini

The i.MX8M Mini uses the same crypto engine as the i.MX8MQ, but the driver is restricting the check to just the i.MX8MQ.

This patch expands the check for either i.MX8MQ or i.MX8MM.

---
V2: Expand the check that forces the setting on imx8mq to also be true for imx8mm
Explictly state imx8mm compatiblity instead of making it generic to all imx8m*
this is mostly due to lack of other hardware to test

drivers/crypto/caam/ctrl.c +3 -1
index d7c3c3805693..c01dda692ecc 100644
@@ -102,7 +102,8 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc,
 	     * Apparently on i.MX8MQ it doesn't matter if virt_en == 1
 	     * and the following steps should be performed regardless
 	     */
-	    of_machine_is_compatible("fsl,imx8mq")) {
+	    of_machine_is_compatible("fsl,imx8mq") ||
+	    of_machine_is_compatible("fsl,imx8mm")) {
 		clrsetbits_32(&ctrl->deco_rsr, 0, DECORSR_JR0);
 
 		while (!(rd_reg32(&ctrl->deco_rsr) & DECORSR_VALID) &&
@@ -509,6 +510,7 @@ static const struct soc_device_attribute caam_imx_soc_table[] = {
 	{ .soc_id = "i.MX6*",  .data = &caam_imx6_data },
 	{ .soc_id = "i.MX7*",  .data = &caam_imx7_data },
 	{ .soc_id = "i.MX8MQ", .data = &caam_imx7_data },
+	{ .soc_id = "i.MX8MM", .data = &caam_imx7_data },
 	{ .family = "Freescale i.MX" },
 	{ /* sentinel */ }
 };
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH v2 2/3 arm64: dts: imx8mm: Add Crypto CAAM support

The i.MX8M Mini supports the same crypto engine as what is in the i.MX8MQ, but it is not currently present in the device tree.

This patch places in into the device tree.

---
V2: Don't disable it by default

arch/arm64/boot/dts/freescale/imx8mm.dtsi +30 -0
index 860cddec9632..1f0178078572 100644
@@ -726,6 +726,36 @@
 				status = "disabled";
 			};
 
+			crypto: crypto@30900000 {
+				compatible = "fsl,sec-v4.0";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				reg = <0x30900000 0x40000>;
+				ranges = <0 0x30900000 0x40000>;
+				interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_AHB>,
+					 <&clk IMX8MM_CLK_IPG_ROOT>;
+				clock-names = "aclk", "ipg";
+
+				sec_jr0: jr@1000 {
+					compatible = "fsl,sec-v4.0-job-ring";
+					reg = <0x1000 0x1000>;
+					interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
+				};
+
+				sec_jr1: jr@2000 {
+					compatible = "fsl,sec-v4.0-job-ring";
+					reg = <0x2000 0x1000>;
+					interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+				};
+
+				sec_jr2: jr@3000 {
+					compatible = "fsl,sec-v4.0-job-ring";
+					reg = <0x3000 0x1000>;
+					interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
+				};
+			};
+
 			i2c1: i2c@30a20000 {
 				compatible = "fsl,imx8mm-i2c", "fsl,imx21-i2c";
 				#address-cells = <1>;
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 2/3
#2 lore raw

Re: [PATCH V2 2/3] arm64: dts: imx8mm: Add Crypto CAAM support

Quoted 4 lines · Adam Ford

The i.MX8M Mini supports the same crypto engine as what is in the i.MX8MQ, but it is not currently present in the device tree.

This patch places in into the device tree.

^ it

Quoted 2 lines

Thanks,
Horia

author
#3 lore raw

PATCH v2 3/3 arm64: defconfig: Enable CRYPTO_DEV_FSL_CAAM

In reply to Adam Ford

Both the i.MX8MQ and i.MX8M Mini support the CAAM driver, but it is currently not enabled by default.

This patch enables this driver by default.

---
V2: New to series

arch/arm64/configs/defconfig +1 -0
index 6a83ba2aea3e..0212975b908b 100644
@@ -845,6 +845,7 @@ CONFIG_SECURITY=y
 CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_ANSI_CPRNG=y
 CONFIG_CRYPTO_DEV_SUN8I_CE=m
+CONFIG_CRYPTO_DEV_FSL_CAAM=y
 CONFIG_CRYPTO_DEV_HISI_ZIP=m
 CONFIG_CMA_SIZE_MBYTES=32
 CONFIG_PRINTK_TIME=y
Signature · 1 line
2.20.1
maintainer
#4 lore raw

Re: [PATCH V2 3/3] arm64: defconfig: Enable CRYPTO_DEV_FSL_CAAM

Quoted 1 line · Adam Ford

Both the i.MX8MQ and i.MX8M Mini support the CAAM driver, but it

So do the Layerscape ARMv8-based SoCs:
LS1012A, LS1028A, LS1043A, LS1046A, LS1088A, LS2088A, LX2160A

Quoted 13 lines

is currently not enabled by default.

This patch enables this driver by default.

---
V2: New to series

arch/arm64/configs/defconfig +0 -0
index 6a83ba2aea3e..0212975b908b 100644

arch/arm64/configs/defconfig CONFIG_SECURITY=y · line 848

Quoted 4 lines
arch/arm64/configs/defconfig +1 -0
@@ -845,6 +845,7 @@ CONFIG_SECURITY=y
 CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_ANSI_CPRNG=y
 CONFIG_CRYPTO_DEV_SUN8I_CE=m
+CONFIG_CRYPTO_DEV_FSL_CAAM=y

This should probably be "m" instead.

Horia

author
#5 lore raw

Re: [PATCH V2 3/3] arm64: defconfig: Enable CRYPTO_DEV_FSL_CAAM

Quoted 14 lines · Horia Geanta
Quoted 1 line · Adam Ford

Both the i.MX8MQ and i.MX8M Mini support the CAAM driver, but it

So do the Layerscape ARMv8-based SoCs:
LS1012A, LS1028A, LS1043A, LS1046A, LS1088A, LS2088A, LX2160A

Quoted 8 lines

is currently not enabled by default.

This patch enables this driver by default.

---
V2: New to series

Quoted 10 lines

arch/arm64/configs/defconfig CONFIG_SECURITY=y · line 848

Quoted 9 lines
arch/arm64/configs/defconfig +1 -0
index 6a83ba2aea3e..0212975b908b 100644
@@ -845,6 +845,7 @@ CONFIG_SECURITY=y
 CONFIG_CRYPTO_ECHAINIV=y
 CONFIG_CRYPTO_ANSI_CPRNG=y
 CONFIG_CRYPTO_DEV_SUN8I_CE=m
+CONFIG_CRYPTO_DEV_FSL_CAAM=y

This should probably be "m" instead.

Out of curiosity, what is the rule for when things are 'm' vs 'y'?

In the Code Aurora repo, it is set to 'y' and the mainline kernel for the i.MX6/7, the imx_v6_v7_defconfig is also set to 'y' which is why I used 'y' here.

I can do a V3 to address the other items you noted, but I want to understand the rules about the defconfig so I don't make the same mistake again.

thanks,

adam

Quoted 2 lines

Horia

reviewer
#6 lore raw

Re: [PATCH V2 3/3] arm64: defconfig: Enable CRYPTO_DEV_FSL_CAAM

Hi Adam,

Quoted 9 lines · Adam Ford

Out of curiosity, what is the rule for when things are 'm' vs 'y'?

In the Code Aurora repo, it is set to 'y' and the mainline kernel for the i.MX6/7, the imx_v6_v7_defconfig is also set to 'y' which is why I used 'y' here.

I can do a V3 to address the other items you noted, but I want to understand the rules about the defconfig so I don't make the same mistake again.

In arch/arm64/configs/defconfig we try to select modules whenever possible.

The exceptions are drivers that are vital for boot such as PMIC, pinctrl, clks, etc.

The CAAM driver does not fall into this category, so selecting it as module is preferred here.

Thanks

author
#7 lore raw

Re: [PATCH V2 3/3] arm64: defconfig: Enable CRYPTO_DEV_FSL_CAAM

Quoted 15 lines · Fabio Estevam

Hi Adam,

Quoted 9 lines · Adam Ford

Out of curiosity, what is the rule for when things are 'm' vs 'y'?

In the Code Aurora repo, it is set to 'y' and the mainline kernel for the i.MX6/7, the imx_v6_v7_defconfig is also set to 'y' which is why I used 'y' here.

I can do a V3 to address the other items you noted, but I want to understand the rules about the defconfig so I don't make the same mistake again.

Quoted 7 lines

In arch/arm64/configs/defconfig we try to select modules whenever possible.

The exceptions are drivers that are vital for boot such as PMIC, pinctrl, clks, etc.

The CAAM driver does not fall into this category, so selecting it as module is preferred here.

That makes sense. Thank you for the clarification. I'll keep that in mind if I submit future updates.

adam

Quoted 2 lines

Thanks

maintainer
#8 lore raw

Re: [PATCH V2 3/3] arm64: defconfig: Enable CRYPTO_DEV_FSL_CAAM

In reply to Fabio Estevam
Quoted 14 lines · Fabio Estevam

Hi Adam,

Quoted 9 lines · Adam Ford

Out of curiosity, what is the rule for when things are 'm' vs 'y'?

In the Code Aurora repo, it is set to 'y' and the mainline kernel for the i.MX6/7, the imx_v6_v7_defconfig is also set to 'y' which is why I used 'y' here.

I can do a V3 to address the other items you noted, but I want to understand the rules about the defconfig so I don't make the same mistake again.

Quoted 8 lines

In arch/arm64/configs/defconfig we try to select modules whenever possible.

The exceptions are drivers that are vital for boot such as PMIC, pinctrl, clks, etc.

The CAAM driver does not fall into this category, so selecting it as module is preferred here.

One comment here though.

CAAM's RNG is not "vital" for booting, but IIUC it would decrease the boot time since it feeds the entropy pool through the hwrng interface.

Once RNG driver is fixed, would it be acceptable to add:
CONFIG_HW_RANDOM=y
CONFIG_CRYPTO_DEV_FSL_CAAM=y
in arm64 defconfig?

Thanks,
Horia

Tested-by Reviewed-by on v2 1/3
#9 lore raw
In reply to Adam Ford
Quoted 7 lines · Adam Ford

The i.MX8M Mini uses the same crypto engine as the i.MX8MQ, but the driver is restricting the check to just the i.MX8MQ.

This patch expands the check for either i.MX8MQ or i.MX8MM.

For the series:

Quoted 28 lines

---
V2: Expand the check that forces the setting on imx8mq to also be true for imx8mm
Explictly state imx8mm compatiblity instead of making it generic to all imx8m*
this is mostly due to lack of other hardware to test

drivers/crypto/caam/ctrl.c +3 -1
index d7c3c3805693..c01dda692ecc 100644
@@ -102,7 +102,8 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc,
  	     * Apparently on i.MX8MQ it doesn't matter if virt_en == 1
  	     * and the following steps should be performed regardless
  	     */
-	    of_machine_is_compatible("fsl,imx8mq")) {
+	    of_machine_is_compatible("fsl,imx8mq") ||
+	    of_machine_is_compatible("fsl,imx8mm")) {
  		clrsetbits_32(&ctrl->deco_rsr, 0, DECORSR_JR0);
 
  		while (!(rd_reg32(&ctrl->deco_rsr) & DECORSR_VALID) &&
@@ -509,6 +510,7 @@ static const struct soc_device_attribute caam_imx_soc_table[] = {
  	{ .soc_id = "i.MX6*",  .data = &caam_imx6_data },
  	{ .soc_id = "i.MX7*",  .data = &caam_imx7_data },
  	{ .soc_id = "i.MX8MQ", .data = &caam_imx7_data },
+	{ .soc_id = "i.MX8MM", .data = &caam_imx7_data },
  	{ .family = "Freescale i.MX" },
  	{ /* sentinel */ }
  };
maintainer Reviewed-by on v2 1/3
#10 lore raw
In reply to Adam Ford
Quoted 6 lines · Adam Ford

The i.MX8M Mini uses the same crypto engine as the i.MX8MQ, but the driver is restricting the check to just the i.MX8MQ.

This patch expands the check for either i.MX8MQ or i.MX8MM.

Thanks,
Horia

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel