Skip to content

Commit ea01853

Browse files
Szynkaanordicjm
authored andcommitted
errata: update check of nrf54h errata 216 presence
Add call to nrf54h_errata_216 to verify chip revision before applying errata. Make most of the errata code visible outside of preprocessor if. Unify errata 216 function names with other errata functions. Jira: NCSDK-34672 Signed-off-by: Szymon Antkowiak <[email protected]>
1 parent 4632f30 commit ea01853

File tree

3 files changed

+112
-101
lines changed

3 files changed

+112
-101
lines changed

samples/bluetooth/direct_test_mode/src/dtm.c

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,9 @@
4242
#include <hal/nrf_power.h>
4343
#endif /* NRF54L_ERRATA_20_PRESENT */
4444

45-
#define NRF54H20_ERRATA_216_PRESENT \
46-
DT_NODE_HAS_STATUS(DT_NODELABEL(cpurad_cpusys_errata216_mboxes), okay)
47-
48-
#if NRF54H20_ERRATA_216_PRESENT
45+
#if NRF54H_ERRATA_216_PRESENT
4946
#include <zephyr/drivers/mbox.h>
50-
51-
/* Delay time from triggering the task "ON" for SysCtrl to starting RADIO (setting RADIO TASK RXEN
52-
* or TXEN)
53-
*/
54-
#define HMPAN_216_DELAY_US (40)
55-
#endif /* NRF54H20_ERRATA_216_PRESENT */
47+
#endif /* NRF54H_ERRATA_216_PRESENT */
5648

5749
#if defined(CONFIG_SOC_SERIES_NRF54HX)
5850
#define DEFAULT_TIMER_INSTANCE 020
@@ -455,12 +447,19 @@ static struct dtm_instance {
455447
#endif
456448
};
457449

458-
#if NRF54H20_ERRATA_216_PRESENT
450+
#if NRF54H_ERRATA_216_PRESENT
459451
static const struct mbox_dt_spec on_channel =
460452
MBOX_DT_SPEC_GET(DT_NODELABEL(cpurad_cpusys_errata216_mboxes), on_req);
461453
static const struct mbox_dt_spec off_channel =
462454
MBOX_DT_SPEC_GET(DT_NODELABEL(cpurad_cpusys_errata216_mboxes), off_req);
463-
static K_SEM_DEFINE(errata216_sem, 0, 1);
455+
#endif /* NRF54H_ERRATA_216_PRESENT */
456+
457+
/* Delay time from triggering the task "ON" for SysCtrl to starting RADIO (setting RADIO TASK RXEN
458+
* or TXEN)
459+
*/
460+
#define HMPAN_216_DELAY_US (40)
461+
462+
static K_SEM_DEFINE(errata_216_sem, 0, 1);
464463

465464
/**
466465
* @brief Send errata HMPAN-216 on request signal to SysCtrl
@@ -472,8 +471,12 @@ static K_SEM_DEFINE(errata216_sem, 0, 1);
472471
*
473472
* @return 0 if successful, otherwise a negative error code
474473
*/
475-
static int errata216_on_wait(void)
474+
static int errata_216_on_wait(void)
476475
{
476+
if (!nrf54h_errata_216()) {
477+
return 0;
478+
}
479+
477480
int err = 0;
478481

479482
nrfx_timer_disable(&dtm_inst.timer);
@@ -485,13 +488,15 @@ static int errata216_on_wait(void)
485488
nrfx_timer_us_to_ticks(&dtm_inst.timer, HMPAN_216_DELAY_US),
486489
true);
487490

491+
#if NRF54H_ERRATA_216_PRESENT
488492
err = mbox_send_dt(&on_channel, NULL);
493+
#endif /* NRF54H_ERRATA_216_PRESENT */
489494

