diff --git a/subsys/logging/backends/Kconfig.swo b/subsys/logging/backends/Kconfig.swo index 8dcbf3f0285..adfc89b274e 100644 --- a/subsys/logging/backends/Kconfig.swo +++ b/subsys/logging/backends/Kconfig.swo @@ -9,6 +9,16 @@ config LOG_BACKEND_SWO When enabled, backend will use SWO for logging. if LOG_BACKEND_SWO + +config LOG_BACKEND_SWO_REF_FREQ_HZ + int "SWO reference clock frequency" + default $(dt_node_int_prop_int,$(dt_nodelabel_path,itm),swo-ref-frequency) if $(dt_nodelabel_enabled,itm) + default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency) if $(dt_node_has_prop,/cpus/cpu@0,clock-frequency) + default 0 + help + Set SWO reference frequency. In most cases it is equal to CPU + frequency. + config LOG_BACKEND_SWO_FREQ_HZ int "Set SWO output frequency" default 0 diff --git a/subsys/logging/backends/log_backend_swo.c b/subsys/logging/backends/log_backend_swo.c index 7c4c89d8b99..2ef29a3e0c6 100644 --- a/subsys/logging/backends/log_backend_swo.c +++ b/subsys/logging/backends/log_backend_swo.c @@ -42,17 +42,12 @@ PINCTRL_DT_DEFINE(DT_NODELABEL(itm)); #define SWO_FREQ_DIV 1 #else -/* Set reference frequency which can be custom or cpu frequency. */ -#if DT_NODE_HAS_PROP(DT_NODELABEL(itm), swo_ref_frequency) -#define SWO_REF_FREQ DT_PROP(DT_NODELABEL(itm), swo_ref_frequency) -#elif DT_NODE_HAS_PROP(DT_PATH(cpus, cpu_0), clock_frequency) -#define SWO_REF_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency) -#else -#error "Missing DT 'clock-frequency' property on cpu@0 node" +#if CONFIG_LOG_BACKEND_SWO_REF_FREQ_HZ == 0 +#error "SWO reference frequency is not configured" #endif #define SWO_FREQ_DIV \ - ((SWO_REF_FREQ + (CONFIG_LOG_BACKEND_SWO_FREQ_HZ / 2)) / \ + ((CONFIG_LOG_BACKEND_SWO_REF_FREQ_HZ + (CONFIG_LOG_BACKEND_SWO_FREQ_HZ / 2)) / \ CONFIG_LOG_BACKEND_SWO_FREQ_HZ) #if SWO_FREQ_DIV > 0xFFFF