1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright 2022 Microsoft
4  *
5  * Definitions for the NXP LX2160A-series Security Monitor (SecMon) driver.
6  */
7 
8 #ifndef __DRIVERS_LS_SEC_MON_H
9 #define __DRIVERS_LS_SEC_MON_H
10 
11 #include <stdlib.h>
12 #include <tee_api_types.h>
13 
14 /**
15  * struct ls_sec_mon_data - Compact data struct of all SecMon registers.
16  * @hplr:	HP Lock Register.
17  * @hpcomr:	HP Command Register.
18  * @hpsicr:	HP Security Interrupt Control Register.
19  * @hpsvcr:	HP Security Violation Control Register.
20  * @hpsr:	HP Status Register.
21  * @hpsvsr:	HP Security Violation Status Register.
22  * @hphacivr:	HP High Assurance Counter IV Register.
23  * @hphacr:	HP High Assurance Counter Register.
24  * @lplr:	LP Lock Register.
25  * @lpcr:	LP Control Register.
26  * @lpmkcr:	LP Master Key Control Register.
27  * @lpsvcr:	LP Security Violation Control Register.
28  * @lptdcr:	LP Tamper Detectors Configuration Register.
29  * @lpsr:	LP Status Register.
30  * @lpsmcmr:	LP Secure Monotonic Counter MSB Register.
31  * @lpsmclr:	LP Secure Monotonic Counter LSB Register.
32  * @lppgdr:	LP Power Glitch Detector Register.
33  * @lpzmkr[8]:	LP Zeroizable Master Key Registers.
34  * @lpgpr[4]:	LP General Purpose Registers.
35  * @hpvidr1:	HP Version ID Register 1.
36  * @hpvidr2:	HP Version ID Register 2.
37  */
38 struct ls_sec_mon_data {
39 	uint32_t hplr;
40 	uint32_t hpcomr;
41 	uint32_t hpsicr;
42 	uint32_t hpsvcr;
43 	uint32_t hpsr;
44 	uint32_t hpsvsr;
45 	uint32_t hphacivr;
46 	uint32_t hphacr;
47 	uint32_t lplr;
48 	uint32_t lpcr;
49 	uint32_t lpmkcr;
50 	uint32_t lpsvcr;
51 	uint32_t lptdcr;
52 	uint32_t lpsr;
53 	uint32_t lpsmcmr;
54 	uint32_t lpsmclr;
55 	uint32_t lppgdr;
56 	uint32_t lpzmkr[8];
57 	uint32_t lpgpr[4];
58 	uint32_t hpvidr1;
59 	uint32_t hpvidr2;
60 };
61 
62 /**
63  * ls_sec_mon_read() - Read a copy of the SecMon register data if the SecMon
64  *		       driver was successfully initialized.
65  * @data:	Location to save SecMon data.
66  *
67  * Return:	0 if successful or > 0 on error.
68  */
69 TEE_Result ls_sec_mon_read(struct ls_sec_mon_data *data);
70 
71 /**
72  * ls_sec_mon_status() - Check if the SecMon driver was initialized
73  *			 successfully.
74  *
75  * Return:	0 if init was successful or TEE_ERROR_GENERIC on init failed.
76  */
77 TEE_Result ls_sec_mon_status(void);
78 
79 #endif /* __DRIVERS_LS_SEC_MON_H */
80