1 /*
2  * Copyright (c) 2020 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef __ESPI_OOB_HANDLER_H__
8 #define __ESPI_OOB_HANDLER_H__
9 
10 /* eSPI host entity address  */
11 #define PCH_DEST_SLV_ADDR     0x02u
12 #define SRC_SLV_ADDR          0x21u
13 
14 #define OOB_RESPONSE_SENDER_INDEX   0x02u
15 #define OOB_RESPONSE_DATA_INDEX     0x04u
16 
17 
18 /* Temperature command opcode */
19 #define OOB_CMDCODE           0x01u
20 #define OOB_RESPONSE_LEN            0x05u
21 
22 /* Maximum bytes for OOB transactions */
23 #define MAX_ESPI_BUF_LEN      80u
24 #define MIN_GET_TEMP_CYCLES   5u
25 
26 /* 100ms */
27 #define MAX_OOB_TIMEOUT       100ul
28 
29 void oob_rx_handler(const struct device *dev, struct espi_callback *cb,
30 		    struct espi_event event);
31 
32 /**
33  * @brief Retrieve PCH temperature over OOB channel.
34  * Assumes OOB Tx and Rx as synchronous operation.
35  *
36  * @param dev eSPI driver handle.
37  *
38  * @retval 0 If successful.
39  * @retval -ENOTSUP returned when OOB channel is not supported.
40  * @retval -EINVAL is returned when OOB parameters are invalid.
41  *
42  */
43 int get_pch_temp_sync(const struct device *dev);
44 
45 
46 /**
47  * @brief Retrieve PCH temperature over OOB channel.
48  * Assumes OOB Tx and Rx as synchronous operation.
49  *
50  * @param dev eSPI driver handle.
51  *
52  * @retval 0 If successful.
53  * @retval -ENOTSUP returned when OOB channel is not supported.
54  * @retval -ETIMEOUT OOB operations could not be started.
55  *
56  */
57 int get_pch_temp_async(const struct device *dev);
58 
59 #endif /* __ESPI_OOB_HANDLER_H__ */
60