1 /*
2  * Copyright (c) 2023 Antmicro <www.antmicro.com>
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_SOC_ARM_QUICKLOGIC_EOS_S3_PINCTRL_H_
8 #define ZEPHYR_SOC_ARM_QUICKLOGIC_EOS_S3_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 pin;
18 	uint32_t iof;
19 	uint32_t input_enable: 1;
20 	uint32_t output_enable: 1;
21 	uint32_t pull_up: 1;
22 	uint32_t pull_down: 1;
23 	uint32_t high_impedance: 1;
24 	uint32_t slew_rate: 2;
25 	uint8_t drive_strength;
26 	uint32_t schmitt_enable: 1;
27 	uint32_t control_selection: 2;
28 } pinctrl_soc_pin_t;
29 
30 #define QUICKLOGIC_EOS_S3_DT_PIN(node_id)			\
31 	{							\
32 		.pin = DT_PROP_BY_IDX(node_id, pinmux, 0),	\
33 		.iof = DT_PROP_BY_IDX(node_id, pinmux, 1),	\
34 		.input_enable = DT_PROP(node_id, input_enable),	\
35 		.output_enable = DT_PROP(node_id, output_enable),	\
36 		.pull_up = DT_PROP(node_id, bias_pull_up),	\
37 		.pull_down = DT_PROP(node_id, bias_pull_down),	\
38 		.high_impedance = DT_PROP(node_id, bias_high_impedance),	\
39 		.slew_rate = DT_ENUM_IDX(node_id, slew_rate),	\
40 		.drive_strength = DT_PROP_OR(node_id, drive_strength, 4),	\
41 		.schmitt_enable = DT_PROP(node_id, input_schmitt_enable),	\
42 		.control_selection = DT_ENUM_IDX(node_id, quicklogic_control_selection),	\
43 	},
44 
45 #define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx)		\
46 	QUICKLOGIC_EOS_S3_DT_PIN(DT_PROP_BY_IDX(node_id, prop, idx))
47 
48 #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop)		\
49 	{ DT_FOREACH_PROP_ELEM(node_id, prop, Z_PINCTRL_STATE_PIN_INIT) }
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 #endif /* ZEPHYR_SOC_ARM_QUICKLOGIC_EOS_S3_PINCTRL_H_ */
56