1 /* 2 * Copyright (c) 2024 Google Inc 3 * SPDX-License-Identifier: Apache-2.0 4 */ 5 6 #ifndef INCLUDE_ZEPHYR_DRIVERS_BBRAM_NPCX_H_ 7 #define INCLUDE_ZEPHYR_DRIVERS_BBRAM_NPCX_H_ 8 9 #include <stdint.h> 10 11 #include <zephyr/devicetree.h> 12 13 /** Device config */ 14 struct bbram_npcx_config { 15 /** BBRAM base address */ 16 uintptr_t base_addr; 17 /** BBRAM size (Unit:bytes) */ 18 int size; 19 /** Status register base address */ 20 uintptr_t status_reg_addr; 21 }; 22 23 #ifdef CONFIG_BBRAM_NPCX_EMUL 24 #define BBRAM_NPCX_DECL_CONFIG(inst) \ 25 static uint8_t bbram_npcx_emul_buffer_##inst[DT_INST_REG_SIZE_BY_NAME(inst, memory)]; \ 26 static uint8_t bbram_npcx_emul_status_##inst; \ 27 static const struct bbram_npcx_config bbram_cfg_##inst = { \ 28 .base_addr = (uintptr_t)bbram_npcx_emul_buffer_##inst, \ 29 .size = DT_INST_REG_SIZE_BY_NAME(inst, memory), \ 30 .status_reg_addr = (uintptr_t)&bbram_npcx_emul_status_##inst, \ 31 } 32 #else 33 #define BBRAM_NPCX_DECL_CONFIG(inst) \ 34 static const struct bbram_npcx_config bbram_cfg_##inst = { \ 35 .base_addr = DT_INST_REG_ADDR_BY_NAME(inst, memory), \ 36 .size = DT_INST_REG_SIZE_BY_NAME(inst, memory), \ 37 .status_reg_addr = DT_INST_REG_ADDR_BY_NAME(inst, status), \ 38 } 39 #endif 40 41 #endif /* INCLUDE_ZEPHYR_DRIVERS_BBRAM_NPCX_H_ */ 42