1 /*
2  * Copyright 2023 NXP
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/drivers/pinctrl.h>
8 #include <svc/pad/pad_api.h>
9 #include <main/ipc.h>
10 
pinctrl_configure_pins(const pinctrl_soc_pin_t * pins,uint8_t pin_cnt,uintptr_t reg)11 int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins,
12 			   uint8_t pin_cnt, uintptr_t reg)
13 {
14 	sc_ipc_t ipc_handle;
15 	int ret, i;
16 
17 	ret = sc_ipc_open(&ipc_handle, DT_REG_ADDR(DT_NODELABEL(scu_mu)));
18 	if (ret != SC_ERR_NONE) {
19 		return -ENODEV;
20 	}
21 
22 	for (i = 0; i < pin_cnt; i++) {
23 		/* TODO: for now, pad configuration is not supported. As such,
24 		 * the state of the pad is the following:
25 		 *	1) Normal configuration (no OD)
26 		 *	2) ISO off
27 		 *	3) Pull select and drive strength initialized by another
28 		 *	entity (e.g: SCFW, Linux etc...) or set to the default
29 		 *	values as specified in the TRM.
30 		 */
31 		ret = sc_pad_set_mux(ipc_handle, pins[i].pad, pins[i].mux, 0, 0);
32 		if (ret != SC_ERR_NONE) {
33 			return -EINVAL;
34 		}
35 	}
36 
37 	return 0;
38 }
39