1 /* 2 * Copyright 2024 Microchip Technology Inc. and its subsidiaries. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef _MEC_ESPI_OOB_H 7 #define _MEC_ESPI_OOB_H 8 9 #include <stdbool.h> 10 #include <stddef.h> 11 #include <stdint.h> 12 13 /* Interfaces to any C modules */ 14 #ifdef __cplusplus 15 extern "C" 16 { 17 #endif 18 19 /* forward declarations */ 20 struct mec_espi_io_regs; 21 struct mec_espi_mem_regs; 22 struct mec_espi_vw_regs; 23 24 /* ---- Out-Of-Band channel (OOB) ---- */ 25 enum mec_espi_oob_dir { 26 MEC_ESPI_OOB_DIR_UP = 1, /* EC TX buffer to upstream Host eSPI controller */ 27 MEC_ESPI_OOB_DIR_DN = 2, /* Host eSPI controller to EC RX buffer */ 28 }; 29 30 enum mec_espi_oob_up_status { 31 MEC_ESPI_OOB_UP_STS_DONE_POS= 0, 32 MEC_ESPI_OOB_UP_STS_CHEN_CHG_POS, 33 MEC_ESPI_OOB_UP_STS_BERR_POS, 34 MEC_ESPI_OOB_UP_STS_OVR_POS, 35 MEC_ESPI_OOB_UP_STS_BAD_REQ_POS, 36 }; 37 38 enum mec_espi_oob_dn_status { 39 MEC_ESPI_OOB_DN_STS_DONE_POS = 0, 40 MEC_ESPI_OOB_DN_STS_BERR_POS, 41 MEC_ESPI_OOB_DN_STS_OVR_POS, 42 }; 43 44 enum mec_espi_oob_up_intr { 45 MEC_ESPI_OOB_UP_INTR_DONE_POS = 0, 46 MEC_ESPI_OOB_UP_INTR_CHEN_CHG_POS, 47 MEC_ESPI_OOB_DN_INTR_DONE_POS, 48 }; 49 50 struct mec_espi_oob_buf { 51 uint32_t maddr; 52 uint16_t len; 53 uint16_t rx_len; /* actual received length from a RX transaction */ 54 }; 55 56 void mec_hal_espi_oob_girq_ctrl(uint8_t enable, uint8_t msk); 57 void mec_hal_espi_oob_girq_status_clr(uint8_t msk); 58 uint32_t mec_hal_espi_oob_girq_status(void); 59 uint32_t mec_hal_espi_oob_girq_result(void); 60 61 void mec_hal_espi_oob_ready_set(struct mec_espi_io_regs *iobase); 62 int mec_hal_espi_oob_is_ready(struct mec_espi_io_regs *iobase); 63 64 /* return bits indicating eSPI OOB channel enable has changed and the 65 * channel enable's current state. 66 */ 67 uint32_t mec_hal_espi_oob_en_status(struct mec_espi_io_regs *iobase); 68 69 uint32_t mec_hal_espi_oob_max_pkt_size(struct mec_espi_io_regs *iobase); 70 71 int mec_hal_espi_oob_buffer_set(struct mec_espi_io_regs *iobase, uint8_t dir, 72 struct mec_espi_oob_buf * buf); 73 void mec_hal_espi_oob_rx_buffer_avail(struct mec_espi_io_regs *iobase); 74 75 void mec_hal_espi_oob_intr_ctrl(struct mec_espi_io_regs *iobase, uint32_t msk, uint8_t en); 76 77 void mec_hal_espi_oob_tx_start(struct mec_espi_io_regs *iobase, uint8_t tag, uint8_t start); 78 79 /* Get the TAG in the OOB RX packet recevied from the eSPI Host */ 80 uint8_t mec_hal_espi_oob_rx_tag(struct mec_espi_io_regs *iobase); 81 82 uint32_t mec_hal_espi_oob_received_len(struct mec_espi_io_regs *iobase); 83 int mec_hal_espi_oob_tx_is_busy(struct mec_espi_io_regs *iobase); 84 85 uint32_t mec_hal_espi_oob_status(struct mec_espi_io_regs *iobase, uint8_t dir); 86 int mec_hal_espi_oob_is_done(uint32_t status, uint8_t dir); 87 int mec_hal_espi_oob_is_error(uint32_t status, uint8_t dir); 88 void mec_hal_espi_oob_status_clr_done(struct mec_espi_io_regs *iobase, uint8_t dir); 89 void mec_hal_espi_oob_status_clr_err(struct mec_espi_io_regs *iobase, uint8_t dir); 90 void mec_hal_espi_oob_status_clr_chen_change(struct mec_espi_io_regs *iobase); 91 int mec_hal_espi_oob_up_is_chan_event(uint32_t status); 92 void mec_hal_espi_oob_status_clr_all(struct mec_espi_io_regs *iobase, uint8_t dir); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 #endif /* #ifndef _MEC_ESPI_OOB_H */ 99