From fa6c990583fa68f367ddf4975aa20cb7a1ff371d Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 23 Apr 2020 06:51:17 -0500 Subject: [PATCH] soc: arm: atmel_sam: Add helper macros to init array of pins Added ATMEL_SAM_DT_NUM_PINS macro which will return the number of pins to initialize for "pinctrl-0" devicetree property. Added ATMEL_SAM_DT_PINS macro which will create an array initializer with all the pins associated with "pinctrl-0" devicetree property. Signed-off-by: Kumar Gala --- soc/arm/atmel_sam/common/atmel_sam_dt.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/soc/arm/atmel_sam/common/atmel_sam_dt.h b/soc/arm/atmel_sam/common/atmel_sam_dt.h index 5d9ca3cef29..d0b84a03122 100644 --- a/soc/arm/atmel_sam/common/atmel_sam_dt.h +++ b/soc/arm/atmel_sam/common/atmel_sam_dt.h @@ -45,6 +45,18 @@ ATMEL_SAM_PIN_PERIPH(inst, idx) << 16 \ } +/* Get the number of pins for pinctrl-0 */ +#define ATMEL_SAM_DT_NUM_PINS(inst) DT_INST_PROP_LEN(inst, pinctrl_0) + +/* internal macro to structure things for use with UTIL_LISTIFY */ +#define ATMEL_SAM_DT_PIN_ELEM(idx, inst) ATMEL_SAM_DT_PIN(inst, idx), + +/* Construct an array intializer for soc_gpio_pin for a device instance */ +#define ATMEL_SAM_DT_PINS(inst) \ + { UTIL_LISTIFY(ATMEL_SAM_DT_NUM_PINS(inst), \ + ATMEL_SAM_DT_PIN_ELEM, inst) \ + } + /* Devicetree macros related to clock */ #define ATMEL_SAM_DT_CPU_CLK_FREQ_HZ \