Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions drivers/counter/counter_nrfx_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,17 @@ static int ppi_setup(const struct device *dev, uint8_t chan)

nrfy_rtc_event_enable(rtc, NRF_RTC_CHANNEL_INT_MASK(chan));
#ifdef DPPI_PRESENT
result = nrfx_dppi_channel_alloc(&data->ppi_ch);
nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to add a comment that instance 0 is used here because COUNTER_RTC_WITH_PPI_WRAP is currently only supported for nRF51/52/53/91 Series.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to add this in a follow up commit.


result = nrfx_dppi_channel_alloc(&dppi, &data->ppi_ch);
if (result != NRFX_SUCCESS) {
ERR("Failed to allocate PPI channel.");
return -ENODEV;
}

nrfy_rtc_subscribe_set(rtc, NRF_RTC_TASK_CLEAR, data->ppi_ch);
nrfy_rtc_publish_set(rtc, evt, data->ppi_ch);
(void)nrfx_dppi_channel_enable(data->ppi_ch);
(void)nrfx_dppi_channel_enable(&dppi, data->ppi_ch);
#else /* DPPI_PRESENT */
uint32_t evt_addr;
uint32_t task_addr;
Expand Down Expand Up @@ -429,11 +431,12 @@ static void ppi_free(const struct device *dev, uint8_t chan)
nrfy_rtc_event_disable(rtc, NRF_RTC_CHANNEL_INT_MASK(chan));
#ifdef DPPI_PRESENT
nrf_rtc_event_t evt = NRF_RTC_CHANNEL_EVENT_ADDR(chan);
nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);

(void)nrfx_dppi_channel_disable(ppi_ch);
(void)nrfx_dppi_channel_disable(&dppi, ppi_ch);
nrfy_rtc_subscribe_clear(rtc, NRF_RTC_TASK_CLEAR);
nrfy_rtc_publish_clear(rtc, evt);
(void)nrfx_dppi_channel_free(ppi_ch);
(void)nrfx_dppi_channel_free(&dppi, ppi_ch);
#else /* DPPI_PRESENT */
(void)nrfx_ppi_channel_disable(ppi_ch);
(void)nrfx_ppi_channel_free(ppi_ch);
Expand Down
73 changes: 71 additions & 2 deletions modules/hal_nordic/nrfx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,77 @@ config NRFX_COMP
depends on $(dt_has_compat,$(DT_COMPAT_NORDIC_NRF_COMP))

config NRFX_DPPI
bool "DPPI allocator"
depends on $(dt_has_compat,$(DT_COMPAT_NORDIC_NRF_DPPIC))
bool

config NRFX_DPPI0
bool "DPPI0 driver instance"
depends on $(dt_nodelabel_has_compat,dppic,$(DT_COMPAT_NORDIC_NRF_DPPIC))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for consistency it would be good to use ddpic0 here and add such node label to nodes labeled as dppic, like it is done for wdt0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reluctant to changing labels of nodes that existed for years, as it might break compatibility somewhere for no good reason really.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can extend the existing nodelabel like this:

dppic0: dppic: dppic {
        ...
};

in devicetree and update NRFX_DPPI0
to

depends on ($(dt_nodelabel_has_compat,dppic,$(DT_COMPAT_NORDIC_NRF_DPPIC)) || \
            $(dt_nodelabel_has_compat,dppic0,$(DT_COMPAT_NORDIC_NRF_DPPIC)))

to keep backward compatibility

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't suggested changing a label but adding another one: dppic: dppic0: dppic@....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address this in a follow up commit then. I want to avoid adding more changes here, as it will block further activities related to nrfx v3.9.

select NRFX_DPPI

