Re: Adding support for Nordic PDM Driver in Devicetree #nrf52832 #pdm #driver


Frederik David Damsgaard Popp
 
Edited

Hi Martí

Thank you for your detailed answer! This was a great help

First of all, I won't claim to be an audio expert, so this is purely based on what I have learned the past couple of weeks.
I'm not an audio expert, but are you sure the existing audio codec API
is not right?

As far as I could work out, the audio codec API is purely output, so that won't work for a microphone.
The other option was the dmic driver, which utilizes PDM hardware, but converts it into PCM for the Application, so that won't work either.

Strictly speaking, actual drivers -- as in drivers/subsystem/my_driver.c
files -- are enabled using Kconfig, not devicetree. So
CONFIG_MY_DRIVER=y in Kconfig means "enable my driver," which means
something like "compile my_driver.c."

I think I get it now. The dts must specify whether or not the PDM hardware is available on the given board, and if so, what pins etc.
The Kconfig are used to enable the driver to use for the application, and the CMakeLists includes the correct sources, based on whether the implementation should be either nrfx or some other implementation.

config MY_AUDIO_DRIVER
bool
default $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_PDM))
help
Enable my audio driver.

It looks like someone already prepared the setup for a PDM driver, since the SOC Kconfig defines a HAS_HW_NRF_PDM, which means I could depend on that?
I tried something like this:

config PDM_NRFX
bool "nRF PDM nrfx driver"
default y
depends on HAS_HW_NRF_PDM
        select NRFX_PDM
        help
           Enable support for nrfx Hardware PDM driver for nRF52 MCU series.

Totally based off of the PWM Kconfig, but it should work right?

 

It looks like there is already a dts/bindings/audio/nordic,nrf-pdm.yaml
file, though, so it doesn't seem like you need to define your own
binding. I didn't find any drivers for it in the upstream tree, though.

I took a look at the pwm_nrfx driver, which seems to act as a sort of wrapper for the nrfx_pwm driver in the Nordic HAL module.
I assume that I would have to do something similar, as there already is a pdm driver in the Nordic HAL module?
This way I would take an already implemented PDM driver for Nordic chipsets (such as the nRF52832 on the Nordic Thingy 52), and incorporate it into the Zephyr system.
The remaining thing to do, is then modify the devicetree for the Nordic devices that actually have PDM hardware, so that the driver can be used for these boards.

Again, I'm working this stuff out as I go, and this is the method I found so far, but I think it makes sense.
I would love to hear your (or anyone else with some knowledge on this) input, to make sure I'm on the right path.

Best
Frederik

Join devel@lists.zephyrproject.org to automatically receive all group messages.