1 /* 2 * Copyright (c) 2022 SEAL AG 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_SOC_ARM_NUVOTON_NUMICRO_COMMON_PINCTRL_SOC_H_ 8 #define ZEPHYR_SOC_ARM_NUVOTON_NUMICRO_COMMON_PINCTRL_SOC_H_ 9 10 #include <stdint.h> 11 #include <zephyr/types.h> 12 #include <zephyr/dt-bindings/gpio/numicro-gpio.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 struct pinctrl_soc_pin { 19 uint32_t pinmux : 12; 20 uint32_t pull_down : 1; 21 uint32_t pull_up : 1; 22 uint32_t open_drain : 1; 23 uint32_t schmitt_trigger : 1; 24 uint32_t slew_rate : 2; 25 uint32_t input_disable : 1; 26 uint32_t input_debounce : 1; 27 }; 28 29 typedef struct pinctrl_soc_pin pinctrl_soc_pin_t; 30 31 #define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ 32 { \ 33 .pinmux = DT_PROP_BY_IDX(node_id, prop, idx), \ 34 .pull_down = DT_PROP(node_id, bias_pull_down), \ 35 .pull_up = DT_PROP(node_id, bias_pull_up), \ 36 .open_drain = DT_PROP(node_id, drive_open_drain), \ 37 .schmitt_trigger = DT_PROP(node_id, input_schmitt_enable),\ 38 .slew_rate = DT_ENUM_IDX(node_id, slew_rate), \ 39 .input_disable = DT_PROP(node_id, input_disable), \ 40 .input_debounce = DT_PROP(node_id, input_debounce), \ 41 }, 42 43 #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ 44 {DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), \ 45 DT_FOREACH_PROP_ELEM, pinmux, \ 46 Z_PINCTRL_STATE_PIN_INIT)} 47 48 #ifdef __cplusplus 49 } 50 #endif 51 52 #endif /* ZEPHYR_SOC_ARM_NUVOTON_NUMICRO_COMMON_PINCTRL_SOC_H_ */ 53