1 /* 2 * Copyright (c) 2022 Vaishnav Achath 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef TI_SIMPLELINK_CC13XX_CC26XX_SOC_PINCTRL_H_ 8 #define TI_SIMPLELINK_CC13XX_CC26XX_SOC_PINCTRL_H_ 9 10 #include <zephyr/types.h> 11 12 #include <driverlib/ioc.h> 13 14 typedef struct pinctrl_soc_pin { 15 uint32_t pin; 16 uint32_t iofunc; 17 uint32_t iomode; 18 } pinctrl_soc_pin_t; 19 20 /* Convert DT flags to SoC flags */ 21 #define CC13XX_CC26XX_PIN_FLAGS(node_id) \ 22 (DT_PROP(node_id, bias_pull_up) * IOC_IOPULL_UP | \ 23 DT_PROP(node_id, bias_pull_down) * IOC_IOPULL_DOWN | \ 24 DT_PROP(node_id, bias_disable) * IOC_NO_IOPULL | \ 25 DT_PROP(node_id, drive_open_drain) * IOC_IOMODE_OPEN_DRAIN_NORMAL | \ 26 DT_PROP(node_id, drive_open_source) * IOC_IOMODE_OPEN_SRC_NORMAL | \ 27 (DT_PROP(node_id, drive_strength) >> 2) << IOC_IOCFG0_IOCURR_S | \ 28 DT_PROP(node_id, input_enable) * IOC_INPUT_ENABLE | \ 29 DT_PROP(node_id, input_schmitt_enable) * IOC_HYST_ENABLE | \ 30 DT_PROP(node_id, ti_input_edge_detect)) 31 32 #define CC13XX_CC26XX_DT_PIN(node_id) \ 33 { \ 34 .pin = DT_PROP_BY_IDX(node_id, pinmux, 0), \ 35 .iofunc = DT_PROP_BY_IDX(node_id, pinmux, 1), \ 36 .iomode = CC13XX_CC26XX_PIN_FLAGS(node_id) \ 37 }, 38 39 #define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ 40 CC13XX_CC26XX_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)) 41 42 #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ 43 { DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) } 44 45 #endif /* TI_SIMPLELINK_CC13XX_CC26XX_SOC_PINCTRL_H_ */ 46