1 /* 2 * Copyright 2024 Microchip Technology Inc. and its subsidiaries. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef _MEC_ACPI_EC_API_H 7 #define _MEC_ACPI_EC_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 /* ACPI EC Controller */ 23 24 /* MEC5_ACPI_EC_INSTANCES from mec5_defs.h */ 25 #define MEC_ACPI_EC_NUM_IRQS 2 /* number of IRQ sources per instance */ 26 27 struct mec_acpi_ec_regs; 28 29 enum mec_acpi_ec_flags { 30 MEC_ACPI_EC_IBF_IRQ = MEC_BIT(0), 31 MEC_ACPI_EC_OBE_IRQ = MEC_BIT(1), 32 MEC_ACPI_EC_4BYTE_MODE = MEC_BIT(2), 33 MEC_ACPI_EC_BURST_MODE = MEC_BIT(4), 34 MEC_ACPI_EC_RESET = MEC_BIT(7), 35 MEC_ACPI_EC_UD0A_SET = MEC_BIT(8), 36 MEC_ACPI_EC_UD1A_SET = MEC_BIT(9), 37 MEC_ACPI_EC_UD0A_ONE = MEC_BIT(16), 38 MEC_ACPI_EC_UD1A_ONE = MEC_BIT(17), 39 }; 40 41 enum mec_acpi_ec_status { 42 MEC_ACPI_EC_STS_OBF = MEC_BIT(0), 43 MEC_ACPI_EC_STS_IBF = MEC_BIT(1), 44 MEC_ACPI_EC_STS_UD1A = MEC_BIT(2), 45 MEC_ACPI_EC_STS_CMD = MEC_BIT(3), 46 MEC_ACPI_EC_STS_BURST = MEC_BIT(4), 47 MEC_ACPI_EC_STS_SCI = MEC_BIT(5), 48 MEC_ACPI_EC_STS_SMI = MEC_BIT(6), 49 MEC_ACPI_EC_STS_UD0A = MEC_BIT(7), 50 }; 51 52 int mec_hal_acpi_ec_init(struct mec_acpi_ec_regs *regs, uint32_t flags); 53 int mec_hal_acpi_ec_is_enabled(struct mec_acpi_ec_regs *regs); 54 int mec_hal_acpi_ec_is_4byte_mode(struct mec_acpi_ec_regs *regs); 55 56 uint8_t mec_hal_acpi_ec_status(struct mec_acpi_ec_regs *regs); 57 void mec_hal_acpi_ec_status_wr(struct mec_acpi_ec_regs *regs, uint8_t val); 58 void mec_hal_acpi_ec_status_set(struct mec_acpi_ec_regs *regs, uint8_t val); 59 void mec_hal_acpi_ec_status_mask(struct mec_acpi_ec_regs *regs, uint8_t val, uint8_t msk); 60 uint8_t mec_hal_acpi_ec_status_obf(struct mec_acpi_ec_regs *regs); 61 uint8_t mec_hal_acpi_ec_status_ibf(struct mec_acpi_ec_regs *regs); 62 63 uint32_t mec_hal_acpi_ec_host_to_ec_data_rd32(struct mec_acpi_ec_regs *regs); 64 void mec_hal_acpi_ec_host_to_ec_data_wr32(struct mec_acpi_ec_regs *regs, uint32_t data); 65 uint8_t mec_hal_acpi_ec_host_to_ec_data_rd8(struct mec_acpi_ec_regs *regs, uint8_t offset); 66 void mec_hal_acpi_ec_host_to_ec_data_wr8(struct mec_acpi_ec_regs *regs, uint8_t offset, 67 uint8_t data); 68 69 uint32_t mec_hal_acpi_ec_e2h_data_rd32(struct mec_acpi_ec_regs *regs); 70 void mec_hal_acpi_ec_e2h_to_ec_data_wr32(struct mec_acpi_ec_regs *regs, uint32_t data); 71 uint8_t mec_hal_acpi_ec_e2h_data_rd8(struct mec_acpi_ec_regs *regs, uint8_t offset); 72 void mec_hal_acpi_ec_e2h_data_wr8(struct mec_acpi_ec_regs *regs, uint8_t offset, uint8_t data); 73 74 int mec_hal_acpi_ec_girq_en(struct mec_acpi_ec_regs *regs, uint32_t flags); 75 int mec_hal_acpi_ec_girq_dis(struct mec_acpi_ec_regs *regs, uint32_t flags); 76 int mec_hal_acpi_ec_girq_clr(struct mec_acpi_ec_regs *regs, uint32_t flags); 77 uint32_t mec_hal_acpi_ec_girq_result(struct mec_acpi_ec_regs *regs); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif /* #ifndef _MEC_ACPI_EC_API_H */ 84