[PATCH 3/3] crypto: caam/qi2 - priority from the DTS

From: Vincent Jardin via B4 Relay

Date: Mon Sep 28 2026 - 10:02:55 EST


From: Vincent Jardin <vjardin@xxxxxxx>

Read fsl,qi2-crypto-priority from the SEC node when dpaa2_caam probes,
so the board's DTS sets the priority its algorithms register with.

The dpaa2_caam.priority parameter has precedence when it is set.
When they are not set, we keep the default behaviour.

Signed-off-by: Vincent Jardin <vjardin@xxxxxxx>
---
drivers/crypto/caam/caamalg_qi2.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index dbb84a6996a2..7d6a5e4ee86e 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -19,6 +19,7 @@
#include <linux/dma-mapping.h>
#include <linux/fsl/mc.h>
#include <linux/kernel.h>
+#include <linux/of.h>
#include <linux/string.h>
#include <linux/string_choices.h>
#include <soc/fsl/dpaa2-io.h>
@@ -35,6 +36,25 @@ MODULE_PARM_DESC(priority,

static int cra_priority = CAAM_CRA_PRIORITY;

+static int dpaa2_caam_cra_priority(void)
+{
+ struct device_node *np;
+ u32 prio;
+ int err;
+
+ if (priority)
+ return priority;
+
+ np = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0");
+ if (!np)
+ return CAAM_CRA_PRIORITY;
+
+ err = of_property_read_u32(np, "fsl,qi2-crypto-priority", &prio);
+ of_node_put(np);
+
+ return err ? CAAM_CRA_PRIORITY : prio;
+}
+
/* max key is sum of AES_MAX_KEY_SIZE, max split key size */
#define CAAM_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE + \
SHA512_DIGEST_SIZE * 2)
@@ -5215,8 +5235,7 @@ static int dpaa2_caam_probe(struct fsl_mc_device *dpseci_dev)

caam_imx = false;

- if (priority)
- cra_priority = priority;
+ cra_priority = dpaa2_caam_cra_priority();

dev = &dpseci_dev->dev;


--
2.43.0