From 1bf7c391b89be76893defcc48dcfa5ea020ac720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Thu, 19 Aug 2021 17:11:46 +0200 Subject: [PATCH] drivers: audio: dmic: Add support for nRF PDM peripherals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a shim that allows using the nrfx PDM driver via the Zephyr API. Add also missing devicetree nodes representing the PDM peripherals in the nRF52 Series SoCs. Extend the "nordic,nrf-pdm" binding with a new property that allows specifying the clock source to be used by the PDM peripheral (so that it is possible to use HFXO for better accuracy of the peripheral clock or, in the nRF53 Series SoCs, to use the dedicated audio oscillator). Signed-off-by: Andrzej Głąbek --- CODEOWNERS | 1 + drivers/audio/CMakeLists.txt | 1 + drivers/audio/Kconfig | 1 + drivers/audio/Kconfig.dmic_pdm_nrfx | 13 + drivers/audio/dmic_nrfx_pdm.c | 575 +++++++++++++++++++++++++ dts/arm/nordic/nrf52810.dtsi | 8 + dts/arm/nordic/nrf52811.dtsi | 8 + dts/arm/nordic/nrf52832.dtsi | 8 + dts/arm/nordic/nrf52833.dtsi | 8 + dts/arm/nordic/nrf52840.dtsi | 8 + dts/bindings/audio/nordic,nrf-pdm.yaml | 27 ++ 11 files changed, 658 insertions(+) create mode 100644 drivers/audio/Kconfig.dmic_pdm_nrfx create mode 100644 drivers/audio/dmic_nrfx_pdm.c diff --git a/CODEOWNERS b/CODEOWNERS index 6745bbbd0b2..f006d318417 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -190,6 +190,7 @@ /drivers/*/*andes* @cwshu @Teng-Shih-Wei /drivers/adc/ @anangl /drivers/adc/adc_stm32.c @cybertale +/drivers/audio/*nrfx* @anangl /drivers/bbram/* @yperess @sjg20 @jackrosenthal /drivers/bluetooth/ @joerchan @jhedberg @Vudentz /drivers/cache/ @carlocaione diff --git a/drivers/audio/CMakeLists.txt b/drivers/audio/CMakeLists.txt index ce2c51a6e00..aa313668003 100644 --- a/drivers/audio/CMakeLists.txt +++ b/drivers/audio/CMakeLists.txt @@ -15,3 +15,4 @@ zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_int32_ zephyr_library_sources_ifdef(CONFIG_AUDIO_INTEL_DMIC decimation/pdm_decim_table.c) zephyr_library_sources_ifdef(CONFIG_AUDIO_MPXXDTYY mpxxdtyy.c) zephyr_library_sources_ifdef(CONFIG_AUDIO_MPXXDTYY mpxxdtyy-i2s.c) +zephyr_library_sources_ifdef(CONFIG_AUDIO_DMIC_NRFX_PDM dmic_nrfx_pdm.c) diff --git a/drivers/audio/Kconfig b/drivers/audio/Kconfig index ea749a58e47..a5664549691 100644 --- a/drivers/audio/Kconfig +++ b/drivers/audio/Kconfig @@ -52,6 +52,7 @@ source "subsys/logging/Kconfig.template.log_config" source "drivers/audio/Kconfig.intel_dmic" source "drivers/audio/Kconfig.mpxxdtyy" +source "drivers/audio/Kconfig.dmic_pdm_nrfx" endif # AUDIO_DMIC diff --git a/drivers/audio/Kconfig.dmic_pdm_nrfx b/drivers/audio/Kconfig.dmic_pdm_nrfx new file mode 100644 index 00000000000..c91fc69f545 --- /dev/null +++ b/drivers/audio/Kconfig.dmic_pdm_nrfx @@ -0,0 +1,13 @@ +# Copyright (c) 2021 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +# Workaround for not being able to have commas in macro arguments +DT_COMPAT_NORDIC_NRF_PDM := nordic,nrf-pdm + +config AUDIO_DMIC_NRFX_PDM + bool "nRF PDM nrfx driver" + depends on $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_PDM)) + default y + select NRFX_PDM + help + Enable support for nrfx PDM driver for nRF MCU series. diff --git a/drivers/audio/dmic_nrfx_pdm.c b/drivers/audio/dmic_nrfx_pdm.c new file mode 100644 index 00000000000..c4597976e13 --- /dev/null +++ b/drivers/audio/dmic_nrfx_pdm.c @@ -0,0 +1,575 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include