diff --git a/boards/arm/lpcxpresso55s36/doc/index.rst b/boards/arm/lpcxpresso55s36/doc/index.rst index d25bf7776c3..e35e285ff6c 100644 --- a/boards/arm/lpcxpresso55s36/doc/index.rst +++ b/boards/arm/lpcxpresso55s36/doc/index.rst @@ -81,6 +81,8 @@ already supported, which can also be re-used on this lpcxpresso55s36 board: +-----------+------------+-------------------------------------+ | USB FS | on-chip | USB Full Speed device | +-----------+------------+-------------------------------------+ +| DAC | on-chip | dac | ++-----------+------------+-------------------------------------+ Other hardware features are not currently enabled. diff --git a/boards/arm/lpcxpresso55s36/lpcxpresso55s36-pinctrl.dtsi b/boards/arm/lpcxpresso55s36/lpcxpresso55s36-pinctrl.dtsi index 2d68da1d13f..8ca6f659f2e 100644 --- a/boards/arm/lpcxpresso55s36/lpcxpresso55s36-pinctrl.dtsi +++ b/boards/arm/lpcxpresso55s36/lpcxpresso55s36-pinctrl.dtsi @@ -2,7 +2,7 @@ * NOTE: File generated by lpc_cfg_utils.py * from LPC55S36.mex * - * Copyright 2022 NXP + * Copyright 2022-2023 NXP * SPDX-License-Identifier: Apache-2.0 */ @@ -119,4 +119,12 @@ slew-rate = "standard"; }; }; + + pinmux_dac0: pinmux_dac0 { + group0 { + pinmux = ; + slew-rate = "standard"; + nxp,analog-mode; + }; + }; }; diff --git a/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts b/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts index 98713617fdb..df4fbbdc99b 100644 --- a/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts +++ b/boards/arm/lpcxpresso55s36/lpcxpresso55s36.dts @@ -175,3 +175,9 @@ zephyr_udc0: &usbfs { &dma0 { status = "okay"; }; + +&dac0 { + status = "okay"; + pinctrl-0 = <&pinmux_dac0>; + pinctrl-names = "default"; +}; diff --git a/boards/arm/lpcxpresso55s36/lpcxpresso55s36.yaml b/boards/arm/lpcxpresso55s36/lpcxpresso55s36.yaml index 823e4d3aeab..499536b1e80 100644 --- a/boards/arm/lpcxpresso55s36/lpcxpresso55s36.yaml +++ b/boards/arm/lpcxpresso55s36/lpcxpresso55s36.yaml @@ -18,3 +18,4 @@ supported: - can - gpio - pwm + - dac diff --git a/dts/arm/nxp/nxp_lpc55S3x_common.dtsi b/dts/arm/nxp/nxp_lpc55S3x_common.dtsi index 51243bcb88e..2d834ff6b80 100644 --- a/dts/arm/nxp/nxp_lpc55S3x_common.dtsi +++ b/dts/arm/nxp/nxp_lpc55S3x_common.dtsi @@ -294,6 +294,33 @@ dma-names = "adc0-dma0", "adc0-dma1"; }; + dac0: dac@b2000 { + compatible = "nxp,lpdac"; + reg = < 0xb2000 0x1000>; + interrupts = <74 0>; + status = "disabled"; + voltage-reference = <0>; + #io-channel-cells = <1>; + }; + + dac1: dac@b6000 { + compatible = "nxp,lpdac"; + reg = < 0xb6000 0x1000>; + interrupts = <75 0>; + status = "disabled"; + voltage-reference = <0>; + #io-channel-cells = <1>; + }; + + dac2: dac@b9000 { + compatible = "nxp,lpdac"; + reg = < 0xb9000 0x1000>; + interrupts = <76 0>; + status = "disabled"; + voltage-reference = <0>; + #io-channel-cells = <1>; + }; + can0: can@4009d000 { compatible = "nxp,lpc-mcan"; reg = <0x4009d000 0x1000>; diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.c b/soc/arm/nxp_lpc/lpc55xxx/soc.c index cd3995764c6..8f756b39c3d 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.c @@ -31,7 +31,8 @@ #include "usb_phy.h" #include "usb.h" #endif -#if defined(CONFIG_SOC_LPC55S36) && defined(CONFIG_ADC_MCUX_LPADC) +#if defined(CONFIG_SOC_LPC55S36) && (defined(CONFIG_ADC_MCUX_LPADC) \ + || defined(CONFIG_DAC_MCUX_LPDAC)) #include #endif @@ -322,8 +323,26 @@ 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); +#else + 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))); -#if defined(CONFIG_ADC_MCUX_LPADC) + /* Power up the ADC */ + POWER_DisablePD(kPDRUNCFG_PD_LDOGPADC); +#endif +#endif +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(dac0), nxp_lpdac, okay) +#if defined(CONFIG_SOC_LPC55S36) + CLOCK_SetClkDiv(kCLOCK_DivDac0Clk, 1U, true); + CLOCK_AttachClk(kMAIN_CLK_to_DAC0); + + /* Disable DAC0 power down */ + POWER_DisablePD(kPDRUNCFG_PD_DAC0); +#endif +#endif +#if defined(CONFIG_SOC_LPC55S36) +#if (defined(CONFIG_ADC_MCUX_LPADC) || defined(CONFIG_DAC_MCUX_LPDAC)) /* Vref is required for LPADC reference */ POWER_DisablePD(kPDRUNCFG_PD_VREF); @@ -335,14 +354,6 @@ DT_FOREACH_STATUS_OKAY(nxp_lpc_ctimer, CTIMER_CLOCK_SETUP) vrefConfig.enableVrefOut = true; VREF_Init((VREF_Type *)VREF_BASE, &vrefConfig); #endif -#else - 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 }