1 /* 2 * Copyright (c) 2021 Microchip Technology Inc. All Rights Reserved. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef _MICROCHIP_XEC_SOC_DT_H_ 8 #define _MICROCHIP_XEC_SOC_DT_H_ 9 10 #include <zephyr/devicetree.h> 11 12 #define MCHP_XEC_PIN_FEAT_EN 0x1 13 #define MCHP_XEC_NO_PULL 0x1 14 #define MCHP_XEC_PULL_UP 0x1 15 #define MCHP_XEC_PULL_DOWN 0x1 16 #define MCHP_XEC_PUSH_PULL 0x1 17 #define MCHP_XEC_OPEN_DRAIN 0x1 18 #define MCHP_XEC_OUT_DIS 0x1 19 #define MCHP_XEC_OUT_EN 0x1 20 #define MCHP_XEC_OUT_DRV_LOW 0x1 21 #define MCHP_XEC_OUT_DRV_HIGH 0x1 22 #define MCHP_XEC_DRVSTR_NONE 0x0 23 #define MCHP_XEC_DRVSTR_2MA 0x1 24 #define MCHP_XEC_DRVSTR_4MA 0x2 25 #define MCHP_XEC_DRVSTR_8MA 0x3 26 #define MCHP_XEC_DRVSTR_12MA 0x4 27 #define MCHP_XEC_FUNC_INVERT 0x1 28 #define MCHP_XEC_PIN_INPUT_DIS 0x1 29 30 #define MCHP_DT_ESPI_VW_FLAG_STATUS_POS 0 31 #define MCHP_DT_ESPI_VW_FLAG_DIR_POS 1 32 #define MCHP_DT_ESPI_VW_FLAG_RST_STATE_POS 2 33 #define MCHP_DT_ESPI_VW_FLAG_RST_STATE_MSK0 0x3 34 #define MCHP_DT_ESPI_VW_FLAG_RST_SRC_POS 4 35 #define MCHP_DT_ESPI_VW_FLAG_RST_SRC_MSK0 0x7 36 37 #define MCHP_DT_NODE_FROM_VWTABLE(name) DT_CHILD(DT_PATH(mchp_xec_espi_vw_routing), name) 38 #define MCHP_DT_VW_NODE_HAS_STATUS(name) DT_NODE_HAS_STATUS(MCHP_DT_NODE_FROM_VWTABLE(name), okay) 39 40 /* Macro to store eSPI virtual wire DT flags 41 * b[0] = DT status property 0 is disabled, 1 enabled, 42 * b[1] = VW direction 0(EC target to host controller), 1(host controller to EC target) 43 * b[3:2] = default virtual wire state 0(HW default), 1(low), 2(high) 44 * b[6:4] = virtual wire state reset event: 45 * 0(HW default), 1(ESPI_RESET), 2(RESET_SYS), 3(RESET_SIO), 4(PLTRST) 46 */ 47 #define MCHP_DT_ESPI_VW_FLAGS(vw) \ 48 ((uint8_t)(MCHP_DT_VW_NODE_HAS_STATUS(vw)) & 0x01U) | \ 49 ((((uint8_t)DT_PROP_BY_IDX(MCHP_DT_NODE_FROM_VWTABLE(vw), vw_reg, 1)) & 0x1) << 1) | \ 50 ((((uint8_t)DT_ENUM_IDX_OR(MCHP_DT_NODE_FROM_VWTABLE(vw), reset_state, 0)) & 0x3) << 2) | \ 51 ((((uint8_t)DT_ENUM_IDX_OR(MCHP_DT_NODE_FROM_VWTABLE(vw), reset_source, 0)) & 0x7) << 4) 52 53 /* Macro for the eSPI driver VW table entries. 54 * e is a symbol from enum espi_vwire_signal. 55 * vw is a node from the XEC ESPI VW routing file. 56 */ 57 #define MCHP_DT_ESPI_VW_ENTRY(e, vw) \ 58 [(e)] = { \ 59 .host_idx = DT_PROP_BY_IDX(MCHP_DT_NODE_FROM_VWTABLE(vw), vw_reg, 0), \ 60 .bit = DT_PROP_BY_IDX(MCHP_DT_NODE_FROM_VWTABLE(vw), vw_reg, 3), \ 61 .xec_reg_idx = DT_PROP_BY_IDX(MCHP_DT_NODE_FROM_VWTABLE(vw), vw_reg, 2), \ 62 .flags = MCHP_DT_ESPI_VW_FLAGS(vw), \ 63 } 64 65 #endif /* _MICROCHIP_XEC_SOC_DT_H_ */ 66