soc: nordic: nrf52: add support for DT-based regulators config

In addition to Kconfig options (soon to be deprecated), allow
configuring the regulators using DT.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2024-06-20 10:16:36 +02:00 committed by Fabio Baltieri
commit e189fb0720

View file

@ -12,6 +12,8 @@
* for the Nordic Semiconductor nRF52 family processor.
*/
#include <zephyr/devicetree.h>
#include <zephyr/dt-bindings/regulator/nrf5x.h>
#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <hal/nrf_power.h>
@ -30,10 +32,12 @@ static int nordicsemi_nrf52_init(void)
NRF_NVMC->ICACHECNF = NVMC_ICACHECNF_CACHEEN_Msk;
#endif
#if defined(CONFIG_SOC_DCDC_NRF52X)
#if defined(CONFIG_SOC_DCDC_NRF52X) || \
(DT_PROP(DT_INST(0, nordic_nrf5x_regulator), regulator_initial_mode) == NRF_REG_MODE_DCDC)
nrf_power_dcdcen_set(NRF_POWER, true);
#endif
#if NRF_POWER_HAS_DCDCEN_VDDH && defined(CONFIG_SOC_DCDC_NRF52X_HV)
#if NRF_POWER_HAS_DCDCEN_VDDH && (defined(CONFIG_SOC_DCDC_NRF52X_HV) || \
DT_NODE_HAS_STATUS(DT_INST(0, nordic_nrf52x_regulator_hv), okay))
nrf_power_dcdcen_vddh_set(NRF_POWER, true);
#endif