config NRFX_DPPI00
bool "DPPI00 driver instance"
depends on $(dt_nodelabel_has_compat,dppic00,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI10
bool "DPPI10 driver instance"
depends on $(dt_nodelabel_has_compat,dppic10,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI20
bool "DPPI20 driver instance"
depends on $(dt_nodelabel_has_compat,dppic20,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI30
bool "DPPI30 driver instance"
depends on $(dt_nodelabel_has_compat,dppic30,$(DT_COMPAT_NORDIC_NRF_DPPIC))
select NRFX_DPPI

config NRFX_DPPI020
bool "DPPI020 driver instance"
depends on $(dt_nodelabel_has_compat,dppic020,$(DT_COMPAT_NORDIC_NRF_DPPIC_LOCAL))
select NRFX_DPPI

config NRFX_DPPI120
bool "DPPI120 driver instance"
depends on $(dt_nodelabel_has_compat,dppic120,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_DPPI130
bool "DPPI130 driver instance"
depends on $(dt_nodelabel_has_compat,dppic130,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_DPPI131
bool "DPPI131 driver instance"
depends on $(dt_nodelabel_has_compat,dppic131,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_DPPI132
bool "DPPI132 driver instance"
depends on $(dt_nodelabel_has_compat,dppic132,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_DPPI133
bool "DPPI133 driver instance"
depends on $(dt_nodelabel_has_compat,dppic133,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_DPPI134
bool "DPPI134 driver instance"
depends on $(dt_nodelabel_has_compat,dppic134,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_DPPI135
bool "DPPI135 driver instance"
depends on $(dt_nodelabel_has_compat,dppic135,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_DPPI136
bool "DPPI136 driver instance"
depends on $(dt_nodelabel_has_compat,dppic136,$(DT_COMPAT_NORDIC_NRF_DPPIC_GLOBAL))
select NRFX_DPPI

config NRFX_EGU
bool
Expand Down
42 changes: 42 additions & 0 deletions modules/hal_nordic/nrfx/nrfx_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,48 @@
#ifdef CONFIG_NRFX_DPPI_LOG
#define NRFX_DPPI_CONFIG_LOG_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI0
#define NRFX_DPPI0_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI00
#define NRFX_DPPI00_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI10
#define NRFX_DPPI10_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI20
#define NRFX_DPPI20_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI30
#define NRFX_DPPI30_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI020
#define NRFX_DPPI020_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI120
#define NRFX_DPPI120_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI130
#define NRFX_DPPI130_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI131
#define NRFX_DPPI131_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI132
#define NRFX_DPPI132_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI133
#define NRFX_DPPI133_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI134
#define NRFX_DPPI134_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI135
#define NRFX_DPPI135_ENABLED 1
#endif
#ifdef CONFIG_NRFX_DPPI136
#define NRFX_DPPI136_ENABLED 1
#endif

#ifdef CONFIG_NRFX_EGU
#define NRFX_EGU_ENABLED 1
Expand Down
2 changes: 1 addition & 1 deletion modules/hal_nordic/nrfx/nrfx_config_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/** @brief Symbol specifying minor version of the nrfx API to be used. */
#ifndef NRFX_CONFIG_API_VER_MINOR
#define NRFX_CONFIG_API_VER_MINOR 7
#define NRFX_CONFIG_API_VER_MINOR 8
#endif

/** @brief Symbol specifying micro version of the nrfx API to be used. */
Expand Down
8 changes: 5 additions & 3 deletions soc/nordic/nrf53/sync_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ static void ppi_rtc_to_ipc(union rtc_sync_channels channels, bool setup)
/* Free DPPI and RTC channels */
static void free_resources(union rtc_sync_channels channels)
{
nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define this as static const at the top of the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach was suggested here: nrfconnect/sdk-nrf#18073 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get how that justification given in the above comment applies to this case, but my point is that static const would cause that this structure ends up in flash, so this would give some savings on its initialization that now needs to be performed at runtime and twice in this file. But it's just a detail. I'm not going to insist on changing this.

nrfx_err_t err;

nrfx_gppi_channels_disable(BIT(channels.ch.ppi));

z_nrf_rtc_timer_chan_free(channels.ch.rtc);

err = nrfx_dppi_channel_free(channels.ch.ppi);
err = nrfx_dppi_channel_free(&dppi, channels.ch.ppi);
__ASSERT_NO_MSG(err == NRFX_SUCCESS);
}

Expand Down Expand Up @@ -224,20 +225,21 @@ static int mbox_rx_init(void *user_data)
/* Setup RTC synchronization. */
static int sync_rtc_setup(void)
{
nrfx_dppi_t dppi = NRFX_DPPI_INSTANCE(0);
nrfx_err_t err;
union rtc_sync_channels channels;
int32_t sync_rtc_ch;
int rv;

err = nrfx_dppi_channel_alloc(&channels.ch.ppi);
err = nrfx_dppi_channel_alloc(&dppi, &channels.ch.ppi);
if (err != NRFX_SUCCESS) {
rv = -ENODEV;
goto bail;
}

sync_rtc_ch = z_nrf_rtc_timer_chan_alloc();
if (sync_rtc_ch < 0) {
nrfx_dppi_channel_free(channels.ch.ppi);
nrfx_dppi_channel_free(&dppi, channels.ch.ppi);
rv = sync_rtc_ch;
goto bail;
}
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ manifest:
groups:
- hal
- name: hal_nordic
revision: 5c8d109371ebb740fbef1f440a3b59e488a36717
revision: 2dbb2ed6cf461062bbac59a65b6e9d4576656350
path: modules/hal/nordic
groups:
- hal
Expand Down