1 /*
2  * Copyright (c) 2024 Antmicro <www.antmicro.com>
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/dt-bindings/pinctrl/pinctrl-zynqmp.h>
8 #include <zephyr/logging/log.h>
9 #include "pinctrl_soc.h"
10 
11 LOG_MODULE_REGISTER(pinctrl_xlnx_zynqmp, CONFIG_PINCTRL_LOG_LEVEL);
12 
13 #define DT_DRV_COMPAT xlnx_pinctrl_zynqmp
14 
15 static mm_reg_t base = DT_INST_REG_ADDR(0);
16 static uint8_t mio_pin_offset = 0x04;
17 
pinctrl_configure_pins(const pinctrl_soc_pin_t * pins,uint8_t pin_cnt,uintptr_t reg)18 int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
19 {
20 	for (uint8_t i = 0U; i < pin_cnt; i++) {
21 		uint32_t sel = 0;
22 
23 		switch (pins[i].func) {
24 			case UART_FUNCTION: {
25 				sel = UARTX_SEL;
26 				break;
27 			}
28 
29 			default: {
30 				LOG_ERR("Unsupported function enum was selected");
31 				break;
32 			}
33 		}
34 		sys_write32(sel, base + mio_pin_offset * pins[i].pin);
35 	}
36 
37 	return 0;
38 }
39