1 /* 2 * Copyright (c) 2023 Antmicro <www.antmicro.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_SOC_ARM_RENESAS_RZT2M_PINCTRL_H_ 8 #define ZEPHYR_SOC_ARM_RENESAS_RZT2M_PINCTRL_H_ 9 10 #include <zephyr/types.h> 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 typedef struct pinctrl_soc_pin_t { 17 uint32_t port; 18 uint32_t pin; 19 uint32_t func; 20 uint32_t input_enable: 1; 21 uint32_t output_enable: 1; 22 uint32_t pull_up: 1; 23 uint32_t pull_down: 1; 24 uint32_t high_impedance: 1; 25 uint32_t slew_rate: 2; 26 uint8_t drive_strength; 27 uint32_t schmitt_enable: 1; 28 } pinctrl_soc_pin_t; 29 30 #define RZT2M_GET_PORT(pinctrl) ((pinctrl >> 16) & 0xff) 31 #define RZT2M_GET_PIN(pinctrl) ((pinctrl >> 8) & 0xff) 32 #define RZT2M_GET_FUNC(pinctrl) (pinctrl & 0xff) 33 34 #define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \ 35 { \ 36 .port = RZT2M_GET_PORT(DT_PROP_BY_IDX(node_id, prop, idx)), \ 37 .pin = RZT2M_GET_PIN(DT_PROP_BY_IDX(node_id, prop, idx)), \ 38 .func = RZT2M_GET_FUNC(DT_PROP_BY_IDX(node_id, prop, idx)), \ 39 .input_enable = DT_PROP(node_id, input_enable), \ 40 .pull_up = DT_PROP(node_id, bias_pull_up), \ 41 .pull_down = DT_PROP(node_id, bias_pull_down), \ 42 .high_impedance = DT_PROP(node_id, bias_high_impedance), \ 43 .slew_rate = DT_ENUM_IDX(node_id, slew_rate), \ 44 .drive_strength = DT_ENUM_IDX(node_id, drive_strength), \ 45 .schmitt_enable = DT_PROP(node_id, input_schmitt_enable), \ 46 }, 47 48 #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ 49 {DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), \ 50 DT_FOREACH_PROP_ELEM, pinmux, \ 51 Z_PINCTRL_STATE_PIN_INIT)} 52 53 #ifdef __cplusplus 54 } 55 #endif 56 57 #endif /* ZEPHYR_SOC_ARM_RENESAS_RZT2M_PINCTRL_H_ */ 58