490495
if (!err) {
491496
nrfx_timer_enable(&dtm_inst.timer);
492497

493498
/* Wait for the TIMER to count the required delay before starting the Radio*/
494-
err = k_sem_take(&errata216_sem, K_FOREVER);
499+
err = k_sem_take(&errata_216_sem, K_FOREVER);
495500
}
496501

497502
return err;
@@ -506,37 +511,33 @@ static int errata216_on_wait(void)
506511
*
507512
* @return 0 if successful, otherwise a negative error code
508513
*/
509-
static int errata216_off(void)
514+
static int errata_216_off(void)
510515
{
516+
if (!nrf54h_errata_216()) {
517+
return 0;
518+
}
519+
520+
#if NRF54H_ERRATA_216_PRESENT
511521
return mbox_send_dt(&off_channel, NULL);
522+
#else
523+
return 0;
524+
#endif /* NRF54H_ERRATA_216_PRESENT */
512525
}
513526

514527
/**
515528
* @brief Return to code execution after the required delay for errata HMPAN-216 has elapsed.
516529
*/
517-
static void errata216_release(void)
530+
static void errata_216_release(void)
518531
{
519-
/* Release the waiting semaphore, coninue code execution and disable TIMER */
520-
k_sem_give(&errata216_sem);
532+
if (!nrf54h_errata_216()) {
533+
return;
534+
}
535+
536+
/* Release the waiting semaphore, continue code execution and disable TIMER */
537+
k_sem_give(&errata_216_sem);
521538
nrfx_timer_disable(&dtm_inst.timer);
522539
nrf_timer_int_disable(dtm_inst.timer.p_reg, ~0);
523540
}
524-
#else
525-
static int errata216_on_wait(void)
526-
{
527-
return 0;
528-
}
529-
530-
static int errata216_off(void)
531-
{
532-
return 0;
533-
}
534-
535-
static void errata216_release(void)
536-
{
537-
/* Do nothing */
538-
}
539-
#endif /* NRF54H20_ERRATA_216_PRESENT */
540541

