1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*
8  * This header is part of mspi_dw.c extracted only for clarity.
9  * It is not supposed to be included by any file other than mspi_dw.c.
10  */
11 
12 #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif)
13 
14 #include <nrf.h>
15 
vendor_specific_init(const struct device * dev)16 static inline void vendor_specific_init(const struct device *dev)
17 {
18 	ARG_UNUSED(dev);
19 
20 	NRF_EXMIF->EVENTS_CORE = 0;
21 	NRF_EXMIF->INTENSET = BIT(EXMIF_INTENSET_CORE_Pos);
22 }
23 
vendor_specific_suspend(const struct device * dev)24 static inline void vendor_specific_suspend(const struct device *dev)
25 {
26 	ARG_UNUSED(dev);
27 
28 	NRF_EXMIF->TASKS_STOP = 1;
29 }
30 
vendor_specific_resume(const struct device * dev)31 static inline void vendor_specific_resume(const struct device *dev)
32 {
33 	ARG_UNUSED(dev);
34 
35 	NRF_EXMIF->TASKS_START = 1;
36 }
37 
vendor_specific_irq_clear(const struct device * dev)38 static inline void vendor_specific_irq_clear(const struct device *dev)
39 {
40 	ARG_UNUSED(dev);
41 
42 	NRF_EXMIF->EVENTS_CORE = 0;
43 }
44 
45 #if defined(CONFIG_MSPI_XIP)
vendor_specific_xip_enable(const struct device * dev,const struct mspi_dev_id * dev_id,const struct mspi_xip_cfg * cfg)46 static inline int vendor_specific_xip_enable(const struct device *dev,
47 					     const struct mspi_dev_id *dev_id,
48 					     const struct mspi_xip_cfg *cfg)
49 {
50 	ARG_UNUSED(dev);
51 
52 	if (dev_id->dev_idx == 0) {
53 		NRF_EXMIF->EXTCONF1.OFFSET = cfg->address_offset;
54 		NRF_EXMIF->EXTCONF1.SIZE = cfg->address_offset
55 					 + cfg->size - 1;
56 		NRF_EXMIF->EXTCONF1.ENABLE = 1;
57 	} else if (dev_id->dev_idx == 1) {
58 		NRF_EXMIF->EXTCONF2.OFFSET = cfg->address_offset;
59 		NRF_EXMIF->EXTCONF2.SIZE = cfg->address_offset
60 					 + cfg->size - 1;
61 		NRF_EXMIF->EXTCONF2.ENABLE = 1;
62 	} else {
63 		return -EINVAL;
64 	}
65 
66 	return 0;
67 }
68 
vendor_specific_xip_disable(const struct device * dev,const struct mspi_dev_id * dev_id,const struct mspi_xip_cfg * cfg)69 static inline int vendor_specific_xip_disable(const struct device *dev,
70 					      const struct mspi_dev_id *dev_id,
71 					      const struct mspi_xip_cfg *cfg)
72 {
73 	ARG_UNUSED(dev);
74 	ARG_UNUSED(cfg);
75 
76 	if (dev_id->dev_idx == 0) {
77 		NRF_EXMIF->EXTCONF1.ENABLE = 0;
78 	} else if (dev_id->dev_idx == 1) {
79 		NRF_EXMIF->EXTCONF2.ENABLE = 0;
80 	} else {
81 		return -EINVAL;
82 	}
83 
84 	return 0;
85 }
86 #endif /* defined(CONFIG_MSPI_XIP) */
87 
88 #endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif) */
89