1 /*
2  * Copyright (c) 2023 Enphase Energy
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #define DT_DRV_COMPAT ti_k3_pinctrl
8 
9 #include <zephyr/arch/cpu.h>
10 #include <zephyr/drivers/pinctrl.h>
11 
12 #define PINCTRL_NODE DT_NODELABEL(pinctrl)
13 
14 static struct pinctrl_ti_k3_dev_data {
15 	DEVICE_MMIO_RAM;
16 } pinctrl_ti_k3_dev;
17 
18 static struct pinctrl_ti_k3_cfg_data {
19 	DEVICE_MMIO_ROM;
20 } pinctrl_ti_k3_cfg = {
21 	DEVICE_MMIO_ROM_INIT(PINCTRL_NODE)
22 };
23 
pinctrl_configure_pins(const pinctrl_soc_pin_t * pins,uint8_t pin_cnt,uintptr_t reg)24 int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
25 {
26 	ARG_UNUSED(reg);
27 	const struct device *dev = DEVICE_DT_GET(PINCTRL_NODE);
28 	uintptr_t virt_reg_base = DEVICE_MMIO_GET(dev);
29 
30 	for (uint8_t i = 0; i < pin_cnt; i++) {
31 		sys_write32(pins[i].value, virt_reg_base + pins[i].offset);
32 	}
33 
34 	return 0;
35 }
36 
pinctrl_ti_k3_init(const struct device * dev)37 static int pinctrl_ti_k3_init(const struct device *dev)
38 {
39 	DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE);
40 	return 0;
41 }
42 
43 DEVICE_DT_DEFINE(PINCTRL_NODE,
44 		 pinctrl_ti_k3_init,
45 		 NULL,
46 		 &pinctrl_ti_k3_dev,
47 		 &pinctrl_ti_k3_cfg,
48 		 PRE_KERNEL_1,
49 		 CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
50 		 NULL);
51