2222#include <zephyr/kernel.h>
2323#include <zephyr/sys/byteorder.h>
2424#include <zephyr/drivers/gpio.h>
25- #if NRF54H_ERRATA_216_PRESENT
26- #include <zephyr/drivers/mbox.h>
27- #endif /* NRF54H_ERRATA_216_PRESENT */
2825
2926#include <mpsl_fem_protocol_api.h>
3027
3128#include "esb_peripherals.h"
3229#include "esb_ppi_api.h"
30+ #include "esb_workarounds.h"
3331
3432LOG_MODULE_REGISTER (esb , CONFIG_ESB_LOG_LEVEL );
3533
@@ -266,13 +264,6 @@ enum {
266264static atomic_t errata_216_status = ATOMIC_INIT (ERRATA_216_DISABLED );
267265static uint32_t errata_216_timer_shorts ;
268266
269- #if NRF54H_ERRATA_216_PRESENT
270- static const struct mbox_dt_spec on_channel =
271- MBOX_DT_SPEC_GET (DT_NODELABEL (cpurad_cpusys_errata216_mboxes ), on_req );
272- static const struct mbox_dt_spec off_channel =
273- MBOX_DT_SPEC_GET (DT_NODELABEL (cpurad_cpusys_errata216_mboxes ), off_req );
274- #endif /* NRF54H_ERRATA_216_PRESENT */
275-
276267static esb_event_handler event_handler ;
277268static struct esb_payload * current_payload ;
278269
@@ -378,39 +369,14 @@ static inline void apply_errata143_workaround(void)
378369 * use a unique address 0 since this will avoid the 3dBm penalty
379370 * incurred from the workaround.
380371 */
381- uint32_t base_address_mask =
382- esb_addr .addr_length == 5 ? 0xFFFF0000 : 0xFF000000 ;
383372
384- /* Load the two addresses before comparing them to ensure
385- * defined ordering of volatile accesses.
386- */
387- uint32_t addr0 = nrf_radio_base0_get (NRF_RADIO ) & base_address_mask ;
388- uint32_t addr1 = nrf_radio_base1_get (NRF_RADIO ) & base_address_mask ;
389-
390- if (addr0 == addr1 ) {
391- uint32_t radio_prefix0 = nrf_radio_prefix0_get (NRF_RADIO );
392- uint32_t radio_prefix1 = nrf_radio_prefix1_get (NRF_RADIO );
393-
394- uint8_t prefix0 = radio_prefix0 & RADIO_PREFIX0_AP0_Msk ;
395- uint8_t prefix1 = (radio_prefix0 & RADIO_PREFIX0_AP1_Msk ) >> RADIO_PREFIX0_AP1_Pos ;
396- uint8_t prefix2 = (radio_prefix0 & RADIO_PREFIX0_AP2_Msk ) >> RADIO_PREFIX0_AP2_Pos ;
397- uint8_t prefix3 = (radio_prefix0 & RADIO_PREFIX0_AP3_Msk ) >> RADIO_PREFIX0_AP3_Pos ;
398- uint8_t prefix4 = radio_prefix1 & RADIO_PREFIX1_AP4_Msk ;
399- uint8_t prefix5 = (radio_prefix1 & RADIO_PREFIX1_AP5_Msk ) >> RADIO_PREFIX1_AP5_Pos ;
400- uint8_t prefix6 = (radio_prefix1 & RADIO_PREFIX1_AP6_Msk ) >> RADIO_PREFIX1_AP6_Pos ;
401- uint8_t prefix7 = (radio_prefix1 & RADIO_PREFIX1_AP7_Msk ) >> RADIO_PREFIX1_AP7_Pos ;
402-
403- if ((prefix0 == prefix1 ) || (prefix0 == prefix2 ) ||
404- (prefix0 == prefix3 ) || (prefix0 == prefix4 ) ||
405- (prefix0 == prefix5 ) || (prefix0 == prefix6 ) ||
406- (prefix0 == prefix7 )) {
407- /* This will cause a 3dBm sensitivity loss,
408- * avoid using such address combinations if possible.
409- */
410- * (volatile uint32_t * )0x40001774 =
411- ((* (volatile uint32_t * )0x40001774 ) & 0xfffffffe ) | 0x01000000 ;
412- }
373+ if (!nrf52_errata_143 ()) {
374+ return ;
413375 }
376+
377+ uint32_t base_address_mask =
378+ esb_addr .addr_length == 5 ? 0xFFFF0000 : 0xFF000000 ;
379+ esb_apply_nrf52_143 (base_address_mask );
414380}
415381
416382static void errata_216_on (void )
@@ -419,15 +385,11 @@ static void errata_216_on(void)
419385 return ;
420386 }
421387
422- #if NRF54H_ERRATA_216_PRESENT
423- if (mbox_send_dt (& on_channel , NULL ) != 0 ) {
424- LOG_ERR ("Failed to enable Errata 216" );
425- /* Should not happen. */
426- __ASSERT_NO_MSG (false);
427- } else {
428- atomic_set (& errata_216_status , ERRATA_216_ENABLED );
429- }
430- #endif /* NRF54H_ERRATA_216_PRESENT */
388+ esb_apply_nrf54h_216 (true);
389+
390+ #if NRF54H_ERRATA_216_ENABLE_WORKAROUND
391+ atomic_set (& errata_216_status , ERRATA_216_ENABLED );
392+ #endif /* NRF54H_ERRATA_216_ENABLE_WORKAROUND */
431393}
432394
433395static void errata_216_off (void )
@@ -436,86 +398,25 @@ static void errata_216_off(void)
436398 return ;
437399 }
438400
439- #if NRF54H_ERRATA_216_PRESENT
440- if (mbox_send_dt (& off_channel , NULL ) != 0 ) {
441- LOG_ERR ("Failed to disable Errata 216" );
442- /* Should not happen. */
443- __ASSERT_NO_MSG (false);
444- } else {
445- atomic_set (& errata_216_status , ERRATA_216_DISABLED );
446- }
447- #endif /* NRF54H_ERRATA_216_PRESENT */
401+ esb_apply_nrf54h_216 (false);
402+
403+ #if NRF54H_ERRATA_216_ENABLE_WORKAROUND
404+ atomic_set (& errata_216_status , ERRATA_216_DISABLED );
405+ #endif /* NRF54H_ERRATA_216_ENABLE_WORKAROUND */
448406}
449407
450408static void apply_radio_init_workarounds (void )
451409{
452410 if (nrf52_errata_182 ()) {
453- /* Check if the device is an nRF52832 Rev. 2. */
454- /* Workaround for nRF52832 rev 2 errata 182 */
455- * (volatile uint32_t * )0x4000173C |= (1 << 10 );
456- }
457-
458- #if defined(CONFIG_SOC_SERIES_NRF54HX )
459- /* Apply HMPAN-102 workaround for nRF54H series */
460- * (volatile uint32_t * )0x5302C7E4 =
461- (((* ((volatile uint32_t * )0x5302C7E4 )) & 0xFF000FFF ) | 0x0012C000 );
462-
463- /* Apply HMPAN-18 workaround for nRF54H series - load trim values*/
464- if (* (volatile uint32_t * )0x0FFFE458 != TRIM_VALUE_EMPTY ) {
465- * (volatile uint32_t * )0x5302C734 = * (volatile uint32_t * )0x0FFFE458 ;
466- }
467-
468- if (* (volatile uint32_t * )0x0FFFE45C != TRIM_VALUE_EMPTY ) {
469- * (volatile uint32_t * )0x5302C738 = * (volatile uint32_t * )0x0FFFE45C ;
470- }
471-
472- if (* (volatile uint32_t * )0x0FFFE460 != TRIM_VALUE_EMPTY ) {
473- * (volatile uint32_t * )0x5302C73C = * (volatile uint32_t * )0x0FFFE460 ;
474- }
475-
476- if (* (volatile uint32_t * )0x0FFFE464 != TRIM_VALUE_EMPTY ) {
477- * (volatile uint32_t * )0x5302C740 = * (volatile uint32_t * )0x0FFFE464 ;
478- }
479-
480- if (* (volatile uint32_t * )0x0FFFE468 != TRIM_VALUE_EMPTY ) {
481- * (volatile uint32_t * )0x5302C74C = * (volatile uint32_t * )0x0FFFE468 ;
482- }
483-
484- /* HMPAN-229 provides hardcoded value if the trim value is 0 */
485- if ((* (volatile uint32_t * )0x0FFFE46C != TRIM_VALUE_EMPTY ) &&
486- (* (volatile uint32_t * )0x0FFFE46C != 0 )) {
487- * (volatile uint32_t * )0x5302C7D8 = * (volatile uint32_t * )0x0FFFE46C ;
488- } else {
489- * (volatile uint32_t * )0x5302C7D8 = 0x00000004 ;
490- }
491-
492- if (* (volatile uint32_t * )0x0FFFE470 != TRIM_VALUE_EMPTY ) {
493- * (volatile uint32_t * )0x5302C840 = * (volatile uint32_t * )0x0FFFE470 ;
494- }
495-
496- if (* (volatile uint32_t * )0x0FFFE474 != TRIM_VALUE_EMPTY ) {
497- * (volatile uint32_t * )0x5302C844 = * (volatile uint32_t * )0x0FFFE474 ;
498- }
499-
500- if (* (volatile uint32_t * )0x0FFFE478 != TRIM_VALUE_EMPTY ) {
501- * (volatile uint32_t * )0x5302C848 = * (volatile uint32_t * )0x0FFFE478 ;
502- }
503-
504- if (* (volatile uint32_t * )0x0FFFE47C != TRIM_VALUE_EMPTY ) {
505- * (volatile uint32_t * )0x5302C84C = * (volatile uint32_t * )0x0FFFE47C ;
411+ esb_apply_nrf52_182 ();
506412 }
507413
508- /* Apply HMPAN-103 workaround for nRF54H series*/
509- if ((* (volatile uint32_t * )0x5302C8A0 == 0x80000000 ) ||
510- (* (volatile uint32_t * )0x5302C8A0 == 0x0058120E )) {
511- * (volatile uint32_t * )0x5302C8A0 = 0x0058090E ;
414+ if (nrf54h_errata_103 ()) {
415+ esb_apply_nrf54h_103 ();
512416 }
513417
514- * (volatile uint32_t * )0x5302C8A4 = 0x00F8AA5F ;
515- * (volatile uint32_t * )0x5302C7AC = 0x8672827A ;
516- * (volatile uint32_t * )0x5302C7B0 = 0x7E768672 ;
517- * (volatile uint32_t * )0x5302C7B4 = 0x0406007E ;
518- #endif /* (CONFIG_SOC_SERIES_NRF54HX) */
418+ /* Currently there is no check for this workaround */
419+ esb_apply_nrf54h_229 ();
519420}
520421
521422static void esb_fem_for_tx_set (bool ack )
0 commit comments