From 3d0909ed18cf3d43da28a53f881d5a4d2abada9a Mon Sep 17 00:00:00 2001 From: Aksel Skauge Mellbye Date: Wed, 2 Oct 2024 21:13:46 +0200 Subject: [PATCH] soc: silabs: Initialize DCDC from device tree The DC-DC converter was unconditionally initialized with default settings on Series 2. Add device tree binding and nodes, and guard call to init function. Map DT options to config header from HAL. Signed-off-by: Aksel Skauge Mellbye --- boards/silabs/dev_kits/sltb010a/sltb010a.dts | 7 +++ .../dev_kits/xg24_dk2601b/xg24_dk2601b.dts | 8 +++ .../dev_kits/xg27_dk2602a/xg27_dk2602a.dts | 7 +++ .../xg24_rb4187c/xg24_rb4187c.dts | 8 +++ .../sparkfun_thing_plus_matter_mgm240p.dts | 8 +++ dts/arm/silabs/efr32bg22.dtsi | 4 ++ dts/arm/silabs/efr32bg27.dtsi | 4 ++ dts/arm/silabs/efr32bg2x.dtsi | 6 ++ dts/arm/silabs/efr32mg24.dtsi | 7 +++ .../regulator/silabs,series2-dcdc.yaml | 63 +++++++++++++++++++ .../dt-bindings/regulator/silabs_dcdc.h | 27 ++++++++ .../hal_silabs/simplicity_sdk/CMakeLists.txt | 7 ++- .../config/sl_device_init_dcdc_config.h | 35 +++++++++++ soc/silabs/CMakeLists.txt | 1 + soc/silabs/common/soc.c | 4 +- soc/silabs/silabs_s2/CMakeLists.txt | 2 + 16 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 dts/bindings/regulator/silabs,series2-dcdc.yaml create mode 100644 include/zephyr/dt-bindings/regulator/silabs_dcdc.h create mode 100644 modules/hal_silabs/simplicity_sdk/config/sl_device_init_dcdc_config.h create mode 100644 soc/silabs/silabs_s2/CMakeLists.txt diff --git a/boards/silabs/dev_kits/sltb010a/sltb010a.dts b/boards/silabs/dev_kits/sltb010a/sltb010a.dts index 3f352ea6008..b0d0e16a4f0 100644 --- a/boards/silabs/dev_kits/sltb010a/sltb010a.dts +++ b/boards/silabs/dev_kits/sltb010a/sltb010a.dts @@ -8,6 +8,7 @@ #include #include #include "thunderboard.dtsi" +#include / { /* These aliases are provided for compatibility with samples */ @@ -27,6 +28,12 @@ }; }; +&dcdc { + status = "okay"; + regulator-boot-on; + regulator-initial-mode = ; +}; + &flash0 { partitions { /* Reserve 48 KiB for the bootloader */ diff --git a/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts b/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts index ac03b32ff37..2b6a5a36079 100644 --- a/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts +++ b/boards/silabs/dev_kits/xg24_dk2601b/xg24_dk2601b.dts @@ -8,6 +8,7 @@ #include #include #include +#include / { model = "Silicon Labs BRD2601B (xG24 Dev Kit)"; @@ -132,6 +133,13 @@ status = "okay"; }; +&dcdc { + status = "okay"; + regulator-boot-on; + regulator-initial-mode = ; + silabs,pfmx-peak-current-milliamp = <120>; +}; + &flash0 { partitions { compatible = "fixed-partitions"; diff --git a/boards/silabs/dev_kits/xg27_dk2602a/xg27_dk2602a.dts b/boards/silabs/dev_kits/xg27_dk2602a/xg27_dk2602a.dts index 6dba2bfa648..aa1da7f157f 100644 --- a/boards/silabs/dev_kits/xg27_dk2602a/xg27_dk2602a.dts +++ b/boards/silabs/dev_kits/xg27_dk2602a/xg27_dk2602a.dts @@ -8,6 +8,7 @@ #include #include #include "thunderboard.dtsi" +#include / { model = "Silicon Labs xG27-DK2602A Dev Kit"; @@ -31,6 +32,12 @@ }; }; +&dcdc { + status = "okay"; + regulator-boot-on; + regulator-initial-mode = ; +}; + &flash0 { partitions { /* Reserve 48 KiB for the bootloader */ diff --git a/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts b/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts index 21a487e758f..b5caabdbf31 100644 --- a/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts +++ b/boards/silabs/radio_boards/xg24_rb4187c/xg24_rb4187c.dts @@ -7,6 +7,7 @@ /dts-v1/; #include #include +#include #include "xg24_rb4187c-pinctrl.dtsi" / { @@ -117,6 +118,13 @@ status = "okay"; }; +&dcdc { + status = "okay"; + regulator-boot-on; + regulator-initial-mode = ; + silabs,pfmx-peak-current-milliamp = <100>; +}; + &flash0 { partitions { compatible = "fixed-partitions"; diff --git a/boards/sparkfun/thing_plus_matter_mgm240p/sparkfun_thing_plus_matter_mgm240p.dts b/boards/sparkfun/thing_plus_matter_mgm240p/sparkfun_thing_plus_matter_mgm240p.dts index 4f12a486815..d137aab6ed3 100644 --- a/boards/sparkfun/thing_plus_matter_mgm240p/sparkfun_thing_plus_matter_mgm240p.dts +++ b/boards/sparkfun/thing_plus_matter_mgm240p/sparkfun_thing_plus_matter_mgm240p.dts @@ -9,6 +9,7 @@ #include #include "sparkfun_thing_plus_matter_mgm240p-pinctrl.dtsi" #include +#include / { model = "Sparkfun MGM240P (Sparkfun Thing Plus Matter)"; @@ -101,6 +102,13 @@ status = "okay"; }; +&dcdc { + status = "okay"; + regulator-boot-on; + regulator-initial-mode = ; + silabs,pfmx-peak-current-milliamp = <50>; +}; + &flash0 { partitions { compatible = "fixed-partitions"; diff --git a/dts/arm/silabs/efr32bg22.dtsi b/dts/arm/silabs/efr32bg22.dtsi index bcf918a9164..03a7c788396 100644 --- a/dts/arm/silabs/efr32bg22.dtsi +++ b/dts/arm/silabs/efr32bg22.dtsi @@ -59,3 +59,7 @@ interrupts = <12 0>; clocks = <&cmu CLOCK_RTCC CLOCK_BRANCH_RTCCCLK>; }; + +&dcdc { + interrupts = <61 0>; +}; diff --git a/dts/arm/silabs/efr32bg27.dtsi b/dts/arm/silabs/efr32bg27.dtsi index 448761f3a50..654168ce52c 100644 --- a/dts/arm/silabs/efr32bg27.dtsi +++ b/dts/arm/silabs/efr32bg27.dtsi @@ -64,3 +64,7 @@ interrupts = <54 0>; clocks = <&cmu CLOCK_IADC0 CLOCK_BRANCH_IADCCLK>; }; + +&dcdc { + interrupts = <8 0>; +}; diff --git a/dts/arm/silabs/efr32bg2x.dtsi b/dts/arm/silabs/efr32bg2x.dtsi index ca42d7c0888..c65077e0b29 100644 --- a/dts/arm/silabs/efr32bg2x.dtsi +++ b/dts/arm/silabs/efr32bg2x.dtsi @@ -231,6 +231,12 @@ status = "disabled"; #io-channel-cells = <1>; }; + + dcdc: dcdc@50094000 { + compatible = "silabs,series2-dcdc"; + reg = <0x50094000 0x4000>; + status = "disabled"; + }; }; bt_hci_silabs: bt_hci_silabs { diff --git a/dts/arm/silabs/efr32mg24.dtsi b/dts/arm/silabs/efr32mg24.dtsi index c12421bc602..c583012cd8d 100644 --- a/dts/arm/silabs/efr32mg24.dtsi +++ b/dts/arm/silabs/efr32mg24.dtsi @@ -248,6 +248,13 @@ status = "disabled"; #io-channel-cells = <1>; }; + + dcdc: dcdc@50094000 { + compatible = "silabs,series2-dcdc"; + reg = <0x50094000 0x4000>; + interrupts = <53 0>; + status = "disabled"; + }; }; diff --git a/dts/bindings/regulator/silabs,series2-dcdc.yaml b/dts/bindings/regulator/silabs,series2-dcdc.yaml new file mode 100644 index 00000000000..1099e99c698 --- /dev/null +++ b/dts/bindings/regulator/silabs,series2-dcdc.yaml @@ -0,0 +1,63 @@ +# Copyright (c) 2024 Silicon Laboratories Inc. +# SPDX-License-Identifier: Apache-2.0 + +description: | + Silicon Labs Series 2 DC-DC converter. + + Include the bindings header file to get + access to relevant symbols for configuration. + + The following standard properties are supported: + + `regulator-boot-on` + Enable DC-DC converter at boot. If not set, the DC-DC converter is powered off. + `regulator-allow-bypass` + Enable bypass mode. If combined with `regulator-boot-on`, the DC-DC converter + is initialized to bypass mode. + `regulator-initial-mode` + DCDC operating mode. One of `SILABS_DCDC_MODE_BUCK` or `SILABS_DCDC_MODE_BOOST`. + `regulator-init-microvolt` + Output voltage for boost mode. Not used in buck mode. + +compatible: "silabs,series2-dcdc" + +include: + - name: base.yaml + - name: regulator.yaml + property-allowlist: + - regulator-boot-on + - regulator-allow-bypass + - regulator-initial-mode + - regulator-init-microvolt + +properties: + reg: + required: true + + regulator-initial-mode: + enum: [0, 1] + + regulator-init-microvolt: + enum: + - 1800000 + - 1900000 + - 2000000 + - 2100000 + - 2200000 + - 2300000 + - 2400000 + + silabs,pfmx-peak-current-milliamp: + type: int + description: Peak current draw in PFMX mode (CCM, continuous conduction mode). + enum: + - 50 + - 65 + - 73 + - 80 + - 86 + - 93 + - 100 + - 106 + - 113 + - 120 diff --git a/include/zephyr/dt-bindings/regulator/silabs_dcdc.h b/include/zephyr/dt-bindings/regulator/silabs_dcdc.h new file mode 100644 index 00000000000..f2547346bc3 --- /dev/null +++ b/include/zephyr/dt-bindings/regulator/silabs_dcdc.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Silicon Laboratories Inc. + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_SILABS_DCDC_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_SILABS_DCDC_H_ + +/** + * @defgroup regulator_silabs_dcdc Silabs DCDC devicetree helpers. + * @ingroup regulator_interface + * @{ + */ + +/** + * @name Silabs DCDC modes + * @{ + */ +/** Buck mode */ +#define SILABS_DCDC_MODE_BUCK 0 +/** Boost mode */ +#define SILABS_DCDC_MODE_BOOST 1 +/** @} */ + +/** @} */ + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_SILABS_DCDC_H_ */ diff --git a/modules/hal_silabs/simplicity_sdk/CMakeLists.txt b/modules/hal_silabs/simplicity_sdk/CMakeLists.txt index 842d5383e83..f329683e2b0 100644 --- a/modules/hal_silabs/simplicity_sdk/CMakeLists.txt +++ b/modules/hal_silabs/simplicity_sdk/CMakeLists.txt @@ -86,6 +86,7 @@ if(CONFIG_SOC_GECKO_HAS_RADIO) endif() zephyr_include_directories( + config ${DEVICE_DIR}/SiliconLabs/${SILABS_DEVICE_FAMILY}/Include ${COMMON_DIR}/config ${COMMON_DIR}/inc @@ -146,8 +147,12 @@ zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_IADC ${EMLIB_DIR}/src/em_i zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_BURTC ${EMLIB_DIR}/src/em_burtc.c) zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_CMU ${EMLIB_DIR}/src/em_cmu.c) -zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT +if(CONFIG_SOC_GECKO_DEV_INIT) +zephyr_library_sources_ifdef(CONFIG_DT_HAS_SILABS_SERIES2_DCDC_ENABLED ${SERVICE_DIR}/device_init/src/sl_device_init_dcdc_s2.c +) +endif() +zephyr_library_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT ${SERVICE_DIR}/device_init/src/sl_device_init_dpll_s2.c ${SERVICE_DIR}/device_init/src/sl_device_init_hfrco.c ${SERVICE_DIR}/device_init/src/sl_device_init_hfxo_s2.c diff --git a/modules/hal_silabs/simplicity_sdk/config/sl_device_init_dcdc_config.h b/modules/hal_silabs/simplicity_sdk/config/sl_device_init_dcdc_config.h new file mode 100644 index 00000000000..1c7eb06a9d0 --- /dev/null +++ b/modules/hal_silabs/simplicity_sdk/config/sl_device_init_dcdc_config.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Silicon Laboratories Inc. + * + * SPDX-License-Identifier: Apache-2.0 + * + * This configuration header is used by the HAL driver device_init_dcdc from hal_silabs, + * invoked through the soc_early_init hook. DeviceTree options are converted to config macros + * expected by the HAL driver. + */ + +#ifndef SL_DEVICE_INIT_DCDC_CONFIG_H +#define SL_DEVICE_INIT_DCDC_CONFIG_H + +#include + +#if DT_HAS_COMPAT_STATUS_OKAY(silabs_series2_dcdc) + +#define DCDC_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(silabs_series2_dcdc) + +#define SL_DEVICE_INIT_DCDC_ENABLE DT_PROP(DCDC_NODE, regulator_boot_on) +#define SL_DEVICE_INIT_DCDC_BYPASS DT_PROP(DCDC_NODE, regulator_allow_bypass) + +#define SL_DEVICE_INIT_DCDC_TYPE DT_PROP_OR(DCDC_NODE, regulator_initial_mode, 0) + +#define SL_DEVICE_INIT_DCDC_BOOST_OUTPUT DT_ENUM_IDX(DCDC_NODE, regulator_init_microvolt) + +#define SL_DEVICE_INIT_DCDC_PFMX_IPKVAL_OVERRIDE \ + DT_NODE_HAS_PROP(DCDC_NODE, silabs_pfmx_peak_current_milliamp) + +#define SL_DEVICE_INIT_DCDC_PFMX_IPKVAL \ + (DT_ENUM_IDX(DCDC_NODE, silabs_pfmx_peak_current_milliamp) + 3) + +#endif /* DT_HAS_COMPAT_STATUS_OKAY */ + +#endif /* SL_DEVICE_INIT_DCDC_CONFIG_H */ diff --git a/soc/silabs/CMakeLists.txt b/soc/silabs/CMakeLists.txt index 53c5acb87d2..d173ecfec66 100644 --- a/soc/silabs/CMakeLists.txt +++ b/soc/silabs/CMakeLists.txt @@ -4,4 +4,5 @@ add_subdirectory(common) zephyr_include_directories(${SOC_FAMILY}/${SOC_SERIES}) +add_subdirectory_ifdef(CONFIG_SOC_FAMILY_SILABS_S2 silabs_s2) add_subdirectory_ifdef(CONFIG_SOC_SERIES_SIM3U silabs_sim3/sim3u) diff --git a/soc/silabs/common/soc.c b/soc/silabs/common/soc.c index d406e615a91..8453f1f9fca 100644 --- a/soc/silabs/common/soc.c +++ b/soc/silabs/common/soc.c @@ -214,7 +214,9 @@ void soc_early_init_hook(void) #endif #ifdef CONFIG_SOC_GECKO_DEV_INIT - sl_device_init_dcdc(); + if (DT_HAS_COMPAT_STATUS_OKAY(silabs_series2_dcdc)) { + sl_device_init_dcdc(); + } sl_device_init_hfxo(); sl_device_init_dpll(); diff --git a/soc/silabs/silabs_s2/CMakeLists.txt b/soc/silabs/silabs_s2/CMakeLists.txt new file mode 100644 index 00000000000..5b11abea25e --- /dev/null +++ b/soc/silabs/silabs_s2/CMakeLists.txt @@ -0,0 +1,2 @@ +# Copyright (c) 2024 Silicon Laboratories Inc. +# SPDX-License-Identifier: Apache-2.0