1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* Copyright (C) 2025 Loongson Technology Corporation Limited */ 3 4 #ifndef __MFD_LOONGSON_SE_H__ 5 #define __MFD_LOONGSON_SE_H__ 6 7 #define LOONGSON_ENGINE_CMD_TIMEOUT_US 10000 8 #define SE_SEND_CMD_REG 0x0 9 #define SE_SEND_CMD_REG_LEN 0x8 10 /* Controller command ID */ 11 #define SE_CMD_START 0x0 12 #define SE_CMD_SET_DMA 0x3 13 #define SE_CMD_SET_ENGINE_CMDBUF 0x4 14 15 #define SE_S2LINT_STAT 0x88 16 #define SE_S2LINT_EN 0x8c 17 #define SE_S2LINT_CL 0x94 18 #define SE_L2SINT_STAT 0x98 19 #define SE_L2SINT_SET 0xa0 20 21 #define SE_INT_ALL 0xffffffff 22 #define SE_INT_CONTROLLER BIT(0) 23 24 #define SE_ENGINE_MAX 16 25 #define SE_ENGINE_RNG 1 26 #define SE_CMD_RNG 0x100 27 28 #define SE_ENGINE_TPM 5 29 #define SE_CMD_TPM 0x500 30 31 #define SE_ENGINE_CMD_SIZE 32 32 33 struct loongson_se_engine { 34 struct loongson_se *se; 35 int id; 36 37 /* Command buffer */ 38 void *command; 39 void *command_ret; 40 41 void *data_buffer; 42 uint buffer_size; 43 /* Data buffer offset to DMA base */ 44 uint buffer_off; 45 46 struct completion completion; 47 48 }; 49 50 struct loongson_se_engine *loongson_se_init_engine(struct device *dev, int id); 51 int loongson_se_send_engine_cmd(struct loongson_se_engine *engine); 52 53 #endif 54