Skip to content

Commit 570aede

Browse files
cvinayaknordicjm
authored andcommitted
[nrf fromtree] Bluetooth: Controller: nRF54Lx: Add Controller Privacy Support
Add Controller Privacy support for nRF54Lx by porting to use NRF_AAR00 h/w peripheral. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]> (cherry picked from commit 6d79d52118d2bdff67ab7f8216f1d2e6e88a3338) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent e2848c0 commit 570aede

File tree

5 files changed

+136
-3
lines changed

5 files changed

+136
-3
lines changed

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,48 @@ void radio_ccm_disable(void)
25622562
#endif /* CONFIG_BT_CTLR_LE_ENC || CONFIG_BT_CTLR_BROADCAST_ISO_ENC */
25632563

25642564
#if defined(CONFIG_BT_CTLR_PRIVACY)
2565+
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
2566+
struct aar_job_ptr {
2567+
void *ptr;
2568+
struct {
2569+
uint32_t length:24;
2570+
uint32_t attribute:8;
2571+
} __packed;
2572+
} __packed;
2573+
2574+
#define AAR_JOB_PTR_ATTRIBUTE_HASH 11U
2575+
#define AAR_JOB_PTR_ATTRIBUTE_PRAND 12U
2576+
#define AAR_JOB_PTR_ATTRIBUTE_IRK 13U
2577+
#define AAR_JOB_PTR_ATTRIBUTE_INDEX 11U
2578+
2579+
#define AAR_JOB_OUT_MAX_RESOLVED 1U
2580+
2581+
#define AAR_IRK_SIZE 16U
2582+
2583+
#define RADIO_PACKET_PTR_TO_PDU_OFFSET 3U
2584+
2585+
#define BDADDR_HASH_OFFSET 0U
2586+
#define BDADDR_HASH_SIZE 3U
2587+
#define BDADDR_PRND_OFFSET 3U
2588+
#define BDADDR_PRND_SIZE 3U
2589+
2590+
/* AAR HAL global memory referenced by the h/w peripheral and its DMA */
2591+
static struct {
2592+
/* Index of the IRK match in the AAR job list, on successful resolution */
2593+
uint32_t status;
2594+
2595+
/* Input AAR job list; list of Hash, Prand, IRKs and a terminating empty job entry */
2596+
struct aar_job_ptr in[CONFIG_BT_CTLR_RL_SIZE + 3];
2597+
2598+
/* Output AAR job list of one entry */
2599+
struct aar_job_ptr out[AAR_JOB_OUT_MAX_RESOLVED];
2600+
2601+
/* NOTE: Refer to the AAR section in the SoC product specification for details */
2602+
} aar_job;
2603+
2604+
#else /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
25652605
static uint8_t MALIGN(4) _aar_scratch[3];
2606+
#endif /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
25662607

