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 <aksel.mellbye@silabs.com>
This commit is contained in:
Aksel Skauge Mellbye 2024-10-02 21:13:46 +02:00 committed by Henrik Brix Andersen
parent 60462266e3
commit 3d0909ed18
16 changed files with 196 additions and 2 deletions

View File

@ -8,6 +8,7 @@
#include <silabs/efr32bg22.dtsi>
#include <silabs/efr32bg2x-pinctrl.dtsi>
#include "thunderboard.dtsi"
#include <zephyr/dt-bindings/regulator/silabs_dcdc.h>
/ {
/* These aliases are provided for compatibility with samples */
@ -27,6 +28,12 @@
};
};
&dcdc {
status = "okay";
regulator-boot-on;
regulator-initial-mode = <SILABS_DCDC_MODE_BUCK>;
};
&flash0 {
partitions {
/* Reserve 48 KiB for the bootloader */

View File

@ -8,6 +8,7 @@
#include <silabs/efr32mg24b310f1536im48.dtsi>
#include <silabs/efr32mg24-pinctrl.dtsi>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/regulator/silabs_dcdc.h>
/ {
model = "Silicon Labs BRD2601B (xG24 Dev Kit)";
@ -132,6 +133,13 @@
status = "okay";
};
&dcdc {
status = "okay";
regulator-boot-on;
regulator-initial-mode = <SILABS_DCDC_MODE_BUCK>;
silabs,pfmx-peak-current-milliamp = <120>;
};
&flash0 {
partitions {
compatible = "fixed-partitions";

View File

@ -8,6 +8,7 @@
#include <silabs/efr32bg27.dtsi>
#include <silabs/efr32bg2x-pinctrl.dtsi>
#include "thunderboard.dtsi"
#include <zephyr/dt-bindings/regulator/silabs_dcdc.h>
/ {
model = "Silicon Labs xG27-DK2602A Dev Kit";
@ -31,6 +32,12 @@
};
};
&dcdc {
status = "okay";
regulator-boot-on;
regulator-initial-mode = <SILABS_DCDC_MODE_BUCK>;
};
&flash0 {
partitions {
/* Reserve 48 KiB for the bootloader */

View File

@ -7,6 +7,7 @@
/dts-v1/;
#include <silabs/efr32mg24b220f1536im48.dtsi>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/regulator/silabs_dcdc.h>
#include "xg24_rb4187c-pinctrl.dtsi"
/ {
@ -117,6 +118,13 @@
status = "okay";
};
&dcdc {
status = "okay";
regulator-boot-on;
regulator-initial-mode = <SILABS_DCDC_MODE_BUCK>;
silabs,pfmx-peak-current-milliamp = <100>;
};
&flash0 {
partitions {
compatible = "fixed-partitions";

View File

@ -9,6 +9,7 @@
#include <silabs/efr32mg24b020f1536im40.dtsi>
#include "sparkfun_thing_plus_matter_mgm240p-pinctrl.dtsi"
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/regulator/silabs_dcdc.h>
/ {
model = "Sparkfun MGM240P (Sparkfun Thing Plus Matter)";
@ -101,6 +102,13 @@
status = "okay";
};
&dcdc {
status = "okay";
regulator-boot-on;
regulator-initial-mode = <SILABS_DCDC_MODE_BUCK>;
silabs,pfmx-peak-current-milliamp = <50>;
};
&flash0 {
partitions {
compatible = "fixed-partitions";

View File

@ -59,3 +59,7 @@
interrupts = <12 0>;
clocks = <&cmu CLOCK_RTCC CLOCK_BRANCH_RTCCCLK>;
};
&dcdc {
interrupts = <61 0>;
};

View File

@ -64,3 +64,7 @@
interrupts = <54 0>;
clocks = <&cmu CLOCK_IADC0 CLOCK_BRANCH_IADCCLK>;
};
&dcdc {
interrupts = <8 0>;
};

View File

@ -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 {

View File

@ -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";
};
};

View File

@ -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 <zephyr/dt-bindings/regulator/silabs_dcdc.h> 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

View File

@ -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_ */

View File

@ -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

View File

@ -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 <zephyr/devicetree.h>
#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 */

View File

@ -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)

View File

@ -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();

View File

@ -0,0 +1,2 @@
# Copyright (c) 2024 Silicon Laboratories Inc.
# SPDX-License-Identifier: Apache-2.0