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