From 8526af4ff6d3ed7a296d10857e926940944153d2 Mon Sep 17 00:00:00 2001 From: Declan Snyder Date: Wed, 12 Apr 2023 15:19:44 +0000 Subject: [PATCH] soc: lpc55s3x: Enable VREF Add node for VREF0 peripheral to LPC55S3X SOC DT Clock VREF peripheral if status = okay in DT Enable VREF on lpcxpresso55s36 Signed-off-by: Declan Snyder --- .../arm/lpcxpresso55s36/lpcxpresso55s36.dts | 4 +++ dts/arm/nxp/nxp_lpc55S3x_common.dtsi | 9 +++++++ soc/arm/nxp_lpc/lpc55xxx/soc.c | 27 +++++++------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts b/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts index 7ac40ff15f3a67b..189a9d9bcd0d878 100644 --- a/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts +++ b/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts @@ -168,3 +168,7 @@ zephyr_udc0: &usbfs { pinctrl-0 = <&pinmux_usbfs>; pinctrl-names = "default"; }; + +&vref0 { + status = "okay"; +}; diff --git a/dts/arm/nxp/nxp_lpc55S3x_common.dtsi b/dts/arm/nxp/nxp_lpc55S3x_common.dtsi index 29ac36e81335e2f..d6bed2f89b81926 100644 --- a/dts/arm/nxp/nxp_lpc55S3x_common.dtsi +++ b/dts/arm/nxp/nxp_lpc55S3x_common.dtsi @@ -389,6 +389,15 @@ prescaler = <2>; #pwm-cells = <3>; }; + + vref0: vref@b5000 { + compatible = "nxp,vref"; + regulator-name = "lpc55s36-vref"; + reg = <0xb5000 0x30>; + status = "disabled"; + nxp,buffer-startup-delay-us = <400>; + nxp,bandgap-startup-time-us = <20>; + }; }; &nvic { diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.c b/soc/arm/nxp_lpc/lpc55xxx/soc.c index 45c51d18424a19a..48ce9904f429b13 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.c @@ -1,5 +1,4 @@ -/* - * Copyright 2017, 2019-2023 NXP +/* Copyright 2017, 2019-2023 NXP * * SPDX-License-Identifier: Apache-2.0 */ @@ -261,28 +260,20 @@ DT_FOREACH_STATUS_OKAY(nxp_lpc_ctimer, CTIMER_CLOCK_SETUP) #if defined(CONFIG_SOC_LPC55S36) CLOCK_SetClkDiv(kCLOCK_DivAdc0Clk, 2U, true); CLOCK_AttachClk(kFRO_HF_to_ADC0); - -#if defined(CONFIG_ADC_MCUX_LPADC) - /* Vref is required for LPADC reference */ - POWER_DisablePD(kPDRUNCFG_PD_VREF); - - vref_config_t vrefConfig; - - VREF_GetDefaultConfig(&vrefConfig); - vrefConfig.bufferMode = kVREF_ModeHighPowerBuffer; - vrefConfig.enableInternalVoltageRegulator = true; - vrefConfig.enableVrefOut = true; - VREF_Init((VREF_Type *)VREF_BASE, &vrefConfig); -#endif -#else +#else /* not LPC55s36 */ CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, DT_PROP(DT_NODELABEL(adc0), clk_divider), true); CLOCK_AttachClk(MUX_A(CM_ADCASYNCCLKSEL, DT_PROP(DT_NODELABEL(adc0), clk_source))); /* Power up the ADC */ POWER_DisablePD(kPDRUNCFG_PD_LDOGPADC); -#endif -#endif +#endif /* platform specific code */ +#endif /* DT has adc0 */ + +#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(vref0), nxp_vref, okay)) + CLOCK_EnableClock(kCLOCK_Vref); + POWER_DisablePD(kPDRUNCFG_PD_VREF); +#endif /* vref0 */ } /**