1 /* 2 * Copyright (c) 2023 ENE Technology Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_SOC_ARM_KB1200_PINCTRL_SOC_H_ 8 #define ZEPHYR_SOC_ARM_KB1200_PINCTRL_SOC_H_ 9 10 #include <zephyr/dt-bindings/pinctrl/ene-kb1200-pinctrl.h> 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 /** @cond INTERNAL_HIDDEN */ 17 18 typedef uint32_t pinctrl_soc_pin_t; 19 20 /* initialize pinmux member fields of pinctrl_pin_t */ 21 #define Z_PINCTRL_ENE_KB1200_PINMUX_INIT(node_id) (uint32_t)(DT_PROP(node_id, pinmux)) 22 23 #define Z_PINCTRL_STATE_PINCFG_INIT(node_id) \ 24 ((DT_PROP(node_id, bias_disable) << ENE_KB1200_NO_PUD_POS) | \ 25 (DT_PROP(node_id, bias_pull_down) << ENE_KB1200_PD_POS) | \ 26 (DT_PROP(node_id, bias_pull_up) << ENE_KB1200_PU_POS) | \ 27 (DT_PROP(node_id, drive_push_pull) << ENE_KB1200_PUSH_PULL_POS) | \ 28 (DT_PROP(node_id, drive_open_drain) << ENE_KB1200_OPEN_DRAIN_POS) | \ 29 (DT_PROP(node_id, output_disable) << ENE_KB1200_OUT_DIS_POS) | \ 30 (DT_PROP(node_id, output_enable) << ENE_KB1200_OUT_EN_POS) | \ 31 (DT_PROP(node_id, output_high) << ENE_KB1200_OUT_HI_POS) | \ 32 (DT_PROP(node_id, output_low) << ENE_KB1200_OUT_LO_POS) | \ 33 (DT_PROP(node_id, low_power_enable) << ENE_KB1200_PIN_LOW_POWER_POS)) 34 35 /* initialize pin structure members */ 36 #define Z_PINCTRL_STATE_PIN_INIT(node_id, state_prop, idx) \ 37 (Z_PINCTRL_ENE_KB1200_PINMUX_INIT(DT_PROP_BY_IDX(node_id, state_prop, idx)) | \ 38 Z_PINCTRL_STATE_PINCFG_INIT(DT_PROP_BY_IDX(node_id, state_prop, idx))), 39 40 /* Use DT FOREACH macro to initialize each used pin */ 41 #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ 42 { \ 43 DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) \ 44 } 45 46 /** @endcond */ 47 48 #ifdef __cplusplus 49 } 50 #endif 51 52 #endif /* ZEPHYR_SOC_ARM_KB1200_PINCTRL_SOC_H_ */ 53