"Frederik David Damsgaard Popp via lists.zephyrproject.org"
Thank you for your detailed answer! This was a great help
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.
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."
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.
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?
Enable my audio driver.
I tried something like this:
bool "nRF PDM nrfx driver"
depends on HAS_HW_NRF_PDM
Enable support for nrfx Hardware PDM driver for nRF52 MCU series.
Totally based off of the PWM Kconfig, but it should work right?
Those HAS_HW_NRF_* options are slated for removal at some point:https://github.com/zephyrproject-rtos/zephyr/issues/8481
It would be better not to add more uses of them, especially if this work
is going upstream.
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.
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 assume that I would have to do something similar, as there already
is a pdm driver in the Nordic HAL module?
That is the "shim driver" approach, yes. It's a perfectly valid way of
doing things in Zephyr.
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, and making it hardware agnostic.
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.
At least the nRF5340 and nRF9160 SoC DTSI files have pdm nodes defined.
If you need to add them for other SoCs, the existing definitions may be
a good starting point.