-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: adc: nrfx_saadc: Add support for DMM #90751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
drivers: adc: nrfx_saadc: Add support for DMM #90751
Conversation
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
a622b40
to
faa7caf
Compare
faa7caf
to
43b7d0b
Compare
43b7d0b
to
6a5a5c3
Compare
8732416
to
d519bd8
Compare
d2e83b2
to
76b5fc3
Compare
76b5fc3
to
9cb6a97
Compare
drivers/adc/adc_nrfx_saadc.c
Outdated
(void **)&m_data.samples_buffer); | ||
if (error != 0) { | ||
LOG_ERR("DMM buffer allocation failed err=%d", error); | ||
dmm_buffer_in_release( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to call in_release
if allocation with in_prepare
failed.
in_release
to be called only after successful in_prepare
and input buffer filled by peripheral DMA, indicated by hardware event
drivers/adc/adc_nrfx_saadc.c
Outdated
(void **)&m_data.samples_buffer); | ||
if (error != 0) { | ||
LOG_ERR("DMM buffer allocation failed err=%d", error); | ||
dmm_buffer_in_release(m_data.mem_reg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed - as explained in comment above
drivers/adc/adc_nrfx_saadc.c
Outdated
if (has_single_ended(&m_data.ctx.sequence)) { | ||
correct_single_ended(&m_data.ctx.sequence); | ||
correct_single_ended(&m_data.ctx.sequence, event->data.done.p_buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct_single_ended
should be called on m_data.user_buffer
after dma_buffer_in_release
call.
User shall not access buffer contents before dmm_buffer_in_release
to make sure data cache is correctly handled. Otherwise there is a risk of modifying cached contents and losing them during dmm_buffer_in_release
uint8_t active_channel_cnt; | ||
|
||
#if defined(ADC_BUFFER_IN_RAM) | ||
void *mem_reg; | ||
void *samples_buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think holding this pointer in static control block is redundant. This pointer can be obtained as local variable in adc_context_update_buffer_pointer
and start_read
. Then this pointer is provided to nrfx via nrfx_saadc_buffer_set
which provides it back in IRQ context via event->data.done.p_buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment about potential removal of samples_buffer
is still valid: https://github.com/zephyrproject-rtos/zephyr/pull/90751/files#r2161217660
Add support for DMM which manages cache and dedicated memory spaces. Signed-off-by: Jakub Zymelka <[email protected]>
9cb6a97
to
7740772
Compare
|
if (has_single_ended(&m_data.ctx.sequence)) { | ||
correct_single_ended(&m_data.ctx.sequence); | ||
correct_single_ended(&m_data.ctx.sequence, m_data.user_buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buffer managed by dmm
cannot be accessed before dmm_buffer_in_release
- should be moved after dmm_buffer_in_release
uint8_t active_channel_cnt; | ||
|
||
#if defined(ADC_BUFFER_IN_RAM) | ||
void *mem_reg; | ||
void *samples_buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment about potential removal of samples_buffer
is still valid: https://github.com/zephyrproject-rtos/zephyr/pull/90751/files#r2161217660
}; | ||
|
||
static struct driver_data m_data = { | ||
ADC_CONTEXT_INIT_TIMER(m_data, ctx), | ||
ADC_CONTEXT_INIT_LOCK(m_data, ctx), | ||
ADC_CONTEXT_INIT_SYNC(m_data, ctx), | ||
#if defined(ADC_BUFFER_IN_RAM) | ||
.samples_buffer = adc_samples_buffer, | ||
#if defined(CONFIG_HAS_NORDIC_DMM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this conditional is redundant - DMM_DEV_TO_REG
will return NULL
if there is no memory-region
prop present
LOG_ERR("DMM buffer allocation failed err=%d", error); | ||
adc_context_complete(ctx, -EIO); | ||
} | ||
#if !defined(CONFIG_HAS_NORDIC_DMM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is spurious and will cause missing buffer update on H20 in case of sequence composed of several samplings
Add support for DMM which manages cache and dedicated memory spaces.
Based on #89469, only the last commit is in scope of this PR.