Skip to content

Commit 8bed962

Browse files
committed
nrf_security: drivers: cracen: Add workaround for ikg issues on 54l09/54l20
Add workaround to handle freezing issue on CRACEN Lite devices. Add compile time error for building with CRACEN Lite and not 54l09/54l20 As the developers should make a decisions if the workaround is needed. This issue stems from the PKE-IKG interrupt not being cleared. To handle this sx_pk_wait is changed to use polling and the PKE-IKG interrupt is disabled except for when in PK mode. In PK mode the interrupt can be cleared by hardware, which means it can be used there. Ref DLT-4048 Signed-off-by: Dag Erik Gjørvad <dag.erik.gjorvad@nordicsemi.no>
1 parent bfd3415 commit 8bed962

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

subsys/nrf_security/src/drivers/cracen/silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c

+17
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#include <security/cracen.h>
2424
#include <nrf_security_mutexes.h>
2525

26+
#if CONFIG_CRACEN_HW_VERSION_LITE && !CONFIG_SOC_NRF54L20 && !CONFIG_SOC_NRF54L09
27+
#error Check to see if the current board needs the IKG-PKE interrupt workaround or not, \
28+
then update this error
29+
#endif
30+
2631
#ifndef ADDR_BA414EP_REGS_BASE
2732
#define ADDR_BA414EP_REGS_BASE CRACEN_ADDR_BA414EP_REGS_BASE
2833
#endif
@@ -92,9 +97,15 @@ int read_status(sx_pk_req *req)
9297
int sx_pk_wait(sx_pk_req *req)
9398
{
9499
do {
100+
#ifndef CONFIG_CRACEN_HW_VERSION_LITE
101+
/* In CRACEN Lite the PKE-IKG interrupt is only active when in PK mode.
102+
* This is to work around a hardware issue where the interrupt is never cleared.
103+
* Therefore sx_pk_wait needs to use polling and not interrupts for CRACEN Lite.
104+
*/
95105
if (!sx_pk_is_ik_cmd(req)) {
96106
cracen_wait_for_pke_interrupt();
97107
}
108+
#endif
98109
} while (is_busy(req));
99110

100111
return read_status(req);
@@ -196,7 +207,13 @@ struct sx_pk_acq_req sx_pk_acquire_req(const struct sx_pk_cmd_def *cmd)
196207
req.req->cnx = &silex_pk_engine;
197208

198209
cracen_acquire();
210+
#ifndef CONFIG_CRACEN_HW_VERSION_LITE
211+
/* In CRACEN Lite the PKE-IKG interrupt is only active when in PK mode.
212+
* This is to work around a hardware issue where the interrupt is never cleared.
213+
* Therefore it is not enabled here for Cracen Lite.
214+
*/
199215
nrf_cracen_int_enable(NRF_CRACEN, NRF_CRACEN_INT_PKE_IKG_MASK);
216+
#endif
200217

201218
/* Wait until initialized. */
202219
while (ba414ep_is_busy(req.req) || ik_is_busy(req.req)) {

subsys/nrf_security/src/drivers/cracen/silexpk/target/hw/ik/ikhardware.c

+21-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "regs_addr.h"
1919
#include <silexpk/ec_curves.h>
2020
#include <silexpk/ik.h>
21+
#ifdef CONFIG_CRACEN_HW_VERSION_LITE
22+
#include "hal/nrf_cracen.h"
23+
#endif
2124

2225
int cracen_prepare_ik_key(const uint8_t *user_data);
2326

@@ -48,6 +51,16 @@ void sx_pk_run(sx_pk_req *req)
4851
if (sx_pk_is_ik_cmd(req)) {
4952
sx_pk_wrreg(&req->regs, IK_REG_PK_CONTROL,
5053
IK_PK_CONTROL_START_OP | IK_PK_CONTROL_CLEAR_IRQ);
54+
#ifdef CONFIG_CRACEN_HW_VERSION_LITE
55+
/* Workaround to handle IKG freezing on CRACEN lite.
56+
* THE PKE-IKG interrupt can not be cleared from software, but can
57+
* be cleared by hardware when in PK mode.
58+
* So the interrupt is disabled after leaving PK mode and enabled when entering.
59+
*/
60+
if (req->cmd != SX_PK_CMD_IK_EXIT) {
61+
nrf_cracen_int_enable(NRF_CRACEN, CRACEN_INTENCLR_PKEIKG_Msk);
62+
}
63+
#endif
5164
} else {
5265
sx_pk_wrreg(&req->regs, PK_REG_CONTROL,
5366
PK_RB_CONTROL_START_OP | PK_RB_CONTROL_CLEAR_IRQ);
@@ -75,11 +88,18 @@ int sx_pk_list_ik_inslots(sx_pk_req *req, unsigned int key, struct sx_pk_slot *i
7588
const struct sx_pk_capabilities *caps;
7689

7790
if (req->cmd->cmdcode == PK_OP_IK_EXIT) {
91+
#ifdef CONFIG_CRACEN_HW_VERSION_LITE
92+
/* Workaround to handle IKG freezing on CRACEN lite.
93+
* THE PKE-IKG interrupt can not be cleared from software, but can
94+
* be cleared by hardware when in PK mode.
95+
* so the interrupt is disabled after leaving PK mode and enabled when entering.
96+
*/
97+
nrf_cracen_int_disable(NRF_CRACEN, CRACEN_INTENCLR_PKEIKG_Msk);
98+
#endif
7899
req->ik_mode = 0;
79100
} else {
80101
if (!req->ik_mode) {
81102
int status = cracen_prepare_ik_key((uint8_t *)&key);
82-
83103
if (status != SX_OK) {
84104
sx_pk_release_req(req);
85105
return SX_ERR_INVALID_PARAM;

0 commit comments

Comments
 (0)