25672608
void radio_ar_configure(uint32_t nirk, void *irk, uint8_t flags)
25682609
{
@@ -2599,10 +2640,57 @@ void radio_ar_configure(uint32_t nirk, void *irk, uint8_t flags)
25992640

26002641
NRF_AAR->ENABLE = (AAR_ENABLE_ENABLE_Enabled << AAR_ENABLE_ENABLE_Pos) &
26012642
AAR_ENABLE_ENABLE_Msk;
2643+
2644+
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
2645+
/* Input, Resolvable Address Hash offset in the legacy or extended advertising PDU.
2646+
* Radio packet pointer offset by 3 compared to legacy AAR in nRF51/52/53 SoCs that took
2647+
* Radio packet pointer value.
2648+
*/
2649+
aar_job.in[0].ptr = (uint8_t *)addrptr + RADIO_PACKET_PTR_TO_PDU_OFFSET +
2650+
BDADDR_HASH_OFFSET;
2651+
aar_job.in[0].length = BDADDR_HASH_SIZE;
2652+
aar_job.in[0].attribute = AAR_JOB_PTR_ATTRIBUTE_HASH;
2653+
2654+
/* Input, Resolvable Address Random offset in the legacy or extended advertising PDU.
2655+
* Radio packet pointer offset by 3 compared to legacy AAR in nRF51/52/53 SoCs that took
2656+
* Radio packet pointer, plus offset of the 24-bit random in the legacy or extended
2657+
* advertising PDU after the 24-bit Hash in the Resolvable Address.
2658+
*/
2659+
aar_job.in[1].ptr = (uint8_t *)addrptr + RADIO_PACKET_PTR_TO_PDU_OFFSET +
2660+
BDADDR_PRND_OFFSET;
2661+
aar_job.in[1].length = BDADDR_PRND_SIZE;
2662+
aar_job.in[1].attribute = AAR_JOB_PTR_ATTRIBUTE_PRAND;
2663+
2664+
/* Input, list of IRKs used for resolution */
2665+
for (uint32_t i = 0; i < nirk; i++) {
2666+
aar_job.in[2U + i].ptr = (void *)(((uint8_t *)irk) + (AAR_IRK_SIZE * i));
2667+
aar_job.in[2U + i].length = AAR_IRK_SIZE;
2668+
aar_job.in[2U + i].attribute = AAR_JOB_PTR_ATTRIBUTE_IRK;
2669+
}
2670+
2671+
/* A terminating empty job entry */
2672+
aar_job.in[2U + nirk].ptr = 0U;
2673+
aar_job.in[2U + nirk].length = 0U;
2674+
aar_job.in[2U + nirk].attribute = 0U;
2675+
2676+
/* Reset match index to invalid value ( >= CONFIG_BT_CTLR_RL_SIZE ) */
2677+
aar_job.status = UINT32_MAX;
2678+
2679+
/* Output, single job entry that populates the `status` value with match index */
2680+
aar_job.out[0].ptr = &aar_job.status;
2681+
aar_job.out[0].length = sizeof(aar_job.status);
2682+
aar_job.out[0].attribute = AAR_JOB_PTR_ATTRIBUTE_INDEX;
2683+
2684+
NRF_AAR->IN.PTR = (uint32_t)&aar_job.in[0];
2685+
NRF_AAR->OUT.PTR = (uint32_t)&aar_job.out[0];
2686+
NRF_AAR->MAXRESOLVED = AAR_JOB_OUT_MAX_RESOLVED;
2687+
2688+
#else /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
26022689
NRF_AAR->NIRK = nirk;
26032690
NRF_AAR->IRKPTR = (uint32_t)irk;
26042691
NRF_AAR->ADDRPTR = addrptr;
26052692
NRF_AAR->SCRATCHPTR = (uint32_t)&_aar_scratch[0];
2693+
#endif /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
26062694

26072695
nrf_aar_event_clear(NRF_AAR, NRF_AAR_EVENT_END);
26082696
nrf_aar_event_clear(NRF_AAR, NRF_AAR_EVENT_RESOLVED);
@@ -2617,7 +2705,11 @@ void radio_ar_configure(uint32_t nirk, void *irk, uint8_t flags)
26172705

26182706
uint32_t radio_ar_match_get(void)
26192707
{
2708+
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
2709+
return aar_job.status;
2710+
#else /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
26202711
return NRF_AAR->STATUS;
2712+
#endif /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
26212713
}
26222714

26232715
void radio_ar_status_reset(void)
@@ -2660,7 +2752,25 @@ uint8_t radio_ar_resolve(const uint8_t *addr)
26602752
NRF_AAR->ENABLE = (AAR_ENABLE_ENABLE_Enabled << AAR_ENABLE_ENABLE_Pos) &
26612753
AAR_ENABLE_ENABLE_Msk;
26622754

2755+
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
2756+
/* Input, Resolvable Address Hash offset in the supplied address buffer */
2757+
aar_job.in[0].ptr = (void *)&addr[BDADDR_HASH_OFFSET];
2758+
2759+
/* Input, Resolvable Address Prand offset in the supplied address buffer */
2760+
aar_job.in[1].ptr = (void *)&addr[BDADDR_PRND_OFFSET];
2761+
2762+
/* Reset match index to invalid value ( >= CONFIG_BT_CTLR_RL_SIZE ) */
2763+
aar_job.status = UINT32_MAX;
2764+
2765+
/* NOTE: Other `aar_job` structure members are initialized in `radio_ar_configure()` */
2766+
2767+
NRF_AAR->IN.PTR = (uint32_t)&aar_job.in[0];
2768+
NRF_AAR->OUT.PTR = (uint32_t)&aar_job.out[0];
2769+
NRF_AAR->MAXRESOLVED = AAR_JOB_OUT_MAX_RESOLVED;
2770+
2771+
#else /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
26632772
NRF_AAR->ADDRPTR = (uint32_t)addr - 3;
2773+
#endif /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
26642774

26652775
nrf_aar_event_clear(NRF_AAR, NRF_AAR_EVENT_END);
26662776
nrf_aar_event_clear(NRF_AAR, NRF_AAR_EVENT_RESOLVED);

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf54lx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@
398398
#define CCM_MODE_DATARATE_500Kbps CCM_MODE_DATARATE_500Kbit
399399
#define CCM_RATEOVERRIDE_RATEOVERRIDE_500Kbps CCM_RATEOVERRIDE_RATEOVERRIDE_500Kbit
400400

401+
/* HAL abstraction of AAR h/w */
402+
#define NRF_AAR NRF_AAR00
403+
401404
static inline void hal_radio_reset(void)
402405
{
403406
/* TODO: Add any required setup for each radio event

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ static inline void hal_trigger_aar_ppi_config(void)
226226
{
227227
nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_BCMATCH, HAL_TRIGGER_AAR_PPI);
228228
nrf_aar_subscribe_set(NRF_AAR, NRF_AAR_TASK_START, HAL_TRIGGER_AAR_PPI);
229+
230+
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
231+
/* Enable same DPPI in MCU domain */
232+
nrf_dppi_channels_enable(NRF_DPPIC00, BIT(HAL_TRIGGER_AAR_PPI));
233+
234+
/* Setup PPIB send subscribe */
235+
nrf_ppib_subscribe_set(NRF_PPIB10, HAL_PPIB_SEND_TRIGGER_AAR_PPI, HAL_TRIGGER_AAR_PPI);
236+
237+
/* Setup PPIB receive publish */
238+
nrf_ppib_publish_set(NRF_PPIB00, HAL_PPIB_RECEIVE_TRIGGER_AAR_PPI, HAL_TRIGGER_AAR_PPI);
239+
#endif /* CONFIG_SOC_COMPATIBLE_NRF54LX */
229240
}
230241
#endif /* CONFIG_BT_CTLR_PRIVACY */
231242

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_nrf5_dppi_resources.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,25 @@
6060
*/
6161
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
6262
#define HAL_TRIGGER_CRYPT_PPI 7
63-
#else /* CONFIG_SOC_COMPATIBLE_NRF54LX */
64-
#define HAL_TRIGGER_CRYPT_PPI HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI
65-
#endif /* CONFIG_SOC_COMPATIBLE_NRF54LX */
6663
#define HAL_PPIB_SEND_TRIGGER_CRYPT_PPI \
6764
_CONCAT(NRF_PPIB_TASK_SEND_, HAL_TRIGGER_CRYPT_PPI)
6865
#define HAL_PPIB_RECEIVE_TRIGGER_CRYPT_PPI \
6966
_CONCAT(NRF_PPIB_EVENT_RECEIVE_, HAL_TRIGGER_CRYPT_PPI)
67+
#else /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
68+
#define HAL_TRIGGER_CRYPT_PPI HAL_RADIO_RECV_TIMEOUT_CANCEL_PPI
69+
#endif /* !CONFIG_SOC_COMPATIBLE_NRF54LX */
7070

7171
/*******************************************************************************
7272
* Trigger automatic address resolution on Bit counter match:
7373
* wire the RADIO EVENTS_BCMATCH event to the AAR TASKS_START task.
7474
*/
7575
#define HAL_TRIGGER_AAR_PPI 6
76+
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
77+
#define HAL_PPIB_SEND_TRIGGER_AAR_PPI \
78+
_CONCAT(NRF_PPIB_TASK_SEND_, HAL_TRIGGER_AAR_PPI)
79+
#define HAL_PPIB_RECEIVE_TRIGGER_AAR_PPI \
80+
_CONCAT(NRF_PPIB_EVENT_RECEIVE_, HAL_TRIGGER_AAR_PPI)
81+
#endif /* CONFIG_SOC_COMPATIBLE_NRF54LX */
7682

7783
#if defined(CONFIG_BT_CTLR_PHY_CODED) && \
7884
defined(CONFIG_HAS_HW_NRF_RADIO_BLE_CODED)

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_sim_nrf54l.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@
392392
#define CCM_MODE_DATARATE_500Kbps CCM_MODE_DATARATE_500Kbit
393393
#define CCM_RATEOVERRIDE_RATEOVERRIDE_500Kbps CCM_RATEOVERRIDE_RATEOVERRIDE_500Kbit
394394

395+
/* HAL abstraction of AAR h/w */
396+
#define NRF_AAR NRF_AAR00
397+
395398
static inline void hal_radio_reset(void)
396399
{
397400
/* TODO: Add any required setup for each radio event

0 commit comments

Comments
 (0)