1 /* 2 * Copyright 2024 Microchip Technology Inc. and its subsidiaries. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef _MEC_MAILBOX_API_H 7 #define _MEC_MAILBOX_API_H 8 9 #include <stdbool.h> 10 #include <stddef.h> 11 #include <stdint.h> 12 13 #include "mec_defs.h" 14 #include "mec_retval.h" 15 16 /* Interfaces to any C modules */ 17 #ifdef __cplusplus 18 extern "C" 19 { 20 #endif 21 22 enum mec_mbox_flags { 23 MEC_MBOX_FLAG_RESET = MEC_BIT(0), 24 MEC_MBOX_FLAG_INTR_EN = MEC_BIT(1), 25 }; 26 27 enum mec_mbox_swi_events { 28 MEC_MBOX_SWI_EC_WR_POS = 0, 29 MEC_MBOX_SWI_1_POS, 30 MEC_MBOX_SWI_2_POS, 31 MEC_MBOX_SWI_3_POS, 32 MEC_MBOX_SWI_4_POS, 33 MEC_MBOX_SWI_5_POS, 34 MEC_MBOX_SWI_6_POS, 35 MEC_MBOX_SWI_7_POS, 36 }; 37 38 struct mec_mbox_regs; 39 40 int mec_hal_mbox_init(struct mec_mbox_regs *base, uint32_t swi_ien_msk, uint32_t flags); 41 int mec_hal_mbox_girq_ctrl(struct mec_mbox_regs *base, uint8_t enable); 42 int mec_hal_mbox_girq_clr(struct mec_mbox_regs *base); 43 uint32_t mec_hal_mbox_girq_result(struct mec_mbox_regs *base); 44 45 int mec_hal_mbox_sirq_set(struct mec_mbox_regs *base, uint8_t bitmap); 46 int mec_hal_mbox_sirq_en_mask(struct mec_mbox_regs *base, uint8_t val, uint8_t mask); 47 48 int mec_hal_mbox_get_host_to_ec(struct mec_mbox_regs *base, uint8_t *data); 49 int mec_hal_mbox_set_host_to_ec(struct mec_mbox_regs *base, uint8_t data); 50 int mec_hal_mbox_get_ec_to_host(struct mec_mbox_regs *base, uint8_t *data); 51 int mec_hal_mbox_set_ec_to_host(struct mec_mbox_regs *base, uint8_t data); 52 53 int mec_hal_mbox_get(struct mec_mbox_regs *base, uint8_t mbox, uint8_t *data); 54 int mec_hal_mbox_put(struct mec_mbox_regs *base, uint8_t mbox, uint8_t data); 55 56 int mec_hal_mbox32_get(struct mec_mbox_regs *base, uint8_t mbox, uint32_t *data); 57 int mec_hal_mbox32_put(struct mec_mbox_regs *base, uint8_t mbox, uint32_t data); 58 59 #ifdef __cplusplus 60 } 61 #endif 62 63 #endif /* #ifndef _MEC_MAILBOX_API_H */ 64