541542
/* The PRBS9 sequence used as packet payload.
542543
* The bytes in the sequence is in the right order, but the bits of each byte
@@ -1879,7 +1880,7 @@ static int dtm_vendor_specific_pkt(uint32_t vendor_cmd, uint32_t vendor_option)
18791880
case CARRIER_TEST:
18801881
case CARRIER_TEST_STUDIO:
18811882
/* Send the nRF54H20 errata 216 on signal */
1882-
if (errata216_on_wait()) {
1883+
if (errata_216_on_wait()) {
18831884
printk("Failed to send errata HMPAN-216 on signal\n");
18841885
}
18851886

@@ -2371,7 +2372,7 @@ int dtm_test_receive(uint8_t channel)
23712372
memset(&dtm_inst.pdu, 0, sizeof(dtm_inst.pdu));
23722373

23732374
/* Send the nRF54H20 errata 216 on signal */
2374-
if (errata216_on_wait()) {
2375+
if (errata_216_on_wait()) {
23752376
printk("Failed to send errata HMPAN-216 on signal\n");
23762377
}
23772378

@@ -2529,7 +2530,7 @@ int dtm_test_transmit(uint8_t channel, uint8_t length, enum dtm_packet pkt)
25292530
}
25302531

25312532
/* Send the nRF54H20 errata 216 on signal */
2532-
if (errata216_on_wait()) {
2533+
if (errata_216_on_wait()) {
25332534
printk("Failed to send errata HMPAN-216 on signal\n");
25342535
}
25352536

@@ -2582,7 +2583,7 @@ int dtm_test_end(uint16_t *pack_cnt)
25822583
dtm_test_done();
25832584

25842585
/* Send the nRF54H20 errata 216 off signal */
2585-
if (errata216_off()) {
2586+
if (errata_216_off()) {
25862587
printk("Failed to send errata HMPAN-216 off signal\n");
25872588
}
25882589

@@ -2698,7 +2699,7 @@ static void dtm_timer_handler(nrf_timer_event_t event_type, void *context)
26982699
* errata workaround for nRF54H20 SoCs
26992700
*/
27002701
if (event_type == NRF_TIMER_EVENT_COMPARE1) {
2701-
errata216_release();
2702+
errata_216_release();
27022703
} else {
27032704
/* Do nothing */
27042705
}

samples/peripheral/radio_test/src/radio_test.c

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,10 @@
2828
#include "fem_al/fem_al.h"
2929
#endif /* CONFIG_FEM */
3030

31-
#define NRF54H20_ERRATA_216_PRESENT \
32-
DT_NODE_HAS_STATUS(DT_NODELABEL(cpurad_cpusys_errata216_mboxes), okay)
33-
34-
#if NRF54H20_ERRATA_216_PRESENT
31+
#include <nrf_erratas.h>
32+
#if NRF54H_ERRATA_216_PRESENT
3533
#include <zephyr/drivers/mbox.h>
36-
37-
/* Delay time from triggering the task "ON" for SysCtrl to starting RADIO (setting RADIO TASK RXEN
38-
* or TXEN)
39-
*/
40-
#define HMPAN_216_DELAY_US (40)
41-
#endif /* NRF54H20_ERRATA_216_PRESENT */
34+
#endif /* NRF54H_ERRATA_216_PRESENT */
4235

4336
/* IEEE 802.15.4 default frequency. */
4437
#define IEEE_DEFAULT_FREQ (5)
@@ -131,12 +124,19 @@ static void (**rx_timeout_cb)(void);
131124
static volatile bool cancel_request;
132125
static volatile bool test_is_running;
133126

134-
#if NRF54H20_ERRATA_216_PRESENT
127+
#if NRF54H_ERRATA_216_PRESENT
135128
static const struct mbox_dt_spec on_channel =
136129
MBOX_DT_SPEC_GET(DT_NODELABEL(cpurad_cpusys_errata216_mboxes), on_req);
137130
static const struct mbox_dt_spec off_channel =
138131
MBOX_DT_SPEC_GET(DT_NODELABEL(cpurad_cpusys_errata216_mboxes), off_req);
139-
static K_SEM_DEFINE(errata216_sem, 0, 1);
132+
#endif /* NRF54H_ERRATA_216_PRESENT */
133+
134+
/* Delay time from triggering the task "ON" for SysCtrl to starting RADIO (setting RADIO TASK RXEN
135+
* or TXEN)
136+
*/
137+
#define HMPAN_216_DELAY_US (40)
138+
139+
static K_SEM_DEFINE(errata_216_sem, 0, 1);
140140

141141
/**
142142
* @brief Send errata HMPAN-216 on request signal to SysCtrl
@@ -146,8 +146,12 @@ static K_SEM_DEFINE(errata216_sem, 0, 1);
146146
*
147147
* @return 0 if successful, otherwise a negative error code
148148
*/
149-
static int errata216_on_wait(void)
149+
static int errata_216_on_wait(void)
150150
{
151+
if (!nrf54h_errata_216()) {
152+
return 0;
153+
}
154+
151155
int err = 0;
152156

153157
nrfx_timer_disable(&timer);
@@ -159,13 +163,15 @@ static int errata216_on_wait(void)
159163
nrfx_timer_us_to_ticks(&timer, HMPAN_216_DELAY_US),
160164
true);
161165

166+
#if NRF54H_ERRATA_216_PRESENT
162167
err = mbox_send_dt(&on_channel, NULL);
168+
#endif /* NRF54H_ERRATA_216_PRESENT */
163169

164170
if (!err) {
165171
nrfx_timer_enable(&timer);
166172

167173
/* Wait for the TIMER to count the required delay before starting the Radio*/
168-
err = k_sem_take(&errata216_sem, K_FOREVER);
174+
err = k_sem_take(&errata_216_sem, K_FOREVER);
169175
}
170176

171177
return err;
@@ -176,37 +182,33 @@ static int errata216_on_wait(void)
176182
*
177183
* @return 0 if successful, otherwise a negative error code
178184
*/
179-
static int errata216_off(void)
185+
static int errata_216_off(void)
180186
{
187+
if (!nrf54h_errata_216()) {
188+
return 0;
189+
}
190+
191+
#if NRF54H_ERRATA_216_PRESENT
181192
return mbox_send_dt(&off_channel, NULL);
193+
#else
194+
return 0;
195+
#endif /* NRF54H_ERRATA_216_PRESENT */
182196
}
183197

184198
/**
185199
* @brief Return to code execution after the required delay for errata HMPAN-216 has elapsed.
186200
*/
187-
static void errata216_release(void)
201+
static void errata_216_release(void)
188202
{
189-
/* Release the waiting semaphore, coninue code execution and disable TIMER */
190-
k_sem_give(&errata216_sem);
203+
if (!nrf54h_errata_216()) {
204+
return;
205+
}
206+
207+
/* Release the waiting semaphore, continue code execution and disable TIMER */
208+
k_sem_give(&errata_216_sem);
191209
nrfx_timer_disable(&timer);
192210
nrf_timer_int_disable(timer.p_reg, ~0);
193211
}
194-
#else
195-
static int errata216_on_wait(void)
196-
{
197-
return 0;
198-
}
199-
200-
static int errata216_off(void)
201-
{
202-
return 0;
203-
}
204-
205-
static void errata216_release(void)
206-
{
207-
/* Do nothing */
208-
}
209-
#endif /* NRF54H20_ERRATA_216_PRESENT */
210212

211213
#if CONFIG_FEM
212214
static struct radio_test_fem fem;
@@ -1053,7 +1055,7 @@ void radio_test_start(const struct radio_test_config *config)
10531055
#endif /* CONFIG_FEM */
10541056

10551057
/* Execute nRF54H20 errata 216 workaround */
1056-
if (errata216_on_wait()) {
1058+
if (errata_216_on_wait()) {
10571059
printk("Failed to send the nRF54H20 errata 216 on request to SysCtrl.\n");
10581060
}
10591061

@@ -1112,7 +1114,7 @@ static void cancel(void)
11121114
endpoints_clear();
11131115
radio_disable();
11141116

1115-
if (errata216_off()) {
1117+
if (errata_216_off()) {
11161118
printk("Failed to send errata HMPAN-216 off.\n");
11171119
}
11181120
}
@@ -1178,7 +1180,7 @@ static void rx_timeout_work_handler(struct k_work *work)
11781180
{
11791181
radio_disable();
11801182
/* Send off signal for nRF54H20 errata HMPAN-216 */
1181-
if (errata216_off()) {
1183+
if (errata_216_off()) {
11821184
printk("Failed to send errata HMPAN-216 off\n");
11831185
}
11841186
if (rx_timeout_cb != NULL && *rx_timeout_cb != NULL) {
@@ -1224,7 +1226,7 @@ static void timer_handler(nrf_timer_event_t event_type, void *context)
12241226
current_channel = channel_start;
12251227
}
12261228
} else if (event_type == NRF_TIMER_EVENT_COMPARE1) { /* HMPAN-216 errata */
1227-
errata216_release();
1229+
errata_216_release();
12281230
} else {
12291231
/* Do nothing */
12301232
}
@@ -1253,7 +1255,7 @@ void on_radio_end(const struct radio_test_config *config)
12531255
config->type == MODULATED_TX) {
12541256
radio_disable();
12551257
/* Send off signal for nRF54H20 errata HMPAN-216 */
1256-
if (errata216_off()) {
1258+
if (errata_216_off()) {
12571259
printk("Failed to send errata HMPAN-216 off\n");
12581260
}
12591261
config->params.modulated_tx.cb();

0 commit comments

Comments
 (0)