1 /*
2  * Copyright (c) 2020 Nuvoton Technology Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _NUVOTON_NPCX_SOC_HOST_H_
8 #define _NUVOTON_NPCX_SOC_HOST_H_
9 
10 #include <stdint.h>
11 
12 #include <zephyr/device.h>
13 #include <zephyr/drivers/espi.h>
14 #include <zephyr/sys/slist.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /**
21  * @brief Initializes all host sub-modules in Core domain.
22  *
23  * This routine initializes all host sub-modules which HW blocks belong to
24  * Core domain. And it also saves the pointer of eSPI callback list to report
25  * any peripheral events application layer.
26  *
27  * @param dev Pointer to the device structure for the host bus driver instance.
28  * @param callbacks A pointer to the list of espi callback functions.
29  *
30  * @retval 0 If successful.
31  * @retval -EIO if cannot turn on host sub-module source clocks in core domain.
32  */
33 int npcx_host_init_subs_core_domain(const struct device *host_bus_dev,
34 							sys_slist_t *callbacks);
35 
36 /**
37  * @brief Initializes all host sub-modules in Host domain.
38  *
39  * This routine initializes all host sub-modules which HW blocks belong to
40  * Host domain. Please notice it must be executed after receiving PLT_RST
41  * de-asserted signal and eSPI peripheral channel is enabled and ready.
42  */
43 void npcx_host_init_subs_host_domain(void);
44 
45 /**
46  * @brief Reads data from a host sub-module which is updated via eSPI.
47  *
48  * This routine provides a generic interface to read a host sub-module which
49  * information was updated by an eSPI transaction through peripheral channel.
50  *
51  * @param op Enum representing opcode for peripheral type and read request.
52  * @param data Parameter to be read from to the host sub-module.
53  *
54  * @retval 0 If successful.
55  * @retval -ENOTSUP if eSPI peripheral is off or not supported.
56  * @retval -EINVAL for unimplemented lpc opcode, but in range.
57  */
58 int npcx_host_periph_read_request(enum lpc_peripheral_opcode op,
59 								uint32_t *data);
60 
61 /**
62  * @brief Writes data to a host sub-module which generates an eSPI transaction.
63  *
64  * This routine provides a generic interface to write data to a host sub-module
65  * which triggers an eSPI transaction through peripheral channel.
66  *
67  * @param op Enum representing an opcode for peripheral type and write request.
68  * @param data Represents the parameter passed to the host sub-module.
69  *
70  * @retval 0 If successful.
71  * @retval -ENOTSUP if eSPI peripheral is off or not supported.
72  * @retval -EINVAL for unimplemented lpc opcode, but in range.
73  */
74 int npcx_host_periph_write_request(enum lpc_peripheral_opcode op,
75 							const uint32_t *data);
76 
77 /**
78  * @brief Enable host access wake-up interrupt. Usually, it is used to wake up
79  * ec during system is in Modern standby power mode.
80  */
81 void npcx_host_enable_access_interrupt(void);
82 
83 /**
84  * @brief Disable host access wake-up interrupt.
85  */
86 void npcx_host_disable_access_interrupt(void);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* _NUVOTON_NPCX_SOC_HOST_H_ */
93