From 23a296f26bc3720ffe9d40e8f2a4001770f3690f Mon Sep 17 00:00:00 2001 From: Julien Panis Date: Wed, 11 Sep 2024 14:40:26 +0200 Subject: [PATCH] soc: ti: cc23x0: Add helper macros for device tree This patch adds an header file which contains helper macros. These macros can be used to access some device tree properties. Signed-off-by: Julien Panis --- soc/ti/simplelink/cc23x0/soc.h | 1 + soc/ti/simplelink/cc23x0/ti_cc23x0_dt.h | 39 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 soc/ti/simplelink/cc23x0/ti_cc23x0_dt.h diff --git a/soc/ti/simplelink/cc23x0/soc.h b/soc/ti/simplelink/cc23x0/soc.h index 968cbc99d9c..353b64b6a11 100644 --- a/soc/ti/simplelink/cc23x0/soc.h +++ b/soc/ti/simplelink/cc23x0/soc.h @@ -9,5 +9,6 @@ #define TI_SIMPLELINK_CC23X0_SOC_H_ #include "cmsis/cc23x0r5.h" +#include "ti_cc23x0_dt.h" #endif /* TI_SIMPLELINK_CC23X0_SOC_H_ */ diff --git a/soc/ti/simplelink/cc23x0/ti_cc23x0_dt.h b/soc/ti/simplelink/cc23x0/ti_cc23x0_dt.h new file mode 100644 index 00000000000..d5af5a3947e --- /dev/null +++ b/soc/ti/simplelink/cc23x0/ti_cc23x0_dt.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 BayLibre, SAS + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief TI CC23X0 MCU family devicetree helper macros + */ + +#ifndef _TI_CC23X0_DT_H_ +#define _TI_CC23X0_DT_H_ + +/* Common macro to get CPU clock frequency */ +#define TI_CC23X0_DT_CPU_CLK_FREQ_HZ \ + DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency) + +/* + * Helper macros for use with TI CC23X0 DMA controller + * return 0xff as default value if there is no 'dmas' property + */ +#define TI_CC23X0_DT_INST_DMA_CELL(n, name, cell) \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(n, dmas), \ + (DT_INST_DMAS_CELL_BY_NAME(n, name, cell)), \ + (0xff)) + +#define TI_CC23X0_DT_INST_DMA_TRIGSRC(n, name) \ + TI_CC23X0_DT_INST_DMA_CELL(n, name, trigsrc) + +#define TI_CC23X0_DT_INST_DMA_CHANNEL(n, name) \ + TI_CC23X0_DT_INST_DMA_CELL(n, name, channel) + +#define TI_CC23X0_DT_INST_DMA_CTLR(n, name) \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(n, dmas), \ + (DT_INST_DMAS_CTLR_BY_NAME(n, name)), \ + (DT_INVALID_NODE)) + +#endif /* _TI_CC23X0_DT_H_ */