xref: /optee_os/core/include/drivers/zynqmp_pm.h (revision 6e96536ef5c53ffa3b81d0b9e5b54ac136370af1)
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.
40  * @buf_sz: buffer size in bytes
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  * Program eFuse memory
50  * @buf: buffer where eFuse data are stored in LE byte order.
51  * @buf_sz: buffer size in bytes
52  * @id: eFuse identifier.
53  * @puf: is eFuse PUF, ZYNQMP_PUF_EFUSE/ZYNQMP_NONPUF_EFUSE
54  * Return a TEE_Result compliant status
55  */
56 TEE_Result zynqmp_efuse_write(uint8_t *buf, size_t buf_sz,
57 			      enum zynqmp_efuse_id id, bool puf);
58 
59 /*
60  * Read the SoC version number:
61  * Different eFuse bitfields carry different meaning depending on this version.
62  */
63 TEE_Result zynqmp_soc_version(uint32_t *version);
64 
65 #endif /*__DRIVERS_ZYNQMP_PM_H__*/
66