From 101f4413c26140d7e81f7948124b4b45a974ed00 Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Thu, 24 Jul 2025 11:01:36 -0400 Subject: [PATCH 1/9] include: zephyr: dt-bindings: clock: silabs: fix clock branch Updated CLOCK_BRANCH bindings to stay in sync with the enum sl_clock_branch_t in the Silicon Labs HAL. Signed-off-by: Bastien Beauchamp --- .../dt-bindings/clock/silabs/common-clock.h | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/include/zephyr/dt-bindings/clock/silabs/common-clock.h b/include/zephyr/dt-bindings/clock/silabs/common-clock.h index 1b5aa5d7a63f7..865d2ebf6fc93 100644 --- a/include/zephyr/dt-bindings/clock/silabs/common-clock.h +++ b/include/zephyr/dt-bindings/clock/silabs/common-clock.h @@ -34,19 +34,20 @@ #define CLOCK_BRANCH_SYSRTCCLK 19 #define CLOCK_BRANCH_EUART0CLK 20 #define CLOCK_BRANCH_EUSART0CLK 21 -#define CLOCK_BRANCH_DPLLREFCLK 22 -#define CLOCK_BRANCH_I2C0CLK 23 -#define CLOCK_BRANCH_LCDCLK 24 -#define CLOCK_BRANCH_PIXELRZCLK 25 -#define CLOCK_BRANCH_PCNT0CLK 26 -#define CLOCK_BRANCH_PRORTCCLK 27 -#define CLOCK_BRANCH_SYSTICKCLK 28 -#define CLOCK_BRANCH_LESENSEHFCLK 29 -#define CLOCK_BRANCH_VDAC0CLK 30 -#define CLOCK_BRANCH_VDAC1CLK 31 -#define CLOCK_BRANCH_USB0CLK 32 -#define CLOCK_BRANCH_FLPLLREFCLK 33 -#define CLOCK_BRANCH_INVALID 34 +#define CLOCK_BRANCH_EUSART1CLK 22 +#define CLOCK_BRANCH_DPLLREFCLK 23 +#define CLOCK_BRANCH_I2C0CLK 24 +#define CLOCK_BRANCH_LCDCLK 25 +#define CLOCK_BRANCH_PIXELRZCLK 26 +#define CLOCK_BRANCH_PCNT0CLK 27 +#define CLOCK_BRANCH_PRORTCCLK 28 +#define CLOCK_BRANCH_SYSTICKCLK 29 +#define CLOCK_BRANCH_LESENSEHFCLK 30 +#define CLOCK_BRANCH_VDAC0CLK 31 +#define CLOCK_BRANCH_VDAC1CLK 32 +#define CLOCK_BRANCH_USB0CLK 33 +#define CLOCK_BRANCH_FLPLLREFCLK 34 +#define CLOCK_BRANCH_INVALID 35 #define CLOCK_BIT_MASK 0x03FUL #define CLOCK_REG_MASK 0x1C0UL From 4e07caf63a62704a76367cdb34eb340d06141abb Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Thu, 24 Jul 2025 11:06:01 -0400 Subject: [PATCH 2/9] modules: hal_silabs: enable VDAC module in series 2 hal This enables Silabs Series 2 HAL source files for the Silabs VDAC module to be compiled when the SOC_SILABS_ACMP configuration is selected. Signed-off-by: Bastien Beauchamp --- modules/hal_silabs/simplicity_sdk/CMakeLists.txt | 1 + modules/hal_silabs/simplicity_sdk/Kconfig | 3 +++ 2 files changed, 4 insertions(+) diff --git a/modules/hal_silabs/simplicity_sdk/CMakeLists.txt b/modules/hal_silabs/simplicity_sdk/CMakeLists.txt index f65f6e3720d48..ea7cfb1646d4f 100644 --- a/modules/hal_silabs/simplicity_sdk/CMakeLists.txt +++ b/modules/hal_silabs/simplicity_sdk/CMakeLists.txt @@ -278,6 +278,7 @@ endif() zephyr_library_sources_ifdef(CONFIG_SILABS_SISDK_LETIMER ${PERIPHERAL_DIR}/src/sl_hal_letimer.c) zephyr_library_sources_ifdef(CONFIG_SILABS_SISDK_TIMER ${PERIPHERAL_DIR}/src/sl_hal_timer.c) +zephyr_library_sources_ifdef(CONFIG_SILABS_SISDK_VDAC ${PERIPHERAL_DIR}/src/sl_hal_vdac.c) zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_LDMA ${EMDRV_DIR}/dmadrv/src/dmadrv.c) diff --git a/modules/hal_silabs/simplicity_sdk/Kconfig b/modules/hal_silabs/simplicity_sdk/Kconfig index cb670e77fdf25..7b762fbcf78b4 100644 --- a/modules/hal_silabs/simplicity_sdk/Kconfig +++ b/modules/hal_silabs/simplicity_sdk/Kconfig @@ -10,6 +10,9 @@ config SILABS_SISDK_LETIMER config SILABS_SISDK_TIMER bool "Peripheral HAL for TIMER" +config SILABS_SISDK_VDAC + bool "Peripheral HAL for VDAC" + config RAIL_PA_CURVE_HEADER string "RAIL PA custom curve header file" default "pa_curves_efr32.h" From 57013171ff8da1365dd38a601a7ef23f2649a42c Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Fri, 25 Jul 2025 10:38:44 -0400 Subject: [PATCH 3/9] include: zephyr: dt-bindings: dac: silabs: generate VDAC Generates bindings that define VDAC auxiliary output. These bindings can be used in devicetree sources to configure the aux-output property. Signed-off-by: Bastien Beauchamp --- include/zephyr/dt-bindings/dac/silabs-vdac.h | 79 ++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 include/zephyr/dt-bindings/dac/silabs-vdac.h diff --git a/include/zephyr/dt-bindings/dac/silabs-vdac.h b/include/zephyr/dt-bindings/dac/silabs-vdac.h new file mode 100644 index 0000000000000..d6bc1c920c631 --- /dev/null +++ b/include/zephyr/dt-bindings/dac/silabs-vdac.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 Silicon Laboratories Inc. + * + * SPDX-License-Identifier: Apache-2.0 + * + * This file was generated by the script gen_vdac.py in the hal_silabs module. + * Do not manually edit. + */ + +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_DAC_SILABS_VDAC_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_DAC_SILABS_VDAC_H_ + +#define VDAC_OUTPUT_AUX 0x0 +#define VDAC_OUTPUT_PA0 0x10 +#define VDAC_OUTPUT_PA1 0x11 +#define VDAC_OUTPUT_PA2 0x12 +#define VDAC_OUTPUT_PA3 0x13 +#define VDAC_OUTPUT_PA4 0x14 +#define VDAC_OUTPUT_PA5 0x15 +#define VDAC_OUTPUT_PA6 0x16 +#define VDAC_OUTPUT_PA7 0x17 +#define VDAC_OUTPUT_PA8 0x18 +#define VDAC_OUTPUT_PA9 0x19 +#define VDAC_OUTPUT_PA10 0x1a +#define VDAC_OUTPUT_PA11 0x1b +#define VDAC_OUTPUT_PA12 0x1c +#define VDAC_OUTPUT_PA13 0x1d +#define VDAC_OUTPUT_PA14 0x1e +#define VDAC_OUTPUT_PA15 0x1f +#define VDAC_OUTPUT_PB0 0x20 +#define VDAC_OUTPUT_PB1 0x21 +#define VDAC_OUTPUT_PB2 0x22 +#define VDAC_OUTPUT_PB3 0x23 +#define VDAC_OUTPUT_PB4 0x24 +#define VDAC_OUTPUT_PB5 0x25 +#define VDAC_OUTPUT_PB6 0x26 +#define VDAC_OUTPUT_PB7 0x27 +#define VDAC_OUTPUT_PB8 0x28 +#define VDAC_OUTPUT_PB9 0x29 +#define VDAC_OUTPUT_PB10 0x2a +#define VDAC_OUTPUT_PB11 0x2b +#define VDAC_OUTPUT_PB12 0x2c +#define VDAC_OUTPUT_PB13 0x2d +#define VDAC_OUTPUT_PB14 0x2e +#define VDAC_OUTPUT_PB15 0x2f +#define VDAC_OUTPUT_PC0 0x30 +#define VDAC_OUTPUT_PC1 0x31 +#define VDAC_OUTPUT_PC2 0x32 +#define VDAC_OUTPUT_PC3 0x33 +#define VDAC_OUTPUT_PC4 0x34 +#define VDAC_OUTPUT_PC5 0x35 +#define VDAC_OUTPUT_PC6 0x36 +#define VDAC_OUTPUT_PC7 0x37 +#define VDAC_OUTPUT_PC8 0x38 +#define VDAC_OUTPUT_PC9 0x39 +#define VDAC_OUTPUT_PC10 0x3a +#define VDAC_OUTPUT_PC11 0x3b +#define VDAC_OUTPUT_PC12 0x3c +#define VDAC_OUTPUT_PC13 0x3d +#define VDAC_OUTPUT_PC14 0x3e +#define VDAC_OUTPUT_PC15 0x3f +#define VDAC_OUTPUT_PD0 0x40 +#define VDAC_OUTPUT_PD1 0x41 +#define VDAC_OUTPUT_PD2 0x42 +#define VDAC_OUTPUT_PD3 0x43 +#define VDAC_OUTPUT_PD4 0x44 +#define VDAC_OUTPUT_PD5 0x45 +#define VDAC_OUTPUT_PD6 0x46 +#define VDAC_OUTPUT_PD7 0x47 +#define VDAC_OUTPUT_PD8 0x48 +#define VDAC_OUTPUT_PD9 0x49 +#define VDAC_OUTPUT_PD10 0x4a +#define VDAC_OUTPUT_PD11 0x4b +#define VDAC_OUTPUT_PD12 0x4c +#define VDAC_OUTPUT_PD13 0x4d +#define VDAC_OUTPUT_PD14 0x4e +#define VDAC_OUTPUT_PD15 0x4f + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_DAC_SILABS_VDAC_H_ */ From 0cf12abcfb0d25bc0cee475c38070a8e459dd0d7 Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Thu, 24 Jul 2025 11:09:39 -0400 Subject: [PATCH 4/9] dts: bindings: dac: define silabs,vdac bindings Defines bindings that are compatible with Silabs VDAC. Reference your part's design book when configuring values for the properties. Signed-off-by: Bastien Beauchamp --- dts/bindings/dac/silabs,vdac.yaml | 174 ++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 dts/bindings/dac/silabs,vdac.yaml diff --git a/dts/bindings/dac/silabs,vdac.yaml b/dts/bindings/dac/silabs,vdac.yaml new file mode 100644 index 0000000000000..3cb334f2f6dfc --- /dev/null +++ b/dts/bindings/dac/silabs,vdac.yaml @@ -0,0 +1,174 @@ +# Copyright (c) 2025 Silicon Laboratories Inc. +# SPDX-License-Identifier: Apache-2.0 +title: | + Silicon Labs Series 2 VDAC (Voltage Digital-to-Analog Converter) + +description: | + The VDAC has two channels, a resolution of 12-bit and a configurable output + range from 0V to 2.5V. + + The minimal default configuration for the Silabs VDAC node is as follows: + + #include + + &vdac0 { + status = "okay"; + voltage-reference = "2.5V"; + channel@0 { + reg = <0>; + main-output; + }; + }; + + Using the main output is the preferred way for any DAC output. Defines like + `VDAC0_CH0_MAIN_OUT_PIN` exists in em_device.h to get the dedicated pin for + your device. + + It is also possible to use the auxiliary output to route the output to other + peripherals like the IADC or the ACMP, or to the analog bus to output on any GPIO. + Note that the analog bus multiplexer adds significant impedance, and this option + may not be suitable for certain loads or dynamic conditions. + + To connect the analog bus to a GPIO, the `pinctrl` driver must be configured to + allocate an analog bus corresponding to the port and pin of each GPIO input selected. + The following is an example of how that can be configured: + + #include + #include + + &pinctrl { + vdac0_default: vdac0_default { + group0 { + silabs,analog-bus = ; + }; + group1 { + silabs,analog-bus = ; + }; + }; + + &vdac0 { + pinctrl-0 = <&vdac0_default>; + pinctrl-names = "default"; + status = "okay"; + voltage-reference = "1.25V"; + channel@0 { + reg = <0>; + aux-output = ; + }; + channel@1 { + reg = <1>; + aux-output = ; + }; + }; + + In the above example, note that the device specific bindings for pinctrl + were included. This header defines the set of analog bus allocations possible + for xg24 parts, and similar headers exist for other parts. + +compatible: "silabs,vdac" + +include: + - dac-controller.yaml + - pinctrl-device.yaml + +properties: + voltage-reference: + description: | + Reference voltage to use. + The default corresponds to the reset value of the register field. + type: string + enum: + - "1.25V" + - "2.5V" + - "AVDD" + - "VREFP" + default: "1.25V" + + warmup-cycles: + description: | + Number of prescaled CLK_VDAC + 1 for the DAC to warmup. + This determines how many clock cycles are needed for the DAC to stabilize + before it can be used for conversions. + The default corresponds to the reset value of the register field. + type: int + default: 0 + + refresh-period-cycles: + description: | + Channel refresh period configuration. + Determines how often the DAC channels are refreshed to maintain accuracy. + The default corresponds to the reset value of the register field. + type: int + enum: [2, 4, 8, 16, 32, 64, 128, 256] + default: 2 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + "#io-channel-cells": + const: 1 + +io-channel-cells: + - output + +child-binding: + description: | + Channel configuration. + + properties: + reg: + description: | + Channel identifier. + type: int + enum: [0, 1] + required: true + + main-output: + description: | + Connects the channel to the dedicated output pin. + type: boolean + + aux-output: + description: | + Connects the low-power channel to the auxiliary outputs. + Connects the channel to the specified output pin on the analog bus. + type: int + + short-output: + description: | + Short-circuits the main and auxiliary outputs. + Set to use high-power mode with auxiliary outputs. + type: boolean + + low-power-mode: + description: | + Sets the power mode of the main output to low instead of high. + type: boolean + + high-capacitance-load: + description: | + Enables high-capacitance load mode for the DAC channel. + Only usable without low-power-mode. + type: boolean + + sample-off-mode: + description: | + Enables sample-off mode for the DAC channel. + If enabled, the output is only driven for a limited time per conversion. + type: boolean + + output-hold-cycles: + description: | + Time in DAC clock cycles that the output is held for the DAC channel. + Only usable with sample-off-mode. + The default corresponds to the reset value of the register field. + type: int + default: 0 + + refresh-timer: + description: | + Enables the refresh timer. + type: boolean From 2c577cb766e798bbd37b245157cfb46085ff189b Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Thu, 24 Jul 2025 11:16:33 -0400 Subject: [PATCH 5/9] drivers: dac: implement the silabs_vdac compatible driver This implements the DAC driver for silabs VDAC peripherals using the silabs,vdac compatible binding. Signed-off-by: Bastien Beauchamp --- drivers/dac/CMakeLists.txt | 1 + drivers/dac/Kconfig | 2 + drivers/dac/Kconfig.silabs | 12 +++ drivers/dac/dac_silabs_vdac.c | 160 ++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 drivers/dac/Kconfig.silabs create mode 100644 drivers/dac/dac_silabs_vdac.c diff --git a/drivers/dac/CMakeLists.txt b/drivers/dac/CMakeLists.txt index 4e69815f4eca4..50a2545f7b36e 100644 --- a/drivers/dac/CMakeLists.txt +++ b/drivers/dac/CMakeLists.txt @@ -30,3 +30,4 @@ zephyr_library_sources_ifdef(CONFIG_DAC_MCUX_GAU dac_mcux_gau.c) zephyr_library_sources_ifdef(CONFIG_DAC_TEST dac_test.c) zephyr_library_sources_ifdef(CONFIG_DAC_MAX22017 dac_max22017.c) zephyr_library_sources_ifdef(CONFIG_DAC_RENESAS_RA dac_renesas_ra.c) +zephyr_library_sources_ifdef(CONFIG_DAC_SILABS_VDAC dac_silabs_vdac.c) diff --git a/drivers/dac/Kconfig b/drivers/dac/Kconfig index 8305189987135..68e4e651867ef 100644 --- a/drivers/dac/Kconfig +++ b/drivers/dac/Kconfig @@ -69,4 +69,6 @@ source "drivers/dac/Kconfig.renesas_ra" source "drivers/dac/Kconfig.samd5x" +source "drivers/dac/Kconfig.silabs" + endif # DAC diff --git a/drivers/dac/Kconfig.silabs b/drivers/dac/Kconfig.silabs new file mode 100644 index 0000000000000..93a5d177a1f34 --- /dev/null +++ b/drivers/dac/Kconfig.silabs @@ -0,0 +1,12 @@ +# Copyright (c) 2025 Silicon Laboratories Inc. +# SPDX-License-Identifier: Apache-2.0 + +config DAC_SILABS_VDAC + bool "Silabs DAC driver for VDAC" + default y + depends on DT_HAS_SILABS_VDAC_ENABLED + select PINCTRL + select SILABS_SISDK_VDAC + help + Enable the Digital-to-Analog Converter driver for the + VDAC hardware block present on Silicon Labs devices. diff --git a/drivers/dac/dac_silabs_vdac.c b/drivers/dac/dac_silabs_vdac.c new file mode 100644 index 0000000000000..9452cc8f579cb --- /dev/null +++ b/drivers/dac/dac_silabs_vdac.c @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2025 Silicon Laboratories Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +LOG_MODULE_REGISTER(silabs_vdac, CONFIG_DAC_LOG_LEVEL); + +#define DT_DRV_COMPAT silabs_vdac + +#define NUM_CHANNELS 2 +#define MAX_FREQUENCY 1000000 + +/* Read-only driver configuration */ +struct vdac_config { + VDAC_TypeDef *base; + const struct pinctrl_dev_config *pincfg; + const struct device *clock_dev; + const struct silabs_clock_control_cmu_config clock_cfg; + sl_hal_vdac_init_t init; + sl_hal_vdac_init_channel_t channel_init[NUM_CHANNELS]; +}; + +static int vdac_init(const struct device *dev) +{ + const struct vdac_config *config = dev->config; + sl_hal_vdac_init_t init = config->init; + uint32_t freq; + int err; + + /* Configure pinctrl */ + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err < 0 && err != -ENOENT) { + LOG_ERR("failed to allocate silabs,analog-bus via pinctrl"); + return err; + } + + /* Enable VDAC Clock */ + err = clock_control_on(config->clock_dev, + (clock_control_subsys_t)&config->clock_cfg); + if (err < 0) { + LOG_ERR("failed to enable clocks via clock_control"); + return err; + } + + /* Calculate clock prescaler */ + err = clock_control_get_rate(config->clock_dev, + (clock_control_subsys_t)&config->clock_cfg, &freq); + if (err < 0) { + LOG_ERR("failed to get clock rate via clock_control"); + return err; + } + init.prescaler = sl_hal_vdac_calculate_prescaler(config->base, MAX_FREQUENCY, freq); + + /* Initialize VDAC */ + sl_hal_vdac_init(config->base, &init); + + return 0; +} + +static int vdac_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg) +{ + const struct vdac_config *config = dev->config; + + if (channel_cfg->channel_id >= NUM_CHANNELS) { + LOG_ERR("unsupported channel %d", channel_cfg->channel_id); + return -ENOTSUP; + } + + if (channel_cfg->resolution != VDAC_RESOLUTION(VDAC_NUM(config->base))) { + LOG_ERR("unsupported resolution %d", channel_cfg->resolution); + return -ENOTSUP; + } + + if (channel_cfg->internal) { + LOG_ERR("internal channels not supported"); + return -ENOTSUP; + } + + /* Configure channel */ + sl_hal_vdac_init_channel(config->base, + &config->channel_init[channel_cfg->channel_id], + channel_cfg->channel_id); + + /* Start channel */ + sl_hal_vdac_enable_channel(config->base, channel_cfg->channel_id); + + return 0; +} + +static int vdac_write_value(const struct device *dev, uint8_t channel, uint32_t value) +{ + const struct vdac_config *config = dev->config; + + if (channel >= NUM_CHANNELS) { + LOG_ERR("unsupported channel %d", channel); + return -ENOTSUP; + } + + if (value >= (1 << VDAC_RESOLUTION(VDAC_NUM(config->base)))) { + LOG_ERR("value %d out of range", value); + return -ENOTSUP; + } + + /* Write value to VDAC channel */ + sl_hal_vdac_set_output_channel(config->base, channel, value); + + return 0; +} + +static DEVICE_API(dac, vdac_api) = { + .channel_setup = vdac_channel_setup, + .write_value = vdac_write_value, +}; + +#define VDAC_CHANNEL(node) \ + .channel_init[DT_REG_ADDR(node)] = { \ + .main_out_enable = DT_PROP(node, main_output), \ + .aux_out_enable = DT_NODE_HAS_PROP(node, aux_output), \ + .short_output = DT_PROP(node, short_output), \ + .power_mode = DT_PROP(node, low_power_mode), \ + .high_cap_load_enable = DT_PROP(node, high_capacitance_load), \ + .port = DT_PROP_OR(node, aux_output, 0) >> 4, \ + .pin = DT_PROP_OR(node, aux_output, 0) & 0xF, \ + .sample_off_mode = DT_PROP(node, sample_off_mode), \ + .hold_out_time = DT_PROP(node, output_hold_cycles), \ + .ch_refresh_source = DT_PROP(node, refresh_timer), \ + .trigger_mode = SL_HAL_VDAC_TRIGGER_MODE_SW, \ + }, + +#define VDAC_DEVICE(inst) \ + \ + PINCTRL_DT_INST_DEFINE(inst); \ + \ + static const struct vdac_config vdac_config_##inst = { \ + .base = (VDAC_TypeDef *)DT_INST_REG_ADDR(inst), \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \ + .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(inst)), \ + .clock_cfg = SILABS_DT_INST_CLOCK_CFG(inst), \ + .init = SL_HAL_VDAC_INIT_DEFAULT, \ + .init.reference = DT_INST_ENUM_IDX(inst, voltage_reference), \ + .init.warmup_time = DT_INST_PROP(inst, warmup_cycles), \ + .init.refresh = DT_INST_ENUM_IDX(inst, refresh_period_cycles), \ + DT_INST_FOREACH_CHILD(inst, VDAC_CHANNEL) \ + }; \ + \ + DEVICE_DT_INST_DEFINE(inst, &vdac_init, PM_DEVICE_DT_INST_GET(inst), \ + NULL, &vdac_config_##inst, POST_KERNEL, \ + CONFIG_DAC_INIT_PRIORITY, &vdac_api); + +DT_INST_FOREACH_STATUS_OKAY(VDAC_DEVICE) From ca5845d47085583332e2418bbf6f63d793b74c0f Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Thu, 24 Jul 2025 11:15:05 -0400 Subject: [PATCH 6/9] dts: arm: silabs: instantiate VDAC nodes for xg2x parts Defines a VDAC node for xg23 and xg24 parts, which are all compatible with the silabs,vdac binding. Signed-off-by: Bastien Beauchamp --- dts/arm/silabs/xg23/xg23.dtsi | 18 ++++++++++++++++++ dts/arm/silabs/xg24/xg24.dtsi | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/dts/arm/silabs/xg23/xg23.dtsi b/dts/arm/silabs/xg23/xg23.dtsi index 64a47f020f8f1..e5a938ad05265 100644 --- a/dts/arm/silabs/xg23/xg23.dtsi +++ b/dts/arm/silabs/xg23/xg23.dtsi @@ -582,6 +582,24 @@ clocks = <&cmu CLOCK_ACMP1 CLOCK_BRANCH_EM01GRPACLK>; status = "disabled"; }; + + vdac0: vdac@59024000 { + compatible = "silabs,vdac"; + reg = <0x59024000 0x4000>; + interrupts = <55 2>; + clocks = <&cmu CLOCK_VDAC0 CLOCK_BRANCH_VDAC0CLK>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + #io-channel-cells = <1>; + + channel@0 { + reg = <0>; + }; + channel@1 { + reg = <1>; + }; + }; }; hwinfo: hwinfo { diff --git a/dts/arm/silabs/xg24/xg24.dtsi b/dts/arm/silabs/xg24/xg24.dtsi index 147f1e639e608..2037e72ff1bb2 100644 --- a/dts/arm/silabs/xg24/xg24.dtsi +++ b/dts/arm/silabs/xg24/xg24.dtsi @@ -552,6 +552,42 @@ clocks = <&cmu CLOCK_ACMP0 CLOCK_BRANCH_EM01GRPACLK>; status = "disabled"; }; + + vdac0: vdac@59024000 { + compatible = "silabs,vdac"; + reg = <0x59024000 0x4000>; + interrupts = <72 2>; + clocks = <&cmu CLOCK_VDAC0 CLOCK_BRANCH_VDAC0CLK>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + #io-channel-cells = <1>; + + channel@0 { + reg = <0>; + }; + channel@1 { + reg = <1>; + }; + }; + + vdac1: vdac@59028000 { + compatible = "silabs,vdac"; + reg = <0x59028000 0x4000>; + interrupts = <73 2>; + clocks = <&cmu CLOCK_VDAC1 CLOCK_BRANCH_VDAC1CLK>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + #io-channel-cells = <1>; + + channel@0 { + reg = <0>; + }; + channel@1 { + reg = <1>; + }; + }; }; }; From fa2e0cfdc5a663672218b177dc56c4f055df9b82 Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Tue, 5 Aug 2025 07:36:11 -0400 Subject: [PATCH 7/9] boards: silabs: enable VDAC nodes for xg2x boards Set status to okay for VDAC nodes for xg23 and xg24 boards. Signed-off-by: Bastien Beauchamp --- boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts | 8 ++++++++ boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.dts | 8 ++++++++ boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts | 4 ++++ boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts b/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts index a6f301b0077d4..69a9af6a9566c 100644 --- a/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts +++ b/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts @@ -291,6 +291,14 @@ status = "okay"; }; +&vdac0 { + status = "okay"; +}; + +&vdac1 { + status = "okay"; +}; + &sysrtc0 { status = "okay"; }; diff --git a/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.dts b/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.dts index 7ef95fff1e0b7..b837a3167d9b9 100644 --- a/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.dts +++ b/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.dts @@ -207,6 +207,14 @@ status = "okay"; }; +&vdac0 { + status = "okay"; +}; + +&vdac1 { + status = "okay"; +}; + &sysrtc0 { status = "okay"; }; diff --git a/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts b/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts index 674f04075767f..4a0f5720a1a1d 100644 --- a/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts +++ b/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts @@ -290,3 +290,7 @@ }; }; }; + +&vdac0 { + status = "okay"; +}; diff --git a/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts b/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts index 1f7fe9222e387..c55d865f539cd 100644 --- a/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts +++ b/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts @@ -267,6 +267,14 @@ }; }; +&vdac0 { + status = "okay"; +}; + +&vdac1 { + status = "okay"; +}; + &bt_hci_silabs { status = "okay"; }; From aaa96320f853791f269f679a0e4578d30c4d04d2 Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Thu, 24 Jul 2025 11:18:42 -0400 Subject: [PATCH 8/9] boards: silabs: update board support for DAC driver The xg24_dk2601b, xg24_ek2703a, xg23_rb4210a and xg24_rb4187c board yaml files were updated to support the DAC driver. Signed-off-by: Bastien Beauchamp --- boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.yaml | 1 + boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.yaml | 1 + boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.yaml | 1 + boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.yaml | 1 + 4 files changed, 4 insertions(+) diff --git a/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.yaml b/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.yaml index 1682cc6038b67..70aa8f6263897 100644 --- a/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.yaml +++ b/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.yaml @@ -17,6 +17,7 @@ supported: - clock_control - comparator - adc + - dac testing: ignore_tags: - pm diff --git a/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.yaml b/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.yaml index 9a0285d442378..e5c360b43a602 100644 --- a/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.yaml +++ b/boards/silabs/dev_kits/xg24_ek2703a/xg24_ek2703a.yaml @@ -15,6 +15,7 @@ supported: - watchdog - clock_control - comparator + - dac testing: ignore_tags: - pm diff --git a/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.yaml b/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.yaml index 1a95532a64fec..2e5769704ac99 100644 --- a/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.yaml +++ b/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.yaml @@ -21,6 +21,7 @@ supported: - dma - watchdog - comparator + - dac testing: ignore_tags: - pm diff --git a/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.yaml b/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.yaml index d783e3919ec56..a024e6e86130a 100644 --- a/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.yaml +++ b/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.yaml @@ -16,6 +16,7 @@ supported: - dma - watchdog - comparator + - dac testing: ignore_tags: - pm From d3179645d088ae7d84057d3274593115fac3e046 Mon Sep 17 00:00:00 2001 From: Bastien Beauchamp Date: Thu, 24 Jul 2025 11:23:59 -0400 Subject: [PATCH 9/9] tests: drivers: dac: add xg23 and xg24 boards to dac tests Add board overlays and defines to the test sources files to execute the dac_api and dac_loopback tests on xg23_rb4210a, xg24_dk2601b, xg24_ek2703a and xg24_rb4187c. Signed-off-by: Bastien Beauchamp --- tests/drivers/dac/dac_api/src/test_dac.c | 6 ++++ .../dac_loopback/boards/xg23_rb4210a.overlay | 33 +++++++++++++++++++ .../dac_loopback/boards/xg24_dk2601b.overlay | 33 +++++++++++++++++++ .../dac_loopback/boards/xg24_ek2703a.overlay | 33 +++++++++++++++++++ .../dac_loopback/boards/xg24_rb4187c.overlay | 33 +++++++++++++++++++ tests/drivers/dac/dac_loopback/src/test_dac.c | 21 +++++++++++- tests/drivers/dac/dac_loopback/testcase.yaml | 4 +++ 7 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 tests/drivers/dac/dac_loopback/boards/xg23_rb4210a.overlay create mode 100644 tests/drivers/dac/dac_loopback/boards/xg24_dk2601b.overlay create mode 100644 tests/drivers/dac/dac_loopback/boards/xg24_ek2703a.overlay create mode 100644 tests/drivers/dac/dac_loopback/boards/xg24_rb4187c.overlay diff --git a/tests/drivers/dac/dac_api/src/test_dac.c b/tests/drivers/dac/dac_api/src/test_dac.c index 0c4bb855804cf..5e1fafebf8be0 100644 --- a/tests/drivers/dac/dac_api/src/test_dac.c +++ b/tests/drivers/dac/dac_api/src/test_dac.c @@ -114,6 +114,12 @@ #define DAC_RESOLUTION 12 #define DAC_CHANNEL_ID 0 +#elif defined(CONFIG_SOC_FAMILY_SILABS_S2) + +#define DAC_DEVICE_NODE DT_NODELABEL(vdac0) +#define DAC_RESOLUTION 12 +#define DAC_CHANNEL_ID 0 + #else #error "Unsupported board." #endif diff --git a/tests/drivers/dac/dac_loopback/boards/xg23_rb4210a.overlay b/tests/drivers/dac/dac_loopback/boards/xg23_rb4210a.overlay new file mode 100644 index 0000000000000..c81006be2282e --- /dev/null +++ b/tests/drivers/dac/dac_loopback/boards/xg23_rb4210a.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Silicon Laboratories Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +&adc0 { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + zephyr,input-positive = ; + }; +}; + +&vdac0 { + status = "okay"; + voltage-reference = "AVDD"; + + channel@0 { + reg = <0>; + aux-output = ; + }; +}; diff --git a/tests/drivers/dac/dac_loopback/boards/xg24_dk2601b.overlay b/tests/drivers/dac/dac_loopback/boards/xg24_dk2601b.overlay new file mode 100644 index 0000000000000..c81006be2282e --- /dev/null +++ b/tests/drivers/dac/dac_loopback/boards/xg24_dk2601b.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Silicon Laboratories Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +&adc0 { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + zephyr,input-positive = ; + }; +}; + +&vdac0 { + status = "okay"; + voltage-reference = "AVDD"; + + channel@0 { + reg = <0>; + aux-output = ; + }; +}; diff --git a/tests/drivers/dac/dac_loopback/boards/xg24_ek2703a.overlay b/tests/drivers/dac/dac_loopback/boards/xg24_ek2703a.overlay new file mode 100644 index 0000000000000..c81006be2282e --- /dev/null +++ b/tests/drivers/dac/dac_loopback/boards/xg24_ek2703a.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Silicon Laboratories Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +&adc0 { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + zephyr,input-positive = ; + }; +}; + +&vdac0 { + status = "okay"; + voltage-reference = "AVDD"; + + channel@0 { + reg = <0>; + aux-output = ; + }; +}; diff --git a/tests/drivers/dac/dac_loopback/boards/xg24_rb4187c.overlay b/tests/drivers/dac/dac_loopback/boards/xg24_rb4187c.overlay new file mode 100644 index 0000000000000..c81006be2282e --- /dev/null +++ b/tests/drivers/dac/dac_loopback/boards/xg24_rb4187c.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Silicon Laboratories Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +&adc0 { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + zephyr,input-positive = ; + }; +}; + +&vdac0 { + status = "okay"; + voltage-reference = "AVDD"; + + channel@0 { + reg = <0>; + aux-output = ; + }; +}; diff --git a/tests/drivers/dac/dac_loopback/src/test_dac.c b/tests/drivers/dac/dac_loopback/src/test_dac.c index 57190003a708d..ddd1bc8972f8a 100644 --- a/tests/drivers/dac/dac_loopback/src/test_dac.c +++ b/tests/drivers/dac/dac_loopback/src/test_dac.c @@ -184,6 +184,24 @@ #define ADC_CHANNEL_ID 0 #endif +#elif defined(CONFIG_SOC_FAMILY_SILABS_S2) + +/* VDAC0CH0 output is internally available on IADC_INPUT_DAC0 */ + +#include + +#define DAC_DEVICE_NODE DT_NODELABEL(vdac0) +#define DAC_RESOLUTION 12 +#define DAC_CHANNEL_ID 0 + +#define ADC_DEVICE_NODE DT_NODELABEL(adc0) +#define ADC_RESOLUTION 12 +#define ADC_GAIN ADC_GAIN_1 +#define ADC_REFERENCE ADC_REF_VDD_1 +#define ADC_ACQUISITION_TIME ADC_ACQ_TIME_DEFAULT +#define ADC_CHANNEL_ID 0 +#define ADC_1ST_CHANNEL_INPUT IADC_INPUT_DAC0 + #else #error "Unsupported board." #endif @@ -208,7 +226,8 @@ static const struct adc_channel_cfg adc_ch_cfg = { defined(CONFIG_BOARD_BL653_DVK) || \ defined(CONFIG_BOARD_BL654_DVK) || \ defined(CONFIG_BOARD_BL5340_DVK) || \ - defined(CONFIG_BOARD_LPCXPRESSO55S36) + defined(CONFIG_BOARD_LPCXPRESSO55S36) || \ + defined(CONFIG_SOC_FAMILY_SILABS_S2) .input_positive = ADC_1ST_CHANNEL_INPUT, #endif }; diff --git a/tests/drivers/dac/dac_loopback/testcase.yaml b/tests/drivers/dac/dac_loopback/testcase.yaml index 1a2c06758b631..c068830a69eba 100644 --- a/tests/drivers/dac/dac_loopback/testcase.yaml +++ b/tests/drivers/dac/dac_loopback/testcase.yaml @@ -29,5 +29,9 @@ tests: - nucleo_g071rb - nucleo_wl55jc - lpcxpresso55s36 + - xg23_rb4210a + - xg24_dk2601b + - xg24_ek2703a + - xg24_rb4187c integration_platforms: - nucleo_f207zg