From 50b267f1d68f951242005a982ad5130b521cdf5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Mon, 19 Jul 2021 17:34:25 -0700 Subject: [PATCH] soc: nordic_nrf: add NRF_DT_GPIOS_TO_PSEL_OR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Helper macro for getting the PSEL value from optional devicetree properties. Signed-off-by: Martí Bolívar --- soc/arm/nordic_nrf/soc_nrf_common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/soc/arm/nordic_nrf/soc_nrf_common.h b/soc/arm/nordic_nrf/soc_nrf_common.h index ca889344f25..c6235f80acf 100644 --- a/soc/arm/nordic_nrf/soc_nrf_common.h +++ b/soc/arm/nordic_nrf/soc_nrf_common.h @@ -130,6 +130,18 @@ (DT_GPIO_PIN(node_id, prop) + \ (DT_PROP_BY_PHANDLE(node_id, prop, port) << 5)) +/** + * If the node has the property, expands to + * NRF_DT_GPIOS_TO_PSEL(node_id, prop). The default_value argument is + * not expanded in this case. + * + * Otherwise, expands to default_value. + */ +#define NRF_DT_GPIOS_TO_PSEL_OR(node_id, prop, default_value) \ + COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \ + (NRF_DT_GPIOS_TO_PSEL(node_id, prop)), \ + (default_value)) + /** * Error out the build if 'prop' is set on node 'node_id' and * DT_GPIO_CTLR(node_id, prop) is not an SoC GPIO controller,