1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (C) 2021 Foundries.io Ltd
4  */
5 
6 #ifndef __DRIVERS_ZYNQMP_PM_H__
7 #define __DRIVERS_ZYNQMP_PM_H__
8 
9 #include <drivers/zynqmp_efuse.h>
10 #include <platform_config.h>
11 #include <tee_api_types.h>
12 #include <util.h>
13 
14 /*
15  * Information about accessing eFuses and the Physically Uncloneable Function
16  * (PUF) Support can be found at
17  * https://www.xilinx.com/support/documentation/application_notes/xapp1319-zynq-usp-prog-nvm.pdf
18  */
19 #define ZYNQMP_NONPUF_EFUSE		0
20 #define ZYNQMP_PUF_EFUSE		1
21 
22 /* List of eFuse identifiers */
23 enum zynqmp_efuse_id {
24 	DNA = 0, IP_DISABLE, MISC_USER_CTRL, SEC_CTRL,
25 };
26 
27 /* Valid bytes in the eFuse */
28 #define ZYNQMP_EFUSE_LEN(_id)	ZYNQMP_EFUSE_##_id##_LENGTH
29 
30 /* Memory required to access the eFuse */
31 #define ZYNQMP_EFUSE_MEM(_id) (ROUNDUP(ZYNQMP_EFUSE_LEN(_id), CACHELINE_LEN))
32 
33 /* Alignment required in the buffers used to read the eFuse */
34 #define __aligned_efuse __aligned(CACHELINE_LEN)
35 
36 /*
37  * Read eFuse memory
38  * @buf: buffer, where eFuse date will be stored. The data is returned
39  *       in LE byte order. The buffer address must be cached aligned
40  * @buf_sz: buffer size in bytes, must be a multiple of the cacheline size
41  * @id: eFuse identifier.
42  * @puf: is eFuse PUF, ZYNQMP_PUF_EFUSE/ZYNQMP_NONPUF_EFUSE
43  * Return a TEE_Result compliant status
44  */
45 TEE_Result zynqmp_efuse_read(uint8_t *buf, size_t buf_sz,
46 			     enum zynqmp_efuse_id id, bool puf);
47 
48 /*
49  * Read the SoC version number:
50  * Different eFuse bitfields carry different meaning depending on this version.
51  */
52 TEE_Result zynqmp_soc_version(uint32_t *version);
53 
54 #endif /*__DRIVERS_ZYNQMP_PM_H__*/
55